pass screen size in instead of polling it later
and add some comments
This commit is contained in:
@@ -37,6 +37,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;
|
||||
|
||||
/** The associated HitObject. */
|
||||
protected HitObject hitObject;
|
||||
|
||||
@@ -46,9 +49,6 @@ 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;
|
||||
|
||||
@@ -66,10 +66,22 @@ public abstract class Curve {
|
||||
this.y = hitObject.getScaledY();
|
||||
this.sliderX = hitObject.getScaledSliderX();
|
||||
this.sliderY = hitObject.getScaledSliderY();
|
||||
this.scale = 100;
|
||||
this.renderState = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static void init(int width, int height, float circleSize)
|
||||
{
|
||||
containerWidth = width;
|
||||
containerHeight = height;
|
||||
CurveRenderState.init(width, height, circleSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the point on the curve at a value t.
|
||||
* @param t the t value [0, 1]
|
||||
@@ -82,26 +94,24 @@ public abstract class Curve {
|
||||
* @param color the color filter
|
||||
*/
|
||||
public void draw(Color color) {
|
||||
if ( curve == null){
|
||||
Log.error("draw curve"+this);
|
||||
return;
|
||||
if (curve == null) {
|
||||
return;
|
||||
}
|
||||
if (Options.GameOption.NEW_SLIDER.getBooleanValue()) {
|
||||
if (renderState == null) {
|
||||
renderState = new CurveRenderState(hitObject);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,14 +136,6 @@ 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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user