From 1a9793197fadaa25520e2cbb7f5d26e23eca2572 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 28 Feb 2016 19:33:05 +0100 Subject: GH-1502 move launch script generation to the Minecraft launch step --- logic/minecraft/legacy/LegacyInstance.cpp | 48 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'logic/minecraft/legacy/LegacyInstance.cpp') diff --git a/logic/minecraft/legacy/LegacyInstance.cpp b/logic/minecraft/legacy/LegacyInstance.cpp index 056079f6..6650598d 100644 --- a/logic/minecraft/legacy/LegacyInstance.cpp +++ b/logic/minecraft/legacy/LegacyInstance.cpp @@ -105,31 +105,10 @@ std::shared_ptr LegacyInstance::createUpdateTask() std::shared_ptr LegacyInstance::createLaunchTask(AuthSessionPtr session) { - QString launchScript; QIcon icon = ENV.icons()->getIcon(iconKey()); auto pixmap = icon.pixmap(128, 128); pixmap.save(FS::PathCombine(minecraftRoot(), "icon.png"), "PNG"); - // create the launch script - { - // window size - QString windowParams; - if (settings()->get("LaunchMaximized").toBool()) - windowParams = "max"; - else - windowParams = QString("%1x%2") - .arg(settings()->get("MinecraftWinWidth").toInt()) - .arg(settings()->get("MinecraftWinHeight").toInt()); - - QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion()) - .absolutePath(); - launchScript += "userName " + session->player_name + "\n"; - launchScript += "sessionId " + session->session + "\n"; - launchScript += "windowTitle " + windowTitle() + "\n"; - launchScript += "windowParams " + windowParams + "\n"; - launchScript += "lwjgl " + lwjgl + "\n"; - launchScript += "launcher legacy\n"; - } auto process = LaunchTask::create(std::dynamic_pointer_cast(getSharedPtr())); auto pptr = process.get(); @@ -163,7 +142,7 @@ std::shared_ptr LegacyInstance::createLaunchTask(AuthSessionPtr sess { auto step = std::make_shared(pptr); step->setWorkingDirectory(minecraftRoot()); - step->setLaunchScript(launchScript); + step->setAuthSession(session); process->appendStep(step); } // run post-exit command if that's needed @@ -261,6 +240,31 @@ std::shared_ptr LegacyInstance::createJarModdingTask() return std::make_shared(std::dynamic_pointer_cast(shared_from_this())); } +QString LegacyInstance::createLaunchScript(AuthSessionPtr session) +{ + QString launchScript; + + // window size + QString windowParams; + if (settings()->get("LaunchMaximized").toBool()) + { + windowParams = "max"; + } + else + { + windowParams = QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt()); + } + + QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion()).absolutePath(); + launchScript += "userName " + session->player_name + "\n"; + launchScript += "sessionId " + session->session + "\n"; + launchScript += "windowTitle " + windowTitle() + "\n"; + launchScript += "windowParams " + windowParams + "\n"; + launchScript += "lwjgl " + lwjgl + "\n"; + launchScript += "launcher legacy\n"; + return launchScript; +} + void LegacyInstance::cleanupAfterRun() { // FIXME: delete the launcher and icons and whatnot. -- cgit