mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 14:38:50 +00:00
Windows taskbar progress (seems to not work?)
This commit is contained in:
1 parent
38d1c65442
commit
92b375fad7
10 files changed
+188
-16
No files matched your search
+1
-1
@@ -71,7 +71,7 @@ dependencies {
|
||||
modCompileOnly("maven.modrinth:bobby:2cuVyTav")
|
||||
modCompileOnly("maven.modrinth:simple-voice-chat:95BK1U8I")
|
||||
modCompileOnly("maven.modrinth:replaymod:NtlpUQgI")
|
||||
modImplementation("maven.modrinth:modmenu:xhN1IvHi")
|
||||
modCompileOnly("maven.modrinth:modmenu:xhN1IvHi")
|
||||
|
||||
shadow(implementation("org.bytedeco:javacv-platform:1.5.10") {
|
||||
exclude group: "org.bytedeco", module: "artoolkitplus"
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.moulberry.flashback.compat.simple_voice_chat.SimpleVoiceChatPlayback;
|
||||
import com.moulberry.flashback.configuration.FlashbackConfig;
|
||||
import com.moulberry.flashback.exporting.AsyncFileDialogs;
|
||||
import com.moulberry.flashback.exporting.ExportJob;
|
||||
import com.moulberry.flashback.exporting.taskbar.TaskbarManager;
|
||||
import com.moulberry.flashback.ext.MinecraftExt;
|
||||
import com.moulberry.flashback.keyframe.KeyframeRegistry;
|
||||
import com.moulberry.flashback.keyframe.types.CameraKeyframeType;
|
||||
@@ -846,6 +847,8 @@ public class Flashback implements ModInitializer, ClientModInitializer {
|
||||
}, WorldStem::new, Util.backgroundExecutor(), executor)).get();
|
||||
|
||||
((MinecraftExt)Minecraft.getInstance()).flashback$startReplayServer(access, packRepository, worldStem, replayUuid, path);
|
||||
|
||||
TaskbarManager.launchTaskbarManager();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.TextureUtil;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportDoneWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportQueueWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportScreenshotWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.MovementWindow;
|
||||
@@ -770,6 +771,8 @@ public class ReplayUI {
|
||||
|
||||
WindowType.renderAll();
|
||||
|
||||
ExportDoneWindow.render();
|
||||
|
||||
popupOpenLastFrame = ImGui.isPopupOpen("", ImGuiPopupFlags.AnyPopup);
|
||||
|
||||
ImGui.render();
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.moulberry.flashback.editor.ui.windows;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.ImGuiViewport;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
|
||||
public class ExportDoneWindow {
|
||||
|
||||
public static boolean exportDoneWindowOpen = false;
|
||||
|
||||
public static void render() {
|
||||
if (!exportDoneWindowOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiViewport viewport = ImGui.getMainViewport();
|
||||
ImGui.setNextWindowPos(viewport.getCenterX(), viewport.getCenterY(), ImGuiCond.Appearing, 0.5f, 0.5f);
|
||||
|
||||
ImBoolean open = new ImBoolean(true);
|
||||
|
||||
ImGui.setNextWindowSizeConstraints(250, 50, 5000, 5000);
|
||||
int flags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoSavedSettings;
|
||||
|
||||
ImGui.openPopup("###ExportDone");
|
||||
if (ImGui.beginPopupModal("Export Finished###ExportDone", open, flags)) {
|
||||
ImGui.text("Export has successfully finished");
|
||||
ImGui.endPopup();
|
||||
}
|
||||
|
||||
if (!open.get()) {
|
||||
exportDoneWindowOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.moulberry.flashback.combo_options.VideoContainer;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import com.moulberry.flashback.exporting.taskbar.ITaskbar;
|
||||
import com.moulberry.flashback.exporting.taskbar.TaskbarHost;
|
||||
import com.moulberry.flashback.exporting.taskbar.TaskbarManager;
|
||||
import com.moulberry.flashback.keyframe.KeyframeType;
|
||||
import com.moulberry.flashback.keyframe.handler.KeyframeHandler;
|
||||
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
||||
@@ -76,12 +77,13 @@ public class ExportJob {
|
||||
private long downloadTimeNanos = 0;
|
||||
private boolean patreonLinkClicked = false;
|
||||
|
||||
public int progressCount = 0;
|
||||
public int progressOutOf = 0;
|
||||
|
||||
private double currentTickDouble = 0.0;
|
||||
|
||||
private double audioSamples = 0.0;
|
||||
|
||||
private ITaskbar taskbar;
|
||||
|
||||
private final AtomicBoolean finishedServerTick = new AtomicBoolean(false);
|
||||
|
||||
public static final int SRC_PIXEL_FORMAT = avutil.AV_PIX_FMT_RGBA;
|
||||
@@ -132,6 +134,8 @@ public class ExportJob {
|
||||
Minecraft.getInstance().mouseHandler.releaseMouse();
|
||||
Minecraft.getInstance().getSoundManager().stop();
|
||||
|
||||
TaskbarManager.launchTaskbarManager();
|
||||
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
||||
String tempFileName = "replay_export_temp/" + uuid + "." + this.settings.container().extension();
|
||||
@@ -232,8 +236,6 @@ public class ExportJob {
|
||||
|
||||
double lastClientTickDouble = 0;
|
||||
|
||||
this.taskbar = TaskbarHost.createTaskbar();
|
||||
|
||||
for (int tickIndex = 0; tickIndex < ticks.size(); tickIndex++) {
|
||||
TickInfo tickInfo = ticks.get(tickIndex);
|
||||
boolean frozen = tickInfo.frozen;
|
||||
@@ -354,9 +356,6 @@ public class ExportJob {
|
||||
|
||||
submitDownloadedFrames(videoWriter, downloader, true);
|
||||
videoWriter.finish();
|
||||
|
||||
this.taskbar.close();
|
||||
this.taskbar = null;
|
||||
}
|
||||
|
||||
private void updateRandoms(Random random, Random mathRandom) {
|
||||
@@ -506,7 +505,8 @@ public class ExportJob {
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - this.lastRenderMillis > 1000/60 || currentFrame == totalFrames) {
|
||||
this.taskbar.setProgress(currentFrame, totalFrames);
|
||||
this.progressCount = currentFrame;
|
||||
this.progressOutOf = totalFrames;
|
||||
|
||||
Window window = Minecraft.getInstance().getWindow();
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.moulberry.flashback.exporting.taskbar;
|
||||
|
||||
public interface ITaskbar {
|
||||
void close();
|
||||
void reset();
|
||||
|
||||
void setProgress(long count, long outOf);
|
||||
void setPaused();
|
||||
void setNormal();
|
||||
}
|
||||
@@ -3,11 +3,21 @@ package com.moulberry.flashback.exporting.taskbar;
|
||||
public class NoopTaskbar implements ITaskbar {
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(long count, long outOf) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaused() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNormal() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.moulberry.flashback.exporting.taskbar;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportDoneWindow;
|
||||
import com.moulberry.flashback.exporting.ExportJob;
|
||||
import net.minecraft.Util;
|
||||
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
||||
public class TaskbarManager {
|
||||
|
||||
private static ITaskbar taskbarInterface = null;
|
||||
|
||||
private static int lastProgressCount = 0;
|
||||
private static int lastProgressOutOf = 0;
|
||||
private static long lastExportJobUpdate = -1;
|
||||
private static boolean lastPaused = false;
|
||||
|
||||
private static volatile boolean started = false;
|
||||
|
||||
public static void launchTaskbarManager() {
|
||||
if (started) {
|
||||
return;
|
||||
}
|
||||
started = true;
|
||||
|
||||
Thread taskbarThread = new Thread(() -> {
|
||||
while (Flashback.isInReplay()) {
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
tickTaskbarProgress();
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
started = false;
|
||||
});
|
||||
taskbarThread.setName("Flashback-Taskbar-Updater");
|
||||
taskbarThread.start();
|
||||
}
|
||||
|
||||
public static void tickTaskbarProgress() {
|
||||
ExportJob exportJob = Flashback.EXPORT_JOB;
|
||||
if (exportJob != null) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (lastExportJobUpdate > currentTime) {
|
||||
lastExportJobUpdate = currentTime;
|
||||
}
|
||||
|
||||
boolean paused = false;
|
||||
if (lastExportJobUpdate > 0 && exportJob.progressCount == lastProgressCount && exportJob.progressOutOf == lastProgressOutOf) {
|
||||
paused = currentTime - lastExportJobUpdate > 5000;
|
||||
} else {
|
||||
lastExportJobUpdate = currentTime;
|
||||
}
|
||||
|
||||
setTaskbarProgress(exportJob.progressCount, exportJob.progressOutOf, paused);
|
||||
return;
|
||||
} else {
|
||||
lastExportJobUpdate = -1;
|
||||
}
|
||||
|
||||
if (ExportDoneWindow.exportDoneWindowOpen) {
|
||||
setTaskbarProgress(1, 1, false);
|
||||
return;
|
||||
}
|
||||
|
||||
setTaskbarProgress(0, 0, false);
|
||||
}
|
||||
|
||||
private static void setTaskbarProgress(int count, int outOf, boolean paused) {
|
||||
if (count == lastProgressCount && outOf == lastProgressOutOf && paused == lastPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (taskbarInterface == null) {
|
||||
taskbarInterface = TaskbarHost.createTaskbar();
|
||||
}
|
||||
|
||||
if (count <= 0 || outOf <= 0) {
|
||||
taskbarInterface.reset();
|
||||
lastPaused = false;
|
||||
} else {
|
||||
if (paused != lastPaused) {
|
||||
if (paused) {
|
||||
taskbarInterface.setPaused();
|
||||
} else {
|
||||
taskbarInterface.setNormal();
|
||||
}
|
||||
lastPaused = paused;
|
||||
}
|
||||
taskbarInterface.setProgress(count, outOf);
|
||||
}
|
||||
|
||||
lastProgressCount = count;
|
||||
lastProgressOutOf = outOf;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,14 +7,15 @@ import com.sun.jna.platform.win32.WinDef;
|
||||
import com.sun.jna.platform.win32.WinNT;
|
||||
|
||||
public class WindowsTaskbar extends COMInvoker implements ITaskbar {
|
||||
|
||||
private final WinDef.HWND hwnd;
|
||||
WindowsTaskbar(Pointer ptr, WinDef.HWND hwnd) {
|
||||
this.setPointer(ptr);
|
||||
this.hwnd = hwnd;
|
||||
try {
|
||||
this.invokeNative(3);//HrInit
|
||||
this.invokeNative(3); // HrInit
|
||||
} finally {
|
||||
this.invokeNative(2);//Release
|
||||
this.invokeNative(2); // Release
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +29,28 @@ public class WindowsTaskbar extends COMInvoker implements ITaskbar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(long count, long outOf) {
|
||||
this.invokeNative(9, this.hwnd, count, outOf);//SetProgressValue
|
||||
public void close() {
|
||||
this.reset();
|
||||
this.invokeNative(2); // Release
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.invokeNative(10, this.hwnd, 0);//SetProgressState TBPF_NOPROGRESS
|
||||
this.invokeNative(2);//Release
|
||||
public void reset() {
|
||||
this.invokeNative(10, this.hwnd, 0); // SetProgressState TBPF_NOPROGRESS (0x00000000)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(long count, long outOf) {
|
||||
this.invokeNative(9, this.hwnd, count, outOf); // SetProgressValue
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaused() {
|
||||
this.invokeNative(10, this.hwnd, 8); // SetProgressState TBPF_PAUSED (0x00000008)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNormal() {
|
||||
this.invokeNative(10, this.hwnd, 2); // SetProgressState TBPF_NORMAL (0x00000002)
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.FreezeSlowdownFormula;
|
||||
import com.moulberry.flashback.editor.ui.windows.ExportDoneWindow;
|
||||
import com.moulberry.flashback.editor.ui.windows.WindowType;
|
||||
import com.moulberry.flashback.exporting.ExportJob;
|
||||
import com.moulberry.flashback.exporting.ExportJobQueue;
|
||||
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
||||
@@ -312,6 +314,7 @@ public abstract class MixinMinecraft implements MinecraftExt {
|
||||
} finally {
|
||||
PerfectFrames.disable();
|
||||
Flashback.EXPORT_JOB = null;
|
||||
ExportDoneWindow.exportDoneWindowOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user