Follow-up to #64.

- Removed NEW_SLIDER option, and use the skin "SliderStyle" instead.  Uses the new style by default, unless STYLE_PEPPYSLIDER is specified.
- Check if OpenGL 3.0 is supported before trying to draw new style sliders.
- Fixed compilation warnings; removed unneeded fields and imports.
- Filled in some missing Javadocs.
- Style changes.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-06-08 15:02:28 -04:00
parent 9c8a8f24c6
commit b6f208a47d
10 changed files with 192 additions and 188 deletions

View File

@@ -18,12 +18,14 @@
package itdelatrisu.opsu.objects.curves;
import itdelatrisu.opsu.render.CurveRenderState;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.beatmap.HitObject;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.render.CurveRenderState;
import itdelatrisu.opsu.skins.Skin;
import org.lwjgl.opengl.GLContext;
import org.newdawn.slick.Color;
import org.newdawn.slick.Image;
import org.newdawn.slick.util.Log;
@@ -37,9 +39,9 @@ public abstract class Curve {
/** Points generated along the curve should be spaced this far apart. */
protected static float CURVE_POINTS_SEPERATION = 5;
/** The width and height of the display container this curve gets drawn into */
protected static int containerWidth = 0, containerHeight = 0;
/** Whether OpenGL 3.0 is supported. */
private static boolean openGL30 = false;
/** The associated HitObject. */
protected HitObject hitObject;
@@ -48,8 +50,8 @@ public abstract class Curve {
/** The scaled slider x, y coordinate lists. */
protected float[] sliderX, sliderY;
/** Per-curve render-state used for the new style curve renders*/
/** Per-curve render-state used for the new style curve renders. */
private CurveRenderState renderState;
/** Points along the curve (set by inherited classes). */
@@ -70,18 +72,22 @@ public abstract class Curve {
}
/**
* Set the width and height of the container that Curves get drawn into
* Set the width and height of the container that Curves get drawn into.
* Should be called before any curves are drawn.
* @param width
* @param height
* @param width the container width
* @param height the container height
* @param circleSize the circle size
*/
public static void init(int width, int height, float circleSize)
{
containerWidth = width;
containerHeight = height;
CurveRenderState.init(width, height, circleSize);
public static void init(int width, int height, float circleSize) {
openGL30 = GLContext.getCapabilities().OpenGL30;
if (openGL30)
CurveRenderState.init(width, height, circleSize);
else {
if (Options.getSkin().getSliderStyle() != Skin.STYLE_PEPPYSLIDER)
Log.warn("New slider style requires OpenGL 3.0, which is not supported.");
}
}
/**
* Returns the point on the curve at a value t.
* @param t the t value [0, 1]
@@ -94,23 +100,24 @@ public abstract class Curve {
* @param color the color filter
*/
public void draw(Color color) {
if (curve == null) {
if (curve == null)
return;
}
if (Options.GameOption.NEW_SLIDER.getBooleanValue()) {
if (renderState == null) {
renderState = new CurveRenderState(hitObject);
}
renderState.draw(color, curve);
} else {
// peppysliders
if (Options.getSkin().getSliderStyle() == Skin.STYLE_PEPPYSLIDER || !openGL30) {
Image hitCircle = GameImage.HITCIRCLE.getImage();
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
for (int i = 0; i < curve.length; i++) {
for (int i = 0; i < curve.length; i++)
hitCircleOverlay.drawCentered(curve[i].x, curve[i].y, Utils.COLOR_WHITE_FADE);
}
for (int i = 0; i < curve.length; i++) {
for (int i = 0; i < curve.length; i++)
hitCircle.drawCentered(curve[i].x, curve[i].y, color);
}
}
// mmsliders
else {
if (renderState == null)
renderState = new CurveRenderState(hitObject);
renderState.draw(color, curve);
}
}
@@ -143,8 +150,11 @@ public abstract class Curve {
return a * (1 - t) + b * t;
}
/**
* Discards the slider cache (only used for mmsliders).
*/
public void discardCache() {
if(renderState != null)
if (renderState != null)
renderState.discardCache();
}
}