Synchronizing the Replay Timeline now respects the Speed Slider's value as a stretch factor. Shift key ignores that stretch value.

This commit is contained in:
CrushedPixel
2015-07-21 23:58:56 +02:00
parent 0a71266a05
commit 9d025cfae0
2 changed files with 13 additions and 11 deletions

View File

@@ -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() {

View File

@@ -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<TimestampValue> 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<TimestampValue> 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);
}