[core, android] Initial playtime implementation #2535
14 changed files with 37 additions and 26 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
@ -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
|
||||
|
||||
)
|
||||
|
||||
|
|
19
src/qt_common/qt_playtime_manager.cpp
Normal file
19
src/qt_common/qt_playtime_manager.cpp
Normal 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));
|
||||
}
|
8
src/qt_common/qt_playtime_manager.h
Normal file
8
src/qt_common/qt_playtime_manager.h
Normal 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);
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue