GH-1502 move launch script generation to the Minecraft launch step
This commit is contained in:
parent
9497b7e96c
commit
1a9793197f
@ -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.
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user