diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/BaseInstance.h | 4 | ||||
-rw-r--r-- | logic/CMakeLists.txt | 14 | ||||
-rw-r--r-- | logic/NullInstance.h | 2 | ||||
-rw-r--r-- | logic/launch/LaunchTask.cpp (renamed from logic/BaseLauncher.cpp) | 86 | ||||
-rw-r--r-- | logic/launch/LaunchTask.h (renamed from logic/BaseLauncher.h) | 8 | ||||
-rw-r--r-- | logic/launch/LoggedProcess.cpp (renamed from logic/LoggedProcess.cpp) | 0 | ||||
-rw-r--r-- | logic/launch/LoggedProcess.h (renamed from logic/LoggedProcess.h) | 0 | ||||
-rw-r--r-- | logic/launch/MessageLevel.cpp (renamed from logic/MessageLevel.cpp) | 0 | ||||
-rw-r--r-- | logic/launch/MessageLevel.h (renamed from logic/MessageLevel.h) | 0 | ||||
-rw-r--r-- | logic/minecraft/LegacyInstance.cpp | 6 | ||||
-rw-r--r-- | logic/minecraft/LegacyInstance.h | 2 | ||||
-rw-r--r-- | logic/minecraft/OneSixInstance.cpp | 6 | ||||
-rw-r--r-- | logic/minecraft/OneSixInstance.h | 2 | ||||
-rw-r--r-- | logic/tools/BaseProfiler.cpp | 2 | ||||
-rw-r--r-- | logic/tools/BaseProfiler.h | 6 | ||||
-rw-r--r-- | logic/tools/JProfiler.cpp | 6 | ||||
-rw-r--r-- | logic/tools/JVisualVM.cpp | 6 |
17 files changed, 76 insertions, 74 deletions
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h index 720385c8..7152ba2d 100644 --- a/logic/BaseInstance.h +++ b/logic/BaseInstance.h @@ -27,7 +27,7 @@ class QDir; class Task; -class BaseLauncher; +class LaunchTask; class BaseInstance; // pointer for lazy people @@ -138,7 +138,7 @@ public: virtual std::shared_ptr<Task> createUpdateTask() = 0; /// returns a valid launcher (task container) - virtual std::shared_ptr<BaseLauncher> createLaunchTask(AuthSessionPtr account) = 0; + virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) = 0; /*! * Returns a task that should be done right before launch diff --git a/logic/CMakeLists.txt b/logic/CMakeLists.txt index 3286b091..53715fa6 100644 --- a/logic/CMakeLists.txt +++ b/logic/CMakeLists.txt @@ -8,13 +8,7 @@ set(LOGIC_SOURCES BaseVersionList.cpp InstanceList.h InstanceList.cpp - LoggedProcess.h - LoggedProcess.cpp - MessageLevel.cpp - MessageLevel.h BaseVersion.h - BaseLauncher.h - BaseLauncher.cpp BaseInstance.h BaseInstance.cpp NullInstance.h @@ -98,6 +92,14 @@ set(LOGIC_SOURCES auth/flows/ValidateTask.h auth/flows/ValidateTask.cpp + # Game launch logic + launch/LoggedProcess.h + launch/LoggedProcess.cpp + launch/MessageLevel.cpp + launch/MessageLevel.h + launch/LaunchTask.h + launch/LaunchTask.cpp + # Update system updater/GoUpdate.h updater/GoUpdate.cpp diff --git a/logic/NullInstance.h b/logic/NullInstance.h index 0927322e..bad4b4de 100644 --- a/logic/NullInstance.h +++ b/logic/NullInstance.h @@ -43,7 +43,7 @@ public: { return instanceRoot(); }; - virtual std::shared_ptr<BaseLauncher> createLaunchTask(AuthSessionPtr) + virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr) { return nullptr; } diff --git a/logic/BaseLauncher.cpp b/logic/launch/LaunchTask.cpp index 4ab0c41a..83bbba97 100644 --- a/logic/BaseLauncher.cpp +++ b/logic/launch/LaunchTask.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "BaseLauncher.h" +#include "launch/LaunchTask.h" #include "MessageLevel.h" #include "MMCStrings.h" #include "java/JavaChecker.h" @@ -30,7 +30,7 @@ #define IBUS "@im=ibus" -void BaseLauncher::initializeEnvironment() +void LaunchTask::initializeEnvironment() { // prepare the process environment QProcessEnvironment rawenv = QProcessEnvironment::systemEnvironment(); @@ -106,37 +106,37 @@ void BaseLauncher::initializeEnvironment() } } -void BaseLauncher::init() +void LaunchTask::init() { initializeEnvironment(); m_process.setProcessEnvironment(m_env); - connect(&m_process, &LoggedProcess::log, this, &BaseLauncher::on_log); - connect(&m_process, &LoggedProcess::stateChanged, this, &BaseLauncher::on_state); + connect(&m_process, &LoggedProcess::log, this, &LaunchTask::on_log); + connect(&m_process, &LoggedProcess::stateChanged, this, &LaunchTask::on_state); m_prelaunchprocess.setProcessEnvironment(m_env); - connect(&m_prelaunchprocess, &LoggedProcess::log, this, &BaseLauncher::on_log); - connect(&m_prelaunchprocess, &LoggedProcess::stateChanged, this, &BaseLauncher::on_pre_state); + connect(&m_prelaunchprocess, &LoggedProcess::log, this, &LaunchTask::on_log); + connect(&m_prelaunchprocess, &LoggedProcess::stateChanged, this, &LaunchTask::on_pre_state); m_postlaunchprocess.setProcessEnvironment(m_env); - connect(&m_postlaunchprocess, &LoggedProcess::log, this, &BaseLauncher::on_log); - connect(&m_postlaunchprocess, &LoggedProcess::stateChanged, this, &BaseLauncher::on_post_state); + connect(&m_postlaunchprocess, &LoggedProcess::log, this, &LaunchTask::on_log); + connect(&m_postlaunchprocess, &LoggedProcess::stateChanged, this, &LaunchTask::on_post_state); m_instance->setRunning(true); } -std::shared_ptr<BaseLauncher> BaseLauncher::create(MinecraftInstancePtr inst) +std::shared_ptr<LaunchTask> LaunchTask::create(MinecraftInstancePtr inst) { - std::shared_ptr<BaseLauncher> proc(new BaseLauncher(inst)); + std::shared_ptr<LaunchTask> proc(new LaunchTask(inst)); proc->init(); return proc; } -BaseLauncher::BaseLauncher(InstancePtr instance): m_instance(instance) +LaunchTask::LaunchTask(InstancePtr instance): m_instance(instance) { } -QString BaseLauncher::censorPrivateInfo(QString in) +QString LaunchTask::censorPrivateInfo(QString in) { if (!m_session) return in; @@ -159,7 +159,7 @@ QString BaseLauncher::censorPrivateInfo(QString in) } // console window -MessageLevel::Enum BaseLauncher::guessLevel(const QString &line, MessageLevel::Enum level) +MessageLevel::Enum LaunchTask::guessLevel(const QString &line, MessageLevel::Enum level) { QRegularExpression re("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]"); auto match = re.match(line); @@ -199,7 +199,7 @@ MessageLevel::Enum BaseLauncher::guessLevel(const QString &line, MessageLevel::E return level; } -QMap<QString, QString> BaseLauncher::getVariables() const +QMap<QString, QString> LaunchTask::getVariables() const { auto mcInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance); QMap<QString, QString> out; @@ -212,7 +212,7 @@ QMap<QString, QString> BaseLauncher::getVariables() const return out; } -QStringList BaseLauncher::javaArguments() const +QStringList LaunchTask::javaArguments() const { QStringList args; @@ -253,7 +253,7 @@ QStringList BaseLauncher::javaArguments() const return args; } -void BaseLauncher::checkJava() +void LaunchTask::checkJava() { m_javaPath = m_instance->settings()->get("JavaPath").toString(); emit log("Java path is:\n" + m_javaPath + "\n\n"); @@ -278,14 +278,14 @@ void BaseLauncher::checkJava() QString errorLog; QString version; emit log(tr("Checking Java version..."), MessageLevel::MultiMC); - connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &BaseLauncher::checkJavaFinished); + connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &LaunchTask::checkJavaFinished); m_JavaChecker->m_path = realJavaPath; m_JavaChecker->performCheck(); } preLaunch(); } -void BaseLauncher::checkJavaFinished(JavaCheckResult result) +void LaunchTask::checkJavaFinished(JavaCheckResult result) { if(!result.valid) { @@ -308,7 +308,7 @@ void BaseLauncher::checkJavaFinished(JavaCheckResult result) } } -void BaseLauncher::executeTask() +void LaunchTask::executeTask() { printHeader(); emit log("Minecraft folder is:\n" + m_process.workingDirectory() + "\n\n"); @@ -316,20 +316,20 @@ void BaseLauncher::executeTask() checkJava(); } -void BaseLauncher::launch() +void LaunchTask::launch() { QString launchString("launch\n"); m_process.write(launchString.toUtf8()); } -void BaseLauncher::abort() +void LaunchTask::abort() { QString launchString("abort\n"); m_process.write(launchString.toUtf8()); } -void BaseLauncher::setWorkdir(QString path) +void LaunchTask::setWorkdir(QString path) { QDir mcDir(path); m_process.setWorkingDirectory(mcDir.absolutePath()); @@ -337,17 +337,17 @@ void BaseLauncher::setWorkdir(QString path) m_postlaunchprocess.setWorkingDirectory(mcDir.absolutePath()); } -void BaseLauncher::printHeader() +void LaunchTask::printHeader() { emit log(m_header); } -void BaseLauncher::on_log(QStringList lines, MessageLevel::Enum level) +void LaunchTask::on_log(QStringList lines, MessageLevel::Enum level) { logOutput(lines, level); } -void BaseLauncher::logOutput(const QStringList &lines, MessageLevel::Enum defaultLevel) +void LaunchTask::logOutput(const QStringList &lines, MessageLevel::Enum defaultLevel) { for (auto & line: lines) { @@ -355,7 +355,7 @@ void BaseLauncher::logOutput(const QStringList &lines, MessageLevel::Enum defaul } } -void BaseLauncher::logOutput(QString line, MessageLevel::Enum level) +void LaunchTask::logOutput(QString line, MessageLevel::Enum level) { // if the launcher part set a log level, use it auto innerLevel = MessageLevel::fromLine(line); @@ -376,7 +376,7 @@ void BaseLauncher::logOutput(QString line, MessageLevel::Enum level) emit log(line, level); } -void BaseLauncher::preLaunch() +void LaunchTask::preLaunch() { QString prelaunch_cmd = m_instance->settings()->get("PreLaunchCommand").toString(); if (!prelaunch_cmd.isEmpty()) @@ -392,7 +392,7 @@ void BaseLauncher::preLaunch() } } -void BaseLauncher::on_pre_state(LoggedProcess::State state) +void LaunchTask::on_pre_state(LoggedProcess::State state) { switch(state) { @@ -419,7 +419,7 @@ void BaseLauncher::on_pre_state(LoggedProcess::State state) } } -void BaseLauncher::updateInstance() +void LaunchTask::updateInstance() { m_updateTask = m_instance->createUpdateTask(); if(m_updateTask) @@ -431,7 +431,7 @@ void BaseLauncher::updateInstance() makeReady(); } -void BaseLauncher::updateFinished() +void LaunchTask::updateFinished() { if(m_updateTask->successful()) { @@ -445,7 +445,7 @@ void BaseLauncher::updateFinished() } } -void BaseLauncher::doJarModding() +void LaunchTask::doJarModding() { m_jarModTask = m_instance->createJarModdingTask(); if(!m_jarModTask) @@ -457,17 +457,17 @@ void BaseLauncher::doJarModding() m_jarModTask->start(); } -void BaseLauncher::jarModdingSucceeded() +void LaunchTask::jarModdingSucceeded() { makeReady(); } -void BaseLauncher::jarModdingFailed(QString reason) +void LaunchTask::jarModdingFailed(QString reason) { emitFailed(reason); } -void BaseLauncher::makeReady() +void LaunchTask::makeReady() { QStringList args = javaArguments(); QString allArgs = args.join(", "); @@ -511,7 +511,7 @@ void BaseLauncher::makeReady() emit readyForLaunch(); } -void BaseLauncher::on_state(LoggedProcess::State state) +void LaunchTask::on_state(LoggedProcess::State state) { QProcess::ExitStatus estat = QProcess::NormalExit; switch(state) @@ -543,7 +543,7 @@ void BaseLauncher::on_state(LoggedProcess::State state) } } -void BaseLauncher::killProcess() +void LaunchTask::killProcess() { killed = true; if (m_prelaunchprocess.state() == LoggedProcess::Running) @@ -560,7 +560,7 @@ void BaseLauncher::killProcess() } } -void BaseLauncher::postLaunch() +void LaunchTask::postLaunch() { if(killed) return; @@ -575,7 +575,7 @@ void BaseLauncher::postLaunch() emitSucceeded(); } -void BaseLauncher::on_post_state(LoggedProcess::State state) +void LaunchTask::on_post_state(LoggedProcess::State state) { switch(state) { @@ -600,21 +600,21 @@ void BaseLauncher::on_post_state(LoggedProcess::State state) } } -void BaseLauncher::emitSucceeded() +void LaunchTask::emitSucceeded() { m_instance->cleanupAfterRun(); m_instance->setRunning(false); Task::emitSucceeded(); } -void BaseLauncher::emitFailed(QString reason) +void LaunchTask::emitFailed(QString reason) { m_instance->cleanupAfterRun(); m_instance->setRunning(false); Task::emitFailed(reason); } -QString BaseLauncher::substituteVariables(const QString &cmd) const +QString LaunchTask::substituteVariables(const QString &cmd) const { QString out = cmd; auto variables = getVariables(); @@ -630,7 +630,7 @@ QString BaseLauncher::substituteVariables(const QString &cmd) const return out; } -qint64 BaseLauncher::pid() +qint64 LaunchTask::pid() { #ifdef Q_OS_WIN struct _PROCESS_INFORMATION *procinfo = m_process.pid(); diff --git a/logic/BaseLauncher.h b/logic/launch/LaunchTask.h index f7b52c89..38142189 100644 --- a/logic/BaseLauncher.h +++ b/logic/launch/LaunchTask.h @@ -32,16 +32,16 @@ class ProcessTask }; class BaseProfilerFactory; -class BaseLauncher: public Task +class LaunchTask: public Task { Q_OBJECT protected: - explicit BaseLauncher(InstancePtr instance); + explicit LaunchTask(InstancePtr instance); void init(); public: /* methods */ - static std::shared_ptr<BaseLauncher> create(MinecraftInstancePtr inst); - virtual ~BaseLauncher() {}; + static std::shared_ptr<LaunchTask> create(MinecraftInstancePtr inst); + virtual ~LaunchTask() {}; InstancePtr instance() { diff --git a/logic/LoggedProcess.cpp b/logic/launch/LoggedProcess.cpp index 53840621..53840621 100644 --- a/logic/LoggedProcess.cpp +++ b/logic/launch/LoggedProcess.cpp diff --git a/logic/LoggedProcess.h b/logic/launch/LoggedProcess.h index 253be2c1..253be2c1 100644 --- a/logic/LoggedProcess.h +++ b/logic/launch/LoggedProcess.h diff --git a/logic/MessageLevel.cpp b/logic/launch/MessageLevel.cpp index a5191290..a5191290 100644 --- a/logic/MessageLevel.cpp +++ b/logic/launch/MessageLevel.cpp diff --git a/logic/MessageLevel.h b/logic/launch/MessageLevel.h index 0128148d..0128148d 100644 --- a/logic/MessageLevel.h +++ b/logic/launch/MessageLevel.h diff --git a/logic/minecraft/LegacyInstance.cpp b/logic/minecraft/LegacyInstance.cpp index 8431c35b..0991b7b5 100644 --- a/logic/minecraft/LegacyInstance.cpp +++ b/logic/minecraft/LegacyInstance.cpp @@ -24,7 +24,7 @@ #include "minecraft/LegacyUpdate.h" #include "icons/IconList.h" -#include "BaseLauncher.h" +#include "launch/LaunchTask.h" #include "minecraft/ModList.h" #include <MMCZip.h> @@ -96,7 +96,7 @@ std::shared_ptr<Task> LegacyInstance::createUpdateTask() return std::shared_ptr<Task>(new LegacyUpdate(this, this)); } -std::shared_ptr<BaseLauncher> LegacyInstance::createLaunchTask(AuthSessionPtr account) +std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr account) { QString launchScript; QIcon icon = ENV.icons()->getIcon(iconKey()); @@ -123,7 +123,7 @@ std::shared_ptr<BaseLauncher> LegacyInstance::createLaunchTask(AuthSessionPtr ac launchScript += "lwjgl " + lwjgl + "\n"; launchScript += "launcher legacy\n"; } - auto process = BaseLauncher::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); + auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); process->setLaunchScript(launchScript); process->setWorkdir(minecraftRoot()); process->setLogin(account); diff --git a/logic/minecraft/LegacyInstance.h b/logic/minecraft/LegacyInstance.h index 51871876..0930c290 100644 --- a/logic/minecraft/LegacyInstance.h +++ b/logic/minecraft/LegacyInstance.h @@ -111,7 +111,7 @@ public: virtual void setShouldUpdate(bool val) override; virtual std::shared_ptr<Task> createUpdateTask() override; - virtual std::shared_ptr<BaseLauncher> createLaunchTask(AuthSessionPtr account) override; + virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override; virtual std::shared_ptr<Task> createJarModdingTask() override; diff --git a/logic/minecraft/OneSixInstance.cpp b/logic/minecraft/OneSixInstance.cpp index 4af56b54..d66236f4 100644 --- a/logic/minecraft/OneSixInstance.cpp +++ b/logic/minecraft/OneSixInstance.cpp @@ -22,7 +22,7 @@ #include "minecraft/OneSixUpdate.h" #include "minecraft/MinecraftProfile.h" #include "minecraft/VersionBuildError.h" -#include "BaseLauncher.h" +#include "launch/LaunchTask.h" #include "minecraft/OneSixProfileStrategy.h" #include "MMCZip.h" @@ -123,7 +123,7 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session) return parts; } -std::shared_ptr<BaseLauncher> OneSixInstance::createLaunchTask(AuthSessionPtr session) +std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr session) { QString launchScript; QIcon icon = ENV.icons()->getIcon(iconKey()); @@ -230,7 +230,7 @@ std::shared_ptr<BaseLauncher> OneSixInstance::createLaunchTask(AuthSessionPtr se } launchScript += "launcher onesix\n"; - auto process = BaseLauncher::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); + auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); process->setLaunchScript(launchScript); process->setWorkdir(minecraftRoot()); process->setLogin(session); diff --git a/logic/minecraft/OneSixInstance.h b/logic/minecraft/OneSixInstance.h index 46545462..42902366 100644 --- a/logic/minecraft/OneSixInstance.h +++ b/logic/minecraft/OneSixInstance.h @@ -49,7 +49,7 @@ public: virtual QString instanceConfigFolder() const override; virtual std::shared_ptr<Task> createUpdateTask() override; - virtual std::shared_ptr<BaseLauncher> createLaunchTask(AuthSessionPtr account) override; + virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override; virtual std::shared_ptr<Task> createJarModdingTask() override; virtual void cleanupAfterRun() override; diff --git a/logic/tools/BaseProfiler.cpp b/logic/tools/BaseProfiler.cpp index 42ed1d93..5ff0fa44 100644 --- a/logic/tools/BaseProfiler.cpp +++ b/logic/tools/BaseProfiler.cpp @@ -7,7 +7,7 @@ BaseProfiler::BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QOb { } -void BaseProfiler::beginProfiling(std::shared_ptr<BaseLauncher> process) +void BaseProfiler::beginProfiling(std::shared_ptr<LaunchTask> process) { beginProfilingImpl(process); } diff --git a/logic/tools/BaseProfiler.h b/logic/tools/BaseProfiler.h index 709c7cb4..5191f7b8 100644 --- a/logic/tools/BaseProfiler.h +++ b/logic/tools/BaseProfiler.h @@ -4,7 +4,7 @@ class BaseInstance; class SettingsObject; -class BaseLauncher; +class LaunchTask; class QProcess; class BaseProfiler : public BaseExternalTool @@ -15,13 +15,13 @@ public: public slots: - void beginProfiling(std::shared_ptr<BaseLauncher> process); + void beginProfiling(std::shared_ptr<LaunchTask> process); void abortProfiling(); protected: QProcess *m_profilerProcess; - virtual void beginProfilingImpl(std::shared_ptr<BaseLauncher> process) = 0; + virtual void beginProfilingImpl(std::shared_ptr<LaunchTask> process) = 0; virtual void abortProfilingImpl(); signals: diff --git a/logic/tools/JProfiler.cpp b/logic/tools/JProfiler.cpp index 975345d5..45b33f79 100644 --- a/logic/tools/JProfiler.cpp +++ b/logic/tools/JProfiler.cpp @@ -4,7 +4,7 @@ #include <QMessageBox> #include "settings/SettingsObject.h" -#include "BaseLauncher.h" +#include "launch/LaunchTask.h" #include "BaseInstance.h" class JProfiler : public BaseProfiler @@ -18,7 +18,7 @@ private slots: void profilerFinished(int exit, QProcess::ExitStatus status); protected: - void beginProfilingImpl(std::shared_ptr<BaseLauncher> process); + void beginProfilingImpl(std::shared_ptr<LaunchTask> process); private: int listeningPort = 0; @@ -48,7 +48,7 @@ void JProfiler::profilerFinished(int exit, QProcess::ExitStatus status) } } -void JProfiler::beginProfilingImpl(std::shared_ptr<BaseLauncher> process) +void JProfiler::beginProfilingImpl(std::shared_ptr<LaunchTask> process) { listeningPort = globalSettings->get("JProfilerPort").toInt(); QProcess *profiler = new QProcess(this); diff --git a/logic/tools/JVisualVM.cpp b/logic/tools/JVisualVM.cpp index a749012b..169967d9 100644 --- a/logic/tools/JVisualVM.cpp +++ b/logic/tools/JVisualVM.cpp @@ -4,7 +4,7 @@ #include <QStandardPaths> #include "settings/SettingsObject.h" -#include "BaseLauncher.h" +#include "launch/LaunchTask.h" #include "BaseInstance.h" class JVisualVM : public BaseProfiler @@ -18,7 +18,7 @@ private slots: void profilerFinished(int exit, QProcess::ExitStatus status); protected: - void beginProfilingImpl(std::shared_ptr<BaseLauncher> process); + void beginProfilingImpl(std::shared_ptr<LaunchTask> process); }; @@ -45,7 +45,7 @@ void JVisualVM::profilerFinished(int exit, QProcess::ExitStatus status) } } -void JVisualVM::beginProfilingImpl(std::shared_ptr<BaseLauncher> process) +void JVisualVM::beginProfilingImpl(std::shared_ptr<LaunchTask> process) { QProcess *profiler = new QProcess(this); QStringList profilerArgs = |