From 9d025cfae0a4cf409556605e9b54396a6aeb4a22 Mon Sep 17 00:00:00 2001 From: CrushedPixel Date: Tue, 21 Jul 2015 23:58:56 +0200 Subject: [PATCH] Synchronizing the Replay Timeline now respects the Speed Slider's value as a stretch factor. Shift key ignores that stretch value. --- .../gui/overlay/GuiReplayOverlay.java | 4 ++++ .../replaymod/replay/ReplayHandler.java | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java b/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java index 886b664c..d4e0549c 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/overlay/GuiReplayOverlay.java @@ -256,6 +256,10 @@ public class GuiReplayOverlay extends Gui { private final GuiReplaySpeedSlider speedSlider = new GuiReplaySpeedSlider(SPEED_X, TOP_ROW, I18n.format("replaymod.gui.speed")); + public double getSpeedSliderValue() { + return speedSlider.getSliderValue(); + } + private boolean toolbarOpen = false; private final DelegatingElement toolbar = new DelegatingElement() { diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java index 81a8cddb..201d7316 100755 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayHandler.java @@ -522,22 +522,18 @@ public class ReplayHandler { return currentReplayFile == null ? null : currentReplayFile.getFile(); } - public static void syncTimeCursor(boolean shiftMode) { + /** + * Synchronizes the cursor on the Keyframe Timeline with the Replay Time + * @param ignoreReplaySpeed If true, it always uses 1.0 as the stretch factor + */ + public static void syncTimeCursor(boolean ignoreReplaySpeed) { selectKeyframe(null); int curTime = ReplayMod.replaySender.currentTimeStamp(); int prevTime, prevRealTime; - Keyframe keyframe; - - //if shift is down, it will refer to the previous Time Keyframe instead of the last one - if(shiftMode) { - int realTime = getRealTimelineCursor(); - keyframe = timeKeyframes.getPreviousKeyframe(realTime, false); - } else { - keyframe = timeKeyframes.last(); - } + Keyframe keyframe = timeKeyframes.last(); if(keyframe == null) { prevTime = 0; @@ -547,7 +543,9 @@ public class ReplayHandler { prevRealTime = keyframe.getRealTimestamp(); } - int newCursorPos = Math.min(GuiReplayOverlay.KEYFRAME_TIMELINE_LENGTH, prevRealTime+(curTime-prevTime)); + double speed = ignoreReplaySpeed ? 1 : ReplayMod.overlay.getSpeedSliderValue(); + + int newCursorPos = Math.min(GuiReplayOverlay.KEYFRAME_TIMELINE_LENGTH, (int)(prevRealTime+((curTime-prevTime)/speed))); setRealTimelineCursor(newCursorPos); }