Add undo/redo to keyframe timeline (closes #305)

This commit is contained in:
Jonas Herzig
2020-11-06 14:19:09 +01:00
parent 28facc430e
commit 577e59fd41
3 changed files with 30 additions and 1 deletions

View File

@@ -147,6 +147,8 @@ If two Keyframes are 5 seconds apart, the Camera Path will take 5 seconds to int
You can drag Keyframes on the **Keyframe Timeline** by left-clicking them, holding the mouse button and moving your mouse. You can drag Keyframes on the **Keyframe Timeline** by left-clicking them, holding the mouse button and moving your mouse.
> **Hint:** Made a mistake? You can use `Ctrl+Z` to undo your changes to the keyframe timeline. Changed you mind? Press `Ctrl+Y` (or `Ctrl+Shift+Z`) to redo them.
### Position Keyframes [place] ### Position Keyframes [place]
The basic components of a Camera Path are **Position Keyframes**. The basic components of a Camera Path are **Position Keyframes**.
A Position Keyframe stores a **Camera Position** (x, y, z, yaw, pitch, roll). A Position Keyframe stores a **Camera Position** (x, y, z, yaw, pitch, roll).

View File

@@ -22,6 +22,7 @@ import com.replaymod.replaystudio.replay.ReplayFile;
import com.replaymod.simplepathing.SPTimeline.SPPath; import com.replaymod.simplepathing.SPTimeline.SPPath;
import com.replaymod.simplepathing.gui.GuiPathing; import com.replaymod.simplepathing.gui.GuiPathing;
import com.replaymod.simplepathing.preview.PathPreview; import com.replaymod.simplepathing.preview.PathPreview;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.CrashException; import net.minecraft.util.crash.CrashException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@@ -114,6 +115,32 @@ public class ReplayModSimplePathing extends EventRegistrations implements Module
guiPathing.toggleKeyframe(SPPath.POSITION, false); guiPathing.toggleKeyframe(SPPath.POSITION, false);
} }
}, true); }, true);
core.getKeyBindingRegistry().registerRaw(Keyboard.KEY_Z, () -> {
if (Screen.hasControlDown() && currentTimeline != null) {
Timeline timeline = currentTimeline.getTimeline();
if (Screen.hasShiftDown()) {
if (timeline.peekRedoStack() != null) {
timeline.redoLastChange();
}
} else {
if (timeline.peekUndoStack() != null) {
timeline.undoLastChange();
}
}
return true;
}
return false;
});
core.getKeyBindingRegistry().registerRaw(Keyboard.KEY_Y, () -> {
if (Screen.hasControlDown() && currentTimeline != null) {
Timeline timeline = currentTimeline.getTimeline();
if (timeline.peekRedoStack() != null) {
timeline.redoLastChange();
}
return true;
}
return false;
});
} }
{ on(ReplayOpenedCallback.EVENT, this::onReplayOpened); } { on(ReplayOpenedCallback.EVENT, this::onReplayOpened); }

View File

@@ -305,7 +305,7 @@ dependencies {
shadow 'com.github.ReplayMod.JavaBlend:2.79.0:a0696f8' shadow 'com.github.ReplayMod.JavaBlend:2.79.0:a0696f8'
shadow "com.github.ReplayMod:ReplayStudio:9558f9e", shadeExclusions shadow "com.github.ReplayMod:ReplayStudio:919db4e", shadeExclusions
implementation(jGui){ implementation(jGui){
transitive = false // FG 1.2 puts all MC deps into the compile configuration and we don't want to shade those transitive = false // FG 1.2 puts all MC deps into the compile configuration and we don't want to shade those