Fix camera path always playing from the beginning regardless of ctrl key
This commit is contained in:
@@ -24,6 +24,7 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
private final ReplayHandler replayHandler;
|
private final ReplayHandler replayHandler;
|
||||||
private Timeline timeline;
|
private Timeline timeline;
|
||||||
|
protected long startOffset;
|
||||||
private long lastTime;
|
private long lastTime;
|
||||||
private long lastTimestamp;
|
private long lastTimestamp;
|
||||||
private ListenableFuture<Void> future;
|
private ListenableFuture<Void> future;
|
||||||
@@ -33,6 +34,11 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
this.replayHandler = replayHandler;
|
this.replayHandler = replayHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ListenableFuture<Void> start(Timeline timeline, long from) {
|
||||||
|
startOffset = from;
|
||||||
|
return start(timeline);
|
||||||
|
}
|
||||||
|
|
||||||
public ListenableFuture<Void> start(Timeline timeline) {
|
public ListenableFuture<Void> start(Timeline timeline) {
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,6 @@ public class RealtimeTimelinePlayer extends AbstractTimelinePlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimePassed() {
|
public long getTimePassed() {
|
||||||
return firstFrame ? 0 : System.currentTimeMillis() - startTime;
|
return startOffset + (firstFrame ? 0 : System.currentTimeMillis() - startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,9 @@ public class GuiPathing {
|
|||||||
if (!preparePathsForPlayback()) return;
|
if (!preparePathsForPlayback()) return;
|
||||||
|
|
||||||
timePath.setActive(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT));
|
timePath.setActive(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT));
|
||||||
ListenableFuture<Void> future = player.start(timeline);
|
// Start from cursor time unless the control key is pressed (then start from beginning)
|
||||||
|
int startTime = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)? 0 : GuiPathing.this.timeline.getCursorPosition();
|
||||||
|
ListenableFuture<Void> future = player.start(timeline, startTime);
|
||||||
overlay.setCloseable(false);
|
overlay.setCloseable(false);
|
||||||
overlay.setMouseVisible(true);
|
overlay.setMouseVisible(true);
|
||||||
Futures.addCallback(future, new FutureCallback<Void>() {
|
Futures.addCallback(future, new FutureCallback<Void>() {
|
||||||
|
|||||||
Reference in New Issue
Block a user