Minor style changes from #134.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-09-18 16:02:19 -04:00
parent daf3a2aad3
commit 14496050ea
5 changed files with 33 additions and 43 deletions

View File

@ -907,7 +907,7 @@ public class GameData {
float oldColorAlpha = hitResult.color.a;
Colors.WHITE_FADE.a = alpha;
hitResult.color.a = alpha;
hitResult.curve.draw(hitResult.color,1.0f);
hitResult.curve.draw(hitResult.color);
Colors.WHITE_FADE.a = oldWhiteAlpha;
hitResult.color.a = oldColorAlpha;
}

View File

@ -188,12 +188,7 @@ public class Slider implements GameObject {
Image hitCircle = GameImage.HITCIRCLE.getImage();
Vec2f endPos = curve.pointAt(1);
float curveInterval;
if(Options.isSliderSnaking()){
curveInterval = alpha;
} else {
curveInterval = 1.0f;
}
float curveInterval = Options.isSliderSnaking() ? alpha : 1f;
curve.draw(color,curveInterval);
color.a = alpha;
@ -209,12 +204,12 @@ public class Slider implements GameObject {
// ticks
if (ticksT != null) {
float tickScale = 0.5f + 0.5f*AnimationEquation.OUT_BACK.calc(decorationsAlpha);
float tickScale = 0.5f + 0.5f * AnimationEquation.OUT_BACK.calc(decorationsAlpha);
Image tick = GameImage.SLIDER_TICK.getImage().getScaledCopy(tickScale);
for (int i = 0; i < ticksT.length; i++) {
Vec2f c = curve.pointAt(ticksT[i]);
Colors.WHITE_FADE.a = decorationsAlpha;
tick.drawCentered(c.x , c.y , Colors.WHITE_FADE);
tick.drawCentered(c.x, c.y, Colors.WHITE_FADE);
Colors.WHITE_FADE.a = alpha;
}
}
@ -240,18 +235,12 @@ public class Slider implements GameObject {
if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
Image arrow = GameImage.REVERSEARROW.getImage();
if (tcurRepeat != currentRepeats) {
if (sliderTime == 0) {
if (sliderTime == 0)
continue;
}
float t = Math.max(getT(trackPosition, true), 0);
arrow.setAlpha((float) (t - Math.floor(t)));
} else {
if(Options.isSliderSnaking()){
arrow.setAlpha(decorationsAlpha);
} else {
arrow.setAlpha(1f);
}
}
} else
arrow.setAlpha(Options.isSliderSnaking() ? decorationsAlpha : 1f);
if (tcurRepeat % 2 == 0) {
// last circle
arrow.setRotation(curve.getEndAngle());

View File

@ -111,6 +111,12 @@ public abstract class Curve {
*/
public abstract Vec2f pointAt(float t);
/**
* Draws the full curve to the graphics context.
* @param color the color filter
*/
public void draw(Color color) { draw(color, 1f); }
/**
* Draws the curve in the range [0, t] (where the full range is [0, 1]) to the graphics context.
* @param color the color filter
@ -120,10 +126,11 @@ public abstract class Curve {
if (curve == null)
return;
t = Utils.clamp(t, 0.0f, 1.0f);
t = Utils.clamp(t, 0f, 1f);
// peppysliders
if (Options.getSkin().getSliderStyle() == Skin.STYLE_PEPPYSLIDER || !mmsliderSupported) {
int drawUpTo = (int)(curve.length*t);
int drawUpTo = (int) (curve.length * t);
Image hitCircle = GameImage.HITCIRCLE.getImage();
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
for (int i = 0; i < drawUpTo; i++)
@ -135,7 +142,7 @@ public abstract class Curve {
// mmsliders
else {
if (renderState == null)
renderState = new CurveRenderState(hitObject,curve);
renderState = new CurveRenderState(hitObject, curve);
renderState.draw(color, borderColor, t);
}
}

View File

@ -59,10 +59,10 @@ public class CurveRenderState {
/** The HitObject associated with the curve to be drawn. */
protected HitObject hitObject;
/** the points along the curve to be drawn */
/** The points along the curve to be drawn. */
protected Vec2f[] curve;
/** The point to which the curve has last been rendered into the texture (as an index into {@code curve}) */
/** The point to which the curve has last been rendered into the texture (as an index into {@code curve}). */
private int lastPointDrawn;
/**
@ -131,10 +131,8 @@ public class CurveRenderState {
int drawUpTo = (int) (t * curve.length);
if (lastPointDrawn != drawUpTo) {
if (drawUpTo == lastPointDrawn) {
if (drawUpTo == lastPointDrawn)
return;
}
int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
@ -269,8 +267,7 @@ public class CurveRenderState {
* curve into the OpenGL buffer with the ID specified by {@code bufferID}
* @param bufferID the buffer ID for the OpenGL buffer the vertices should be written into
*/
private void createVertexBuffer(int bufferID)
{
private void createVertexBuffer(int bufferID) {
int arrayBufferBinding = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING);
FloatBuffer buff = BufferUtils.createByteBuffer(4 * (4 + 2) * (2 * curve.length - 1) * (NewCurveStyleState.DIVIDES + 2)).asFloatBuffer();
for (int i = 0; i < curve.length; ++i) {
@ -313,7 +310,7 @@ public class CurveRenderState {
//2*4 is for skipping the first 2 floats (u,v)
GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4);
GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0);
for (int i = from*2; i < to * 2 - 1; ++i)
for (int i = from * 2; i < to * 2 - 1; ++i)
GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, i * (NewCurveStyleState.DIVIDES + 2), NewCurveStyleState.DIVIDES + 2);
GL11.glFlush();
GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
@ -334,15 +331,14 @@ public class CurveRenderState {
float offx = -1.0f;
float offy = 1.0f;
float radius = scale / 2;
for(int i = 0; i<NewCurveStyleState.unitCone.length/6; ++i)
{
buff.put(NewCurveStyleState.unitCone[i*6+0]);
buff.put(NewCurveStyleState.unitCone[i*6+1]);
buff.put(offx + (x1 + radius * NewCurveStyleState.unitCone[i*6+2])/divx);
buff.put(offy - (y1 + radius * NewCurveStyleState.unitCone[i*6+3])/divy);
buff.put(NewCurveStyleState.unitCone[i*6+4]);
buff.put(NewCurveStyleState.unitCone[i*6+5]);
for (int i = 0; i < NewCurveStyleState.unitCone.length / 6; ++i) {
buff.put(NewCurveStyleState.unitCone[i * 6 + 0]);
buff.put(NewCurveStyleState.unitCone[i * 6 + 1]);
buff.put(offx + (x1 + radius * NewCurveStyleState.unitCone[i * 6 + 2]) / divx);
buff.put(offy - (y1 + radius * NewCurveStyleState.unitCone[i * 6 + 3]) / divy);
buff.put(NewCurveStyleState.unitCone[i * 6 + 4]);
buff.put(NewCurveStyleState.unitCone[i * 6 + 5]);
}
}
@ -364,7 +360,7 @@ public class CurveRenderState {
* of a cone with DIVIDES vertices at its base, that is centered around
* (0,0) and has a radius of 1 (so that it can be translated and scaled easily).
*/
protected static float[] unitCone = new float[(DIVIDES+2)*6];
protected static float[] unitCone = new float[(DIVIDES + 2) * 6];
/** OpenGL shader program ID used to draw and recolor the curve. */
protected int program = 0;
@ -417,8 +413,7 @@ public class CurveRenderState {
int index = 0;
//check if initialization has already happened
if (unitCone[0] == 0.0f) {
//tip of the cone
//tip of the cone
//vec2 texture coordinates
unitCone[index++] = 1.0f;
unitCone[index++] = 0.5f;
@ -448,7 +443,6 @@ public class CurveRenderState {
unitCone[index++] = 1.0f;
unitCone[index++] = 1.0f;
}
}
/**

View File

@ -32,7 +32,7 @@ public class Rendertarget {
/** The dimensions. */
public final int width, height;
/** ID of the vertex buffer associated with this rendertarget*/
/** The ID of the vertex buffer associated with this rendertarget. */
private final int vboID;
/** The FBO ID. */