mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-03 06:28:48 +00:00
Merge pull request #18 from MCRcortex/taskbar-progress
Taskbar progress
This commit is contained in:
1 parent
519cdf2dea
commit
38d1c65442
6 files changed
+115
-1
No files matched your search
@@ -51,7 +51,7 @@ import static org.lwjgl.system.MemoryUtil.NULL;
|
|||||||
|
|
||||||
public class CustomImGuiImplGlfw {
|
public class CustomImGuiImplGlfw {
|
||||||
private static final String OS = System.getProperty("os.name", "generic").toLowerCase();
|
private static final String OS = System.getProperty("os.name", "generic").toLowerCase();
|
||||||
protected static final boolean IS_WINDOWS = OS.contains("win");
|
public static final boolean IS_WINDOWS = OS.contains("win");
|
||||||
protected static final boolean IS_APPLE = OS.contains("mac") || OS.contains("darwin");
|
protected static final boolean IS_APPLE = OS.contains("mac") || OS.contains("darwin");
|
||||||
|
|
||||||
// ImGui Structs
|
// ImGui Structs
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import com.moulberry.flashback.FreezeSlowdownFormula;
|
|||||||
import com.moulberry.flashback.Utils;
|
import com.moulberry.flashback.Utils;
|
||||||
import com.moulberry.flashback.combo_options.VideoContainer;
|
import com.moulberry.flashback.combo_options.VideoContainer;
|
||||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
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.keyframe.KeyframeType;
|
||||||
import com.moulberry.flashback.keyframe.handler.KeyframeHandler;
|
import com.moulberry.flashback.keyframe.handler.KeyframeHandler;
|
||||||
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
import com.moulberry.flashback.keyframe.handler.MinecraftKeyframeHandler;
|
||||||
import com.moulberry.flashback.keyframe.handler.TickrateKeyframeCapture;
|
import com.moulberry.flashback.keyframe.handler.TickrateKeyframeCapture;
|
||||||
@@ -77,6 +80,8 @@ public class ExportJob {
|
|||||||
|
|
||||||
private double audioSamples = 0.0;
|
private double audioSamples = 0.0;
|
||||||
|
|
||||||
|
private ITaskbar taskbar;
|
||||||
|
|
||||||
private final AtomicBoolean finishedServerTick = new AtomicBoolean(false);
|
private final AtomicBoolean finishedServerTick = new AtomicBoolean(false);
|
||||||
|
|
||||||
public static final int SRC_PIXEL_FORMAT = avutil.AV_PIX_FMT_RGBA;
|
public static final int SRC_PIXEL_FORMAT = avutil.AV_PIX_FMT_RGBA;
|
||||||
@@ -227,6 +232,8 @@ public class ExportJob {
|
|||||||
|
|
||||||
double lastClientTickDouble = 0;
|
double lastClientTickDouble = 0;
|
||||||
|
|
||||||
|
this.taskbar = TaskbarHost.createTaskbar();
|
||||||
|
|
||||||
for (int tickIndex = 0; tickIndex < ticks.size(); tickIndex++) {
|
for (int tickIndex = 0; tickIndex < ticks.size(); tickIndex++) {
|
||||||
TickInfo tickInfo = ticks.get(tickIndex);
|
TickInfo tickInfo = ticks.get(tickIndex);
|
||||||
boolean frozen = tickInfo.frozen;
|
boolean frozen = tickInfo.frozen;
|
||||||
@@ -347,6 +354,9 @@ public class ExportJob {
|
|||||||
|
|
||||||
submitDownloadedFrames(videoWriter, downloader, true);
|
submitDownloadedFrames(videoWriter, downloader, true);
|
||||||
videoWriter.finish();
|
videoWriter.finish();
|
||||||
|
|
||||||
|
this.taskbar.close();
|
||||||
|
this.taskbar = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRandoms(Random random, Random mathRandom) {
|
private void updateRandoms(Random random, Random mathRandom) {
|
||||||
@@ -496,6 +506,8 @@ public class ExportJob {
|
|||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (currentTime - this.lastRenderMillis > 1000/60 || currentFrame == totalFrames) {
|
if (currentTime - this.lastRenderMillis > 1000/60 || currentFrame == totalFrames) {
|
||||||
|
this.taskbar.setProgress(currentFrame, totalFrames);
|
||||||
|
|
||||||
Window window = Minecraft.getInstance().getWindow();
|
Window window = Minecraft.getInstance().getWindow();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.moulberry.flashback.exporting.taskbar;
|
||||||
|
|
||||||
|
public interface ITaskbar {
|
||||||
|
void close();
|
||||||
|
|
||||||
|
void setProgress(long count, long outOf);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.moulberry.flashback.exporting.taskbar;
|
||||||
|
|
||||||
|
public class NoopTaskbar implements ITaskbar {
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProgress(long count, long outOf) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.moulberry.flashback.exporting.taskbar;
|
||||||
|
|
||||||
|
import com.moulberry.flashback.Flashback;
|
||||||
|
import com.replaymod.lib.com.googlecode.mp4parser.util.Logger;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.*;
|
||||||
|
import com.sun.jna.ptr.PointerByReference;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.lwjgl.glfw.GLFWNativeWin32;
|
||||||
|
|
||||||
|
import static com.moulberry.flashback.editor.ui.CustomImGuiImplGlfw.IS_WINDOWS;
|
||||||
|
|
||||||
|
public class TaskbarHost {
|
||||||
|
public static ITaskbar createTaskbar() {
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
try {
|
||||||
|
return createWindowsInterface();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Flashback.LOGGER.error("Unable to create windows taskbar interface", e);
|
||||||
|
return new NoopTaskbar();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new NoopTaskbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WindowsTaskbar createWindowsInterface() {
|
||||||
|
var itaskbar3res = new PointerByReference();
|
||||||
|
|
||||||
|
if (W32Errors.FAILED(Ole32.INSTANCE.CoCreateInstance(new Guid.GUID("56FDF344-FD6D-11d0-958A-006097C9A090"),
|
||||||
|
null,
|
||||||
|
WTypes.CLSCTX_SERVER,
|
||||||
|
new Guid.GUID("EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF"),
|
||||||
|
itaskbar3res))) {
|
||||||
|
throw new IllegalStateException("Failed to create ITaskbar3");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var hwnd = new WinDef.HWND(new Pointer(GLFWNativeWin32.glfwGetWin32Window(Minecraft.getInstance().getWindow().getWindow())));
|
||||||
|
return new WindowsTaskbar(itaskbar3res.getValue(), hwnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.moulberry.flashback.exporting.taskbar;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.COM.COMInvoker;
|
||||||
|
import com.sun.jna.platform.win32.W32Errors;
|
||||||
|
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
|
||||||
|
} finally {
|
||||||
|
this.invokeNative(2);//Release
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invokeNative(int ventry, Object... objects) {
|
||||||
|
Object[] args = new Object[objects.length+1];
|
||||||
|
args[0] = this.getPointer();
|
||||||
|
System.arraycopy(objects, 0, args, 1, objects.length);
|
||||||
|
if (W32Errors.FAILED((WinNT.HRESULT) this._invokeNativeObject(ventry, args, WinNT.HRESULT.class))) {
|
||||||
|
throw new IllegalStateException("Failed to invoke vtable: " + ventry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProgress(long count, long outOf) {
|
||||||
|
this.invokeNative(9, this.hwnd, count, outOf);//SetProgressValue
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
this.invokeNative(10, this.hwnd, 0);//SetProgressState TBPF_NOPROGRESS
|
||||||
|
this.invokeNative(2);//Release
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user