mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 14:38:50 +00:00
Implement scene switcher
This commit is contained in:
1 parent
959144e227
commit
590b35aa76
15 files changed
+473
-314
No files matched your search
@@ -2,7 +2,6 @@ package com.moulberry.flashback;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.moulberry.flashback.keyframe.Keyframe;
|
||||
import com.moulberry.flashback.keyframe.KeyframeRegistry;
|
||||
@@ -18,7 +17,7 @@ import com.moulberry.flashback.serialization.QuaterniondTypeAdapater;
|
||||
import com.moulberry.flashback.serialization.QuaternionfTypeAdapater;
|
||||
import com.moulberry.flashback.serialization.Vector3dTypeAdapater;
|
||||
import com.moulberry.flashback.serialization.Vector3fTypeAdapater;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryAction;
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
@@ -47,11 +46,11 @@ public class FlashbackGson {
|
||||
.registerTypeAdapter(TimeOfDayKeyframe.class, new TimeOfDayKeyframe.TypeAdapter())
|
||||
.registerTypeAdapter(Keyframe.class, new Keyframe.TypeAdapter())
|
||||
|
||||
.registerTypeAdapter(EditorStateHistoryAction.SetKeyframe.class, new EditorStateHistoryAction.SetKeyframe.TypeAdapter())
|
||||
.registerTypeAdapter(EditorStateHistoryAction.RemoveKeyframe.class, new EditorStateHistoryAction.RemoveKeyframe.TypeAdapter())
|
||||
.registerTypeAdapter(EditorStateHistoryAction.AddTrack.class, new EditorStateHistoryAction.AddTrack.TypeAdapter())
|
||||
.registerTypeAdapter(EditorStateHistoryAction.RemoveTrack.class, new EditorStateHistoryAction.RemoveTrack.TypeAdapter())
|
||||
.registerTypeAdapter(EditorStateHistoryAction.class, new EditorStateHistoryAction.TypeAdapter());
|
||||
.registerTypeAdapter(EditorSceneHistoryAction.SetKeyframe.class, new EditorSceneHistoryAction.SetKeyframe.TypeAdapter())
|
||||
.registerTypeAdapter(EditorSceneHistoryAction.RemoveKeyframe.class, new EditorSceneHistoryAction.RemoveKeyframe.TypeAdapter())
|
||||
.registerTypeAdapter(EditorSceneHistoryAction.AddTrack.class, new EditorSceneHistoryAction.AddTrack.TypeAdapter())
|
||||
.registerTypeAdapter(EditorSceneHistoryAction.RemoveTrack.class, new EditorSceneHistoryAction.RemoveTrack.TypeAdapter())
|
||||
.registerTypeAdapter(EditorSceneHistoryAction.class, new EditorSceneHistoryAction.TypeAdapter());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,10 @@ package com.moulberry.flashback.editor;
|
||||
|
||||
import com.moulberry.flashback.keyframe.Keyframe;
|
||||
import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryEntry;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryEntry;
|
||||
import com.moulberry.flashback.state.KeyframeTrack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -15,37 +16,37 @@ import java.util.TreeMap;
|
||||
|
||||
public record SavedTrack(KeyframeType<?> type, int track, boolean copiedFromDisabled,
|
||||
TreeMap<Integer, Keyframe> keyframes) {
|
||||
public int applyToEditorState(EditorState editorState, int cursorTicks, int totalTicks) {
|
||||
public int applyToScene(EditorScene editorScene, int cursorTicks, int totalTicks) {
|
||||
if (this.keyframes == null || this.keyframes.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Try to apply directly to copied track
|
||||
if (this.track >= 0 && this.track < editorState.keyframeTracks.size()) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(this.track);
|
||||
if (this.track >= 0 && this.track < editorScene.keyframeTracks.size()) {
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(this.track);
|
||||
if ((keyframeTrack.enabled || this.copiedFromDisabled) && keyframeTrack.keyframeType == this.type) {
|
||||
return this.applyTo(editorState, this.type, keyframeTrack, this.track, cursorTicks, totalTicks);
|
||||
return this.applyTo(editorScene, this.type, keyframeTrack, this.track, cursorTicks, totalTicks);
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find first eligible enabled track
|
||||
for (KeyframeTrack keyframeTrack : editorState.keyframeTracks) {
|
||||
for (KeyframeTrack keyframeTrack : editorScene.keyframeTracks) {
|
||||
if (keyframeTrack.enabled && keyframeTrack.keyframeType == this.type) {
|
||||
return this.applyTo(editorState, this.type, keyframeTrack, this.track, cursorTicks, totalTicks);
|
||||
return this.applyTo(editorScene, this.type, keyframeTrack, this.track, cursorTicks, totalTicks);
|
||||
}
|
||||
}
|
||||
|
||||
// Create new track
|
||||
return this.applyTo(editorState, this.type, null, this.track, cursorTicks, totalTicks);
|
||||
return this.applyTo(editorScene, this.type, null, this.track, cursorTicks, totalTicks);
|
||||
}
|
||||
|
||||
private int applyTo(EditorState editorState, KeyframeType type, @Nullable KeyframeTrack existing, int trackIndex, int cursorTicks, int totalTicks) {
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
private int applyTo(EditorScene editorScene, KeyframeType<?> type, @Nullable KeyframeTrack existing, int trackIndex, int cursorTicks, int totalTicks) {
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
if (existing == null) {
|
||||
undo.add(new EditorStateHistoryAction.RemoveTrack(type, trackIndex));
|
||||
redo.add(new EditorStateHistoryAction.AddTrack(type, trackIndex));
|
||||
undo.add(new EditorSceneHistoryAction.RemoveTrack(type, trackIndex));
|
||||
redo.add(new EditorSceneHistoryAction.AddTrack(type, trackIndex));
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
@@ -56,18 +57,18 @@ public record SavedTrack(KeyframeType<?> type, int track, boolean copiedFromDisa
|
||||
Keyframe old = existing.keyframesByTick.get(newTick);
|
||||
|
||||
if (old != null) {
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(type, trackIndex, newTick, old.copy()));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(type, trackIndex, newTick, old.copy()));
|
||||
} else {
|
||||
undo.add(new EditorStateHistoryAction.RemoveKeyframe(type, trackIndex, newTick));
|
||||
undo.add(new EditorSceneHistoryAction.RemoveKeyframe(type, trackIndex, newTick));
|
||||
}
|
||||
}
|
||||
redo.add(new EditorStateHistoryAction.SetKeyframe(type, trackIndex, newTick, entry.getValue().copy()));
|
||||
redo.add(new EditorSceneHistoryAction.SetKeyframe(type, trackIndex, newTick, entry.getValue().copy()));
|
||||
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Pasted " + count + " keyframe(s)"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Pasted " + count + " keyframe(s)"));
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.moulberry.flashback.editor;
|
||||
|
||||
import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.KeyframeTrack;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
public record SelectedKeyframes(KeyframeType<?> type, int trackIndex, IntSet keyframeTicks) {
|
||||
public boolean checkValid(EditorState state) {
|
||||
if (this.trackIndex < 0 || this.trackIndex >= state.keyframeTracks.size()) {
|
||||
public boolean checkValid(EditorScene scene) {
|
||||
if (this.trackIndex < 0 || this.trackIndex >= scene.keyframeTracks.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KeyframeTrack keyframeTrack = state.keyframeTracks.get(this.trackIndex);
|
||||
KeyframeTrack keyframeTrack = scene.keyframeTracks.get(this.trackIndex);
|
||||
if (keyframeTrack.keyframeType != this.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ public class ReplayUI {
|
||||
builder.addChar('\ue872');
|
||||
builder.addChar('\ue3c9');
|
||||
builder.addChar('\ue40a');
|
||||
builder.addChar('\ue92b');
|
||||
return builder.buildRanges();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.moulberry.flashback.editor.ui.ImGuiHelper;
|
||||
import com.moulberry.flashback.exporting.AsyncFileDialogs;
|
||||
import com.moulberry.flashback.exporting.ExportJob;
|
||||
import com.moulberry.flashback.exporting.ExportSettings;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import imgui.ImGui;
|
||||
@@ -79,7 +80,9 @@ public class ExportScreenshotWindow {
|
||||
boolean noGui = StartExportWindow.noGui;
|
||||
|
||||
EditorState copiedEditorState = editorState.copy();
|
||||
copiedEditorState.keyframeTracks.clear();
|
||||
for (EditorScene scene : copiedEditorState.scenes) {
|
||||
scene.keyframeTracks.clear();
|
||||
}
|
||||
|
||||
ExportSettings settings = new ExportSettings(null, copiedEditorState,
|
||||
player.position(), player.getYRot(), player.getXRot(),
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.moulberry.flashback.combo_options.Sizing;
|
||||
import com.moulberry.flashback.combo_options.VideoCodec;
|
||||
import com.moulberry.flashback.combo_options.VideoContainer;
|
||||
import com.moulberry.flashback.exporting.ExportJobQueue;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.editor.ui.ImGuiHelper;
|
||||
@@ -158,7 +159,8 @@ public class StartExportWindow {
|
||||
if (ImGuiHelper.inputInt("Start/end tick", startEndTick)) {
|
||||
ReplayServer replayServer = Flashback.getReplayServer();
|
||||
if (editorState != null && replayServer != null) {
|
||||
editorState.setExportTicks(startEndTick[0], startEndTick[1], replayServer.getTotalReplayTicks());
|
||||
editorState.currentScene().setExportTicks(startEndTick[0], startEndTick[1], replayServer.getTotalReplayTicks());
|
||||
editorState.markDirty();
|
||||
}
|
||||
}
|
||||
ImGuiHelper.inputFloat("Framerate", framerate);
|
||||
@@ -487,14 +489,15 @@ public class StartExportWindow {
|
||||
open = true;
|
||||
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
EditorScene editorScene = editorState == null ? null : editorState.currentScene();
|
||||
|
||||
if (editorState != null && editorState.exportStartTicks >= 0) {
|
||||
startEndTick[0] = editorState.exportStartTicks;
|
||||
if (editorScene != null && editorScene.exportStartTicks >= 0) {
|
||||
startEndTick[0] = editorScene.exportStartTicks;
|
||||
} else {
|
||||
startEndTick[0] = 0;
|
||||
}
|
||||
if (editorState != null && editorState.exportEndTicks >= 0) {
|
||||
startEndTick[1] = editorState.exportEndTicks;
|
||||
if (editorScene != null && editorScene.exportEndTicks >= 0) {
|
||||
startEndTick[1] = editorScene.exportEndTicks;
|
||||
} else {
|
||||
ReplayServer replayServer = Flashback.getReplayServer();
|
||||
if (replayServer == null) {
|
||||
|
||||
@@ -10,12 +10,12 @@ import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
import com.moulberry.flashback.keyframe.KeyframeRegistry;
|
||||
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
||||
import com.moulberry.flashback.keyframe.types.CameraKeyframeType;
|
||||
import com.moulberry.flashback.keyframe.types.TimelapseKeyframeType;
|
||||
import com.moulberry.flashback.record.ReplayMarker;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryEntry;
|
||||
import com.moulberry.flashback.keyframe.impl.TimelapseKeyframe;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryEntry;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.keyframe.Keyframe;
|
||||
@@ -28,11 +28,8 @@ import com.moulberry.flashback.state.KeyframeTrack;
|
||||
import imgui.ImDrawList;
|
||||
import imgui.ImGui;
|
||||
import imgui.ImVec4;
|
||||
import imgui.flag.ImGuiButtonFlags;
|
||||
import imgui.flag.ImGuiCol;
|
||||
import imgui.flag.ImGuiComboFlags;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.flag.ImGuiDragDropFlags;
|
||||
import imgui.flag.ImGuiHoveredFlags;
|
||||
import imgui.flag.ImGuiInputTextFlags;
|
||||
import imgui.flag.ImGuiMouseButton;
|
||||
@@ -52,6 +49,8 @@ import java.util.*;
|
||||
|
||||
public class TimelineWindow {
|
||||
|
||||
private static EditorState editorState;
|
||||
private static EditorScene editorScene;
|
||||
private static double zoomMinBeforeDrag = 0.0f;
|
||||
private static double zoomMaxBeforeDrag = 1.0f;
|
||||
private static boolean grabbedZoomBar = false;
|
||||
@@ -78,6 +77,7 @@ public class TimelineWindow {
|
||||
|
||||
private static KeyframeType.KeyframeCreatePopup<?> createKeyframeWithPopup = null;
|
||||
private static int createKeyframeWithPopupTick = 0;
|
||||
private static ImString sceneNameString = null;
|
||||
|
||||
private static float mouseX;
|
||||
private static float mouseY;
|
||||
@@ -153,7 +153,8 @@ public class TimelineWindow {
|
||||
|
||||
if (timelineVisible) {
|
||||
FlashbackMeta metadata = replayServer.getMetadata();
|
||||
EditorState editorState = EditorStateManager.get(metadata.replayIdentifier);
|
||||
editorState = EditorStateManager.get(metadata.replayIdentifier);
|
||||
editorScene = editorState.currentScene();
|
||||
|
||||
ImDrawList drawList = ImGui.getWindowDrawList();
|
||||
|
||||
@@ -172,7 +173,7 @@ public class TimelineWindow {
|
||||
return;
|
||||
}
|
||||
|
||||
selectedKeyframesList.removeIf(k -> !k.checkValid(editorState));
|
||||
selectedKeyframesList.removeIf(k -> !k.checkValid(editorScene));
|
||||
|
||||
if (editingKeyframeTrack >= 0 && editingKeyframeTick >= 0) {
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
@@ -238,12 +239,12 @@ public class TimelineWindow {
|
||||
cursorTicks = Math.max(0, cursorTicks - pendingStepBackwardsTicks);
|
||||
}
|
||||
|
||||
if (grabbedPlayback && !editorState.keyframeTracks.isEmpty()) {
|
||||
if (grabbedPlayback && !editorScene.keyframeTracks.isEmpty()) {
|
||||
boolean isCtrlDown = ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL);
|
||||
boolean isShiftDown = ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||
|
||||
if (isShiftDown) {
|
||||
int closestTick = findClosestKeyframeForSnap(editorState, cursorTicks);
|
||||
int closestTick = findClosestKeyframeForSnap(cursorTicks);
|
||||
if (closestTick != -1) {
|
||||
cursorTicks = closestTick;
|
||||
}
|
||||
@@ -278,14 +279,14 @@ public class TimelineWindow {
|
||||
// Middle divider (y)
|
||||
drawList.addLine(x, y + middleY, x + width, y + middleY, -1);
|
||||
|
||||
renderKeyframeElements(replayServer, editorState, x, y + middleY, cursorTicks, middleX);
|
||||
renderKeyframeElements(x, y + middleY, cursorTicks, middleX);
|
||||
|
||||
drawList.pushClipRect(x + middleX, y, x + width, y + height);
|
||||
|
||||
renderExportBar(editorState, drawList);
|
||||
renderExportBar(drawList);
|
||||
|
||||
drawList.pushClipRect(x + middleX, y + middleY, x + width, y + height);
|
||||
renderKeyframes(editorState, x, y + middleY, mouseX, minTicks, availableTicks, totalTicks);
|
||||
renderKeyframes(x, y + middleY, mouseX, minTicks, availableTicks, totalTicks);
|
||||
drawList.popClipRect();
|
||||
|
||||
renderSeparators(minorsPerMajor, x, middleX, minorSeparatorWidth, errorOffset, width, drawList, y, timestampHeight, middleY, minTicks, ticksPerMinor, showSubSeconds, majorSeparatorHeight, minorSeparatorHeight);
|
||||
@@ -430,7 +431,7 @@ public class TimelineWindow {
|
||||
}
|
||||
|
||||
if (ImGui.beginPopup("##KeyframePopup")) {
|
||||
renderKeyframeOptionsPopup(editorState);
|
||||
renderKeyframeOptionsPopup();
|
||||
ImGui.endPopup();
|
||||
} else {
|
||||
editingKeyframeTrack = -1;
|
||||
@@ -459,12 +460,12 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
handleKeyPresses(replayServer, cursorTicks, editorState, totalTicks);
|
||||
handleKeyPresses(replayServer, cursorTicks, totalTicks);
|
||||
|
||||
boolean leftClicked = ImGui.isMouseClicked(ImGuiMouseButton.Left);
|
||||
boolean rightClicked = ImGui.isMouseClicked(ImGuiMouseButton.Right);
|
||||
if (leftClicked || rightClicked) {
|
||||
handleClick(editorState, replayServer, totalTicks);
|
||||
handleClick(replayServer, totalTicks);
|
||||
if (leftClicked) {
|
||||
draggingMouseButton = ImGuiMouseButton.Left;
|
||||
} else {
|
||||
@@ -473,22 +474,22 @@ public class TimelineWindow {
|
||||
dragStartMouseX = mouseX;
|
||||
dragStartMouseY = mouseY;
|
||||
} else if (ImGui.isMouseDragging(draggingMouseButton)) {
|
||||
if (repositioningKeyframeTrack >= 0 && repositioningKeyframeTrack < editorState.keyframeTracks.size()) {
|
||||
if (repositioningKeyframeTrack >= 0 && repositioningKeyframeTrack < editorScene.keyframeTracks.size()) {
|
||||
float lineHeight = ImGui.getTextLineHeightWithSpacing() + ImGui.getStyle().getItemSpacingY();
|
||||
|
||||
float mouseDeltaY = mouseY - dragStartMouseY;
|
||||
if (mouseDeltaY > lineHeight/2) {
|
||||
if (repositioningKeyframeTrack < editorState.keyframeTracks.size()-1) {
|
||||
if (repositioningKeyframeTrack < editorScene.keyframeTracks.size()-1) {
|
||||
selectedKeyframesList.clear();
|
||||
editingKeyframeTrack = -1;
|
||||
editingKeyframeTick = -1;
|
||||
|
||||
dragStartMouseY += lineHeight;
|
||||
|
||||
var track = editorState.keyframeTracks.remove(repositioningKeyframeTrack);
|
||||
editorState.keyframeTracks.get(repositioningKeyframeTrack).animatedOffsetInUi += lineHeight;
|
||||
var track = editorScene.keyframeTracks.remove(repositioningKeyframeTrack);
|
||||
editorScene.keyframeTracks.get(repositioningKeyframeTrack).animatedOffsetInUi += lineHeight;
|
||||
repositioningKeyframeTrack += 1;
|
||||
editorState.keyframeTracks.add(repositioningKeyframeTrack, track);
|
||||
editorScene.keyframeTracks.add(repositioningKeyframeTrack, track);
|
||||
}
|
||||
} else if (mouseDeltaY < -lineHeight/2) {
|
||||
if (repositioningKeyframeTrack > 0) {
|
||||
@@ -498,10 +499,10 @@ public class TimelineWindow {
|
||||
|
||||
dragStartMouseY -= lineHeight;
|
||||
|
||||
var track = editorState.keyframeTracks.remove(repositioningKeyframeTrack);
|
||||
var track = editorScene.keyframeTracks.remove(repositioningKeyframeTrack);
|
||||
repositioningKeyframeTrack -= 1;
|
||||
editorState.keyframeTracks.get(repositioningKeyframeTrack).animatedOffsetInUi -= lineHeight;
|
||||
editorState.keyframeTracks.add(repositioningKeyframeTrack, track);
|
||||
editorScene.keyframeTracks.get(repositioningKeyframeTrack).animatedOffsetInUi -= lineHeight;
|
||||
editorScene.keyframeTracks.add(repositioningKeyframeTrack, track);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -512,13 +513,14 @@ public class TimelineWindow {
|
||||
int target = timelineXToReplayTick(mouseX - x);
|
||||
|
||||
if (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) {
|
||||
int closestTick = findClosestKeyframeForSnap(editorState, target);
|
||||
int closestTick = findClosestKeyframeForSnap(target);
|
||||
if (closestTick != -1) {
|
||||
target = closestTick;
|
||||
}
|
||||
}
|
||||
|
||||
editorState.setExportTicks(target, -1, totalTicks);
|
||||
editorScene.setExportTicks(target, -1, totalTicks);
|
||||
editorState.markDirty();
|
||||
}
|
||||
if (grabbedExportBarResizeRight) {
|
||||
ImGui.setMouseCursor(ImGuiMouseCursor.ResizeEW);
|
||||
@@ -526,13 +528,14 @@ public class TimelineWindow {
|
||||
int target = timelineXToReplayTick(mouseX - x);
|
||||
|
||||
if (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) {
|
||||
int closestTick = findClosestKeyframeForSnap(editorState, target);
|
||||
int closestTick = findClosestKeyframeForSnap(target);
|
||||
if (closestTick != -1) {
|
||||
target = closestTick;
|
||||
}
|
||||
}
|
||||
|
||||
editorState.setExportTicks(-1, target, totalTicks);
|
||||
editorScene.setExportTicks(-1, target, totalTicks);
|
||||
editorState.markDirty();
|
||||
}
|
||||
if (zoomBarWidth > 1f && grabbedZoomBar) {
|
||||
float dx = mouseX - dragStartMouseX;
|
||||
@@ -575,18 +578,18 @@ public class TimelineWindow {
|
||||
dragStartMouseX = mouseX;
|
||||
dragStartMouseY = mouseY;
|
||||
} else if (!ImGui.isAnyMouseDown()) {
|
||||
releaseGrabbed(editorState, replayServer, totalTicks);
|
||||
releaseGrabbed(replayServer, totalTicks);
|
||||
}
|
||||
} else {
|
||||
releaseGrabbed(editorState, replayServer, totalTicks);
|
||||
releaseGrabbed(replayServer, totalTicks);
|
||||
}
|
||||
}
|
||||
ImGui.end();
|
||||
}
|
||||
|
||||
private static int findClosestKeyframeForSnap(EditorState editorState, int tick) {
|
||||
private static int findClosestKeyframeForSnap(int tick) {
|
||||
int closestTick = -1;
|
||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||
for (KeyframeTrack track : editorScene.keyframeTracks) {
|
||||
Integer floor = track.keyframesByTick.floorKey(tick);
|
||||
Integer ceil = track.keyframesByTick.ceilingKey(tick);
|
||||
|
||||
@@ -605,7 +608,7 @@ public class TimelineWindow {
|
||||
return closestTick;
|
||||
}
|
||||
|
||||
private static void handleKeyPresses(ReplayServer replayServer, int cursorTicks, EditorState editorState, int totalTicks) {
|
||||
private static void handleKeyPresses(ReplayServer replayServer, int cursorTicks, int totalTicks) {
|
||||
boolean pressedIn = ImGui.isKeyPressed(GLFW.GLFW_KEY_I, false);
|
||||
boolean pressedOut = ImGui.isKeyPressed(GLFW.GLFW_KEY_O, false);
|
||||
|
||||
@@ -616,7 +619,7 @@ public class TimelineWindow {
|
||||
boolean pressedDelete = ImGui.isKeyPressed(GLFW.GLFW_KEY_DELETE, false) || ImGui.isKeyPressed(GLFW.GLFW_KEY_BACKSPACE, false);
|
||||
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_P, false)) {
|
||||
togglePaused(replayServer, editorState);
|
||||
togglePaused(replayServer);
|
||||
}
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_LEFT, false)) {
|
||||
pendingStepBackwardsTicks += 1;
|
||||
@@ -631,10 +634,10 @@ public class TimelineWindow {
|
||||
}
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_UP, false)) {
|
||||
int nextKeyframeTick;
|
||||
if (editorState.exportStartTicks >= 0 && editorState.exportStartTicks > cursorTicks) {
|
||||
nextKeyframeTick = editorState.exportStartTicks;
|
||||
} else if (editorState.exportEndTicks >= 0 && editorState.exportEndTicks > cursorTicks) {
|
||||
nextKeyframeTick = editorState.exportEndTicks;
|
||||
if (editorScene.exportStartTicks >= 0 && editorScene.exportStartTicks > cursorTicks) {
|
||||
nextKeyframeTick = editorScene.exportStartTicks;
|
||||
} else if (editorScene.exportEndTicks >= 0 && editorScene.exportEndTicks > cursorTicks) {
|
||||
nextKeyframeTick = editorScene.exportEndTicks;
|
||||
} else {
|
||||
nextKeyframeTick = totalTicks;
|
||||
}
|
||||
@@ -645,7 +648,7 @@ public class TimelineWindow {
|
||||
nextKeyframeTick = nextMarker;
|
||||
}
|
||||
|
||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||
for (KeyframeTrack track : editorScene.keyframeTracks) {
|
||||
Integer ceilingKey = track.keyframesByTick.ceilingKey(cursorTicks+1);
|
||||
if (ceilingKey != null && ceilingKey < nextKeyframeTick) {
|
||||
nextKeyframeTick = ceilingKey;
|
||||
@@ -656,10 +659,10 @@ public class TimelineWindow {
|
||||
}
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_DOWN, false)) {
|
||||
int previousKeyframeTick;
|
||||
if (editorState.exportEndTicks >= 0 && editorState.exportEndTicks < cursorTicks) {
|
||||
previousKeyframeTick = editorState.exportEndTicks;
|
||||
} else if (editorState.exportStartTicks >= 0 && editorState.exportStartTicks < cursorTicks) {
|
||||
previousKeyframeTick = editorState.exportStartTicks;
|
||||
if (editorScene.exportEndTicks >= 0 && editorScene.exportEndTicks < cursorTicks) {
|
||||
previousKeyframeTick = editorScene.exportEndTicks;
|
||||
} else if (editorScene.exportStartTicks >= 0 && editorScene.exportStartTicks < cursorTicks) {
|
||||
previousKeyframeTick = editorScene.exportStartTicks;
|
||||
} else {
|
||||
previousKeyframeTick = 0;
|
||||
}
|
||||
@@ -670,7 +673,7 @@ public class TimelineWindow {
|
||||
previousKeyframeTick = lastMarker;
|
||||
}
|
||||
|
||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||
for (KeyframeTrack track : editorScene.keyframeTracks) {
|
||||
Integer floorKey = track.keyframesByTick.floorKey(cursorTicks-1);
|
||||
if (floorKey != null && floorKey > previousKeyframeTick) {
|
||||
previousKeyframeTick = floorKey;
|
||||
@@ -680,10 +683,12 @@ public class TimelineWindow {
|
||||
replayServer.forceApplyKeyframes.set(true);
|
||||
}
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_Z, false) && (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL))) {
|
||||
editorState.undo(ReplayUI::setInfoOverlayShort);
|
||||
editorScene.undo(ReplayUI::setInfoOverlayShort);
|
||||
editorState.markDirty();
|
||||
}
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_Y, false) && (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL))) {
|
||||
editorState.redo(ReplayUI::setInfoOverlayShort);
|
||||
editorScene.redo(ReplayUI::setInfoOverlayShort);
|
||||
editorState.markDirty();
|
||||
}
|
||||
|
||||
if (pressedIn || pressedOut) {
|
||||
@@ -695,11 +700,12 @@ public class TimelineWindow {
|
||||
if (pressedOut) {
|
||||
end = cursorTicks;
|
||||
}
|
||||
editorState.setExportTicks(start, end, totalTicks);
|
||||
editorScene.setExportTicks(start, end, totalTicks);
|
||||
editorState.markDirty();
|
||||
}
|
||||
|
||||
if (pressedDelete && !selectedKeyframesList.isEmpty()) {
|
||||
removeAllSelectedKeyframes(editorState);
|
||||
removeAllSelectedKeyframes();
|
||||
}
|
||||
|
||||
if (pressedCopy && !selectedKeyframesList.isEmpty()) {
|
||||
@@ -716,7 +722,7 @@ public class TimelineWindow {
|
||||
}
|
||||
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
|
||||
TreeMap<Integer, Keyframe> keyframes = new TreeMap<>();
|
||||
for (int tick : selectedKeyframes.keyframeTicks()) {
|
||||
@@ -744,37 +750,41 @@ public class TimelineWindow {
|
||||
|
||||
int count = 0;
|
||||
for (SavedTrack savedTrack : tracks) {
|
||||
count += savedTrack.applyToEditorState(editorState, cursorTicks, totalTicks);
|
||||
count += savedTrack.applyToScene(editorScene, cursorTicks, totalTicks);
|
||||
}
|
||||
|
||||
ReplayUI.setInfoOverlay("Pasted " + count + " keyframe(s) from clipboard");
|
||||
if (count > 0) {
|
||||
ReplayUI.setInfoOverlay("Pasted " + count + " keyframe(s) from clipboard");
|
||||
editorState.markDirty();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeAllSelectedKeyframes(EditorState editorState) {
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
private static void removeAllSelectedKeyframes() {
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
for (int tick : selectedKeyframes.keyframeTicks()) {
|
||||
Keyframe keyframe = track.keyframesByTick.get(tick);
|
||||
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
redo.add(new EditorStateHistoryAction.RemoveKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
redo.add(new EditorSceneHistoryAction.RemoveKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick));
|
||||
}
|
||||
}
|
||||
|
||||
selectedKeyframesList.clear();
|
||||
editingKeyframeTrack = -1;
|
||||
editingKeyframeTick = -1;
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Deleted " + undo.size() + " keyframe(s)"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Deleted " + undo.size() + " keyframe(s)"));
|
||||
editorState.markDirty();
|
||||
}
|
||||
|
||||
private static void handleClick(EditorState editorState, ReplayServer replayServer, int totalTicks) {
|
||||
releaseGrabbed(editorState, replayServer, totalTicks);
|
||||
private static void handleClick(ReplayServer replayServer, int totalTicks) {
|
||||
releaseGrabbed(replayServer, totalTicks);
|
||||
List<SelectedKeyframes> oldSelectedKeyframesList = new ArrayList<>(selectedKeyframesList);
|
||||
selectedKeyframesList.clear();
|
||||
|
||||
@@ -813,7 +823,7 @@ public class TimelineWindow {
|
||||
|
||||
// Pause button
|
||||
if (hoveredPause) {
|
||||
togglePaused(replayServer, editorState);
|
||||
togglePaused(replayServer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -850,9 +860,9 @@ public class TimelineWindow {
|
||||
|
||||
// Timeline
|
||||
if (mouseY > y && mouseY < y + middleY && mouseX > x + middleX && mouseX < x + width) {
|
||||
if (editorState.exportStartTicks >= 0 && editorState.exportEndTicks >= 0 && mouseY > y + timestampHeight) {
|
||||
int exportStartX = replayTickToTimelineX(editorState.exportStartTicks);
|
||||
int exportEndX = replayTickToTimelineX(editorState.exportEndTicks);
|
||||
if (editorScene.exportStartTicks >= 0 && editorScene.exportEndTicks >= 0 && mouseY > y + timestampHeight) {
|
||||
int exportStartX = replayTickToTimelineX(editorScene.exportStartTicks);
|
||||
int exportEndX = replayTickToTimelineX(editorScene.exportEndTicks);
|
||||
|
||||
Utils.ClosestElement closestElement = Utils.findClosest(mouseX, exportStartX, exportEndX, 5);
|
||||
|
||||
@@ -907,8 +917,8 @@ public class TimelineWindow {
|
||||
|
||||
int trackIndex = (int) Math.max(0, Math.floor((mouseY - (y + middleY + 2))/lineHeight));
|
||||
|
||||
if (trackIndex >= 0 && trackIndex < editorState.keyframeTracks.size()) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(trackIndex);
|
||||
if (trackIndex >= 0 && trackIndex < editorScene.keyframeTracks.size()) {
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(trackIndex);
|
||||
|
||||
int tick = timelineXToReplayTick(mouseX - x);
|
||||
|
||||
@@ -967,7 +977,7 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void togglePaused(ReplayServer replayServer, EditorState editorState) {
|
||||
private static void togglePaused(ReplayServer replayServer) {
|
||||
if (replayServer.getReplayTick() >= replayServer.getTotalReplayTicks()) {
|
||||
replayServer.jumpToTick = 0;
|
||||
}
|
||||
@@ -980,10 +990,10 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderExportBar(EditorState editorState, ImDrawList drawList) {
|
||||
if (editorState.exportStartTicks >= 0 && editorState.exportEndTicks >= 0) {
|
||||
int exportStartX = replayTickToTimelineX(editorState.exportStartTicks);
|
||||
int exportEndX = replayTickToTimelineX(editorState.exportEndTicks);
|
||||
private static void renderExportBar(ImDrawList drawList) {
|
||||
if (editorScene.exportStartTicks >= 0 && editorScene.exportEndTicks >= 0) {
|
||||
int exportStartX = replayTickToTimelineX(editorScene.exportStartTicks);
|
||||
int exportEndX = replayTickToTimelineX(editorScene.exportEndTicks);
|
||||
drawList.addRectFilled(x +exportStartX, y + timestampHeight, x +exportEndX, y + middleY, 0x60FFAA00);
|
||||
drawList.addLine(x +exportStartX, y + timestampHeight, x +exportStartX, y + middleY, 0xFFFFAA00, 4);
|
||||
drawList.addLine(x +exportEndX, y + timestampHeight, x +exportEndX, y + middleY, 0xFFFFAA00, 4);
|
||||
@@ -996,12 +1006,12 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderKeyframeOptionsPopup(EditorState editorState) {
|
||||
private static void renderKeyframeOptionsPopup() {
|
||||
if (editingKeyframeTrack < 0 || editingKeyframeTick < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(editingKeyframeTrack);
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(editingKeyframeTrack);
|
||||
Keyframe editingKeyframe = keyframeTrack.keyframesByTick.get(editingKeyframeTick);
|
||||
|
||||
if (editingKeyframe == null || selectedKeyframesList.isEmpty()) {
|
||||
@@ -1011,27 +1021,28 @@ public class TimelineWindow {
|
||||
}
|
||||
|
||||
editingKeyframe.renderEditKeyframe(updateFunction -> {
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
int modified = 0;
|
||||
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
for (int tick : selectedKeyframes.keyframeTicks()) {
|
||||
Keyframe keyframe = track.keyframesByTick.get(tick);
|
||||
if (keyframe.getClass() == editingKeyframe.getClass()) {
|
||||
modified += 1;
|
||||
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
updateFunction.accept(keyframe);
|
||||
redo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
redo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modified > 0) {
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Modified " + modified + " keyframe(s)"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Modified " + modified + " keyframe(s)"));
|
||||
editorState.markDirty();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1041,11 +1052,11 @@ public class TimelineWindow {
|
||||
if (ImGuiHelper.combo("Type", type, InterpolationType.NAMES)) {
|
||||
InterpolationType interpolationType = InterpolationType.INTERPOLATION_TYPES[type[0]];
|
||||
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
for (int tick : selectedKeyframes.keyframeTicks()) {
|
||||
Keyframe keyframe = track.keyframesByTick.get(tick);
|
||||
|
||||
@@ -1053,13 +1064,14 @@ public class TimelineWindow {
|
||||
Keyframe changed = keyframe.copy();
|
||||
changed.interpolationType(interpolationType);
|
||||
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
redo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, changed));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, keyframe.copy()));
|
||||
redo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), tick, changed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Changed interpolation type to " + interpolationType));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Changed interpolation type to " + interpolationType));
|
||||
editorState.markDirty();
|
||||
}
|
||||
}
|
||||
if (editingKeyframe.keyframeType().allowChangingTimelineTick()) {
|
||||
@@ -1070,20 +1082,21 @@ public class TimelineWindow {
|
||||
|
||||
if (ImGui.isItemDeactivatedAfterEdit() && newEditingKeyframeTick != editingKeyframeTick) {
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(selectedKeyframes.trackIndex());
|
||||
|
||||
Keyframe possibleKeyframe = track.keyframesByTick.get(editingKeyframeTick);
|
||||
if (possibleKeyframe == editingKeyframe) {
|
||||
List<EditorStateHistoryAction> undo = List.of(
|
||||
new EditorStateHistoryAction.RemoveKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), newEditingKeyframeTick),
|
||||
new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), editingKeyframeTick, editingKeyframe.copy())
|
||||
List<EditorSceneHistoryAction> undo = List.of(
|
||||
new EditorSceneHistoryAction.RemoveKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), newEditingKeyframeTick),
|
||||
new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), editingKeyframeTick, editingKeyframe.copy())
|
||||
);
|
||||
List<EditorStateHistoryAction> redo = List.of(
|
||||
new EditorStateHistoryAction.RemoveKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), editingKeyframeTick),
|
||||
new EditorStateHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), newEditingKeyframeTick, editingKeyframe.copy())
|
||||
List<EditorSceneHistoryAction> redo = List.of(
|
||||
new EditorSceneHistoryAction.RemoveKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), editingKeyframeTick),
|
||||
new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, selectedKeyframes.trackIndex(), newEditingKeyframeTick, editingKeyframe.copy())
|
||||
);
|
||||
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Moved 1 keyframe(s)"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Moved 1 keyframe(s)"));
|
||||
editorState.markDirty();
|
||||
selectedKeyframes.keyframeTicks().remove(editingKeyframeTick);
|
||||
selectedKeyframes.keyframeTicks().add(newEditingKeyframeTick);
|
||||
editingKeyframeTick = newEditingKeyframeTick;
|
||||
@@ -1097,7 +1110,7 @@ public class TimelineWindow {
|
||||
|
||||
if (ImGui.button(multiple ? "Remove All" : "Remove")) {
|
||||
ImGui.closeCurrentPopup();
|
||||
removeAllSelectedKeyframes(editorState);
|
||||
removeAllSelectedKeyframes();
|
||||
}
|
||||
|
||||
if (!multiple && editingKeyframe instanceof CameraKeyframe cameraKeyframe) {
|
||||
@@ -1108,7 +1121,7 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void releaseGrabbed(EditorState editorState, ReplayServer replayServer, int totalTicks) {
|
||||
private static void releaseGrabbed(ReplayServer replayServer, int totalTicks) {
|
||||
grabbedZoomBar = false;
|
||||
grabbedZoomBarResizeLeft = false;
|
||||
grabbedZoomBarResizeRight = false;
|
||||
@@ -1130,10 +1143,10 @@ public class TimelineWindow {
|
||||
int minTrackIndex = (int) Math.floor((dragMinY - (y + middleY + 2))/lineHeight);
|
||||
int maxTrackIndex = (int) Math.floor((dragMaxY - (y + middleY + 2))/lineHeight);
|
||||
minTrackIndex = Math.max(0, minTrackIndex);
|
||||
maxTrackIndex = Math.min(editorState.keyframeTracks.size()-1, maxTrackIndex);
|
||||
maxTrackIndex = Math.min(editorScene.keyframeTracks.size()-1, maxTrackIndex);
|
||||
|
||||
for (int trackIndex = minTrackIndex; trackIndex <= maxTrackIndex; trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(trackIndex);
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(trackIndex);
|
||||
|
||||
int minTick = timelineXToReplayTick(dragMinX - KEYFRAME_SIZE);
|
||||
int maxTick = timelineXToReplayTick(dragMaxX + KEYFRAME_SIZE);
|
||||
@@ -1165,16 +1178,16 @@ public class TimelineWindow {
|
||||
}
|
||||
|
||||
if (grabbedKeyframe) {
|
||||
GrabMovementInfo grabMovementInfo = calculateGrabMovementInfo(editorState, totalTicks);
|
||||
GrabMovementInfo grabMovementInfo = calculateGrabMovementInfo(totalTicks);
|
||||
|
||||
if (grabMovementInfo.grabbedScalePivotTick >= 0 || grabMovementInfo.grabbedDelta != 0) {
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
int movedKeyframes = 0;
|
||||
|
||||
for (SelectedKeyframes selectedKeyframes : selectedKeyframesList) {
|
||||
int trackIndex = selectedKeyframes.trackIndex();
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(trackIndex);
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(trackIndex);
|
||||
|
||||
IntList selectedTicks = new IntArrayList(selectedKeyframes.keyframeTicks());
|
||||
|
||||
@@ -1223,27 +1236,28 @@ public class TimelineWindow {
|
||||
|
||||
for (int removeTick : removeFromTick.keySet()) {
|
||||
if (!addToTick.containsKey(removeTick)) {
|
||||
redo.add(new EditorStateHistoryAction.RemoveKeyframe(keyframeTrack.keyframeType, trackIndex, removeTick));
|
||||
redo.add(new EditorSceneHistoryAction.RemoveKeyframe(keyframeTrack.keyframeType, trackIndex, removeTick));
|
||||
}
|
||||
}
|
||||
for (Int2ObjectMap.Entry<Keyframe> entry : addToTick.int2ObjectEntrySet()) {
|
||||
redo.add(new EditorStateHistoryAction.SetKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey(), entry.getValue()));
|
||||
redo.add(new EditorSceneHistoryAction.SetKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey(), entry.getValue()));
|
||||
|
||||
if (!removeFromTick.containsKey(entry.getIntKey())) {
|
||||
Keyframe existing = keyframeTrack.keyframesByTick.get(entry.getIntKey());
|
||||
if (existing != null) {
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey(), existing.copy()));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey(), existing.copy()));
|
||||
} else {
|
||||
undo.add(new EditorStateHistoryAction.RemoveKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey()));
|
||||
undo.add(new EditorSceneHistoryAction.RemoveKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Int2ObjectMap.Entry<Keyframe> entry : removeFromTick.int2ObjectEntrySet()) {
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey(), entry.getValue()));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(keyframeTrack.keyframeType, trackIndex, entry.getIntKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Moved " + movedKeyframes + " keyframe(s)"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Moved " + movedKeyframes + " keyframe(s)"));
|
||||
editorState.markDirty();
|
||||
}
|
||||
|
||||
grabbedKeyframe = false;
|
||||
@@ -1258,7 +1272,7 @@ public class TimelineWindow {
|
||||
|
||||
record GrabMovementInfo(int grabbedDelta, int grabbedScalePivotTick, float grabbedScaleFactor) {}
|
||||
|
||||
private static GrabMovementInfo calculateGrabMovementInfo(EditorState editorState, int totalTicks) {
|
||||
private static GrabMovementInfo calculateGrabMovementInfo(int totalTicks) {
|
||||
int grabbedDelta = 0;
|
||||
int grabbedScalePivotTick = -1;
|
||||
float grabbedScaleFactor = 0f;
|
||||
@@ -1304,12 +1318,12 @@ public class TimelineWindow {
|
||||
|
||||
if (isShiftDown) {
|
||||
int closestTick = -1;
|
||||
for (int i = 0; i < editorState.keyframeTracks.size(); i++) {
|
||||
for (int i = 0; i < editorScene.keyframeTracks.size(); i++) {
|
||||
if (i == grabbedKeyframeTrack) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(i);
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(i);
|
||||
|
||||
Integer floor = track.keyframesByTick.floorKey(grabbedKeyframeTick);
|
||||
Integer ceil = track.keyframesByTick.ceilingKey(grabbedKeyframeTick);
|
||||
@@ -1339,7 +1353,7 @@ public class TimelineWindow {
|
||||
tooltip += " (" + grabbedDelta + " ticks)";
|
||||
}
|
||||
|
||||
if (!isShiftDown && editorState.keyframeTracks.size() > 1) {
|
||||
if (!isShiftDown && editorScene.keyframeTracks.size() > 1) {
|
||||
tooltip += "\nHold SHIFT to snap";
|
||||
}
|
||||
|
||||
@@ -1349,18 +1363,18 @@ public class TimelineWindow {
|
||||
return new GrabMovementInfo(grabbedDelta, grabbedScalePivotTick, grabbedScaleFactor);
|
||||
}
|
||||
|
||||
private static void renderKeyframes(EditorState editorState, float x, float y, float mouseX, int minTicks, float availableTicks, int totalTicks) {
|
||||
private static void renderKeyframes(float x, float y, float mouseX, int minTicks, float availableTicks, int totalTicks) {
|
||||
float lineHeight = ImGui.getTextLineHeightWithSpacing() + ImGui.getStyle().getItemSpacingY();
|
||||
|
||||
ImDrawList drawList = ImGui.getWindowDrawList();
|
||||
|
||||
GrabMovementInfo grabMovementInfo = null;
|
||||
if (grabbedKeyframe) {
|
||||
grabMovementInfo = calculateGrabMovementInfo(editorState, totalTicks);
|
||||
grabMovementInfo = calculateGrabMovementInfo(totalTicks);
|
||||
}
|
||||
|
||||
for (int trackIndex = 0; trackIndex < editorState.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(trackIndex);
|
||||
for (int trackIndex = 0; trackIndex < editorScene.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(trackIndex);
|
||||
|
||||
TreeMap<Integer, Keyframe> keyframeTimes = keyframeTrack.keyframesByTick;
|
||||
|
||||
@@ -1530,7 +1544,7 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderKeyframeElements(ReplayServer replayServer, EditorState editorState, float x, float y, int cursorTicks, int middleX) {
|
||||
private static void renderKeyframeElements(float x, float y, int cursorTicks, int middleX) {
|
||||
ImGui.setCursorScreenPos(x + 8, y + 6);
|
||||
|
||||
int keyframeTrackToClear = -1;
|
||||
@@ -1544,8 +1558,8 @@ public class TimelineWindow {
|
||||
|
||||
double animationMultiplier = Math.pow(0.9D, renderDeltaNanos / 10_000_000D);
|
||||
|
||||
for (int trackIndex = 0; trackIndex < editorState.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(trackIndex);
|
||||
for (int trackIndex = 0; trackIndex < editorScene.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(trackIndex);
|
||||
KeyframeType<?> keyframeType = keyframeTrack.keyframeType;
|
||||
|
||||
ImGui.pushID(trackIndex);
|
||||
@@ -1560,7 +1574,7 @@ public class TimelineWindow {
|
||||
ImGui.closeCurrentPopup();
|
||||
ImGui.endPopup();
|
||||
|
||||
createNewKeyframe(editorState, trackIndex, createKeyframeAtTick, keyframeType, keyframeTrack);
|
||||
createNewKeyframe(trackIndex, createKeyframeAtTick, keyframeType, keyframeTrack);
|
||||
} else {
|
||||
ImGui.endPopup();
|
||||
}
|
||||
@@ -1674,7 +1688,7 @@ public class TimelineWindow {
|
||||
buttonX += buttonSize + spacingX;
|
||||
ImGui.setCursorPosX(buttonX - x);
|
||||
if (ImGui.invisibleButton("##Add", buttonSize, buttonSize)) {
|
||||
createNewKeyframe(editorState, trackIndex, cursorTicks, keyframeType, keyframeTrack);
|
||||
createNewKeyframe(trackIndex, cursorTicks, keyframeType, keyframeTrack);
|
||||
}
|
||||
drawList.addText(buttonX - 2, buttonY, -1, "\ue148");
|
||||
ImGuiHelper.tooltip("Add keyframe");
|
||||
@@ -1684,7 +1698,8 @@ public class TimelineWindow {
|
||||
hasOpenPopup = true;
|
||||
Keyframe keyframe = createKeyframeWithPopup.render();
|
||||
if (keyframe != null) {
|
||||
editorState.setKeyframe(trackIndex, createKeyframeWithPopupTick, keyframe);
|
||||
editorScene.setKeyframe(trackIndex, createKeyframeWithPopupTick, keyframe);
|
||||
editorState.markDirty();
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
} else {
|
||||
@@ -1700,12 +1715,12 @@ public class TimelineWindow {
|
||||
keyframeTrack.nameEditField = ImGuiHelper.createResizableImString(name);
|
||||
keyframeTrack.forceFocusTrack = true;
|
||||
}
|
||||
if (ImGui.menuItem("\ue872 Delete track")) {
|
||||
keyframeTrackToClear = trackIndex;
|
||||
}
|
||||
if (ImGui.menuItem("\ue40a Set Colour")) {
|
||||
openTrackColourPopup = true;
|
||||
}
|
||||
if (ImGui.menuItem("\ue872 Delete track")) {
|
||||
keyframeTrackToClear = trackIndex;
|
||||
}
|
||||
ImGui.endPopup();
|
||||
}
|
||||
|
||||
@@ -1745,19 +1760,20 @@ public class TimelineWindow {
|
||||
openCreateKeyframeAtTickTrack = -1;
|
||||
|
||||
if (keyframeTrackToClear >= 0) {
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(keyframeTrackToClear);
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(keyframeTrackToClear);
|
||||
|
||||
undo.add(new EditorStateHistoryAction.AddTrack(keyframeTrack.keyframeType, keyframeTrackToClear));
|
||||
undo.add(new EditorSceneHistoryAction.AddTrack(keyframeTrack.keyframeType, keyframeTrackToClear));
|
||||
for (Map.Entry<Integer, Keyframe> entry : keyframeTrack.keyframesByTick.entrySet()) {
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(keyframeTrack.keyframeType, keyframeTrackToClear, entry.getKey(), entry.getValue().copy()));
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(keyframeTrack.keyframeType, keyframeTrackToClear, entry.getKey(), entry.getValue().copy()));
|
||||
}
|
||||
|
||||
redo.add(new EditorStateHistoryAction.RemoveTrack(keyframeTrack.keyframeType, keyframeTrackToClear));
|
||||
redo.add(new EditorSceneHistoryAction.RemoveTrack(keyframeTrack.keyframeType, keyframeTrackToClear));
|
||||
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Delete " + keyframeTrack.keyframeType.name() + " track"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Delete " + keyframeTrack.keyframeType.name() + " track"));
|
||||
editorState.markDirty();
|
||||
selectedKeyframesList.clear();
|
||||
}
|
||||
|
||||
@@ -1768,24 +1784,127 @@ public class TimelineWindow {
|
||||
|
||||
ImGui.sameLine();
|
||||
|
||||
boolean openNewScenePopup = false;
|
||||
boolean openRenameScenePopup = false;
|
||||
boolean openDeleteScenePopup = false;
|
||||
|
||||
ImGui.setNextItemWidth(middleX - ImGui.getCursorPosX() - spacingX);
|
||||
ImGui.pushStyleVar(ImGuiStyleVar.FramePadding, 4, 0);
|
||||
ImGuiHelper.combo("##SceneSwitcher", new int[]{0}, new String[]{
|
||||
"Scene 1", "\ue148 New Scene"
|
||||
});
|
||||
if (ImGui.beginCombo("##SceneSwitcher", editorScene.name, ImGuiComboFlags.HeightLargest)) {
|
||||
if (ImGui.menuItem("\ue148 New Scene")) {
|
||||
openNewScenePopup = true;
|
||||
}
|
||||
if (ImGui.menuItem("\ue3c9 Rename")) {
|
||||
openRenameScenePopup = true;
|
||||
}
|
||||
if (editorState.scenes.size() > 1 && editorScene.keyframeTracks.isEmpty() && ImGui.menuItem("\ue92b Delete Forever")) {
|
||||
openDeleteScenePopup = true;
|
||||
}
|
||||
|
||||
ImGui.separator();
|
||||
|
||||
for (int i = 0; i < editorState.scenes.size(); i++) {
|
||||
EditorScene otherScene = editorState.scenes.get(i);
|
||||
|
||||
ImGui.pushID(i);
|
||||
boolean selected = i == editorState.sceneIndex;
|
||||
if (ImGui.selectable(otherScene.name, selected) && !selected) {
|
||||
editorState.sceneIndex = i;
|
||||
}
|
||||
if (selected) ImGui.setItemDefaultFocus();
|
||||
ImGui.popID();
|
||||
}
|
||||
|
||||
ImGui.endCombo();
|
||||
}
|
||||
ImGui.popStyleVar();
|
||||
|
||||
if (openNewScenePopup) {
|
||||
ImGui.openPopup("##NewScene");
|
||||
sceneNameString = ImGuiHelper.createResizableImString("Scene " + (editorState.scenes.size() + 1));
|
||||
}
|
||||
if (ImGui.beginPopup("##NewScene")) {
|
||||
ImGui.inputText("Name", sceneNameString);
|
||||
|
||||
if (ImGui.button("Create")) {
|
||||
String sceneName = ImGuiHelper.getString(sceneNameString).trim();
|
||||
if (!sceneName.isEmpty()) {
|
||||
editorState.scenes.add(new EditorScene(sceneName));
|
||||
editorState.sceneIndex = editorState.scenes.size() - 1;
|
||||
editorState.markDirty();
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Cancel")) {
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui.endPopup();
|
||||
}
|
||||
|
||||
if (openRenameScenePopup) {
|
||||
ImGui.openPopup("##RenameScene");
|
||||
sceneNameString = ImGuiHelper.createResizableImString(editorScene.name);
|
||||
}
|
||||
if (ImGui.beginPopup("##RenameScene")) {
|
||||
ImGui.inputText("Name", sceneNameString);
|
||||
|
||||
if (ImGui.button("Rename")) {
|
||||
String sceneName = ImGuiHelper.getString(sceneNameString).trim();
|
||||
if (!sceneName.isEmpty()) {
|
||||
editorScene.name = sceneName;
|
||||
editorState.markDirty();
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Cancel")) {
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui.endPopup();
|
||||
}
|
||||
|
||||
if (openDeleteScenePopup) {
|
||||
ImGui.openPopup("##DeleteScene");
|
||||
}
|
||||
if (ImGui.beginPopup("##DeleteScene")) {
|
||||
if (editorState.scenes.size() > 1 && editorScene.keyframeTracks.isEmpty()) {
|
||||
ImGui.text("Are you sure you want to delete this scene?");
|
||||
ImGui.text("This action is PERMANENT");
|
||||
ImGui.text("You will not be able to undo this action");
|
||||
|
||||
if (ImGui.button("Delete Forever")) {
|
||||
editorState.scenes.remove(editorState.sceneIndex);
|
||||
if (editorState.sceneIndex >= editorState.scenes.size()) {
|
||||
editorState.sceneIndex = editorState.scenes.size() - 1;
|
||||
}
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("Cancel")) {
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
} else {
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui.endPopup();
|
||||
}
|
||||
|
||||
if (ImGui.beginPopup("##AddKeyframeElement")) {
|
||||
for (KeyframeType<?> type : KeyframeRegistry.getTypes()) {
|
||||
if (ImGui.selectable(type.name())) {
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
int index = editorState.keyframeTracks.size();
|
||||
undo.add(new EditorStateHistoryAction.RemoveTrack(type, index));
|
||||
redo.add(new EditorStateHistoryAction.AddTrack(type, index));
|
||||
int index = editorScene.keyframeTracks.size();
|
||||
undo.add(new EditorSceneHistoryAction.RemoveTrack(type, index));
|
||||
redo.add(new EditorSceneHistoryAction.AddTrack(type, index));
|
||||
|
||||
editorState.push(new EditorStateHistoryEntry(undo, redo, "Create " + type.name() + " track"));
|
||||
editorScene.push(new EditorSceneHistoryEntry(undo, redo, "Create " + type.name() + " track"));
|
||||
editorState.markDirty();
|
||||
ImGui.closeCurrentPopup();
|
||||
}
|
||||
}
|
||||
@@ -1793,13 +1912,15 @@ public class TimelineWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void createNewKeyframe(EditorState editorState, int trackIndex, int tick, KeyframeType<?> keyframeType, KeyframeTrack keyframeTrack) {
|
||||
private static void createNewKeyframe(int trackIndex, int tick, KeyframeType<?> keyframeType, KeyframeTrack keyframeTrack) {
|
||||
Keyframe keyframe = keyframeType.createDirect();
|
||||
if (keyframe != null) {
|
||||
editorState.setKeyframe(trackIndex, tick, keyframe);
|
||||
editorScene.setKeyframe(trackIndex, tick, keyframe);
|
||||
editorState.markDirty();
|
||||
} else {
|
||||
if (keyframeType == TimelapseKeyframeType.INSTANCE && keyframeTrack.keyframesByTick.isEmpty()) {
|
||||
editorState.setKeyframe(trackIndex, tick, new TimelapseKeyframe(0));
|
||||
editorScene.setKeyframe(trackIndex, tick, new TimelapseKeyframe(0));
|
||||
editorState.markDirty();
|
||||
} else {
|
||||
createKeyframeWithPopup = keyframeType.createPopup();
|
||||
if (createKeyframeWithPopup != null) {
|
||||
|
||||
@@ -6,21 +6,19 @@ import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
import com.moulberry.flashback.keyframe.impl.CameraShakeKeyframe;
|
||||
import com.moulberry.flashback.keyframe.impl.FOVKeyframe;
|
||||
import com.moulberry.flashback.keyframe.impl.TimeOfDayKeyframe;
|
||||
import com.moulberry.flashback.keyframe.types.FOVKeyframeType;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.flashback.record.FlashbackMeta;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorStateHistoryEntry;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryAction;
|
||||
import com.moulberry.flashback.state.EditorSceneHistoryEntry;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.state.KeyframeTrack;
|
||||
import com.moulberry.flashback.visuals.ReplayVisuals;
|
||||
import com.moulberry.flashback.combo_options.Sizing;
|
||||
import com.moulberry.flashback.editor.ui.ImGuiHelper;
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiColorEditFlags;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -329,34 +327,36 @@ public class VisualsWindow {
|
||||
|
||||
private static void addKeyframe(EditorState editorState, ReplayServer replayServer, Keyframe keyframe) {
|
||||
KeyframeType<?> keyframeType = keyframe.keyframeType();
|
||||
EditorScene scene = editorState.currentScene();
|
||||
|
||||
// Try add to existing enabled keyframe track
|
||||
for (int i = 0; i < editorState.keyframeTracks.size(); i++) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(i);
|
||||
for (int i = 0; i < scene.keyframeTracks.size(); i++) {
|
||||
KeyframeTrack keyframeTrack = scene.keyframeTracks.get(i);
|
||||
if (keyframeTrack.enabled && keyframeTrack.keyframeType == keyframeType) {
|
||||
editorState.setKeyframe(i, replayServer.getReplayTick(), keyframe);
|
||||
scene.setKeyframe(i, replayServer.getReplayTick(), keyframe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Try add to any keyframe track
|
||||
for (int i = 0; i < editorState.keyframeTracks.size(); i++) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(i);
|
||||
for (int i = 0; i < scene.keyframeTracks.size(); i++) {
|
||||
KeyframeTrack keyframeTrack = scene.keyframeTracks.get(i);
|
||||
if (keyframeTrack.keyframeType == keyframeType) {
|
||||
editorState.setKeyframe(i, replayServer.getReplayTick(), keyframe);
|
||||
scene.setKeyframe(i, replayServer.getReplayTick(), keyframe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String description = "Added " + keyframeType.name() + " keyframe";
|
||||
int newKeyframeTrackIndex = editorState.keyframeTracks.size();
|
||||
editorState.push(new EditorStateHistoryEntry(
|
||||
List.of(new EditorStateHistoryAction.RemoveTrack(keyframeType, newKeyframeTrackIndex)),
|
||||
int newKeyframeTrackIndex = scene.keyframeTracks.size();
|
||||
scene.push(new EditorSceneHistoryEntry(
|
||||
List.of(new EditorSceneHistoryAction.RemoveTrack(keyframeType, newKeyframeTrackIndex)),
|
||||
List.of(
|
||||
new EditorStateHistoryAction.AddTrack(keyframeType, newKeyframeTrackIndex),
|
||||
new EditorStateHistoryAction.SetKeyframe(keyframeType, newKeyframeTrackIndex, replayServer.getReplayTick(), keyframe)
|
||||
new EditorSceneHistoryAction.AddTrack(keyframeType, newKeyframeTrackIndex),
|
||||
new EditorSceneHistoryAction.SetKeyframe(keyframeType, newKeyframeTrackIndex, replayServer.getReplayTick(), keyframe)
|
||||
),
|
||||
description
|
||||
));
|
||||
editorState.markDirty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.moulberry.flashback.state;
|
||||
|
||||
import com.moulberry.flashback.keyframe.Keyframe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EditorScene {
|
||||
|
||||
public String name;
|
||||
public final List<KeyframeTrack> keyframeTracks = new ArrayList<>();
|
||||
public int exportStartTicks = -1;
|
||||
public int exportEndTicks = -1;
|
||||
|
||||
private final EditorSceneHistory history = new EditorSceneHistory();
|
||||
|
||||
public EditorScene(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setKeyframe(int trackIndex, int tick, Keyframe keyframe) {
|
||||
if (trackIndex >= this.keyframeTracks.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<EditorSceneHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorSceneHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
String description;
|
||||
|
||||
KeyframeTrack track = this.keyframeTracks.get(trackIndex);
|
||||
Keyframe old = track.keyframesByTick.get(tick);
|
||||
if (old != null) {
|
||||
undo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, trackIndex, tick, old.copy()));
|
||||
description = "Replaced " + track.keyframeType.name() + " keyframe";
|
||||
} else {
|
||||
undo.add(new EditorSceneHistoryAction.RemoveKeyframe(track.keyframeType, trackIndex, tick));
|
||||
description = "Added " + track.keyframeType.name() + " keyframe";
|
||||
}
|
||||
redo.add(new EditorSceneHistoryAction.SetKeyframe(track.keyframeType, trackIndex, tick, keyframe.copy()));
|
||||
|
||||
this.push(new EditorSceneHistoryEntry(undo, redo, description));
|
||||
}
|
||||
|
||||
public void push(EditorSceneHistoryEntry entry) {
|
||||
if (entry.undo().isEmpty() && entry.redo().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.history.push(this, entry);
|
||||
}
|
||||
|
||||
public void undo(Consumer<String> descriptionConsumer) {
|
||||
this.history.undo(this, descriptionConsumer);
|
||||
}
|
||||
|
||||
public void redo(Consumer<String> descriptionConsumer) {
|
||||
this.history.redo(this, descriptionConsumer);
|
||||
}
|
||||
|
||||
public void setExportTicks(int start, int end, int totalTicks) {
|
||||
if (this.exportEndTicks < 0) {
|
||||
this.exportEndTicks = totalTicks;
|
||||
}
|
||||
this.exportStartTicks = Math.max(0, Math.min(totalTicks, this.exportStartTicks));
|
||||
this.exportEndTicks = Math.max(0, Math.min(totalTicks, this.exportEndTicks));
|
||||
|
||||
if (start >= 0) {
|
||||
this.exportStartTicks = start;
|
||||
if (this.exportEndTicks < start) {
|
||||
this.exportEndTicks = start;
|
||||
}
|
||||
}
|
||||
|
||||
if (end >= 0) {
|
||||
this.exportEndTicks = end;
|
||||
if (this.exportStartTicks > end) {
|
||||
this.exportStartTicks = end;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.exportStartTicks <= 0 && this.exportEndTicks >= totalTicks) {
|
||||
this.exportStartTicks = -1;
|
||||
this.exportEndTicks = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+13
-13
@@ -4,12 +4,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EditorStateHistory {
|
||||
public class EditorSceneHistory {
|
||||
|
||||
private final List<EditorStateHistoryEntry> entries = new ArrayList<>();
|
||||
private final List<EditorSceneHistoryEntry> entries = new ArrayList<>();
|
||||
private int position = 0;
|
||||
|
||||
public void push(EditorState editorState, EditorStateHistoryEntry entry) {
|
||||
public void push(EditorScene editorScene, EditorSceneHistoryEntry entry) {
|
||||
while (this.entries.size() > this.position) {
|
||||
this.entries.removeLast();
|
||||
}
|
||||
@@ -18,35 +18,35 @@ public class EditorStateHistory {
|
||||
this.position -= 1;
|
||||
}
|
||||
|
||||
for (EditorStateHistoryAction redo : entry.redo()) {
|
||||
redo.apply(editorState);
|
||||
for (EditorSceneHistoryAction redo : entry.redo()) {
|
||||
redo.apply(editorScene);
|
||||
}
|
||||
|
||||
this.entries.add(entry);
|
||||
this.position += 1;
|
||||
}
|
||||
|
||||
public void undo(EditorState editorState, Consumer<String> descriptionConsumer) {
|
||||
public void undo(EditorScene editorScene, Consumer<String> descriptionConsumer) {
|
||||
if (this.position == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.position -= 1;
|
||||
EditorStateHistoryEntry entry = this.entries.get(this.position);
|
||||
for (EditorStateHistoryAction undo : entry.undo()) {
|
||||
undo.apply(editorState);
|
||||
EditorSceneHistoryEntry entry = this.entries.get(this.position);
|
||||
for (EditorSceneHistoryAction undo : entry.undo()) {
|
||||
undo.apply(editorScene);
|
||||
}
|
||||
descriptionConsumer.accept("Undo '" + entry.description() + "'");
|
||||
}
|
||||
|
||||
public void redo(EditorState editorState, Consumer<String> descriptionConsumer) {
|
||||
public void redo(EditorScene editorScene, Consumer<String> descriptionConsumer) {
|
||||
if (this.position >= this.entries.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorStateHistoryEntry entry = this.entries.get(this.position);
|
||||
for (EditorStateHistoryAction redo : entry.redo()) {
|
||||
redo.apply(editorState);
|
||||
EditorSceneHistoryEntry entry = this.entries.get(this.position);
|
||||
for (EditorSceneHistoryAction redo : entry.redo()) {
|
||||
redo.apply(editorScene);
|
||||
}
|
||||
descriptionConsumer.accept("Redo '" + entry.description() + "'");
|
||||
|
||||
+22
-22
@@ -12,15 +12,15 @@ import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public interface EditorStateHistoryAction {
|
||||
public interface EditorSceneHistoryAction {
|
||||
|
||||
void apply(EditorState editorState);
|
||||
void apply(EditorScene editorScene);
|
||||
|
||||
record SetKeyframe(KeyframeType<?> type, int trackIndex, int tick, Keyframe keyframe) implements EditorStateHistoryAction {
|
||||
record SetKeyframe(KeyframeType<?> type, int trackIndex, int tick, Keyframe keyframe) implements EditorSceneHistoryAction {
|
||||
@Override
|
||||
public void apply(EditorState editorState) {
|
||||
if (this.trackIndex < editorState.keyframeTracks.size()) {
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(this.trackIndex);
|
||||
public void apply(EditorScene editorScene) {
|
||||
if (this.trackIndex < editorScene.keyframeTracks.size()) {
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(this.trackIndex);
|
||||
if (track.keyframeType == this.type) {
|
||||
track.keyframesByTick.put(this.tick, this.keyframe.copy());
|
||||
}
|
||||
@@ -51,11 +51,11 @@ public interface EditorStateHistoryAction {
|
||||
}
|
||||
}
|
||||
|
||||
record RemoveKeyframe(KeyframeType<?> type, int trackIndex, int tick) implements EditorStateHistoryAction {
|
||||
record RemoveKeyframe(KeyframeType<?> type, int trackIndex, int tick) implements EditorSceneHistoryAction {
|
||||
@Override
|
||||
public void apply(EditorState editorState) {
|
||||
if (this.trackIndex < editorState.keyframeTracks.size()) {
|
||||
KeyframeTrack track = editorState.keyframeTracks.get(this.trackIndex);
|
||||
public void apply(EditorScene editorScene) {
|
||||
if (this.trackIndex < editorScene.keyframeTracks.size()) {
|
||||
KeyframeTrack track = editorScene.keyframeTracks.get(this.trackIndex);
|
||||
if (track.keyframeType == this.type) {
|
||||
track.keyframesByTick.remove(this.tick);
|
||||
}
|
||||
@@ -84,11 +84,11 @@ public interface EditorStateHistoryAction {
|
||||
}
|
||||
}
|
||||
|
||||
record AddTrack(KeyframeType<?> type, int trackIndex) implements EditorStateHistoryAction {
|
||||
record AddTrack(KeyframeType<?> type, int trackIndex) implements EditorSceneHistoryAction {
|
||||
@Override
|
||||
public void apply(EditorState editorState) {
|
||||
if (this.trackIndex <= editorState.keyframeTracks.size()) {
|
||||
editorState.keyframeTracks.add(this.trackIndex, new KeyframeTrack(this.type));
|
||||
public void apply(EditorScene editorScene) {
|
||||
if (this.trackIndex <= editorScene.keyframeTracks.size()) {
|
||||
editorScene.keyframeTracks.add(this.trackIndex, new KeyframeTrack(this.type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,13 +112,13 @@ public interface EditorStateHistoryAction {
|
||||
}
|
||||
}
|
||||
|
||||
record RemoveTrack(KeyframeType<?> type, int trackIndex) implements EditorStateHistoryAction {
|
||||
record RemoveTrack(KeyframeType<?> type, int trackIndex) implements EditorSceneHistoryAction {
|
||||
@Override
|
||||
public void apply(EditorState editorState) {
|
||||
if (this.trackIndex < editorState.keyframeTracks.size()) {
|
||||
KeyframeTrack keyframeTrack = editorState.keyframeTracks.get(this.trackIndex);
|
||||
public void apply(EditorScene editorScene) {
|
||||
if (this.trackIndex < editorScene.keyframeTracks.size()) {
|
||||
KeyframeTrack keyframeTrack = editorScene.keyframeTracks.get(this.trackIndex);
|
||||
if (keyframeTrack.keyframeType == type) {
|
||||
editorState.keyframeTracks.remove(this.trackIndex);
|
||||
editorScene.keyframeTracks.remove(this.trackIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,9 +143,9 @@ public interface EditorStateHistoryAction {
|
||||
}
|
||||
}
|
||||
|
||||
class TypeAdapter implements JsonSerializer<EditorStateHistoryAction>, JsonDeserializer<EditorStateHistoryAction> {
|
||||
class TypeAdapter implements JsonSerializer<EditorSceneHistoryAction>, JsonDeserializer<EditorSceneHistoryAction> {
|
||||
@Override
|
||||
public EditorStateHistoryAction deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
public EditorSceneHistoryAction deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
String type = jsonObject.get("action_type").getAsString();
|
||||
return switch (type) {
|
||||
@@ -158,7 +158,7 @@ public interface EditorStateHistoryAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(EditorStateHistoryAction src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
public JsonElement serialize(EditorSceneHistoryAction src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject jsonObject;
|
||||
switch (src) {
|
||||
case SetKeyframe setKeyframe -> {
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.moulberry.flashback.state;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record EditorSceneHistoryEntry(List<EditorSceneHistoryAction> undo, List<EditorSceneHistoryAction> redo, String description) {
|
||||
}
|
||||
@@ -35,14 +35,13 @@ public class EditorState {
|
||||
transient boolean dirty = false;
|
||||
public transient int modCount = ThreadLocalRandom.current().nextInt();
|
||||
|
||||
public final List<KeyframeTrack> keyframeTracks = new ArrayList<>();
|
||||
public final ReplayVisuals replayVisuals = new ReplayVisuals();
|
||||
private final EditorStateHistory history = new EditorStateHistory();
|
||||
|
||||
public final List<EditorScene> scenes;
|
||||
public int sceneIndex = 0;
|
||||
|
||||
public double zoomMin = 0.0;
|
||||
public double zoomMax = 1.0;
|
||||
public int exportStartTicks = -1;
|
||||
public int exportEndTicks = -1;
|
||||
|
||||
public UUID audioSourceEntity = null;
|
||||
public Set<UUID> hideDuringExport = new HashSet<>();
|
||||
@@ -50,28 +49,16 @@ public class EditorState {
|
||||
public Map<UUID, GameProfile> skinOverride = new HashMap<>();
|
||||
public Map<UUID, String> nameOverride = new HashMap<>();
|
||||
|
||||
public void setKeyframe(int trackIndex, int tick, Keyframe keyframe) {
|
||||
if (trackIndex >= this.keyframeTracks.size()) {
|
||||
return;
|
||||
public EditorState() {
|
||||
this.scenes = new ArrayList<>();
|
||||
this.scenes.add(new EditorScene("Scene 1"));
|
||||
}
|
||||
|
||||
public EditorScene currentScene() {
|
||||
if (this.scenes.isEmpty()) {
|
||||
this.scenes.add(new EditorScene("Scene 1"));
|
||||
}
|
||||
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
String description;
|
||||
|
||||
KeyframeTrack track = this.keyframeTracks.get(trackIndex);
|
||||
Keyframe old = track.keyframesByTick.get(tick);
|
||||
if (old != null) {
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, trackIndex, tick, old.copy()));
|
||||
description = "Replaced " + track.keyframeType.name() + " keyframe";
|
||||
} else {
|
||||
undo.add(new EditorStateHistoryAction.RemoveKeyframe(track.keyframeType, trackIndex, tick));
|
||||
description = "Added " + track.keyframeType.name() + " keyframe";
|
||||
}
|
||||
redo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, trackIndex, tick, keyframe.copy()));
|
||||
|
||||
this.push(new EditorStateHistoryEntry(undo, redo, description));
|
||||
return this.scenes.get(this.sceneIndex);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -96,54 +83,6 @@ public class EditorState {
|
||||
return dummyCamera;
|
||||
}
|
||||
|
||||
public void push(EditorStateHistoryEntry entry) {
|
||||
if (entry.undo().isEmpty() && entry.redo().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.history.push(this, entry);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void undo(Consumer<String> descriptionConsumer) {
|
||||
this.history.undo(this, descriptionConsumer);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void redo(Consumer<String> descriptionConsumer) {
|
||||
this.history.redo(this, descriptionConsumer);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void setExportTicks(int start, int end, int totalTicks) {
|
||||
if (this.exportEndTicks < 0) {
|
||||
this.exportEndTicks = totalTicks;
|
||||
}
|
||||
this.exportStartTicks = Math.max(0, Math.min(totalTicks, this.exportStartTicks));
|
||||
this.exportEndTicks = Math.max(0, Math.min(totalTicks, this.exportEndTicks));
|
||||
|
||||
if (start >= 0) {
|
||||
this.exportStartTicks = start;
|
||||
if (this.exportEndTicks < start) {
|
||||
this.exportEndTicks = start;
|
||||
}
|
||||
}
|
||||
|
||||
if (end >= 0) {
|
||||
this.exportEndTicks = end;
|
||||
if (this.exportStartTicks > end) {
|
||||
this.exportStartTicks = end;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.exportStartTicks <= 0 && this.exportEndTicks >= totalTicks) {
|
||||
this.exportStartTicks = -1;
|
||||
this.exportEndTicks = -1;
|
||||
}
|
||||
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
this.dirty = true;
|
||||
this.modCount += 1;
|
||||
@@ -187,7 +126,7 @@ public class EditorState {
|
||||
|
||||
public void applyKeyframes(KeyframeHandler keyframeHandler, float tick) {
|
||||
Set<KeyframeType<?>> applied = new HashSet<>();
|
||||
for (KeyframeTrack keyframeTrack : this.keyframeTracks) {
|
||||
for (KeyframeTrack keyframeTrack : this.currentScene().keyframeTracks) {
|
||||
// Ignore lines that are disabled
|
||||
if (!keyframeTrack.enabled) {
|
||||
continue;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.moulberry.flashback.state;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record EditorStateHistoryEntry(List<EditorStateHistoryAction> undo, List<EditorStateHistoryAction> redo, String description) {
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.moulberry.flashback.keyframe.types.CameraKeyframeType;
|
||||
import com.moulberry.flashback.keyframe.types.CameraOrbitKeyframeType;
|
||||
import com.moulberry.flashback.keyframe.types.FOVKeyframeType;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import com.moulberry.flashback.state.EditorScene;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.state.KeyframeTrack;
|
||||
@@ -54,7 +55,7 @@ public class CameraPath {
|
||||
int replayTick = TimelineWindow.getCursorTick();
|
||||
|
||||
if (lastEditorStateModCount != state.modCount || lastCursorTick != replayTick) {
|
||||
CameraPathArgs cameraPathArgs = createCameraPathArgs(state, replayTick, SUPPORTED_CAMERA_KEYFRAMES);
|
||||
CameraPathArgs cameraPathArgs = createCameraPathArgs(state.currentScene(), replayTick, SUPPORTED_CAMERA_KEYFRAMES);
|
||||
|
||||
if (lastEditorStateModCount != state.modCount || !cameraPathArgs.equals(lastCameraPathArgs)) {
|
||||
lastCameraPathArgs = cameraPathArgs;
|
||||
@@ -130,12 +131,12 @@ public class CameraPath {
|
||||
|
||||
private record CameraPathArgs(int lastLastCameraTick, int lastCameraTick, int nextCameraTick, int nextNextCameraTick) {}
|
||||
|
||||
private static CameraPathArgs createCameraPathArgs(EditorState state, int replayTick, Set<KeyframeType<?>> supportedKeyframes) {
|
||||
private static CameraPathArgs createCameraPathArgs(EditorScene scene, int replayTick, Set<KeyframeType<?>> supportedKeyframes) {
|
||||
int lastCameraTick = -1;
|
||||
int nextCameraTick = -1;
|
||||
|
||||
for (int trackIndex = 0; trackIndex < state.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = state.keyframeTracks.get(trackIndex);
|
||||
for (int trackIndex = 0; trackIndex < scene.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = scene.keyframeTracks.get(trackIndex);
|
||||
if (keyframeTrack.enabled && supportedKeyframes.contains(keyframeTrack.keyframeType) && !keyframeTrack.keyframesByTick.isEmpty()) {
|
||||
var lastEntry = keyframeTrack.keyframesByTick.floorEntry(replayTick);
|
||||
var nextEntry = keyframeTrack.keyframesByTick.ceilingEntry(replayTick + 1);
|
||||
@@ -156,8 +157,8 @@ public class CameraPath {
|
||||
int lastLastCameraTick = -1;
|
||||
int nextNextCameraTick = -1;
|
||||
|
||||
for (int trackIndex = 0; trackIndex < state.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = state.keyframeTracks.get(trackIndex);
|
||||
for (int trackIndex = 0; trackIndex < scene.keyframeTracks.size(); trackIndex++) {
|
||||
KeyframeTrack keyframeTrack = scene.keyframeTracks.get(trackIndex);
|
||||
if (keyframeTrack.enabled && supportedKeyframes.contains(keyframeTrack.keyframeType) && !keyframeTrack.keyframesByTick.isEmpty()) {
|
||||
var lastLastEntry = lastCameraTick == -1 ? null : keyframeTrack.keyframesByTick.floorEntry(lastCameraTick - 1);
|
||||
var nextNextEntry = nextCameraTick == -1 ? null : keyframeTrack.keyframesByTick.ceilingEntry(nextCameraTick + 1);
|
||||
|
||||
Reference in new issue
Block a user