mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Set WM_CLASS and WM_INSTANCE_NAME for early progress window (#7534)
This commit is contained in:
1 parent
020102d87f
commit
7220e9d0b0
3 files changed
+29
-10
No files matched your search
@@ -185,11 +185,12 @@ public class FMLLoader
|
||||
naming = commonLaunchHandler.getNaming();
|
||||
dist = commonLaunchHandler.getDist();
|
||||
production = commonLaunchHandler.isProduction();
|
||||
progressWindowTick = EarlyProgressVisualization.INSTANCE.accept(dist, commonLaunchHandler.isData());
|
||||
|
||||
mcVersion = (String) arguments.get("mcVersion");
|
||||
progressWindowTick = EarlyProgressVisualization.INSTANCE.accept(dist, commonLaunchHandler.isData(), mcVersion);
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Early Loading!"));
|
||||
accessTransformer.getExtension().accept(Pair.of(naming, "srg"));
|
||||
|
||||
mcVersion = (String) arguments.get("mcVersion");
|
||||
mcpVersion = (String) arguments.get("mcpVersion");
|
||||
forgeVersion = (String) arguments.get("forgeVersion");
|
||||
forgeGroup = (String) arguments.get("forgeGroup");
|
||||
|
||||
+15
-3
@@ -43,6 +43,8 @@ import java.util.function.IntSupplier;
|
||||
import java.util.function.LongSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
@@ -60,7 +62,7 @@ class ClientVisualization implements EarlyProgressVisualization.Visualization {
|
||||
private GLFWFramebufferSizeCallback framebufferSizeCallback;
|
||||
private int[] fbSize;
|
||||
|
||||
private void initWindow() {
|
||||
private void initWindow(@Nullable String mcVersion) {
|
||||
GLFWErrorCallback.createPrint(System.err).set();
|
||||
|
||||
long glfwInitBegin = System.nanoTime();
|
||||
@@ -82,6 +84,16 @@ class ClientVisualization implements EarlyProgressVisualization.Visualization {
|
||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||
|
||||
if (mcVersion != null)
|
||||
{
|
||||
// this emulates what we would get without early progress window
|
||||
// as vanilla never sets these, so GLFW uses the first window title
|
||||
// set them explicitly to avoid it using "FML early loading progress" as the class
|
||||
String vanillaWindowTitle = "Minecraft* " + mcVersion;
|
||||
glfwWindowHintString(GLFW_X11_CLASS_NAME, vanillaWindowTitle);
|
||||
glfwWindowHintString(GLFW_X11_INSTANCE_NAME, vanillaWindowTitle);
|
||||
}
|
||||
|
||||
window = glfwCreateWindow(screenWidth, screenHeight, "FML early loading progress", NULL, NULL);
|
||||
if (window == NULL) {
|
||||
throw new RuntimeException("Failed to create the GLFW window"); // ignore it and make the GUI optional?
|
||||
@@ -301,8 +313,8 @@ class ClientVisualization implements EarlyProgressVisualization.Visualization {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable start() {
|
||||
initWindow();
|
||||
public Runnable start(@Nullable String mcVersion) {
|
||||
initWindow(mcVersion);
|
||||
renderThread.setDaemon(true); // Don't hang the game if it terminates before handoff (i.e. datagen)
|
||||
renderThread.start();
|
||||
return org.lwjgl.glfw.GLFW::glfwPollEvents;
|
||||
|
||||
+11
-5
@@ -21,20 +21,26 @@ package net.minecraftforge.fml.loading.progress;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.LongSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum EarlyProgressVisualization {
|
||||
INSTANCE;
|
||||
|
||||
private Visualization visualization;
|
||||
|
||||
public Runnable accept(final Dist dist, final boolean isData) {
|
||||
public Runnable accept(Dist dist, boolean isData)
|
||||
{
|
||||
return accept(dist, isData, null);
|
||||
}
|
||||
|
||||
public Runnable accept(final Dist dist, final boolean isData, @Nullable String mcVersion) {
|
||||
visualization = !isData && dist.isClient() && Boolean.parseBoolean(System.getProperty("fml.earlyprogresswindow", "true")) ? new ClientVisualization() : new NoVisualization();
|
||||
return visualization.start();
|
||||
return visualization.start(mcVersion);
|
||||
}
|
||||
|
||||
public long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, final LongSupplier monitor) {
|
||||
@@ -46,7 +52,7 @@ public enum EarlyProgressVisualization {
|
||||
}
|
||||
|
||||
interface Visualization {
|
||||
Runnable start();
|
||||
Runnable start(@Nullable String mcVersion);
|
||||
|
||||
default long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier<String> title, LongSupplier monitorSupplier) {
|
||||
return new LongSupplier() {
|
||||
@@ -63,7 +69,7 @@ public enum EarlyProgressVisualization {
|
||||
|
||||
private static class NoVisualization implements Visualization {
|
||||
@Override
|
||||
public Runnable start() {
|
||||
public Runnable start(@Nullable String mcVersion) {
|
||||
return () -> {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user