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:
@@ -256,6 +256,10 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
|
|
||||||
private final GuiReplaySpeedSlider speedSlider = new GuiReplaySpeedSlider(SPEED_X, TOP_ROW, I18n.format("replaymod.gui.speed"));
|
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 boolean toolbarOpen = false;
|
||||||
|
|
||||||
private final DelegatingElement toolbar = new DelegatingElement() {
|
private final DelegatingElement toolbar = new DelegatingElement() {
|
||||||
|
|||||||
@@ -522,22 +522,18 @@ public class ReplayHandler {
|
|||||||
return currentReplayFile == null ? null : currentReplayFile.getFile();
|
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);
|
selectKeyframe(null);
|
||||||
|
|
||||||
int curTime = ReplayMod.replaySender.currentTimeStamp();
|
int curTime = ReplayMod.replaySender.currentTimeStamp();
|
||||||
|
|
||||||
int prevTime, prevRealTime;
|
int prevTime, prevRealTime;
|
||||||
|
|
||||||
Keyframe<TimestampValue> keyframe;
|
Keyframe<TimestampValue> keyframe = timeKeyframes.last();
|
||||||
|
|
||||||
//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();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(keyframe == null) {
|
if(keyframe == null) {
|
||||||
prevTime = 0;
|
prevTime = 0;
|
||||||
@@ -547,7 +543,9 @@ public class ReplayHandler {
|
|||||||
prevRealTime = keyframe.getRealTimestamp();
|
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);
|
setRealTimelineCursor(newCursorPos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user