diff options
author | Liam <byteslice@airmail.cc> | 2023-08-28 00:41:42 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-08-28 01:45:25 +0200 |
commit | 667ec286970560d3a5b12b987010082657aec7c3 (patch) | |
tree | c03a8e4279fe4d6a1e74896f727b75f9b13e9c45 /src/yuzu/play_time_manager.h | |
parent | yuzu-qt: Track play time (diff) | |
download | yuzu-667ec286970560d3a5b12b987010082657aec7c3.tar yuzu-667ec286970560d3a5b12b987010082657aec7c3.tar.gz yuzu-667ec286970560d3a5b12b987010082657aec7c3.tar.bz2 yuzu-667ec286970560d3a5b12b987010082657aec7c3.tar.lz yuzu-667ec286970560d3a5b12b987010082657aec7c3.tar.xz yuzu-667ec286970560d3a5b12b987010082657aec7c3.tar.zst yuzu-667ec286970560d3a5b12b987010082657aec7c3.zip |
Diffstat (limited to 'src/yuzu/play_time_manager.h')
-rw-r--r-- | src/yuzu/play_time_manager.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/yuzu/play_time_manager.h b/src/yuzu/play_time_manager.h new file mode 100644 index 000000000..5f96f3447 --- /dev/null +++ b/src/yuzu/play_time_manager.h @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <QString> + +#include <map> + +#include "common/common_funcs.h" +#include "common/common_types.h" +#include "common/polyfill_thread.h" + +namespace PlayTime { + +using ProgramId = u64; +using PlayTime = u64; +using PlayTimeDatabase = std::map<ProgramId, PlayTime>; + +class PlayTimeManager { +public: + explicit PlayTimeManager(); + ~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); + void Start(); + void Stop(); + +private: + PlayTimeDatabase database; + u64 running_program_id; + std::jthread play_time_thread; + void AutoTimestamp(std::stop_token stop_token); + void Save(); +}; + +QString ReadablePlayTime(qulonglong time_seconds); + +} // namespace PlayTime |