From b82d6678594a105b1d33bf50ccfa9607f460ee9a Mon Sep 17 00:00:00 2001 From: arthomnix Date: Wed, 2 Nov 2022 16:11:56 +0000 Subject: [PATCH] NOISSUE Add setting to display playtime in hours only --- launcher/Application.cpp | 1 + launcher/minecraft/MinecraftInstance.cpp | 12 ++++++++++-- launcher/ui/MainWindow.cpp | 6 +++++- launcher/ui/pages/global/MinecraftPage.cpp | 3 ++- launcher/ui/pages/global/MinecraftPage.ui | 7 +++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index dc3b9a75..475b05a1 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -718,6 +718,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("ShowGameTime", true); m_settings->registerSetting("ShowGlobalGameTime", true); m_settings->registerSetting("RecordGameTime", true); + m_settings->registerSetting("ShowGameTimeHours", false); // Minecraft launch method m_settings->registerSetting("MCLaunchMethod", "LauncherPart"); diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index ae0fbd31..3769f826 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -785,11 +785,19 @@ QString MinecraftInstance::getStatusbarDescription() if(m_settings->get("ShowGameTime").toBool()) { if (lastTimePlayed() > 0) { - description.append(tr(", last played for %1").arg(Time::prettifyDuration(lastTimePlayed()))); + if (APPLICATION->settings()->get("ShowGameTimeHours").toBool()) { + description.append(tr(", last played for %1 hours").arg(lastTimePlayed() / 3600.0, 0, 'f', 2)); + } else { + description.append(tr(", last played for %1").arg(Time::prettifyDuration(lastTimePlayed()))); + } } if (totalTimePlayed() > 0) { - description.append(tr(", total played for %1").arg(Time::prettifyDuration(totalTimePlayed()))); + if (APPLICATION->settings()->get("ShowGameTimeHours").toBool()) { + description.append(tr(", total played for %1 hours").arg(totalTimePlayed() / 3600.0, 0, 'f', 1)); + } else { + description.append(tr(", total played for %1").arg(Time::prettifyDuration(totalTimePlayed()))); + } } } if(hasCrashed()) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 139ca780..0a1eba4e 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2006,6 +2006,10 @@ void MainWindow::updateStatusCenter() int timePlayed = APPLICATION->instances()->getTotalPlayTime(); if (timePlayed > 0) { - m_statusCenter->setText(tr("Total playtime: %1").arg(Time::prettifyDuration(timePlayed))); + if (APPLICATION->settings()->get("ShowGameTimeHours").toBool()) { + m_statusCenter->setText(tr("Total playtime: %1 hours").arg(timePlayed / 3600.0, 0, 'f', 1)); + } else { + m_statusCenter->setText(tr("Total playtime: %1").arg(Time::prettifyDuration(timePlayed))); + } } } diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp index c763f8ac..3815d912 100644 --- a/launcher/ui/pages/global/MinecraftPage.cpp +++ b/launcher/ui/pages/global/MinecraftPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2021 MultiMC Contributors +/* Copyright 2013-2022 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,6 +71,7 @@ void MinecraftPage::applySettings() s->set("ShowGameTime", ui->showGameTime->isChecked()); s->set("ShowGlobalGameTime", ui->showGlobalGameTime->isChecked()); s->set("RecordGameTime", ui->recordGameTime->isChecked()); + s->set("ShowGameTimeHours", ui->showGameTimeHours->isChecked()); } void MinecraftPage::loadSettings() diff --git a/launcher/ui/pages/global/MinecraftPage.ui b/launcher/ui/pages/global/MinecraftPage.ui index 857b8cfb..7a5137d8 100644 --- a/launcher/ui/pages/global/MinecraftPage.ui +++ b/launcher/ui/pages/global/MinecraftPage.ui @@ -161,6 +161,13 @@ + + + + Show time spent playing in hours only + + +