2025-09-15 17:21:18 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-08-27 18:41:42 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/common_types.h"
|
2025-09-15 17:21:18 +02:00
|
|
|
#include <common/polyfill_thread.h>
|
2023-08-27 18:41:42 -04:00
|
|
|
|
2025-09-15 17:21:18 +02:00
|
|
|
// TODO(crueter): Extract this into frontend_common
|
2023-12-09 23:28:18 -06:00
|
|
|
namespace Service::Account {
|
|
|
|
class ProfileManager;
|
|
|
|
}
|
|
|
|
|
2023-08-27 18:41:42 -04:00
|
|
|
namespace PlayTime {
|
|
|
|
|
|
|
|
using ProgramId = u64;
|
|
|
|
using PlayTime = u64;
|
|
|
|
using PlayTimeDatabase = std::map<ProgramId, PlayTime>;
|
|
|
|
|
|
|
|
class PlayTimeManager {
|
|
|
|
public:
|
2025-10-09 15:39:20 +02:00
|
|
|
explicit PlayTimeManager();
|
2023-08-27 18:41:42 -04:00
|
|
|
~PlayTimeManager();
|
|
|
|
|
|
|
|
YUZU_NON_COPYABLE(PlayTimeManager);
|
|
|
|
YUZU_NON_MOVEABLE(PlayTimeManager);
|
|
|
|
|
|
|
|
u64 GetPlayTime(u64 program_id) const;
|
|
|
|
void ResetProgramPlayTime(u64 program_id);
|
|
|
|
void SetProgramId(u64 program_id);
|
2025-10-09 17:52:31 +02:00
|
|
|
void SetPlayTime(u64 program_id, u64 play_time);
|
2023-08-27 18:41:42 -04:00
|
|
|
void Start();
|
|
|
|
void Stop();
|
|
|
|
|
2025-10-10 07:01:17 +02:00
|
|
|
static std::string GetReadablePlayTime(u64 time_seconds);
|
|
|
|
static std::string GetPlayTimeHours(u64 time_seconds);
|
|
|
|
static std::string GetPlayTimeMinutes(u64 time_seconds);
|
|
|
|
static std::string GetPlayTimeSeconds(u64 time_seconds);
|
|
|
|
|
2023-08-27 18:41:42 -04:00
|
|
|
private:
|
2023-12-09 23:28:18 -06:00
|
|
|
void AutoTimestamp(std::stop_token stop_token);
|
|
|
|
void Save();
|
|
|
|
|
2023-08-27 18:41:42 -04:00
|
|
|
PlayTimeDatabase database;
|
|
|
|
u64 running_program_id;
|
|
|
|
std::jthread play_time_thread;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace PlayTime
|