mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
Merge branch 'master' into taskbar-progress
This commit is contained in:
75 files changed
+2559
-1218
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import imgui.flag.ImGuiComboFlags;
|
||||
import imgui.flag.ImGuiHoveredFlags;
|
||||
import imgui.flag.ImGuiInputTextFlags;
|
||||
import imgui.flag.ImGuiNavInput;
|
||||
import imgui.flag.ImGuiStyleVar;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
import imgui.type.ImFloat;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.moulberry.flashback.editor.ui.windows.MovementWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.PlayerListWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.PreferencesWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.SelectedEntityPopup;
|
||||
import com.moulberry.flashback.editor.ui.windows.WindowType;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.combo_options.Sizing;
|
||||
@@ -96,7 +97,6 @@ public class ReplayUI {
|
||||
|
||||
private static String infoOverlayText = null;
|
||||
private static long infoOverlayEndMillis = 0;
|
||||
public static boolean recordCameraMovement = false;
|
||||
|
||||
private static UUID selectedEntity = null;
|
||||
private static boolean openSelectedEntityPopup = false;
|
||||
@@ -216,10 +216,16 @@ public class ReplayUI {
|
||||
fontConfig.setOversampleV(2);
|
||||
|
||||
fontConfig.setName("Inter (Medium), 16px");
|
||||
fontConfig.setGlyphOffset(0, 0);
|
||||
font = fonts.addFontFromMemoryTTF(loadFont("inter-medium.ttf"), size, fontConfig, glyphRanges);
|
||||
|
||||
// Merge in Japanese/Korean/Chinese/etc. characters if needed
|
||||
fontConfig.setMergeMode(true);
|
||||
|
||||
fontConfig.setGlyphOffset(0, (int)(5 * getUiScale()));
|
||||
io.getFonts().addFontFromMemoryTTF(loadFont("materialiconsround-regular.otf"), (int)(20 * getUiScale()), fontConfig, buildMaterialIconRanges());
|
||||
fontConfig.setGlyphOffset(0, 0);
|
||||
|
||||
if (languageCode.startsWith("he")) {
|
||||
short[] hebrewRanges = new short[]{(short)'\u0590', (short)'\u05FF', (short)'\uFB1D', (short)'\uFB4F', 0};
|
||||
io.getFonts().addFontFromMemoryTTF(loadFont("heebo-medium.ttf"), size, fontConfig, hebrewRanges);
|
||||
@@ -241,6 +247,27 @@ public class ReplayUI {
|
||||
fonts.clearTexData();
|
||||
}
|
||||
|
||||
private static short[] buildMaterialIconRanges() {
|
||||
ImFontGlyphRangesBuilder builder = new ImFontGlyphRangesBuilder();
|
||||
builder.addChar('\ue04b');
|
||||
builder.addChar('\ue577');
|
||||
builder.addChar('\uefeb');
|
||||
builder.addChar('\ue3af');
|
||||
builder.addChar('\ue9e4');
|
||||
builder.addChar('\ue422');
|
||||
builder.addChar('\ue518');
|
||||
builder.addChar('\ue945');
|
||||
builder.addChar('\ue8f4');
|
||||
builder.addChar('\ue8f5');
|
||||
builder.addChar('\ue148');
|
||||
builder.addChar('\ue5d2');
|
||||
builder.addChar('\ue872');
|
||||
builder.addChar('\ue3c9');
|
||||
builder.addChar('\ue40a');
|
||||
builder.addChar('\ue92b');
|
||||
return builder.buildRanges();
|
||||
}
|
||||
|
||||
private static byte[] loadFont(String name) {
|
||||
try {
|
||||
var resource = Minecraft.getInstance().getResourceManager().getResource(Flashback.createResourceLocation(name));
|
||||
@@ -629,9 +656,6 @@ public class ReplayUI {
|
||||
showText = infoOverlayText;
|
||||
showTextBorderColour = 0xFF00FFFF;
|
||||
}
|
||||
} else if (recordCameraMovement) {
|
||||
showText = "Recording Movement as Keyframes...";
|
||||
showTextBorderColour = 0xFF0000FF;
|
||||
}
|
||||
|
||||
if (showText != null) {
|
||||
@@ -743,8 +767,8 @@ public class ReplayUI {
|
||||
ExportScreenshotWindow.render();
|
||||
PreferencesWindow.render();
|
||||
ExportQueueWindow.render();
|
||||
PlayerListWindow.render();
|
||||
MovementWindow.render();
|
||||
|
||||
WindowType.renderAll();
|
||||
|
||||
popupOpenLastFrame = ImGui.isPopupOpen("", ImGuiPopupFlags.AnyPopup);
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import imgui.type.ImBoolean;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ImGuiWindowRenderer {
|
||||
|
||||
void render(ImBoolean open, boolean newlyOpened);
|
||||
|
||||
}
|
||||
@@ -2,9 +2,8 @@ package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.configuration.FlashbackConfig;
|
||||
import com.moulberry.flashback.exporting.AsyncFileDialogs;
|
||||
import com.moulberry.flashback.exporting.ExportJobQueue;
|
||||
import com.moulberry.flashback.screen.SelectReplayScreen;
|
||||
import com.moulberry.flashback.screen.select_replay.SelectReplayScreen;
|
||||
import imgui.ImGui;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
@@ -73,7 +72,7 @@ public class MainMenuBar {
|
||||
minecraft.level.disconnect();
|
||||
}
|
||||
minecraft.disconnect();
|
||||
minecraft.setScreen(new SelectReplayScreen(new TitleScreen()));
|
||||
minecraft.setScreen(new SelectReplayScreen(new TitleScreen(), Flashback.getReplayFolder()));
|
||||
}
|
||||
ImGui.endMenu();
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public class MainMenuBar {
|
||||
} else {
|
||||
openedWindows.add(windowName);
|
||||
}
|
||||
Flashback.getConfig().saveToDefaultFolder();
|
||||
Flashback.getConfig().delayedSaveToDefaultFolder();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import imgui.ImGui;
|
||||
import imgui.ImGuiViewport;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
import imgui.type.ImString;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -27,30 +28,23 @@ import java.util.Locale;
|
||||
|
||||
public class MovementWindow {
|
||||
|
||||
private static WindowOpenState wasOpen = WindowOpenState.UNKNOWN;
|
||||
private static boolean wasDocked = false;
|
||||
|
||||
public static void render() {
|
||||
if (!Flashback.getConfig().openedWindows.contains("movement")) {
|
||||
wasOpen = WindowOpenState.CLOSED;
|
||||
return;
|
||||
}
|
||||
if (wasOpen == WindowOpenState.CLOSED) {
|
||||
public static void render(ImBoolean open, boolean newlyOpened) {
|
||||
if (newlyOpened) {
|
||||
ImGuiViewport viewport = ImGui.getMainViewport();
|
||||
ImGui.setNextWindowPos(viewport.getCenterX(), viewport.getCenterY(), ImGuiCond.Appearing, 0.5f, 0.5f);
|
||||
}
|
||||
wasOpen = WindowOpenState.OPEN;
|
||||
|
||||
FlashbackConfig config = Flashback.getConfig();
|
||||
|
||||
ImGui.setNextWindowSizeConstraints(250, 50, 5000, 5000);
|
||||
int flags = ImGuiWindowFlags.NoFocusOnAppearing;
|
||||
if (!wasDocked) {
|
||||
flags |= ImGuiWindowFlags.AlwaysAutoResize;
|
||||
}
|
||||
if (ImGui.begin("Movement###Movement", flags)) {
|
||||
if (ImGui.begin("Movement###Movement", open, flags)) {
|
||||
wasDocked = ImGui.isWindowDocked();
|
||||
|
||||
FlashbackConfig config = Flashback.getConfig();
|
||||
int[] direction = new int[]{config.flightCameraDirection ? 1 : 0};
|
||||
|
||||
ImGuiHelper.combo("Direction", direction, new String[]{
|
||||
@@ -60,46 +54,40 @@ public class MovementWindow {
|
||||
boolean flightCameraDirection = direction[0] == 1;
|
||||
if (config.flightCameraDirection != flightCameraDirection) {
|
||||
config.flightCameraDirection = flightCameraDirection;
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
|
||||
float[] momentum = new float[]{config.flightMomentum};
|
||||
ImGui.sliderFloat("Momentum", momentum, 0.0f, 1.0f);
|
||||
if (config.flightMomentum != momentum[0]) {
|
||||
config.flightMomentum = momentum[0];
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
|
||||
if (ImGui.checkbox("Lock X", config.flightLockX)) {
|
||||
config.flightLockX = !config.flightLockX;
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.checkbox("Lock Y", config.flightLockY)) {
|
||||
config.flightLockY = !config.flightLockY;
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.checkbox("Lock Z", config.flightLockZ)) {
|
||||
config.flightLockZ = !config.flightLockZ;
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
|
||||
if (ImGui.checkbox("Lock Yaw", config.flightLockYaw)) {
|
||||
config.flightLockYaw = !config.flightLockYaw;
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.checkbox("Lock Pitch", config.flightLockPitch)) {
|
||||
config.flightLockPitch = !config.flightLockPitch;
|
||||
config.saveToDefaultFolder();
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
|
||||
// todo: record movement: can we make this smoother?
|
||||
// if (ImGui.checkbox("Record Movement as Keyframes", ReplayUI.recordCameraMovement)) {
|
||||
// ReplayUI.recordCameraMovement = !ReplayUI.recordCameraMovement;
|
||||
// }
|
||||
|
||||
}
|
||||
ImGui.end();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import imgui.ImGui;
|
||||
import imgui.ImGuiViewport;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
import imgui.type.ImString;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -25,8 +26,6 @@ import java.util.Locale;
|
||||
|
||||
public class PlayerListWindow {
|
||||
|
||||
private static WindowOpenState wasOpen = WindowOpenState.UNKNOWN;
|
||||
|
||||
private static String lastSearch = null;
|
||||
private static long lastUpdate = 0;
|
||||
private static ImString search = ImGuiHelper.createResizableImString("");
|
||||
@@ -90,20 +89,14 @@ public class PlayerListWindow {
|
||||
}
|
||||
}
|
||||
|
||||
public static void render() {
|
||||
// todo: refactor this if we want to add a lot more windows
|
||||
if (!Flashback.getConfig().openedWindows.contains("player_list")) {
|
||||
wasOpen = WindowOpenState.CLOSED;
|
||||
return;
|
||||
}
|
||||
if (wasOpen == WindowOpenState.CLOSED) {
|
||||
public static void render(ImBoolean open, boolean newlyOpened) {
|
||||
if (newlyOpened) {
|
||||
ImGuiViewport viewport = ImGui.getMainViewport();
|
||||
ImGui.setNextWindowPos(viewport.getCenterX(), viewport.getCenterY(), ImGuiCond.Appearing, 0.5f, 0.5f);
|
||||
}
|
||||
wasOpen = WindowOpenState.OPEN;
|
||||
|
||||
ImGui.setNextWindowSizeConstraints(250, 50, 5000, 5000);
|
||||
if (ImGui.begin("Player List###PlayerList", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoFocusOnAppearing)) {
|
||||
if (ImGui.begin("Player List###PlayerList", open, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoFocusOnAppearing)) {
|
||||
ImGui.setNextItemWidth(ImGui.getContentRegionAvailX() - ImGuiHelper.calcTextWidth("Search") - 32);
|
||||
if (ImGui.inputText("Search", search)) {
|
||||
lastSearch = null;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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;
|
||||
|
||||
@@ -324,34 +322,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,48 @@
|
||||
package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.configuration.FlashbackConfig;
|
||||
import com.moulberry.flashback.editor.ui.WindowOpenState;
|
||||
import imgui.type.ImBoolean;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public enum WindowType {
|
||||
|
||||
PLAYER_LIST("player_list", PlayerListWindow::render),
|
||||
MOVEMENT("movement", MovementWindow::render);
|
||||
|
||||
private final String windowId;
|
||||
private final ImGuiWindowRenderer renderMethod;
|
||||
private final ImBoolean open = new ImBoolean();
|
||||
private WindowOpenState openState = WindowOpenState.UNKNOWN;
|
||||
|
||||
WindowType(String windowId, ImGuiWindowRenderer renderMethod) {
|
||||
this.windowId = windowId;
|
||||
this.renderMethod = renderMethod;
|
||||
}
|
||||
|
||||
public static void renderAll() {
|
||||
FlashbackConfig config = Flashback.getConfig();
|
||||
Set<String> openWindows = config.openedWindows;
|
||||
|
||||
for (WindowType windowType : values()) {
|
||||
if (openWindows.contains(windowType.windowId)) {
|
||||
boolean justOpened = windowType.openState == WindowOpenState.CLOSED;
|
||||
|
||||
windowType.open.set(true);
|
||||
windowType.renderMethod.render(windowType.open, justOpened);
|
||||
|
||||
if (!windowType.open.get()) {
|
||||
openWindows.remove(windowType.windowId);
|
||||
config.delayedSaveToDefaultFolder();
|
||||
}
|
||||
|
||||
windowType.openState = WindowOpenState.OPEN;
|
||||
} else {
|
||||
windowType.openState = WindowOpenState.CLOSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user