diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-08-06 15:39:29 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-08-07 11:48:15 +0200 |
commit | bc6d1b5304f715ad0d8be27efd6630f820572da4 (patch) | |
tree | 6f42bdd351664b6f828247b4860ee3ad723b0971 /api | |
parent | c44d41ee9b132d4f757658bd62d4b115b7887fe3 (diff) | |
download | MultiMC-bc6d1b5304f715ad0d8be27efd6630f820572da4.tar MultiMC-bc6d1b5304f715ad0d8be27efd6630f820572da4.tar.gz MultiMC-bc6d1b5304f715ad0d8be27efd6630f820572da4.tar.lz MultiMC-bc6d1b5304f715ad0d8be27efd6630f820572da4.tar.xz MultiMC-bc6d1b5304f715ad0d8be27efd6630f820572da4.zip |
GH-338, GH-513, GH-700 Unify edit instance with console window
* The resulting instance window can be closed at any point.
* Main window is kept open and running instances are marked with a badge.
* Multiple instances can now run from the same MultiMC - it's even more **multi** now.
* MultiMC can be entirely closed, keeping Minecraft(s) running.
Diffstat (limited to 'api')
-rw-r--r-- | api/logic/BaseInstance.cpp | 16 | ||||
-rw-r--r-- | api/logic/BaseInstance.h | 8 | ||||
-rw-r--r-- | api/logic/minecraft/MinecraftInstance.cpp | 4 |
3 files changed, 24 insertions, 4 deletions
diff --git a/api/logic/BaseInstance.cpp b/api/logic/BaseInstance.cpp index ce55d5e4..9dee2c38 100644 --- a/api/logic/BaseInstance.cpp +++ b/api/logic/BaseInstance.cpp @@ -92,11 +92,14 @@ bool BaseInstance::isRunning() const void BaseInstance::setRunning(bool running) { - if(running && !m_isRunning) + if(running == m_isRunning) + return; + + if(running) { m_timeStarted = QDateTime::currentDateTime(); } - else if(!running && m_isRunning) + else { qint64 current = settings()->get("totalTimePlayed").toLongLong(); QDateTime timeEnded = QDateTime::currentDateTime(); @@ -104,6 +107,8 @@ void BaseInstance::setRunning(bool running) emit propertiesChanged(this); } m_isRunning = running; + + emit runningStatusChanged(running); } int64_t BaseInstance::totalTimePlayed() const @@ -179,7 +184,7 @@ void BaseInstance::unsetFlag(const BaseInstance::InstanceFlag flag) bool BaseInstance::canLaunch() const { - return !(flags() & VersionBrokenFlag); + return (!(flags() & VersionBrokenFlag)) && (!isRunning()); } bool BaseInstance::reload() @@ -268,3 +273,8 @@ QStringList BaseInstance::extraArguments() const { return Commandline::splitArgs(settings()->get("JvmArgs").toString()); } + +std::shared_ptr<LaunchTask> BaseInstance::getLaunchTask() +{ + return m_launchProcess; +} diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h index f0fb6096..9a6976cb 100644 --- a/api/logic/BaseInstance.h +++ b/api/logic/BaseInstance.h @@ -157,6 +157,9 @@ public: /// returns a valid launcher (task container) virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) = 0; + /// returns the current launch task (if any) + std::shared_ptr<LaunchTask> getLaunchTask(); + /*! * Returns a task that should be done right before launch * This task should do any extra preparations needed @@ -231,6 +234,10 @@ signals: void flagsChanged(); + void launchTaskChanged(std::shared_ptr<LaunchTask>); + + void runningStatusChanged(bool running); + protected slots: void iconUpdated(QString key); @@ -240,6 +247,7 @@ protected: SettingsObjectPtr m_settings; InstanceFlags m_flags; bool m_isRunning = false; + std::shared_ptr<LaunchTask> m_launchProcess; QDateTime m_timeStarted; }; diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index f706c16d..b64d9bd2 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -465,7 +465,9 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s { process->setCensorFilter(createCensorFilterFromSession(session)); } - return process; + m_launchProcess = process; + emit launchTaskChanged(m_launchProcess); + return m_launchProcess; } QString MinecraftInstance::launchMethod() |