GH-1053 add launch step creation to legacy instances
This commit is contained in:
parent
61c5a67777
commit
2fc18921b0
@ -27,7 +27,7 @@ LaunchCommand::LaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
|||||||
void LaunchCommand::executeTask()
|
void LaunchCommand::executeTask()
|
||||||
{
|
{
|
||||||
auto instance = m_parent->instance();
|
auto instance = m_parent->instance();
|
||||||
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<OneSixInstance>(instance);
|
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
|
||||||
QStringList args = minecraftInstance->javaArguments();
|
QStringList args = minecraftInstance->javaArguments();
|
||||||
|
|
||||||
QString allArgs = args.join(", ");
|
QString allArgs = args.join(", ");
|
||||||
|
@ -25,6 +25,12 @@
|
|||||||
#include "minecraft/LegacyUpdate.h"
|
#include "minecraft/LegacyUpdate.h"
|
||||||
#include "icons/IconList.h"
|
#include "icons/IconList.h"
|
||||||
#include "launch/LaunchTask.h"
|
#include "launch/LaunchTask.h"
|
||||||
|
#include <launch/steps/LaunchCommand.h>
|
||||||
|
#include <launch/steps/PostLaunchCommand.h>
|
||||||
|
#include <launch/steps/ModMinecraftJar.h>
|
||||||
|
#include <launch/steps/Update.h>
|
||||||
|
#include <launch/steps/PreLaunchCommand.h>
|
||||||
|
#include <launch/steps/TextPrint.h>
|
||||||
#include "minecraft/ModList.h"
|
#include "minecraft/ModList.h"
|
||||||
#include <MMCZip.h>
|
#include <MMCZip.h>
|
||||||
|
|
||||||
@ -96,7 +102,7 @@ std::shared_ptr<Task> LegacyInstance::createUpdateTask()
|
|||||||
return std::shared_ptr<Task>(new LegacyUpdate(this, this));
|
return std::shared_ptr<Task>(new LegacyUpdate(this, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr account)
|
std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr session)
|
||||||
{
|
{
|
||||||
QString launchScript;
|
QString launchScript;
|
||||||
QIcon icon = ENV.icons()->getIcon(iconKey());
|
QIcon icon = ENV.icons()->getIcon(iconKey());
|
||||||
@ -116,17 +122,70 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr acco
|
|||||||
|
|
||||||
QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion())
|
QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion())
|
||||||
.absolutePath();
|
.absolutePath();
|
||||||
launchScript += "userName " + account->player_name + "\n";
|
launchScript += "userName " + session->player_name + "\n";
|
||||||
launchScript += "sessionId " + account->session + "\n";
|
launchScript += "sessionId " + session->session + "\n";
|
||||||
launchScript += "windowTitle " + windowTitle() + "\n";
|
launchScript += "windowTitle " + windowTitle() + "\n";
|
||||||
launchScript += "windowParams " + windowParams + "\n";
|
launchScript += "windowParams " + windowParams + "\n";
|
||||||
launchScript += "lwjgl " + lwjgl + "\n";
|
launchScript += "lwjgl " + lwjgl + "\n";
|
||||||
launchScript += "launcher legacy\n";
|
launchScript += "launcher legacy\n";
|
||||||
}
|
}
|
||||||
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr()));
|
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr()));
|
||||||
// process->setLaunchScript(launchScript);
|
auto pptr = process.get();
|
||||||
// process->setWorkdir(minecraftRoot());
|
|
||||||
// process->setLogin(account);
|
// print a header
|
||||||
|
{
|
||||||
|
process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC));
|
||||||
|
}
|
||||||
|
// run pre-launch command if that's needed
|
||||||
|
if(getPreLaunchCommand().size())
|
||||||
|
{
|
||||||
|
auto step = std::make_shared<PreLaunchCommand>(pptr);
|
||||||
|
step->setWorkingDirectory(minecraftRoot());
|
||||||
|
process->appendStep(step);
|
||||||
|
}
|
||||||
|
// if we aren't in offline mode,.
|
||||||
|
if(session->status != AuthSession::PlayableOffline)
|
||||||
|
{
|
||||||
|
process->appendStep(std::make_shared<Update>(pptr));
|
||||||
|
}
|
||||||
|
// if there are any jar mods
|
||||||
|
if(getJarMods().size())
|
||||||
|
{
|
||||||
|
auto step = std::make_shared<ModMinecraftJar>(pptr);
|
||||||
|
process->appendStep(step);
|
||||||
|
}
|
||||||
|
// actually launch the game
|
||||||
|
{
|
||||||
|
auto step = std::make_shared<LaunchCommand>(pptr);
|
||||||
|
step->setWorkingDirectory(minecraftRoot());
|
||||||
|
step->setLaunchScript(launchScript);
|
||||||
|
process->appendStep(step);
|
||||||
|
}
|
||||||
|
// run post-exit command if that's needed
|
||||||
|
if(getPostExitCommand().size())
|
||||||
|
{
|
||||||
|
auto step = std::make_shared<PostLaunchCommand>(pptr);
|
||||||
|
step->setWorkingDirectory(minecraftRoot());
|
||||||
|
process->appendStep(step);
|
||||||
|
}
|
||||||
|
if (session)
|
||||||
|
{
|
||||||
|
QMap<QString, QString> filter;
|
||||||
|
if (session->session != "-")
|
||||||
|
filter[session->session] = tr("<SESSION ID>");
|
||||||
|
filter[session->access_token] = tr("<ACCESS TOKEN>");
|
||||||
|
filter[session->client_token] = tr("<CLIENT TOKEN>");
|
||||||
|
filter[session->uuid] = tr("<PROFILE ID>");
|
||||||
|
filter[session->player_name] = tr("<PROFILE NAME>");
|
||||||
|
|
||||||
|
auto i = session->u.properties.begin();
|
||||||
|
while (i != session->u.properties.end())
|
||||||
|
{
|
||||||
|
filter[i.value()] = "<" + i.key().toUpper() + ">";
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
process->setCensorFilter(filter);
|
||||||
|
}
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ void LegacyUpdate::extractLwjgl()
|
|||||||
setStatus(tr("Installing new LWJGL - extracting ") + name + "...");
|
setStatus(tr("Installing new LWJGL - extracting ") + name + "...");
|
||||||
QFile output(destFileName);
|
QFile output(destFileName);
|
||||||
output.open(QIODevice::WriteOnly);
|
output.open(QIODevice::WriteOnly);
|
||||||
output.write(file.readAll()); // FIXME: wste of memory!?
|
output.write(file.readAll());
|
||||||
output.close();
|
output.close();
|
||||||
}
|
}
|
||||||
file.close(); // do not forget to close!
|
file.close(); // do not forget to close!
|
||||||
|
Loading…
Reference in New Issue
Block a user