Fixed playtime recording
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
e499aa4783
commit
e3af4f9a78
@ -267,13 +267,18 @@ void BaseInstance::setRunning(bool running)
|
||||
|
||||
m_isRunning = running;
|
||||
|
||||
if (!m_settings->get("RecordGameTime").toBool()) {
|
||||
emit runningStatusChanged(running);
|
||||
emit runningStatusChanged(running);
|
||||
}
|
||||
|
||||
void BaseInstance::setMinecraftRunning(bool running)
|
||||
{
|
||||
if (!settings()->get("RecordGameTime").toBool()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (running) {
|
||||
m_timeStarted = QDateTime::currentDateTime();
|
||||
setLastLaunch(m_timeStarted.toMSecsSinceEpoch());
|
||||
} else {
|
||||
QDateTime timeEnded = QDateTime::currentDateTime();
|
||||
|
||||
@ -283,8 +288,6 @@ void BaseInstance::setRunning(bool running)
|
||||
|
||||
emit propertiesChanged(this);
|
||||
}
|
||||
|
||||
emit runningStatusChanged(running);
|
||||
}
|
||||
|
||||
int64_t BaseInstance::totalTimePlayed() const
|
||||
|
@ -104,6 +104,7 @@ class BaseInstance : public QObject, public std::enable_shared_from_this<BaseIns
|
||||
/// be unique.
|
||||
virtual QString id() const;
|
||||
|
||||
void setMinecraftRunning(bool running);
|
||||
void setRunning(bool running);
|
||||
bool isRunning() const;
|
||||
int64_t totalTimePlayed() const;
|
||||
|
@ -213,6 +213,7 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
|
||||
APPLICATION->showMainWindow();
|
||||
|
||||
m_parent->setPid(-1);
|
||||
m_parent->instance()->setMinecraftRunning(false);
|
||||
// if the exit code wasn't 0, report this as a crash
|
||||
auto exitCode = m_process.exitCode();
|
||||
if (exitCode != 0) {
|
||||
@ -228,7 +229,6 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
|
||||
case LoggedProcess::Running:
|
||||
emit logLine(QString("Minecraft process ID: %1\n\n").arg(m_process.processId()), MessageLevel::Launcher);
|
||||
m_parent->setPid(m_process.processId());
|
||||
m_parent->instance()->setLastLaunch();
|
||||
// send the launch script to the launcher part
|
||||
m_process.write(m_launchScript.toUtf8());
|
||||
|
||||
@ -248,6 +248,7 @@ void LauncherPartLaunch::setWorkingDirectory(const QString& wd)
|
||||
void LauncherPartLaunch::proceed()
|
||||
{
|
||||
if (mayProceed) {
|
||||
m_parent->instance()->setMinecraftRunning(true);
|
||||
QString launchString("launch\n");
|
||||
m_process.write(launchString.toUtf8());
|
||||
mayProceed = false;
|
||||
|
Loading…
Reference in New Issue
Block a user