reset the setting if is under 0
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
b075711be0
commit
52c94eb568
@ -64,6 +64,8 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
|
|||||||
|
|
||||||
m_settings->registerSetting("lastLaunchTime", 0);
|
m_settings->registerSetting("lastLaunchTime", 0);
|
||||||
m_settings->registerSetting("totalTimePlayed", 0);
|
m_settings->registerSetting("totalTimePlayed", 0);
|
||||||
|
if (m_settings->get("totalTimePlayed").toLongLong() < 0)
|
||||||
|
m_settings->set("totalTimePlayed", 0);
|
||||||
m_settings->registerSetting("lastTimePlayed", 0);
|
m_settings->registerSetting("lastTimePlayed", 0);
|
||||||
|
|
||||||
m_settings->registerSetting("linkedInstances", "[]");
|
m_settings->registerSetting("linkedInstances", "[]");
|
||||||
@ -278,8 +280,6 @@ void BaseInstance::setRunning(bool running)
|
|||||||
QDateTime timeEnded = QDateTime::currentDateTime();
|
QDateTime timeEnded = QDateTime::currentDateTime();
|
||||||
|
|
||||||
qint64 current = settings()->get("totalTimePlayed").toLongLong();
|
qint64 current = settings()->get("totalTimePlayed").toLongLong();
|
||||||
if (current < 0)
|
|
||||||
current = 0;
|
|
||||||
settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded));
|
settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded));
|
||||||
settings()->set("lastTimePlayed", m_timeStarted.secsTo(timeEnded));
|
settings()->set("lastTimePlayed", m_timeStarted.secsTo(timeEnded));
|
||||||
|
|
||||||
@ -292,8 +292,6 @@ void BaseInstance::setRunning(bool running)
|
|||||||
int64_t BaseInstance::totalTimePlayed() const
|
int64_t BaseInstance::totalTimePlayed() const
|
||||||
{
|
{
|
||||||
qint64 current = m_settings->get("totalTimePlayed").toLongLong();
|
qint64 current = m_settings->get("totalTimePlayed").toLongLong();
|
||||||
if (current < 0)
|
|
||||||
current = 0;
|
|
||||||
if (m_isRunning) {
|
if (m_isRunning) {
|
||||||
QDateTime timeNow = QDateTime::currentDateTime();
|
QDateTime timeNow = QDateTime::currentDateTime();
|
||||||
return current + m_timeStarted.secsTo(timeNow);
|
return current + m_timeStarted.secsTo(timeNow);
|
||||||
|
Loading…
Reference in New Issue
Block a user