New optional slider style
New slider rendering works by rendering the slider to an offscreen buffer Add CurveRenderState.java and FrameBufferCache.java that were forgotten in the last commit
This commit is contained in:
@@ -30,12 +30,20 @@ import itdelatrisu.opsu.objects.curves.CatmullCurve;
|
||||
import itdelatrisu.opsu.objects.curves.CircumscribedCircle;
|
||||
import itdelatrisu.opsu.objects.curves.Curve;
|
||||
import itdelatrisu.opsu.objects.curves.LinearBezier;
|
||||
import itdelatrisu.opsu.render.Rendertarget;
|
||||
import itdelatrisu.opsu.states.Game;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.util.Log;
|
||||
|
||||
/**
|
||||
* Data type representing a slider object.
|
||||
@@ -50,6 +58,9 @@ public class Slider implements GameObject {
|
||||
/** Rate at which slider ticks are placed. */
|
||||
private static float sliderTickRate = 1.0f;
|
||||
|
||||
/** Scaling factor for display elements */
|
||||
private static int diameter = 1;
|
||||
|
||||
/** The amount of time, in milliseconds, to fade in the slider. */
|
||||
private static final int FADE_IN_TIME = 375;
|
||||
|
||||
@@ -111,7 +122,7 @@ public class Slider implements GameObject {
|
||||
containerWidth = container.getWidth();
|
||||
containerHeight = container.getHeight();
|
||||
|
||||
int diameter = (int) (104 - (circleSize * 8));
|
||||
diameter = (int) (104 - (circleSize * 8));
|
||||
diameter = (int) (diameter * HitObject.getXMultiplier()); // convert from Osupixels (640x480)
|
||||
|
||||
// slider ball
|
||||
@@ -170,12 +181,26 @@ public class Slider implements GameObject {
|
||||
float fadeinScale = (timeDiff - game.getApproachTime() + FADE_IN_TIME) / (float) FADE_IN_TIME;
|
||||
float approachScale = 1 + scale * 3;
|
||||
float alpha = Utils.clamp(1 - fadeinScale, 0, 1);
|
||||
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
||||
|
||||
float oldAlpha = Utils.COLOR_WHITE_FADE.a;
|
||||
Utils.COLOR_WHITE_FADE.a = color.a = alpha;
|
||||
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
||||
float[] endPos = curve.pointAt(1);
|
||||
|
||||
// curve
|
||||
curve.draw(color);
|
||||
color.a = alpha;
|
||||
|
||||
// end circle
|
||||
hitCircle.drawCentered(endPos[0], endPos[1], color);
|
||||
hitCircleOverlay.drawCentered(endPos[0], endPos[1], Utils.COLOR_WHITE_FADE);
|
||||
|
||||
// start circle
|
||||
hitCircle.drawCentered(x, y, color);
|
||||
if (!overlayAboveNumber) {
|
||||
hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE);
|
||||
}
|
||||
|
||||
// ticks
|
||||
if (ticksT != null) {
|
||||
@@ -185,25 +210,11 @@ public class Slider implements GameObject {
|
||||
tick.drawCentered(c[0], c[1], Utils.COLOR_WHITE_FADE);
|
||||
}
|
||||
}
|
||||
|
||||
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
||||
|
||||
// end circle
|
||||
float[] endPos = curve.pointAt(1);
|
||||
hitCircle.drawCentered(endPos[0], endPos[1], color);
|
||||
hitCircleOverlay.drawCentered(endPos[0], endPos[1], Utils.COLOR_WHITE_FADE);
|
||||
|
||||
// start circle
|
||||
hitCircle.drawCentered(x, y, color);
|
||||
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
||||
if (!overlayAboveNumber)
|
||||
hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE);
|
||||
if (sliderClickedInitial)
|
||||
; // don't draw current combo number if already clicked
|
||||
else
|
||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
||||
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
||||
if (overlayAboveNumber)
|
||||
hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE);
|
||||
|
||||
@@ -388,6 +399,7 @@ public class Slider implements GameObject {
|
||||
|
||||
// calculate and send slider result
|
||||
hitResult();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -469,6 +481,8 @@ public class Slider implements GameObject {
|
||||
this.curve = new CatmullCurve(hitObject, color);
|
||||
else
|
||||
this.curve = new LinearBezier(hitObject, color, hitObject.getSliderType() == HitObject.SLIDER_LINEAR);
|
||||
|
||||
this.curve.setScale(diameter );//* 118 / 128);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
|
||||
package itdelatrisu.opsu.objects.curves;
|
||||
|
||||
import itdelatrisu.opsu.render.CurveRenderState;
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.beatmap.HitObject;
|
||||
import itdelatrisu.opsu.Options;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.util.Log;
|
||||
|
||||
/**
|
||||
* Representation of a curve.
|
||||
@@ -42,6 +45,12 @@ public abstract class Curve {
|
||||
|
||||
/** The scaled slider x, y coordinate lists. */
|
||||
protected float[] sliderX, sliderY;
|
||||
|
||||
/** scaling factor for drawing. */
|
||||
protected static float scale;
|
||||
|
||||
/** Per-curve render-state used for the new style curve renders*/
|
||||
private CurveRenderState renderState;
|
||||
|
||||
/** Points along the curve (set by inherited classes). */
|
||||
protected Vec2f[] curve;
|
||||
@@ -57,6 +66,8 @@ public abstract class Curve {
|
||||
this.y = hitObject.getScaledY();
|
||||
this.sliderX = hitObject.getScaledSliderX();
|
||||
this.sliderY = hitObject.getScaledSliderY();
|
||||
this.scale = 100;
|
||||
this.renderState = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,15 +82,26 @@ public abstract class Curve {
|
||||
* @param color the color filter
|
||||
*/
|
||||
public void draw(Color color) {
|
||||
if (curve == null)
|
||||
return;
|
||||
|
||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
||||
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
||||
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++)
|
||||
hitCircle.drawCentered(curve[i].x, curve[i].y, color);
|
||||
if ( curve == null){
|
||||
Log.error("draw curve"+this);
|
||||
return;
|
||||
}
|
||||
if (Options.GameOption.NEW_SLIDER.getBooleanValue()) {
|
||||
if(renderState == null)
|
||||
{
|
||||
renderState = new CurveRenderState(scale,hitObject);
|
||||
}
|
||||
renderState.draw(color,curve);
|
||||
} else {
|
||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
||||
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
||||
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++){
|
||||
hitCircle.drawCentered(curve[i].x, curve[i].y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,10 +126,23 @@ public abstract class Curve {
|
||||
*/
|
||||
public float getY(int i) { return (i == 0) ? y : sliderY[i - 1]; }
|
||||
|
||||
/**
|
||||
* Set the scaling factor.
|
||||
* @param factor the new scaling factor for the UI representation
|
||||
*/
|
||||
public static void setScale(float factor) {
|
||||
scale = factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Linear interpolation of a and b at t.
|
||||
*/
|
||||
protected float lerp(float a, float b, float t) {
|
||||
return a * (1 - t) + b * t;
|
||||
}
|
||||
|
||||
public void discardCache() {
|
||||
if(renderState != null)
|
||||
renderState.discardCache();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user