mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
0.10.0
This commit is contained in:
1 parent
be99313e81
commit
63535e6b3d
79 files changed
+2007
-529
No files matched your search
@@ -367,8 +367,10 @@ public class CustomImGuiImplGlfw {
|
||||
Minecraft.getInstance().options.keyLeft.matches(key, scancode) ||
|
||||
Minecraft.getInstance().options.keyDown.matches(key, scancode) ||
|
||||
Minecraft.getInstance().options.keyRight.matches(key, scancode) ||
|
||||
Minecraft.getInstance().options.keyJump.matches(key, scancode) ||
|
||||
Minecraft.getInstance().options.keyChat.matches(key, scancode) ||
|
||||
Minecraft.getInstance().options.keyCommand.matches(key, scancode)) {
|
||||
ReplayUI.focusMainWindowCounter = 5;
|
||||
passToMinecraft = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -364,11 +364,20 @@ public class ImGuiHelper {
|
||||
focusLastIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
if (ImGui.inputInt("", imInt, 0)) {
|
||||
valueChanged = true;
|
||||
value[i] = imInt.get();
|
||||
}
|
||||
|
||||
if (ImGui.isItemHovered()) {
|
||||
int scroll = (int) Math.signum(ImGui.getIO().getMouseWheel());
|
||||
if (scroll != 0) {
|
||||
valueChanged = true;
|
||||
value[i] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!handledFocusNext && ImGui.isItemActive() && ImGui.isKeyPressed(GLFW.GLFW_KEY_TAB, false)) {
|
||||
handledFocusNext = true;
|
||||
if (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) {
|
||||
@@ -429,11 +438,19 @@ public class ImGuiHelper {
|
||||
focusLastIndex = 0;
|
||||
}
|
||||
|
||||
int scroll = (int) Math.signum(ImGui.getIO().getMouseWheel());
|
||||
if (ImGui.inputFloat("", imFloat, 0)) {
|
||||
valueChanged = true;
|
||||
value[i] = imFloat.get();
|
||||
}
|
||||
|
||||
if (ImGui.isItemHovered()) {
|
||||
if (scroll != 0) {
|
||||
valueChanged = true;
|
||||
value[i] = Math.round(value[i] + scroll);
|
||||
}
|
||||
}
|
||||
|
||||
if (!handledFocusNext && ImGui.isItemActive() && ImGui.isKeyPressed(GLFW.GLFW_KEY_TAB, false)) {
|
||||
handledFocusNext = true;
|
||||
if (ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) {
|
||||
|
||||
@@ -5,8 +5,10 @@ import com.mojang.blaze3d.platform.TextureUtil;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportQueueWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportScreenshotWindow;
|
||||
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.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
@@ -65,7 +67,7 @@ public class ReplayUI {
|
||||
public static int viewportSizeY = 1;
|
||||
private static boolean activeLastFrame = false;
|
||||
|
||||
private static int focusMainWindowCounter = 0;
|
||||
public static int focusMainWindowCounter = 0;
|
||||
|
||||
public static boolean hasAnyPopupOpen = false;
|
||||
|
||||
@@ -535,10 +537,19 @@ public class ReplayUI {
|
||||
ImGui.getIO().removeConfigFlags(ImGuiConfigFlags.NavEnableKeyboard);
|
||||
}
|
||||
|
||||
char controlIcon = Minecraft.ON_OSX ? '\u2318' : '\u2303';
|
||||
|
||||
MainMenuBar.render();
|
||||
|
||||
// The main menu bar can disconnect us, so make sure to check if the UI should still be active here
|
||||
if (!isActiveInternal()) {
|
||||
ImGui.render();
|
||||
ImGuiHelper.endFrame();
|
||||
|
||||
transitionActiveState(false);
|
||||
imguiGlfw.updateReleaseAllKeys(true);
|
||||
focusMainWindowCounter = 5;
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup docking
|
||||
ImGui.setNextWindowBgAlpha(0);
|
||||
int mainDock = ImGui.dockSpaceOverViewport(ImGui.getMainViewport(), ImGuiDockNodeFlags.NoDockingInCentralNode);
|
||||
@@ -671,15 +682,16 @@ public class ReplayUI {
|
||||
|
||||
if (selectedEntity != null) {
|
||||
Entity entity = Minecraft.getInstance().level.getEntities().get(selectedEntity);
|
||||
if (entity == null) {
|
||||
if (entity == null || editorState == null) {
|
||||
selectedEntity = null;
|
||||
} else if (entity instanceof Player && editorState != null && !editorState.replayVisuals.renderPlayers) {
|
||||
} else if (entity instanceof Player && !editorState.replayVisuals.renderPlayers) {
|
||||
selectedEntity = null;
|
||||
} else if (!(entity instanceof Player) && editorState != null && !editorState.replayVisuals.renderEntities) {
|
||||
} else if (!(entity instanceof Player) && !editorState.replayVisuals.renderEntities) {
|
||||
selectedEntity = null;
|
||||
} else {
|
||||
if (openSelectedEntityPopup) {
|
||||
ImGui.openPopup("###EntityPopup");
|
||||
SelectedEntityPopup.open(entity, editorState);
|
||||
}
|
||||
|
||||
if (ImGuiHelper.beginPopup("###EntityPopup")) {
|
||||
@@ -728,6 +740,8 @@ public class ReplayUI {
|
||||
VisualsWindow.render();
|
||||
TimelineWindow.render();
|
||||
StartExportWindow.render();
|
||||
ExportScreenshotWindow.render();
|
||||
PreferencesWindow.render();
|
||||
ExportQueueWindow.render();
|
||||
PlayerListWindow.render();
|
||||
MovementWindow.render();
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.Utils;
|
||||
import com.moulberry.flashback.combo_options.VideoCodec;
|
||||
import com.moulberry.flashback.combo_options.VideoContainer;
|
||||
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.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ExportScreenshotWindow {
|
||||
|
||||
private static boolean open = false;
|
||||
private static boolean close = false;
|
||||
|
||||
private static final int[] resolution = new int[]{1920, 1080};
|
||||
|
||||
public static void render() {
|
||||
if (open) {
|
||||
open = false;
|
||||
ImGui.openPopup("###ExportScreenshot");
|
||||
}
|
||||
|
||||
if (ImGuiHelper.beginPopupModalCloseable("Export screenshot###ExportScreenshot", ImGuiWindowFlags.AlwaysAutoResize)) {
|
||||
if (close) {
|
||||
close = false;
|
||||
ImGui.closeCurrentPopup();
|
||||
ImGuiHelper.endPopupModalCloseable();
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiHelper.inputInt("Resolution", resolution);
|
||||
resolution[0] = Math.max(1, resolution[0]);
|
||||
resolution[1] = Math.max(1, resolution[1]);
|
||||
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
|
||||
if (ImGui.checkbox("SSAA", StartExportWindow.ssaa)) {
|
||||
StartExportWindow.ssaa = !StartExportWindow.ssaa;
|
||||
}
|
||||
ImGuiHelper.tooltip("Supersampling Anti-Aliasing: Remove jagged edges by rendering the game at double resolution and downscaling");
|
||||
|
||||
ImGui.sameLine();
|
||||
|
||||
if (ImGui.checkbox("No GUI", StartExportWindow.noGui)) {
|
||||
StartExportWindow.noGui = !StartExportWindow.noGui;
|
||||
}
|
||||
ImGuiHelper.tooltip("Removes all UI from the screen, rendering only the world");
|
||||
|
||||
if (editorState != null && !editorState.replayVisuals.renderSky) {
|
||||
if (ImGui.checkbox("Transparent Sky", StartExportWindow.transparentBackground)) {
|
||||
StartExportWindow.transparentBackground = !StartExportWindow.transparentBackground;
|
||||
}
|
||||
}
|
||||
|
||||
if (editorState != null && ImGui.button("Take Screenshot")) {
|
||||
String defaultName = StartExportWindow.getDefaultFilename(null, "png");
|
||||
String defaultExportPathString = StartExportWindow.defaultExportPath.toString();
|
||||
|
||||
AsyncFileDialogs.saveFileDialog(defaultExportPathString, defaultName, "PNG", "png").thenAccept(pathStr -> {
|
||||
if (pathStr != null) {
|
||||
Path path = Path.of(pathStr);
|
||||
StartExportWindow.defaultExportPath = path.getParent();
|
||||
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
int tick = Flashback.getReplayServer().getReplayTick();
|
||||
|
||||
boolean transparent = StartExportWindow.transparentBackground && !editorState.replayVisuals.renderSky;
|
||||
boolean ssaa = StartExportWindow.ssaa;
|
||||
boolean noGui = StartExportWindow.noGui;
|
||||
|
||||
EditorState copiedEditorState = editorState.copy();
|
||||
copiedEditorState.keyframeTracks.clear();
|
||||
|
||||
ExportSettings settings = new ExportSettings(null, copiedEditorState,
|
||||
player.position(), player.getYRot(), player.getXRot(),
|
||||
resolution[0], resolution[1], tick, tick,
|
||||
1, false, VideoContainer.PNG_SEQUENCE, null, null, 0, transparent, ssaa, noGui,
|
||||
false, false, null,
|
||||
path);
|
||||
|
||||
close = true;
|
||||
Utils.exportSequenceCount += 1;
|
||||
Flashback.EXPORT_JOB = new ExportJob(settings);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ImGuiHelper.endPopupModalCloseable();
|
||||
}
|
||||
|
||||
close = false;
|
||||
}
|
||||
|
||||
public static void open() {
|
||||
open = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,16 @@
|
||||
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 imgui.ImGui;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MainMenuBar {
|
||||
|
||||
@@ -15,15 +22,63 @@ public class MainMenuBar {
|
||||
}
|
||||
|
||||
public static void renderInner() {
|
||||
if (ImGui.menuItem("Export Video")) {
|
||||
StartExportWindow.open();
|
||||
}
|
||||
FlashbackConfig config = Flashback.getConfig();
|
||||
|
||||
if (!ExportJobQueue.queuedJobs.isEmpty()) {
|
||||
String name = "Export Queue (" + ExportJobQueue.count() + ")";
|
||||
if (ImGui.menuItem(name + "###QueuedJobs")) {
|
||||
ExportQueueWindow.open();
|
||||
if (ImGui.beginMenu("File")) {
|
||||
if (ImGui.menuItem("Export Video")) {
|
||||
StartExportWindow.open();
|
||||
}
|
||||
if (!ExportJobQueue.queuedJobs.isEmpty()) {
|
||||
String name = "Export Queue (" + ExportJobQueue.count() + ")";
|
||||
if (ImGui.menuItem(name + "###QueuedJobs")) {
|
||||
ExportQueueWindow.open();
|
||||
}
|
||||
}
|
||||
if (ImGui.menuItem("Export Screenshot")) {
|
||||
ExportScreenshotWindow.open();
|
||||
}
|
||||
ImGui.separator();
|
||||
if (ImGui.menuItem("Open Replay")) {
|
||||
Flashback.openReplayFromFileBrowser();
|
||||
}
|
||||
if (!config.recentReplays.isEmpty()) {
|
||||
if (ImGui.beginMenu("Open Recent")) {
|
||||
Path replayFolder = Flashback.getReplayFolder();
|
||||
for (String recentReplay : config.recentReplays) {
|
||||
Path path = Path.of(recentReplay);
|
||||
|
||||
if (Files.exists(path)) {
|
||||
String display = path.toString();
|
||||
|
||||
try {
|
||||
Path relative = replayFolder.relativize(path);
|
||||
String relativeStr = relative.toString();
|
||||
if (!relativeStr.contains("..")) {
|
||||
display = relativeStr;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
if (ImGui.menuItem(display)) {
|
||||
Flashback.openReplayWorld(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.endMenu();
|
||||
}
|
||||
}
|
||||
if (ImGui.menuItem("Exit Replay")) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (minecraft.level != null) {
|
||||
minecraft.level.disconnect();
|
||||
}
|
||||
minecraft.disconnect();
|
||||
minecraft.setScreen(new SelectReplayScreen(new TitleScreen()));
|
||||
}
|
||||
ImGui.endMenu();
|
||||
}
|
||||
if (ImGui.menuItem("Preferences")) {
|
||||
PreferencesWindow.open();
|
||||
}
|
||||
|
||||
ImGui.separator();
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.combo_options.VideoContainer;
|
||||
import com.moulberry.flashback.configuration.FlashbackConfig;
|
||||
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.keyframe.interpolation.InterpolationType;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImShort;
|
||||
import imgui.type.ImString;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class PreferencesWindow {
|
||||
|
||||
private static boolean open = false;
|
||||
private static boolean close = false;
|
||||
|
||||
public static void render() {
|
||||
if (open) {
|
||||
open = false;
|
||||
ImGui.openPopup("###Preferences");
|
||||
}
|
||||
|
||||
boolean wasOpen = ImGui.isPopupOpen("###Preferences");
|
||||
|
||||
if (ImGuiHelper.beginPopupModalCloseable("Preferences###Preferences", ImGuiWindowFlags.AlwaysAutoResize)) {
|
||||
if (close) {
|
||||
close = false;
|
||||
ImGui.closeCurrentPopup();
|
||||
ImGuiHelper.endPopupModalCloseable();
|
||||
return;
|
||||
}
|
||||
|
||||
FlashbackConfig config = Flashback.getConfig();
|
||||
|
||||
// Exporting
|
||||
ImGuiHelper.separatorWithText("Exporting");
|
||||
|
||||
ImString imString = ImGuiHelper.createResizableImString(config.defaultExportFilename);
|
||||
if (ImGui.inputText("Export Filename", imString)) {
|
||||
config.defaultExportFilename = ImGuiHelper.getString(imString);
|
||||
}
|
||||
ImGuiHelper.tooltip("The default filename when exporting\nVariables:\n\t%date%\tyear-month-day\n\t%time%\thh_mm_ss\n\t%replay%\tReplay name\n\t%seq%\tExport count for this session");
|
||||
|
||||
// Keyframes
|
||||
ImGuiHelper.separatorWithText("Keyframes");
|
||||
|
||||
config.defaultInterpolationType = ImGuiHelper.enumCombo("Default Interpolation", config.defaultInterpolationType);
|
||||
|
||||
ImGuiHelper.endPopupModalCloseable();
|
||||
}
|
||||
|
||||
if (wasOpen && !ImGui.isPopupOpen("###Preferences")) {
|
||||
Flashback.getConfig().saveToDefaultFolder();
|
||||
}
|
||||
|
||||
close = false;
|
||||
}
|
||||
|
||||
public static void open() {
|
||||
open = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,43 @@
|
||||
package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.yggdrasil.ProfileResult;
|
||||
import com.moulberry.flashback.editor.ui.ImGuiHelper;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import imgui.ImGui;
|
||||
import imgui.type.ImString;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SelectedEntityPopup {
|
||||
|
||||
private static ImString changeSkinInput = ImGuiHelper.createResizableImString("");
|
||||
static {
|
||||
changeSkinInput.inputData.allowedChars = "0123456789abcdef-";
|
||||
}
|
||||
private static ImString changeNameInput = ImGuiHelper.createResizableImString("");
|
||||
|
||||
public static void open(Entity entity, EditorState editorState) {
|
||||
String nameOverride = editorState.nameOverride.get(entity.getUUID());
|
||||
if (nameOverride != null) {
|
||||
changeNameInput.set(nameOverride);
|
||||
} else {
|
||||
changeNameInput.set("");
|
||||
}
|
||||
|
||||
GameProfile skinOverride = editorState.skinOverride.get(entity.getUUID());
|
||||
if (skinOverride != null) {
|
||||
changeSkinInput.set(skinOverride.getId().toString());
|
||||
} else {
|
||||
changeSkinInput.set("");
|
||||
}
|
||||
}
|
||||
|
||||
public static void render(Entity entity, EditorState editorState) {
|
||||
UUID uuid = entity.getUUID();
|
||||
ImGui.text("Entity: " + uuid);
|
||||
@@ -45,6 +71,57 @@ public class SelectedEntityPopup {
|
||||
editorState.markDirty();
|
||||
}
|
||||
|
||||
if (!isHiddenDuringExport && entity instanceof Player player) {
|
||||
boolean hideNametag = editorState.hideNametags.contains(entity.getUUID());
|
||||
if (ImGui.checkbox("Render Nametag", !hideNametag)) {
|
||||
if (hideNametag) {
|
||||
editorState.hideNametags.remove(entity.getUUID());
|
||||
} else {
|
||||
editorState.hideNametags.add(entity.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
if (!hideNametag) {
|
||||
boolean changedName = ImGui.inputTextWithHint("Name##SetNameInput", player.getScoreboardName(), changeNameInput);
|
||||
|
||||
if (changedName) {
|
||||
String string = ImGuiHelper.getString(changeNameInput);
|
||||
if (string.isEmpty()) {
|
||||
editorState.nameOverride.remove(entity.getUUID());
|
||||
} else {
|
||||
editorState.nameOverride.put(entity.getUUID(), string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiHelper.separatorWithText("Change Skin & Cape (UUID)");
|
||||
ImGui.setNextItemWidth(320);
|
||||
ImGui.inputTextWithHint("##SetSkinInput", "e.g. d0e05de7-6067-454d-beae-c6d19d886191", changeSkinInput);
|
||||
|
||||
boolean hasApplySkin = false;
|
||||
if (!changeSkinInput.isEmpty()) {
|
||||
String string = ImGuiHelper.getString(changeSkinInput);
|
||||
try {
|
||||
UUID changeSkinUuid = UUID.fromString(string);
|
||||
if (ImGui.button("Apply Skin")) {
|
||||
ProfileResult profile = Minecraft.getInstance().getMinecraftSessionService().fetchProfile(changeSkinUuid, true);
|
||||
editorState.skinOverride.put(entity.getUUID(), profile.profile());
|
||||
}
|
||||
hasApplySkin = true;
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
if (editorState.skinOverride.containsKey(entity.getUUID())) {
|
||||
if (hasApplySkin) {
|
||||
ImGui.sameLine();
|
||||
}
|
||||
if (ImGui.button("Reset Skin")) {
|
||||
editorState.skinOverride.remove(entity.getUUID());
|
||||
changeSkinInput.set("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ImGui.sameLine();
|
||||
// ImGui.button("Track Entity");
|
||||
//
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.Utils;
|
||||
import com.moulberry.flashback.combo_options.AspectRatio;
|
||||
import com.moulberry.flashback.combo_options.AudioCodec;
|
||||
import com.moulberry.flashback.combo_options.Sizing;
|
||||
@@ -22,6 +23,7 @@ import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.FileUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.nio.file.Files;
|
||||
@@ -43,8 +45,8 @@ public class StartExportWindow {
|
||||
private static final int[] startEndTick = new int[]{0, 100};
|
||||
private static final float[] framerate = new float[]{60};
|
||||
private static boolean resetRng = false;
|
||||
private static boolean ssaa = false;
|
||||
private static boolean noGui = false;
|
||||
public static boolean ssaa = false;
|
||||
public static boolean noGui = false;
|
||||
|
||||
private static VideoContainer[] supportedContainers = null;
|
||||
private static VideoContainer[] supportedContainersWithTransparency = null;
|
||||
@@ -56,11 +58,11 @@ public class StartExportWindow {
|
||||
private static final ImString bitrate = ImGuiHelper.createResizableImString("20m");
|
||||
|
||||
private static boolean recordAudio = false;
|
||||
private static boolean transparentBackground = false;
|
||||
public static boolean transparentBackground = false;
|
||||
private static AudioCodec audioCodec = AudioCodec.AAC;
|
||||
private static boolean stereoAudio = false;
|
||||
|
||||
private static Path defaultExportPath = null;
|
||||
public static Path defaultExportPath = null;
|
||||
private static final ImString jobName = ImGuiHelper.createResizableImString("");
|
||||
|
||||
private static String installedIncompatibleModsString = null;
|
||||
@@ -229,6 +231,7 @@ public class StartExportWindow {
|
||||
createExportSettings(null).thenAccept(settings -> {
|
||||
if (settings != null) {
|
||||
close = true;
|
||||
Utils.exportSequenceCount += 1;
|
||||
Flashback.EXPORT_JOB = new ExportJob(settings);
|
||||
}
|
||||
});
|
||||
@@ -247,6 +250,7 @@ public class StartExportWindow {
|
||||
createExportSettings(ImGuiHelper.getString(jobName)).thenAccept(settings -> {
|
||||
if (settings != null) {
|
||||
close = true;
|
||||
Utils.exportSequenceCount += 1;
|
||||
ExportJobQueue.queuedJobs.add(settings);
|
||||
}
|
||||
});
|
||||
@@ -351,24 +355,7 @@ public class StartExportWindow {
|
||||
numBitrate = stringToBitrate(ImGuiHelper.getString(bitrate));
|
||||
}
|
||||
|
||||
if (defaultExportPath == null || !Files.exists(defaultExportPath)) {
|
||||
defaultExportPath = FabricLoader.getInstance().getGameDir();
|
||||
}
|
||||
|
||||
String defaultName = null;
|
||||
if (name != null) {
|
||||
try {
|
||||
defaultName = FileUtil.findAvailableName(defaultExportPath, name, "." + container.extension());
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if (defaultName == null) {
|
||||
try {
|
||||
defaultName = FileUtil.findAvailableName(defaultExportPath, "output", "." + container.extension());
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if (defaultName == null) {
|
||||
defaultName = "output." + container.extension();
|
||||
}
|
||||
String defaultName = getDefaultFilename(name, container.extension());
|
||||
|
||||
Function<String, ExportSettings> callback = pathStr -> {
|
||||
if (pathStr != null) {
|
||||
@@ -432,6 +419,30 @@ public class StartExportWindow {
|
||||
|
||||
}
|
||||
|
||||
public static @NotNull String getDefaultFilename(@Nullable String name, String extension) {
|
||||
if (defaultExportPath == null || !Files.exists(defaultExportPath)) {
|
||||
defaultExportPath = FabricLoader.getInstance().getGameDir();
|
||||
}
|
||||
|
||||
String defaultName = null;
|
||||
if (name != null) {
|
||||
try {
|
||||
defaultName = FileUtil.findAvailableName(defaultExportPath, name, "." + extension);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if (defaultName == null) {
|
||||
String desiredName = Utils.resolveFilenameTemplate(Flashback.getConfig().defaultExportFilename);
|
||||
try {
|
||||
defaultName = FileUtil.findAvailableName(defaultExportPath, desiredName, "." + extension);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if (defaultName == null) {
|
||||
String desiredName = Utils.resolveFilenameTemplate(Flashback.getConfig().defaultExportFilename);
|
||||
defaultName = desiredName + "." + extension;
|
||||
}
|
||||
return defaultName;
|
||||
}
|
||||
|
||||
private static int stringToBitrate(String string) {
|
||||
int number = 0;
|
||||
int modifier = 1;
|
||||
|
||||
@@ -27,15 +27,12 @@ import com.moulberry.flashback.record.FlashbackMeta;
|
||||
import com.moulberry.flashback.state.KeyframeTrack;
|
||||
import imgui.ImDrawList;
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiButtonFlags;
|
||||
import imgui.flag.ImGuiHoveredFlags;
|
||||
import imgui.flag.ImGuiMouseButton;
|
||||
import imgui.flag.ImGuiMouseCursor;
|
||||
import imgui.flag.ImGuiPopupFlags;
|
||||
import imgui.flag.ImGuiStyleVar;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImFloat;
|
||||
import imgui.type.ImInt;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -60,6 +57,9 @@ public class TimelineWindow {
|
||||
private static boolean enableKeyframeMovement = false;
|
||||
private static int grabbedKeyframeTick = 0;
|
||||
private static int grabbedKeyframeTrack = 0;
|
||||
private static int draggingMouseButton = ImGuiMouseButton.Left;
|
||||
private static float dragStartMouseX = 0;
|
||||
private static float dragStartMouseY = 0;
|
||||
|
||||
private static boolean trackDisabledButtonDrag = false;
|
||||
private static boolean trackDisabledButtonDragValue = false;
|
||||
@@ -130,7 +130,11 @@ public class TimelineWindow {
|
||||
boolean hoveredBody = mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height;
|
||||
|
||||
ImGuiHelper.pushStyleVar(ImGuiStyleVar.WindowPadding, 0, 0);
|
||||
boolean timelineVisible = ImGui.begin("Timeline (" + timestamp + "/" + cursorTicks + ")###Timeline", hoveredBody ? ImGuiWindowFlags.NoMove : ImGuiWindowFlags.None);
|
||||
int flags = ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoScrollbar;
|
||||
if (hoveredBody) {
|
||||
flags |= ImGuiWindowFlags.NoMove;
|
||||
}
|
||||
boolean timelineVisible = ImGui.begin("Timeline (" + timestamp + "/" + cursorTicks + ")###Timeline", flags);
|
||||
ImGuiHelper.popStyleVar();
|
||||
|
||||
cursorTicks = replayServer.getReplayTick();
|
||||
@@ -223,23 +227,7 @@ public class TimelineWindow {
|
||||
boolean isShiftDown = ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || ImGui.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||
|
||||
if (isShiftDown) {
|
||||
int closestTick = -1;
|
||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||
Integer floor = track.keyframesByTick.floorKey(cursorTicks);
|
||||
Integer ceil = track.keyframesByTick.ceilingKey(cursorTicks);
|
||||
|
||||
float floorX = floor == null ? Float.NaN : x + replayTickToTimelineX(floor);
|
||||
float ceilX = ceil == null ? Float.NaN : x + replayTickToTimelineX(ceil);
|
||||
|
||||
Integer closest = Utils.chooseClosest(mouseX, floorX, floor, ceilX, ceil, KEYFRAME_SIZE);
|
||||
if (closest != null) {
|
||||
if (closestTick == -1) {
|
||||
closestTick = closest;
|
||||
} else if (Math.abs(closest - cursorTicks) < Math.abs(closestTick - cursorTicks)) {
|
||||
closestTick = closest;
|
||||
}
|
||||
}
|
||||
}
|
||||
int closestTick = findClosestKeyframeForSnap(editorState, cursorTicks);
|
||||
if (closestTick != -1) {
|
||||
cursorTicks = closestTick;
|
||||
}
|
||||
@@ -272,7 +260,7 @@ public class TimelineWindow {
|
||||
drawList.addLine(x + middleX, y + timestampHeight, x + middleX, y + height, -1);
|
||||
|
||||
// Middle divider (y)
|
||||
drawList.addLine(0, y + middleY, width, y + middleY, -1);
|
||||
drawList.addLine(x, y + middleY, x + width, y + middleY, -1);
|
||||
|
||||
renderKeyframeElements(replayServer, editorState, x, y + middleY, cursorTicks, middleX);
|
||||
|
||||
@@ -433,58 +421,81 @@ public class TimelineWindow {
|
||||
editingKeyframeTick = -1;
|
||||
}
|
||||
|
||||
if (mouseX > x + middleX && mouseX < x + width && mouseY > y && mouseY < y + height) {
|
||||
int scroll = (int) Math.signum(ImGui.getIO().getMouseWheel());
|
||||
|
||||
double mousePercentage = (mouseX - (x + middleX)) / (width - middleX);
|
||||
|
||||
if (scroll > 0) {
|
||||
double zoomDelta = editorState.zoomMax - editorState.zoomMin;
|
||||
if (zoomDelta > 0.001) {
|
||||
editorState.zoomMin += zoomDelta * 0.05 * mousePercentage;
|
||||
editorState.zoomMax -= zoomDelta * 0.05 * (1 - mousePercentage);
|
||||
editorState.markDirty();
|
||||
}
|
||||
} else if (scroll < 0) {
|
||||
double zoomDelta = editorState.zoomMax - editorState.zoomMin;
|
||||
|
||||
editorState.zoomMin = Math.max(0, editorState.zoomMin - zoomDelta * 0.05/0.9 * mousePercentage);
|
||||
editorState.zoomMax = Math.min(1, editorState.zoomMax + zoomDelta * 0.05/0.9 * (1 - mousePercentage));
|
||||
editorState.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
boolean shouldProcessInput = !ImGui.isPopupOpen("", ImGuiPopupFlags.AnyPopup) && !ImGui.getIO().getWantTextInput();
|
||||
if (shouldProcessInput) {
|
||||
int scroll = (int) Math.signum(ImGui.getIO().getMouseWheel());
|
||||
if (scroll != 0 && mouseX > x + middleX && mouseX < x + width && mouseY > y && mouseY < y + height) {
|
||||
double mousePercentage = (mouseX - (x + middleX)) / (width - middleX);
|
||||
|
||||
if (scroll > 0) {
|
||||
double zoomDelta = editorState.zoomMax - editorState.zoomMin;
|
||||
if (zoomDelta > 0.001) {
|
||||
editorState.zoomMin += zoomDelta * 0.05 * mousePercentage;
|
||||
editorState.zoomMax -= zoomDelta * 0.05 * (1 - mousePercentage);
|
||||
editorState.markDirty();
|
||||
}
|
||||
} else if (scroll < 0) {
|
||||
double zoomDelta = editorState.zoomMax - editorState.zoomMin;
|
||||
|
||||
editorState.zoomMin = Math.max(0, editorState.zoomMin - zoomDelta * 0.05/0.9 * mousePercentage);
|
||||
editorState.zoomMax = Math.min(1, editorState.zoomMax + zoomDelta * 0.05/0.9 * (1 - mousePercentage));
|
||||
editorState.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
handleKeyPresses(replayServer, cursorTicks, editorState, totalTicks);
|
||||
|
||||
boolean leftClicked = ImGui.isMouseClicked(ImGuiMouseButton.Left);
|
||||
boolean rightClicked = ImGui.isMouseClicked(ImGuiMouseButton.Right);
|
||||
if (leftClicked || rightClicked) {
|
||||
handleClick(editorState, replayServer, totalTicks);
|
||||
} else if (ImGui.isMouseDragging(ImGuiMouseButton.Left)) {
|
||||
if (leftClicked) {
|
||||
draggingMouseButton = ImGuiMouseButton.Left;
|
||||
} else {
|
||||
draggingMouseButton = ImGuiMouseButton.Right;
|
||||
}
|
||||
dragStartMouseX = mouseX;
|
||||
dragStartMouseY = mouseY;
|
||||
} else if (ImGui.isMouseDragging(draggingMouseButton)) {
|
||||
if (grabbedExportBarResizeLeft) {
|
||||
ImGui.setMouseCursor(ImGuiMouseCursor.ResizeEW);
|
||||
|
||||
|
||||
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);
|
||||
if (closestTick != -1) {
|
||||
target = closestTick;
|
||||
}
|
||||
}
|
||||
|
||||
editorState.setExportTicks(target, -1, totalTicks);
|
||||
}
|
||||
if (grabbedExportBarResizeRight) {
|
||||
ImGui.setMouseCursor(ImGuiMouseCursor.ResizeEW);
|
||||
|
||||
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);
|
||||
if (closestTick != -1) {
|
||||
target = closestTick;
|
||||
}
|
||||
}
|
||||
|
||||
editorState.setExportTicks(-1, target, totalTicks);
|
||||
}
|
||||
if (zoomBarWidth > 1f && grabbedZoomBar) {
|
||||
float dx = ImGui.getMouseDragDeltaX();
|
||||
float dx = mouseX - dragStartMouseX;
|
||||
float factor = dx / zoomBarWidth;
|
||||
|
||||
if (grabbedZoomBarResizeLeft) {
|
||||
ImGui.setMouseCursor(ImGuiMouseCursor.ResizeEW);
|
||||
editorState.zoomMin = Math.max(0, Math.min(editorState.zoomMax-0.01f, zoomMinBeforeDrag + factor));
|
||||
editorState.zoomMin = Math.max(0, Math.min(editorState.zoomMax - 0.01f, zoomMinBeforeDrag + factor));
|
||||
} else if (grabbedZoomBarResizeRight) {
|
||||
ImGui.setMouseCursor(ImGuiMouseCursor.ResizeEW);
|
||||
editorState.zoomMax = Math.max(editorState.zoomMin+0.01f, Math.min(1, zoomMaxBeforeDrag + factor));
|
||||
editorState.zoomMax = Math.max(editorState.zoomMin + 0.01f, Math.min(1, zoomMaxBeforeDrag + factor));
|
||||
} else {
|
||||
ImGui.setMouseCursor(ImGuiMouseCursor.Hand);
|
||||
|
||||
@@ -508,6 +519,13 @@ public class TimelineWindow {
|
||||
|
||||
replayServer.replayPaused = true;
|
||||
}
|
||||
} else if (zoomBarWidth > 1f && mouseY > y + middleY && mouseY < y + height && mouseX > x + middleX && mouseX < x + width && ImGui.isMouseDown(ImGuiMouseButton.Middle)) {
|
||||
grabbedZoomBar = true;
|
||||
draggingMouseButton = ImGuiMouseButton.Middle;
|
||||
zoomMinBeforeDrag = editorState.zoomMin;
|
||||
zoomMaxBeforeDrag = editorState.zoomMax;
|
||||
dragStartMouseX = mouseX;
|
||||
dragStartMouseY = mouseY;
|
||||
} else if (!ImGui.isAnyMouseDown()) {
|
||||
releaseGrabbed(editorState, replayServer, totalTicks);
|
||||
}
|
||||
@@ -518,6 +536,27 @@ public class TimelineWindow {
|
||||
ImGui.end();
|
||||
}
|
||||
|
||||
private static int findClosestKeyframeForSnap(EditorState editorState, int tick) {
|
||||
int closestTick = -1;
|
||||
for (KeyframeTrack track : editorState.keyframeTracks) {
|
||||
Integer floor = track.keyframesByTick.floorKey(tick);
|
||||
Integer ceil = track.keyframesByTick.ceilingKey(tick);
|
||||
|
||||
float floorX = floor == null ? Float.NaN : x + replayTickToTimelineX(floor);
|
||||
float ceilX = ceil == null ? Float.NaN : x + replayTickToTimelineX(ceil);
|
||||
|
||||
Integer closest = Utils.chooseClosest(mouseX, floorX, floor, ceilX, ceil, KEYFRAME_SIZE);
|
||||
if (closest != null) {
|
||||
if (closestTick == -1) {
|
||||
closestTick = closest;
|
||||
} else if (Math.abs(closest - tick) < Math.abs(closestTick - tick)) {
|
||||
closestTick = closest;
|
||||
}
|
||||
}
|
||||
}
|
||||
return closestTick;
|
||||
}
|
||||
|
||||
private static void handleKeyPresses(ReplayServer replayServer, int cursorTicks, EditorState editorState, int totalTicks) {
|
||||
boolean pressedIn = ImGui.isKeyPressed(GLFW.GLFW_KEY_I, false);
|
||||
boolean pressedOut = ImGui.isKeyPressed(GLFW.GLFW_KEY_O, false);
|
||||
@@ -528,7 +567,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_SPACE, false)) {
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_P, false)) {
|
||||
togglePaused(replayServer, editorState);
|
||||
}
|
||||
if (ImGui.isKeyPressed(GLFW.GLFW_KEY_LEFT, false)) {
|
||||
@@ -1656,7 +1695,7 @@ public class TimelineWindow {
|
||||
}
|
||||
|
||||
private static void renderPlaybackHead(int cursorX, float x, int middleX, float width, int cursorTicks, int currentReplayTick, ImDrawList drawList, float y, int middleY, int timestampHeight, float height, int zoomBarHeight) {
|
||||
if (cursorX > x + middleX -10 && cursorX < x + width +10) {
|
||||
if (cursorX > middleX - 10 && cursorX < width +10) {
|
||||
int colour = -1;
|
||||
if (cursorTicks < currentReplayTick) {
|
||||
colour = 0x80FFFFFF;
|
||||
|
||||
@@ -201,6 +201,11 @@ public class VisualsWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// Night vision
|
||||
if (ImGui.checkbox("Night Vision", visuals.overrideNightVision)) {
|
||||
visuals.overrideNightVision = !visuals.overrideNightVision;
|
||||
}
|
||||
|
||||
// Camera shake
|
||||
if (ImGui.checkbox("Camera Shake", visuals.overrideCameraShake)) {
|
||||
visuals.overrideCameraShake = !visuals.overrideCameraShake;
|
||||
|
||||
Reference in new issue
Block a user