From c1ed09e74765e7e362c644685b49b77529b748af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 10 Mar 2023 19:56:17 +0100 Subject: [PATCH] NOISSUE add an interface to pass information to CraftPresence Specifically, the icon key and instance title. --- launcher/BaseInstance.cpp | 5 +++++ launcher/BaseInstance.h | 2 ++ launcher/minecraft/MinecraftInstance.cpp | 2 ++ launcher/translations/TranslationsModel.cpp | 2 -- .../launcher/org/multimc/onesix/OneSixLauncher.java | 10 ++++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp index 5602c728..928a70a5 100644 --- a/launcher/BaseInstance.cpp +++ b/launcher/BaseInstance.cpp @@ -313,6 +313,11 @@ QString BaseInstance::windowTitle() const return BuildConfig.LAUNCHER_NAME + ": " + name().replace(QRegExp("[ \n\r\t]+"), " "); } +QString BaseInstance::instanceTitle() const +{ + return name().replace(QRegExp("[ \n\r\t]+"), " "); +} + // FIXME: why is this here? move it to MinecraftInstance!!! QStringList BaseInstance::extraArguments() const { diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 9f8e58d3..c148f37e 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -110,6 +110,8 @@ public: /// Value used for instance window titles QString windowTitle() const; + QString instanceTitle() const; + QString iconKey() const; void setIconKey(QString val); diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index dbb9c98f..24650235 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -513,6 +513,8 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS .arg(settings()->get("MinecraftWinHeight").toInt()); launchScript += "windowTitle " + windowTitle() + "\n"; launchScript += "windowParams " + windowParams + "\n"; + launchScript += "instanceTitle " + instanceTitle() + "\n"; + launchScript += "instanceIconId " + iconKey() + "\n"; } // legacy auth diff --git a/launcher/translations/TranslationsModel.cpp b/launcher/translations/TranslationsModel.cpp index 5064eebd..3ce89391 100644 --- a/launcher/translations/TranslationsModel.cpp +++ b/launcher/translations/TranslationsModel.cpp @@ -192,7 +192,6 @@ void readIndex(const QString & path, QMap& languages) return; } - int index = 1; try { auto toplevel_doc = Json::requireDocument(data); @@ -225,7 +224,6 @@ void readIndex(const QString & path, QMap& languages) lang.file_size = Json::requireInteger(langObj, "size"); languages.insert(lang.key, lang); - index++; } } catch (Json::JsonException & e) diff --git a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java index d341cad7..7c4bab3d 100644 --- a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java +++ b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java @@ -42,6 +42,9 @@ public class OneSixLauncher implements Launcher private String windowTitle; private String windowParams; + private String instanceTitle; + private String instanceIconId; + // secondary parameters private int winSizeW; private int winSizeH; @@ -68,6 +71,13 @@ public class OneSixLauncher implements Launcher windowTitle = params.firstSafe("windowTitle", "Minecraft"); windowParams = params.firstSafe("windowParams", "854x480"); + instanceTitle = params.firstSafe("instanceTitle", "Minecraft"); + instanceIconId = params.firstSafe("instanceIconId", "default"); + + // NOTE: this is included for the CraftPresence mod + System.setProperty("multimc.instance.title", instanceTitle); + System.setProperty("multimc.instance.icon", instanceIconId); + serverAddress = params.firstSafe("serverAddress", null); serverPort = params.firstSafe("serverPort", null);