[core, android] Initial playtime implementation #2535

Open
inix wants to merge 10 commits from inix/eden:playtime-android into master
14 changed files with 37 additions and 26 deletions
Showing only changes of commit 2fd807f5cd - Show all commits

View file

@ -36,7 +36,7 @@
#include "common/scope_exit.h"
#include "common/settings.h"
#include "common/string_util.h"
#include "common/play_time_manager.h"
#include "frontend_common/play_time_manager.h"
#include "core/core.h"
#include "core/cpu_manager.h"
#include "core/crypto/key_manager.h"

View file

@ -104,8 +104,6 @@ add_library(
parent_of_member.h
point.h
precompiled_headers.h
play_time_manager.cpp
play_time_manager.h
quaternion.h
range_map.h
range_mutex.h

View file

@ -7,6 +7,8 @@ add_library(frontend_common STATIC
content_manager.h
firmware_manager.h
firmware_manager.cpp
play_time_manager.cpp
play_time_manager.h
)
create_target_directory_groups(frontend_common)

View file

@ -11,7 +11,7 @@
#include "common/settings.h"
#include "common/thread.h"
#include "core/hle/service/acc/profile_manager.h"
#include "common/play_time_manager.h"
#include "play_time_manager.h"
namespace PlayTime {

View file

@ -27,6 +27,8 @@ add_library(qt_common STATIC
qt_rom_util.h qt_rom_util.cpp
qt_applet_util.h qt_applet_util.cpp
qt_progress_dialog.h qt_progress_dialog.cpp
qt_playtime_manager.cpp
qt_playtime_manager.h
)

View file

@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#include "qt_playtime_manager.h"
QString ReadablePlayTime(qulonglong time_seconds) {
if (time_seconds == 0) {
return {};
}
const auto time_minutes = std::max(static_cast<double>(time_seconds) / 60, 1.0);
const auto time_hours = static_cast<double>(time_seconds) / 3600;
const bool is_minutes = time_minutes < 60;
const char* unit = is_minutes ? "m" : "h";
const auto value = is_minutes ? time_minutes : time_hours;
return QStringLiteral("%L1 %2")
.arg(value, 0, 'f', !is_minutes && time_seconds % 60 != 0)
.arg(QString::fromUtf8(unit));
}

View file

@ -0,0 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#include <QString>
// Converts a length of time in seconds into a readable format
QString ReadablePlayTime(qulonglong time_seconds);

View file

@ -23,7 +23,7 @@
#include "qt_common/uisettings.h"
#include "qt_common/qt_game_util.h"
#include "yuzu/compatibility_list.h"
#include "common/play_time_manager.h"
#include "frontend_common/play_time_manager.h"
namespace Core {
class System;

View file

@ -21,7 +21,7 @@
#include "common/common_types.h"
#include "common/logging/log.h"
#include "common/string_util.h"
#include "common/play_time_manager.h""
#include "qt_common/qt_playtime_manager.h"
#include "qt_common/uisettings.h"
#include "yuzu/util/util.h"

View file

@ -20,7 +20,7 @@
#include "core/file_sys/registered_cache.h"
#include "qt_common/uisettings.h"
#include "yuzu/compatibility_list.h"
#include "common/play_time_manager.h""
#include "frontend_common/play_time_manager.h"
namespace Core {
class System;

View file

@ -163,7 +163,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "yuzu/install_dialog.h"
#include "yuzu/loading_screen.h"
#include "yuzu/main.h"
#include "common/play_time_manager.h"
#include "frontend_common/play_time_manager.h"
#include "yuzu/startup_checks.h"
#include "qt_common/uisettings.h"
#include "yuzu/util/clickable_label.h"

View file

@ -48,21 +48,6 @@ QPixmap CreateCirclePixmapFromColor(const QColor& color) {
return circle_pixmap;
}
QString ReadableDuration(qulonglong time_seconds) {
if (time_seconds == 0) {
return {};
}
const auto time_minutes = std::max(static_cast<double>(time_seconds) / 60, 1.0);
const auto time_hours = static_cast<double>(time_seconds) / 3600;
const bool is_minutes = time_minutes < 60;
const char* unit = is_minutes ? "m" : "h";
const auto value = is_minutes ? time_minutes : time_hours;
return QStringLiteral("%L1 %2")
.arg(value, 0, 'f', !is_minutes && time_seconds % 60 != 0)
.arg(QString::fromUtf8(unit));
}
bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image) {
#if defined(WIN32)
#pragma pack(push, 2)

View file

@ -27,6 +27,3 @@
* @return bool If the operation succeeded
*/
[[nodiscard]] bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image);
// Converts a length of time in seconds into a readable format
QString ReadableDuration(qulonglong time_seconds);