Fix: 0x0 window if getter called before input ready

This commit is contained in:
Duy Tran Khanh committed 2023-05-15 19:28:32 +07:00
1 parent 91eb8725bb
commit 35dc75e69c
5 files changed
+6 -16

No files matched your search

@@ -61,8 +61,8 @@ public class PojavLauncher {
System.setProperty("appdir", "./spiral");
System.setProperty("resource_dir", "./spiral/rsrc");
System.setProperty("glfw.windowSize", args[2]);
String[] size = args[2].split("x");
MCOptionUtils.load();
MCOptionUtils.set("fullscreen", "false");
MCOptionUtils.set("overrideWidth", size[0]);
@@ -82,12 +82,6 @@ public class PojavLauncher {
System.setProperty("org.lwjgl.vulkan.libname", "libMoltenVK.dylib");
Tools.mGLFWWindowWidth = Integer.parseInt(size[0]);
Tools.mGLFWWindowHeight = Integer.parseInt(size[1]);
//GLFW.internalChangeMonitorSize(width, height);
//CallbackBridge.mouseX = width / 2;
//CallbackBridge.mouseY = height / 2;
MinecraftAccount account = MinecraftAccount.load(args[0]);
JMinecraftVersionList.Version version = Tools.getVersionInfo(args[1]);
System.out.println("Launching Minecraft " + version.id);
@@ -73,8 +73,6 @@ public final class Tools
public static final String NATIVE_LIB_DIR = DIR_BUNDLE + "/Frameworks";
volatile public static int mGLFWWindowWidth, mGLFWWindowHeight;
public static void launchMinecraft(MinecraftAccount profile, final JMinecraftVersionList.Version versionInfo) throws Throwable {
String javaVersion = System.getProperty("java.version");
if (javaVersion.startsWith("1.")) {
@@ -94,7 +94,7 @@ public class UIKit {
String str = MCOptionUtils.get("guiScale");
guiScale = (str == null ? 0 :Integer.parseInt(str));
int scale = Math.max(Math.min(Tools.mGLFWWindowWidth / 320, Tools.mGLFWWindowHeight / 240), 1);
int scale = Math.max(Math.min(GLFW.mGLFWWindowWidth / 320, GLFW.mGLFWWindowHeight / 240), 1);
if(scale < guiScale || guiScale == 0){
guiScale = scale;
}
@@ -501,8 +501,6 @@ public class GLFW
private static ArrayMap<Long, GLFWWindowProperties> mGLFWWindowMap;
public static final ByteBuffer keyDownBuffer = ByteBuffer.allocateDirect(317);
private static final String PROP_WINDOW_WIDTH = "glfwstub.windowWidth";
private static final String PROP_WINDOW_HEIGHT= "glfwstub.windowHeight";
public static long mainContext = 0;
static {
@@ -511,8 +509,9 @@ public class GLFW
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
}
mGLFWWindowWidth = Tools.mGLFWWindowWidth;
mGLFWWindowHeight = Tools.mGLFWWindowHeight;
String[] size = System.getProperty("glfw.windowSize").split("x");
mGLFWWindowWidth = Integer.valueOf(size[0]);
mGLFWWindowHeight = Integer.valueOf(size[1]);
// Minecraft triggers a glfwPollEvents() on splash screen, so update window size there.
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0);
@@ -4,8 +4,7 @@ import java.util.*;
import net.kdt.pojavlaunch.Tools;
public class GLFWWindowProperties {
public int width = Tools.mGLFWWindowWidth;
public int height = Tools.mGLFWWindowHeight;
public int width, height;
public float x, y;
public CharSequence title;
public boolean shouldClose, isInitialSizeCalled, isCursorEntered;