diff options
| author | liamwhite <liamwhite@users.noreply.github.com> | 2023-12-12 11:06:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-12 11:06:37 -0500 |
| commit | 15bebf1695246c85852835b0fae58d795626dc39 (patch) | |
| tree | 03de654621e65cb185b2a2e3511f71b933b005ef /src/yuzu/play_time_manager.cpp | |
| parent | 5c840334b8c1fae4e54986768a46e46a350b6318 (diff) | |
| parent | a22a025c5bd579d782225cafba1b56896d22e4cd (diff) | |
Merge pull request #12328 from german77/profile_manager
core: Use single instance of profile manager
Diffstat (limited to 'src/yuzu/play_time_manager.cpp')
| -rw-r--r-- | src/yuzu/play_time_manager.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/yuzu/play_time_manager.cpp b/src/yuzu/play_time_manager.cpp index 155c36b7d..94c99274d 100644 --- a/src/yuzu/play_time_manager.cpp +++ b/src/yuzu/play_time_manager.cpp @@ -20,8 +20,8 @@ struct PlayTimeElement { PlayTime play_time; }; -std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { - const Service::Account::ProfileManager manager; +std::optional<std::filesystem::path> GetCurrentUserPlayTimePath( + const Service::Account::ProfileManager& manager) { const auto uuid = manager.GetUser(static_cast<s32>(Settings::values.current_user)); if (!uuid.has_value()) { return std::nullopt; @@ -30,8 +30,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { uuid->RawString().append(".bin"); } -[[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db) { - const auto filename = GetCurrentUserPlayTimePath(); +[[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db, + const Service::Account::ProfileManager& manager) { + const auto filename = GetCurrentUserPlayTimePath(manager); if (!filename.has_value()) { LOG_ERROR(Frontend, "Failed to get current user path"); @@ -66,8 +67,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { return true; } -[[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db) { - const auto filename = GetCurrentUserPlayTimePath(); +[[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db, + const Service::Account::ProfileManager& manager) { + const auto filename = GetCurrentUserPlayTimePath(manager); if (!filename.has_value()) { LOG_ERROR(Frontend, "Failed to get current user path"); @@ -96,8 +98,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { } // namespace -PlayTimeManager::PlayTimeManager() { - if (!ReadPlayTimeFile(database)) { +PlayTimeManager::PlayTimeManager(Service::Account::ProfileManager& profile_manager) + : manager{profile_manager} { + if (!ReadPlayTimeFile(database, manager)) { LOG_ERROR(Frontend, "Failed to read play time database! Resetting to default."); } } @@ -142,7 +145,7 @@ void PlayTimeManager::AutoTimestamp(std::stop_token stop_token) { } void PlayTimeManager::Save() { - if (!WritePlayTimeFile(database)) { + if (!WritePlayTimeFile(database, manager)) { LOG_ERROR(Frontend, "Failed to update play time database!"); } } |
