From 14496050ead706487a79e82d8a535a5fb3764124 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Fri, 18 Sep 2015 16:02:19 -0400 Subject: [PATCH] Minor style changes from #134. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/GameData.java | 2 +- src/itdelatrisu/opsu/objects/Slider.java | 23 ++++-------- .../opsu/objects/curves/Curve.java | 13 +++++-- .../opsu/render/CurveRenderState.java | 36 ++++++++----------- src/itdelatrisu/opsu/render/Rendertarget.java | 2 +- 5 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/itdelatrisu/opsu/GameData.java b/src/itdelatrisu/opsu/GameData.java index ebc3a28c..1dd3de06 100644 --- a/src/itdelatrisu/opsu/GameData.java +++ b/src/itdelatrisu/opsu/GameData.java @@ -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; } diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index 7c394276..e9a3cbc6 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -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()); diff --git a/src/itdelatrisu/opsu/objects/curves/Curve.java b/src/itdelatrisu/opsu/objects/curves/Curve.java index aab35343..e72b137c 100644 --- a/src/itdelatrisu/opsu/objects/curves/Curve.java +++ b/src/itdelatrisu/opsu/objects/curves/Curve.java @@ -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); } } diff --git a/src/itdelatrisu/opsu/render/CurveRenderState.java b/src/itdelatrisu/opsu/render/CurveRenderState.java index 42baab40..737db42b 100644 --- a/src/itdelatrisu/opsu/render/CurveRenderState.java +++ b/src/itdelatrisu/opsu/render/CurveRenderState.java @@ -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