Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More system properties #1515

Merged
merged 5 commits into from Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion launcher/BaseInstance.cpp
Expand Up @@ -388,7 +388,7 @@ QString BaseInstance::name() const

QString BaseInstance::windowTitle() const
{
return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name().replace(QRegularExpression("\\s+"), " ");
return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name();
}

// FIXME: why is this here? move it to MinecraftInstance!!!
Expand Down
15 changes: 14 additions & 1 deletion launcher/minecraft/MinecraftInstance.cpp
Expand Up @@ -710,14 +710,27 @@ 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());
launchScript += "windowTitle " + windowTitle() + "\n";
launchScript += "windowParams " + windowParams + "\n";
}

// launcher info
{
launchScript += "launcherBrand " + BuildConfig.LAUNCHER_NAME + "\n";
launchScript += "launcherVersion " + BuildConfig.printableVersionString() + "\n";
}

// instance info
{
launchScript += "instanceName " + name() + "\n";
launchScript += "instanceIconKey " + name() + "\n";
launchScript += "instanceIconPath icon.png\n"; // we already save a copy here
}

// legacy auth
if (session) {
launchScript += "userName " + session->player_name + "\n";
Expand Down
42 changes: 39 additions & 3 deletions libraries/launcher/org/prismlauncher/EntryPoint.java
Expand Up @@ -105,13 +105,16 @@ private static ExitCode listen() {
return ExitCode.ABORT;
}

setProperties(params);

String launcherType = params.getString("launcher");

try {
LegacyProxy.applyOnlineFixes(params);

Launcher launcher;
String type = params.getString("launcher");

switch (type) {
switch (launcherType) {
case "standard":
launcher = new StandardLauncher(params);
break;
Expand All @@ -121,7 +124,7 @@ private static ExitCode listen() {
break;

default:
throw new IllegalArgumentException("Invalid launcher type: " + type);
throw new IllegalArgumentException("Invalid launcher type: " + launcherType);
}

launcher.launch();
Expand All @@ -138,6 +141,39 @@ private static ExitCode listen() {
}
}

private static void setProperties(Parameters params) {
String launcherBrand = params.getString("launcherBrand", null);
String launcherVersion = params.getString("launcherVersion", null);
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);

if (launcherBrand != null)
System.setProperty("minecraft.launcher.brand", launcherBrand);
if (launcherVersion != null)
System.setProperty("minecraft.launcher.version", launcherVersion);

// 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);
Scrumplex marked this conversation as resolved.
Show resolved Hide resolved
Scrumplex marked this conversation as resolved.
Show resolved Hide resolved

// set multimc properties for compatibility
if (name != null)
System.setProperty("multimc.instance.title", name);
if (iconId != null)
System.setProperty("multimc.instance.icon", iconId);
TheKodeToad marked this conversation as resolved.
Show resolved Hide resolved
}

private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException {
switch (input) {
case "":
Expand Down
Expand Up @@ -83,7 +83,7 @@ protected AbstractLauncher(Parameters params) {

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;
Expand Down