1648d189d3
Some checks failed
suyu verify / Verify Format (push) Waiting to run
suyu verify / test build (linux-fresh, clang) (push) Blocked by required conditions
suyu verify / test build (linux-fresh, linux) (push) Blocked by required conditions
suyu verify / test build (linux-mingw, windows) (push) Blocked by required conditions
suyu verify / android (push) Blocked by required conditions
suyu-ci / Check REUSE Specification (push) Failing after 12s
codespell / Check for spelling errors (push) Successful in 10s
Co-authored-by: palfaiate <syl.paulo.alfaiate@gmail.com> Co-authored-by: SylverDiscord51 <p71468162@gmail.com> Co-committed-by: SylverDiscord51 <p71468162@gmail.com>
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
// 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 Service::Account {
|
|
class ProfileManager;
|
|
}
|
|
|
|
namespace PlayTime {
|
|
|
|
using ProgramId = u64;
|
|
using PlayTime = u64;
|
|
using PlayTimeDatabase = std::map<ProgramId, PlayTime>;
|
|
|
|
class PlayTimeManager {
|
|
public:
|
|
explicit PlayTimeManager(Service::Account::ProfileManager& profile_manager);
|
|
~PlayTimeManager();
|
|
|
|
SUYU_NON_COPYABLE(PlayTimeManager);
|
|
SUYU_NON_MOVEABLE(PlayTimeManager);
|
|
|
|
u64 GetPlayTime(u64 program_id) const;
|
|
void ResetProgramPlayTime(u64 program_id);
|
|
void SetProgramId(u64 program_id);
|
|
void Start();
|
|
void Stop();
|
|
|
|
private:
|
|
void AutoTimestamp(std::stop_token stop_token);
|
|
void Save();
|
|
|
|
PlayTimeDatabase database;
|
|
u64 running_program_id;
|
|
std::jthread play_time_thread;
|
|
Service::Account::ProfileManager& manager;
|
|
};
|
|
|
|
QString ReadablePlayTime(qulonglong time_seconds);
|
|
|
|
} // namespace PlayTime
|