diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-02-28 19:33:05 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-02-28 19:33:05 +0100 |
commit | 1a9793197fadaa25520e2cbb7f5d26e23eca2572 (patch) | |
tree | 9d8884d63d60a0e072f733b60c49a1661c48f12f | |
parent | 9497b7e96cfac6e60a53fe05c0ca945ecc839533 (diff) | |
download | MultiMC-1a9793197fadaa25520e2cbb7f5d26e23eca2572.tar MultiMC-1a9793197fadaa25520e2cbb7f5d26e23eca2572.tar.gz MultiMC-1a9793197fadaa25520e2cbb7f5d26e23eca2572.tar.lz MultiMC-1a9793197fadaa25520e2cbb7f5d26e23eca2572.tar.xz MultiMC-1a9793197fadaa25520e2cbb7f5d26e23eca2572.zip |
GH-1502 move launch script generation to the Minecraft launch step
-rw-r--r-- | logic/launch/steps/LaunchMinecraft.cpp | 3 | ||||
-rw-r--r-- | logic/launch/steps/LaunchMinecraft.h | 6 | ||||
-rw-r--r-- | logic/minecraft/MinecraftInstance.h | 3 | ||||
-rw-r--r-- | logic/minecraft/legacy/LegacyInstance.cpp | 48 | ||||
-rw-r--r-- | logic/minecraft/legacy/LegacyInstance.h | 2 | ||||
-rw-r--r-- | logic/minecraft/onesix/OneSixInstance.cpp | 8 | ||||
-rw-r--r-- | logic/minecraft/onesix/OneSixInstance.h | 2 |
7 files changed, 46 insertions, 26 deletions
diff --git a/logic/launch/steps/LaunchMinecraft.cpp b/logic/launch/steps/LaunchMinecraft.cpp index b0fe056f..77a89f17 100644 --- a/logic/launch/steps/LaunchMinecraft.cpp +++ b/logic/launch/steps/LaunchMinecraft.cpp @@ -29,6 +29,9 @@ void LaunchMinecraft::executeTask() { auto instance = m_parent->instance(); std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance); + + m_launchScript = minecraftInstance->createLaunchScript(m_session); + QStringList args = minecraftInstance->javaArguments(); // HACK: this is a workaround for MCL-3732 - 'server-resource-packs' is created. diff --git a/logic/launch/steps/LaunchMinecraft.h b/logic/launch/steps/LaunchMinecraft.h index 808ec33b..6b9f7919 100644 --- a/logic/launch/steps/LaunchMinecraft.h +++ b/logic/launch/steps/LaunchMinecraft.h @@ -17,6 +17,7 @@ #include <launch/LaunchStep.h> #include <launch/LoggedProcess.h> +#include <minecraft/auth/AuthSession.h> class LaunchMinecraft: public LaunchStep { @@ -31,9 +32,9 @@ public: return true; } void setWorkingDirectory(const QString &wd); - void setLaunchScript(const QString &ls) + void setAuthSession(AuthSessionPtr session) { - m_launchScript = ls; + m_session = session; } private slots: void on_state(LoggedProcess::State state); @@ -42,5 +43,6 @@ private: LoggedProcess m_process; QString m_command; QString m_launchScript; + AuthSessionPtr m_session; bool mayProceed = false; }; diff --git a/logic/minecraft/MinecraftInstance.h b/logic/minecraft/MinecraftInstance.h index 5381ce4f..cd3a8d90 100644 --- a/logic/minecraft/MinecraftInstance.h +++ b/logic/minecraft/MinecraftInstance.h @@ -36,6 +36,9 @@ public: return QList<Mod>(); } + /// get the launch script to be used with this + virtual QString createLaunchScript(AuthSessionPtr session) = 0; + //FIXME: nuke? virtual std::shared_ptr<BaseVersionList> versionList() const override; 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<Task> LegacyInstance::createUpdateTask() std::shared_ptr<LaunchTask> 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<MinecraftInstance>(getSharedPtr())); auto pptr = process.get(); @@ -163,7 +142,7 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr sess { auto step = std::make_shared<LaunchMinecraft>(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<Task> LegacyInstance::createJarModdingTask() return std::make_shared<JarModTask>(std::dynamic_pointer_cast<LegacyInstance>(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. diff --git a/logic/minecraft/legacy/LegacyInstance.h b/logic/minecraft/legacy/LegacyInstance.h index a2ab86de..d88e2a71 100644 --- a/logic/minecraft/legacy/LegacyInstance.h +++ b/logic/minecraft/legacy/LegacyInstance.h @@ -118,6 +118,8 @@ public: virtual std::shared_ptr<Task> createJarModdingTask() override; + virtual QString createLaunchScript(AuthSessionPtr session) override; + virtual void cleanupAfterRun() override; virtual QString typeName() const override; diff --git a/logic/minecraft/onesix/OneSixInstance.cpp b/logic/minecraft/onesix/OneSixInstance.cpp index 54381a99..2846640c 100644 --- a/logic/minecraft/onesix/OneSixInstance.cpp +++ b/logic/minecraft/onesix/OneSixInstance.cpp @@ -150,7 +150,7 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session) return parts; } -std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr session) +QString OneSixInstance::createLaunchScript(AuthSessionPtr session) { QString launchScript; QIcon icon = ENV.icons()->getIcon(iconKey()); @@ -256,7 +256,11 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess launchScript += "traits " + trait + "\n"; } launchScript += "launcher onesix\n"; + return launchScript; +} +std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr session) +{ auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); auto pptr = process.get(); @@ -290,7 +294,7 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess { auto step = std::make_shared<LaunchMinecraft>(pptr); step->setWorkingDirectory(minecraftRoot()); - step->setLaunchScript(launchScript); + step->setAuthSession(session); process->appendStep(step); } // run post-exit command if that's needed diff --git a/logic/minecraft/onesix/OneSixInstance.h b/logic/minecraft/onesix/OneSixInstance.h index 824e3786..09150158 100644 --- a/logic/minecraft/onesix/OneSixInstance.h +++ b/logic/minecraft/onesix/OneSixInstance.h @@ -56,6 +56,8 @@ public: virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override; virtual std::shared_ptr<Task> createJarModdingTask() override; + virtual QString createLaunchScript(AuthSessionPtr session) override; + virtual void cleanupAfterRun() override; virtual QString intendedVersionId() const override; |