summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/BaseInstance.cpp16
-rw-r--r--api/logic/BaseInstance.h8
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp4
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()