From 580f11a3d3c8ed1f5b8a092f5cb861bfe1655ac4 Mon Sep 17 00:00:00 2001 From: yugecin Date: Sat, 3 Dec 2016 19:11:36 +0100 Subject: [PATCH] draw sliders on correct times --- src/itdelatrisu/opsu/objects/Slider.java | 7 +++++++ src/itdelatrisu/opsu/states/Game.java | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index cabd0ca4..858e4767 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -122,6 +122,8 @@ public class Slider extends GameObject { private int tickExpand = 0; private final int TICKEXPAND = 200; + public int baseSliderFrom; + /** * Initializes the Slider data type with images and dimensions. * @param container the game container @@ -221,6 +223,11 @@ public class Slider extends GameObject { float curveInterval = Options.isSliderSnaking() ? alpha : 1f; //curve.draw(curveColor, curveInterval); + float sliderprogress = (float) (trackPosition - getTime()) / sliderTimeTotal; + if (sliderprogress > 0) { + game.setSlidercurveFrom(baseSliderFrom + (int) (sliderprogress * curve.getCurvePoints().length)); + } + game.setSlidercurveTo(baseSliderFrom + (int) (curveInterval * curve.getCurvePoints().length)); color.a = alpha; g.pushTransform(); diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 96fe6d47..d18ca304 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -44,9 +44,7 @@ import itdelatrisu.opsu.objects.Slider; import itdelatrisu.opsu.objects.Spinner; import itdelatrisu.opsu.objects.curves.Curve; import itdelatrisu.opsu.objects.curves.Vec2f; -import itdelatrisu.opsu.render.CurveRenderState; import itdelatrisu.opsu.render.FrameBufferCache; -import itdelatrisu.opsu.render.KnorkeCurveRenderStuff; import itdelatrisu.opsu.replay.PlaybackSpeed; import itdelatrisu.opsu.replay.Replay; import itdelatrisu.opsu.replay.ReplayFrame; @@ -1461,12 +1459,15 @@ public class Game extends BasicGameState { List curvepoints = new ArrayList<>(); for (GameObject gameObject : gameObjects) { if (gameObject.isSlider()) { + ((Slider) gameObject).baseSliderFrom = curvepoints.size(); curvepoints.addAll(Arrays.asList(((Slider) gameObject).getCurve().getCurvePoints())); } } knorkesliders = new FakeCombinedCurve(curvepoints.toArray(new Vec2f[curvepoints.size()])); } + slidercurveFrom = 0; + slidercurveTo = 0; Dancer.instance.setGameObjects(gameObjects); sbOverlay.setGameObjects(gameObjects); @@ -1511,12 +1512,12 @@ public class Game extends BasicGameState { private float slidercurveTo; public void setSlidercurveFrom(int slidercurveFrom) { - float pos = slidercurveFrom / knorkesliders.getCurvePoints().length; - this.slidercurveFrom = Math.min(pos, this.slidercurveFrom); + float pos = (float) slidercurveFrom / knorkesliders.getCurvePoints().length; + this.slidercurveFrom = Math.max(pos, this.slidercurveFrom); } public void setSlidercurveTo(int slidercurveTo) { - float pos = slidercurveTo / knorkesliders.getCurvePoints().length; + float pos = (float) slidercurveTo / knorkesliders.getCurvePoints().length; this.slidercurveTo = Math.max(pos, this.slidercurveTo); }