From f6d8c9659cefd133ec0234fb5a72207088f542dd Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 11 Aug 2023 00:37:27 +0100 Subject: [PATCH] Rework Signed-off-by: TheKodeToad --- launcher/minecraft/MinecraftInstance.cpp | 5 ++- .../org/prismlauncher/EntryPoint.java | 39 +++++++++++++------ .../launcher/impl/AbstractLauncher.java | 2 +- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f9b0d05ff..f31fc4001 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -626,7 +626,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS { QString windowParams; if (settings()->get("LaunchMaximized").toBool()) - windowParams = "max"; + windowParams = "maximized"; else windowParams = QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt()); @@ -637,7 +637,8 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS // instance info { launchScript += "instanceName " + name() + "\n"; - launchScript += "instanceIconKey " + iconKey() + "\n"; + launchScript += "instanceIconKey " + name() + "\n"; + launchScript += "instanceIconPath icon.png\n"; // we already save a copy here } // legacy auth diff --git a/libraries/launcher/org/prismlauncher/EntryPoint.java b/libraries/launcher/org/prismlauncher/EntryPoint.java index 4fc57c8e5..9a8a7ee1d 100644 --- a/libraries/launcher/org/prismlauncher/EntryPoint.java +++ b/libraries/launcher/org/prismlauncher/EntryPoint.java @@ -105,19 +105,8 @@ public final class EntryPoint { return ExitCode.ABORT; } - // populate properties to provide mods with more info - String name = params.getString("instanceName", ""); - String iconKey = params.getString("instanceIconKey", "default"); + setProperties(params); - System.setProperty("org.prismlauncher.instance.name", name); - System.setProperty("org.prismlauncher.instance.icon.id", iconKey); - System.setProperty("org.prismlauncher.instance.icon.path", "icon.png"); - - // set multimc properties for compatibility - System.setProperty("multimc.instance.title", name); - System.setProperty("multimc.instance.icon", iconKey); - - // launch the game String launcherType = params.getString("launcher"); try { @@ -150,6 +139,32 @@ public final class EntryPoint { } } + private static void setProperties(Parameters params) { + String name = params.getString("instanceName", null); + String iconId = params.getString("instanceIconKey", null); + String iconPath = params.getString("instanceIconPath", null); + String windowTitle = params.getString("windowTitle", null); + String windowDimensions = params.getString("windowParams", null); + + // set useful properties for mods + if (name != null) + System.setProperty("org.prismlauncher.instance.name", name); + if (iconId != null) + System.setProperty("org.prismlauncher.instance.icon.id", iconId); + if (iconPath != null) + System.setProperty("org.prismlauncher.instance.icon.path", iconPath); + if (windowTitle != null) + System.setProperty("org.prismlauncher.window.title", windowTitle); + if (windowDimensions != null) + System.setProperty("org.prismlauncher.window.dimensions", windowDimensions); + + // set multimc properties for compatibility + if (name != null) + System.setProperty("multimc.instance.title", name); + if (iconId != null) + System.setProperty("multimc.instance.icon", iconId); + } + private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException { switch (input) { case "": diff --git a/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java b/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java index 761837041..de28a0401 100644 --- a/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java +++ b/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java @@ -83,7 +83,7 @@ public abstract class AbstractLauncher implements Launcher { String windowParams = params.getString("windowParams", null); - if ("max".equals(windowParams) || windowParams == null) { + if ("maximized".equals(windowParams) || windowParams == null) { maximize = windowParams != null; width = DEFAULT_WINDOW_WIDTH;