summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar german772023-12-09 23:28:18 -0600
committerGravatar german772023-12-10 11:29:43 -0600
commita22a025c5bd579d782225cafba1b56896d22e4cd (patch)
tree2dc2cb8f3a603c91b24b71cc308489f6328633bf /src
parentMerge pull request #12296 from liamwhite/client-session (diff)
downloadyuzu-a22a025c5bd579d782225cafba1b56896d22e4cd.tar.gz
yuzu-a22a025c5bd579d782225cafba1b56896d22e4cd.tar.xz
yuzu-a22a025c5bd579d782225cafba1b56896d22e4cd.zip
core: Use single instance of profile manager
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/jni/native.cpp7
-rw-r--r--src/android/app/src/main/jni/native.h1
-rw-r--r--src/core/core.cpp14
-rw-r--r--src/core/core.h7
-rw-r--r--src/yuzu/applets/qt_profile_select.cpp14
-rw-r--r--src/yuzu/applets/qt_profile_select.h15
-rw-r--r--src/yuzu/configuration/configure_profile_manager.cpp36
-rw-r--r--src/yuzu/configuration/configure_profile_manager.h5
-rw-r--r--src/yuzu/main.cpp19
-rw-r--r--src/yuzu/multiplayer/lobby.cpp11
-rw-r--r--src/yuzu/multiplayer/lobby.h5
-rw-r--r--src/yuzu/play_time_manager.cpp21
-rw-r--r--src/yuzu/play_time_manager.h12
13 files changed, 94 insertions, 73 deletions
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index 3d795b57f..e5d3158c8 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -291,9 +291,6 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string
291 // Initialize filesystem. 291 // Initialize filesystem.
292 ConfigureFilesystemProvider(filepath); 292 ConfigureFilesystemProvider(filepath);
293 293
294 // Initialize account manager
295 m_profile_manager = std::make_unique<Service::Account::ProfileManager>();
296
297 // Load the ROM. 294 // Load the ROM.
298 m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath); 295 m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath);
299 if (m_load_result != Core::SystemResultStatus::Success) { 296 if (m_load_result != Core::SystemResultStatus::Success) {
@@ -736,8 +733,8 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv*
736 auto vfs_nand_dir = EmulationSession::GetInstance().System().GetFilesystem()->OpenDirectory( 733 auto vfs_nand_dir = EmulationSession::GetInstance().System().GetFilesystem()->OpenDirectory(
737 Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read); 734 Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read);
738 735
739 Service::Account::ProfileManager manager; 736 const auto user_id = EmulationSession::GetInstance().System().GetProfileManager().GetUser(
740 const auto user_id = manager.GetUser(static_cast<std::size_t>(0)); 737 static_cast<std::size_t>(0));
741 ASSERT(user_id); 738 ASSERT(user_id);
742 739
743 const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( 740 const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h
index 78ef96802..f1457bd1f 100644
--- a/src/android/app/src/main/jni/native.h
+++ b/src/android/app/src/main/jni/native.h
@@ -73,7 +73,6 @@ private:
73 std::atomic<bool> m_is_running = false; 73 std::atomic<bool> m_is_running = false;
74 std::atomic<bool> m_is_paused = false; 74 std::atomic<bool> m_is_paused = false;
75 SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; 75 SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{};
76 std::unique_ptr<Service::Account::ProfileManager> m_profile_manager;
77 std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; 76 std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider;
78 77
79 // GPU driver parameters 78 // GPU driver parameters
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 229cb879c..b14f74976 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -36,6 +36,7 @@
36#include "core/hle/kernel/k_scheduler.h" 36#include "core/hle/kernel/k_scheduler.h"
37#include "core/hle/kernel/kernel.h" 37#include "core/hle/kernel/kernel.h"
38#include "core/hle/kernel/physical_core.h" 38#include "core/hle/kernel/physical_core.h"
39#include "core/hle/service/acc/profile_manager.h"
39#include "core/hle/service/am/applets/applets.h" 40#include "core/hle/service/am/applets/applets.h"
40#include "core/hle/service/apm/apm_controller.h" 41#include "core/hle/service/apm/apm_controller.h"
41#include "core/hle/service/filesystem/filesystem.h" 42#include "core/hle/service/filesystem/filesystem.h"
@@ -130,8 +131,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
130struct System::Impl { 131struct System::Impl {
131 explicit Impl(System& system) 132 explicit Impl(System& system)
132 : kernel{system}, fs_controller{system}, memory{system}, hid_core{}, room_network{}, 133 : kernel{system}, fs_controller{system}, memory{system}, hid_core{}, room_network{},
133 cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system}, 134 cpu_manager{system}, reporter{system}, applet_manager{system}, profile_manager{},
134 gpu_dirty_memory_write_manager{} { 135 time_manager{system}, gpu_dirty_memory_write_manager{} {
135 memory.SetGPUDirtyManagers(gpu_dirty_memory_write_manager); 136 memory.SetGPUDirtyManagers(gpu_dirty_memory_write_manager);
136 } 137 }
137 138
@@ -532,6 +533,7 @@ struct System::Impl {
532 533
533 /// Service State 534 /// Service State
534 Service::Glue::ARPManager arp_manager; 535 Service::Glue::ARPManager arp_manager;
536 Service::Account::ProfileManager profile_manager;
535 Service::Time::TimeManager time_manager; 537 Service::Time::TimeManager time_manager;
536 538
537 /// Service manager 539 /// Service manager
@@ -921,6 +923,14 @@ const Service::APM::Controller& System::GetAPMController() const {
921 return impl->apm_controller; 923 return impl->apm_controller;
922} 924}
923 925
926Service::Account::ProfileManager& System::GetProfileManager() {
927 return impl->profile_manager;
928}
929
930const Service::Account::ProfileManager& System::GetProfileManager() const {
931 return impl->profile_manager;
932}
933
924Service::Time::TimeManager& System::GetTimeManager() { 934Service::Time::TimeManager& System::GetTimeManager() {
925 return impl->time_manager; 935 return impl->time_manager;
926} 936}
diff --git a/src/core/core.h b/src/core/core.h
index 05a222f5c..473204db7 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -45,6 +45,10 @@ class Memory;
45 45
46namespace Service { 46namespace Service {
47 47
48namespace Account {
49class ProfileManager;
50} // namespace Account
51
48namespace AM::Applets { 52namespace AM::Applets {
49struct AppletFrontendSet; 53struct AppletFrontendSet;
50class AppletManager; 54class AppletManager;
@@ -383,6 +387,9 @@ public:
383 [[nodiscard]] Service::APM::Controller& GetAPMController(); 387 [[nodiscard]] Service::APM::Controller& GetAPMController();
384 [[nodiscard]] const Service::APM::Controller& GetAPMController() const; 388 [[nodiscard]] const Service::APM::Controller& GetAPMController() const;
385 389
390 [[nodiscard]] Service::Account::ProfileManager& GetProfileManager();
391 [[nodiscard]] const Service::Account::ProfileManager& GetProfileManager() const;
392
386 [[nodiscard]] Service::Time::TimeManager& GetTimeManager(); 393 [[nodiscard]] Service::Time::TimeManager& GetTimeManager();
387 [[nodiscard]] const Service::Time::TimeManager& GetTimeManager() const; 394 [[nodiscard]] const Service::Time::TimeManager& GetTimeManager() const;
388 395
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp
index 1f3f23038..79162a491 100644
--- a/src/yuzu/applets/qt_profile_select.cpp
+++ b/src/yuzu/applets/qt_profile_select.cpp
@@ -14,6 +14,8 @@
14#include "common/fs/path_util.h" 14#include "common/fs/path_util.h"
15#include "common/string_util.h" 15#include "common/string_util.h"
16#include "core/constants.h" 16#include "core/constants.h"
17#include "core/core.h"
18#include "core/hle/service/acc/profile_manager.h"
17#include "yuzu/applets/qt_profile_select.h" 19#include "yuzu/applets/qt_profile_select.h"
18#include "yuzu/main.h" 20#include "yuzu/main.h"
19#include "yuzu/util/controller_navigation.h" 21#include "yuzu/util/controller_navigation.h"
@@ -47,9 +49,9 @@ QPixmap GetIcon(Common::UUID uuid) {
47} // Anonymous namespace 49} // Anonymous namespace
48 50
49QtProfileSelectionDialog::QtProfileSelectionDialog( 51QtProfileSelectionDialog::QtProfileSelectionDialog(
50 Core::HID::HIDCore& hid_core, QWidget* parent, 52 Core::System& system, QWidget* parent,
51 const Core::Frontend::ProfileSelectParameters& parameters) 53 const Core::Frontend::ProfileSelectParameters& parameters)
52 : QDialog(parent), profile_manager(std::make_unique<Service::Account::ProfileManager>()) { 54 : QDialog(parent), profile_manager{system.GetProfileManager()} {
53 outer_layout = new QVBoxLayout; 55 outer_layout = new QVBoxLayout;
54 56
55 instruction_label = new QLabel(); 57 instruction_label = new QLabel();
@@ -68,7 +70,7 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(
68 tree_view = new QTreeView; 70 tree_view = new QTreeView;
69 item_model = new QStandardItemModel(tree_view); 71 item_model = new QStandardItemModel(tree_view);
70 tree_view->setModel(item_model); 72 tree_view->setModel(item_model);
71 controller_navigation = new ControllerNavigation(hid_core, this); 73 controller_navigation = new ControllerNavigation(system.HIDCore(), this);
72 74
73 tree_view->setAlternatingRowColors(true); 75 tree_view->setAlternatingRowColors(true);
74 tree_view->setSelectionMode(QHeaderView::SingleSelection); 76 tree_view->setSelectionMode(QHeaderView::SingleSelection);
@@ -106,10 +108,10 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(
106 SelectUser(tree_view->currentIndex()); 108 SelectUser(tree_view->currentIndex());
107 }); 109 });
108 110
109 const auto& profiles = profile_manager->GetAllUsers(); 111 const auto& profiles = profile_manager.GetAllUsers();
110 for (const auto& user : profiles) { 112 for (const auto& user : profiles) {
111 Service::Account::ProfileBase profile{}; 113 Service::Account::ProfileBase profile{};
112 if (!profile_manager->GetProfileBase(user, profile)) 114 if (!profile_manager.GetProfileBase(user, profile))
113 continue; 115 continue;
114 116
115 const auto username = Common::StringFromFixedZeroTerminatedBuffer( 117 const auto username = Common::StringFromFixedZeroTerminatedBuffer(
@@ -134,7 +136,7 @@ QtProfileSelectionDialog::~QtProfileSelectionDialog() {
134 136
135int QtProfileSelectionDialog::exec() { 137int QtProfileSelectionDialog::exec() {
136 // Skip profile selection when there's only one. 138 // Skip profile selection when there's only one.
137 if (profile_manager->GetUserCount() == 1) { 139 if (profile_manager.GetUserCount() == 1) {
138 user_index = 0; 140 user_index = 0;
139 return QDialog::Accepted; 141 return QDialog::Accepted;
140 } 142 }
diff --git a/src/yuzu/applets/qt_profile_select.h b/src/yuzu/applets/qt_profile_select.h
index 99056e274..607f1777c 100644
--- a/src/yuzu/applets/qt_profile_select.h
+++ b/src/yuzu/applets/qt_profile_select.h
@@ -7,7 +7,6 @@
7#include <QDialog> 7#include <QDialog>
8#include <QList> 8#include <QList>
9#include "core/frontend/applets/profile_select.h" 9#include "core/frontend/applets/profile_select.h"
10#include "core/hle/service/acc/profile_manager.h"
11 10
12class ControllerNavigation; 11class ControllerNavigation;
13class GMainWindow; 12class GMainWindow;
@@ -20,15 +19,19 @@ class QStandardItemModel;
20class QTreeView; 19class QTreeView;
21class QVBoxLayout; 20class QVBoxLayout;
22 21
23namespace Core::HID { 22namespace Core {
24class HIDCore; 23class System;
25} // namespace Core::HID 24}
25
26namespace Service::Account {
27class ProfileManager;
28}
26 29
27class QtProfileSelectionDialog final : public QDialog { 30class QtProfileSelectionDialog final : public QDialog {
28 Q_OBJECT 31 Q_OBJECT
29 32
30public: 33public:
31 explicit QtProfileSelectionDialog(Core::HID::HIDCore& hid_core, QWidget* parent, 34 explicit QtProfileSelectionDialog(Core::System& system, QWidget* parent,
32 const Core::Frontend::ProfileSelectParameters& parameters); 35 const Core::Frontend::ProfileSelectParameters& parameters);
33 ~QtProfileSelectionDialog() override; 36 ~QtProfileSelectionDialog() override;
34 37
@@ -58,7 +61,7 @@ private:
58 QScrollArea* scroll_area; 61 QScrollArea* scroll_area;
59 QDialogButtonBox* buttons; 62 QDialogButtonBox* buttons;
60 63
61 std::unique_ptr<Service::Account::ProfileManager> profile_manager; 64 Service::Account::ProfileManager& profile_manager;
62 ControllerNavigation* controller_navigation = nullptr; 65 ControllerNavigation* controller_navigation = nullptr;
63}; 66};
64 67
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp
index 6d2219bf5..fa5f383d6 100644
--- a/src/yuzu/configuration/configure_profile_manager.cpp
+++ b/src/yuzu/configuration/configure_profile_manager.cpp
@@ -76,9 +76,9 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t
76} 76}
77} // Anonymous namespace 77} // Anonymous namespace
78 78
79ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent) 79ConfigureProfileManager::ConfigureProfileManager(Core::System& system_, QWidget* parent)
80 : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()}, 80 : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()},
81 profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_} { 81 profile_manager{system_.GetProfileManager()}, system{system_} {
82 ui->setupUi(this); 82 ui->setupUi(this);
83 83
84 tree_view = new QTreeView; 84 tree_view = new QTreeView;
@@ -149,10 +149,10 @@ void ConfigureProfileManager::SetConfiguration() {
149} 149}
150 150
151void ConfigureProfileManager::PopulateUserList() { 151void ConfigureProfileManager::PopulateUserList() {
152 const auto& profiles = profile_manager->GetAllUsers(); 152 const auto& profiles = profile_manager.GetAllUsers();
153 for (const auto& user : profiles) { 153 for (const auto& user : profiles) {
154 Service::Account::ProfileBase profile{}; 154 Service::Account::ProfileBase profile{};
155 if (!profile_manager->GetProfileBase(user, profile)) 155 if (!profile_manager.GetProfileBase(user, profile))
156 continue; 156 continue;
157 157
158 const auto username = Common::StringFromFixedZeroTerminatedBuffer( 158 const auto username = Common::StringFromFixedZeroTerminatedBuffer(
@@ -167,11 +167,11 @@ void ConfigureProfileManager::PopulateUserList() {
167} 167}
168 168
169void ConfigureProfileManager::UpdateCurrentUser() { 169void ConfigureProfileManager::UpdateCurrentUser() {
170 ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS); 170 ui->pm_add->setEnabled(profile_manager.GetUserCount() < Service::Account::MAX_USERS);
171 171
172 const auto& current_user = profile_manager->GetUser(Settings::values.current_user.GetValue()); 172 const auto& current_user = profile_manager.GetUser(Settings::values.current_user.GetValue());
173 ASSERT(current_user); 173 ASSERT(current_user);
174 const auto username = GetAccountUsername(*profile_manager, *current_user); 174 const auto username = GetAccountUsername(profile_manager, *current_user);
175 175
176 scene->clear(); 176 scene->clear();
177 scene->addPixmap( 177 scene->addPixmap(
@@ -187,11 +187,11 @@ void ConfigureProfileManager::ApplyConfiguration() {
187 187
188void ConfigureProfileManager::SelectUser(const QModelIndex& index) { 188void ConfigureProfileManager::SelectUser(const QModelIndex& index) {
189 Settings::values.current_user = 189 Settings::values.current_user =
190 std::clamp<s32>(index.row(), 0, static_cast<s32>(profile_manager->GetUserCount() - 1)); 190 std::clamp<s32>(index.row(), 0, static_cast<s32>(profile_manager.GetUserCount() - 1));
191 191
192 UpdateCurrentUser(); 192 UpdateCurrentUser();
193 193
194 ui->pm_remove->setEnabled(profile_manager->GetUserCount() >= 2); 194 ui->pm_remove->setEnabled(profile_manager.GetUserCount() >= 2);
195 ui->pm_rename->setEnabled(true); 195 ui->pm_rename->setEnabled(true);
196 ui->pm_set_image->setEnabled(true); 196 ui->pm_set_image->setEnabled(true);
197} 197}
@@ -204,18 +204,18 @@ void ConfigureProfileManager::AddUser() {
204 } 204 }
205 205
206 const auto uuid = Common::UUID::MakeRandom(); 206 const auto uuid = Common::UUID::MakeRandom();
207 profile_manager->CreateNewUser(uuid, username.toStdString()); 207 profile_manager.CreateNewUser(uuid, username.toStdString());
208 208
209 item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); 209 item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)});
210} 210}
211 211
212void ConfigureProfileManager::RenameUser() { 212void ConfigureProfileManager::RenameUser() {
213 const auto user = tree_view->currentIndex().row(); 213 const auto user = tree_view->currentIndex().row();
214 const auto uuid = profile_manager->GetUser(user); 214 const auto uuid = profile_manager.GetUser(user);
215 ASSERT(uuid); 215 ASSERT(uuid);
216 216
217 Service::Account::ProfileBase profile{}; 217 Service::Account::ProfileBase profile{};
218 if (!profile_manager->GetProfileBase(*uuid, profile)) 218 if (!profile_manager.GetProfileBase(*uuid, profile))
219 return; 219 return;
220 220
221 const auto new_username = GetProfileUsernameFromUser(this, tr("Enter a new username:")); 221 const auto new_username = GetProfileUsernameFromUser(this, tr("Enter a new username:"));
@@ -227,7 +227,7 @@ void ConfigureProfileManager::RenameUser() {
227 std::fill(profile.username.begin(), profile.username.end(), '\0'); 227 std::fill(profile.username.begin(), profile.username.end(), '\0');
228 std::copy(username_std.begin(), username_std.end(), profile.username.begin()); 228 std::copy(username_std.begin(), username_std.end(), profile.username.begin());
229 229
230 profile_manager->SetProfileBase(*uuid, profile); 230 profile_manager.SetProfileBase(*uuid, profile);
231 231
232 item_model->setItem( 232 item_model->setItem(
233 user, 0, 233 user, 0,
@@ -238,9 +238,9 @@ void ConfigureProfileManager::RenameUser() {
238 238
239void ConfigureProfileManager::ConfirmDeleteUser() { 239void ConfigureProfileManager::ConfirmDeleteUser() {
240 const auto index = tree_view->currentIndex().row(); 240 const auto index = tree_view->currentIndex().row();
241 const auto uuid = profile_manager->GetUser(index); 241 const auto uuid = profile_manager.GetUser(index);
242 ASSERT(uuid); 242 ASSERT(uuid);
243 const auto username = GetAccountUsername(*profile_manager, *uuid); 243 const auto username = GetAccountUsername(profile_manager, *uuid);
244 244
245 confirm_dialog->SetInfo(username, *uuid, [this, uuid]() { DeleteUser(*uuid); }); 245 confirm_dialog->SetInfo(username, *uuid, [this, uuid]() { DeleteUser(*uuid); });
246 confirm_dialog->show(); 246 confirm_dialog->show();
@@ -252,7 +252,7 @@ void ConfigureProfileManager::DeleteUser(const Common::UUID& uuid) {
252 } 252 }
253 UpdateCurrentUser(); 253 UpdateCurrentUser();
254 254
255 if (!profile_manager->RemoveUser(uuid)) { 255 if (!profile_manager.RemoveUser(uuid)) {
256 return; 256 return;
257 } 257 }
258 258
@@ -265,7 +265,7 @@ void ConfigureProfileManager::DeleteUser(const Common::UUID& uuid) {
265 265
266void ConfigureProfileManager::SetUserImage() { 266void ConfigureProfileManager::SetUserImage() {
267 const auto index = tree_view->currentIndex().row(); 267 const auto index = tree_view->currentIndex().row();
268 const auto uuid = profile_manager->GetUser(index); 268 const auto uuid = profile_manager.GetUser(index);
269 ASSERT(uuid); 269 ASSERT(uuid);
270 270
271 const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), 271 const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(),
@@ -317,7 +317,7 @@ void ConfigureProfileManager::SetUserImage() {
317 } 317 }
318 } 318 }
319 319
320 const auto username = GetAccountUsername(*profile_manager, *uuid); 320 const auto username = GetAccountUsername(profile_manager, *uuid);
321 item_model->setItem(index, 0, 321 item_model->setItem(index, 0,
322 new QStandardItem{GetIcon(*uuid), FormatUserEntryText(username, *uuid)}); 322 new QStandardItem{GetIcon(*uuid), FormatUserEntryText(username, *uuid)});
323 UpdateCurrentUser(); 323 UpdateCurrentUser();
diff --git a/src/yuzu/configuration/configure_profile_manager.h b/src/yuzu/configuration/configure_profile_manager.h
index c4b1a334e..39560fdd9 100644
--- a/src/yuzu/configuration/configure_profile_manager.h
+++ b/src/yuzu/configuration/configure_profile_manager.h
@@ -52,7 +52,7 @@ class ConfigureProfileManager : public QWidget {
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 explicit ConfigureProfileManager(const Core::System& system_, QWidget* parent = nullptr); 55 explicit ConfigureProfileManager(Core::System& system_, QWidget* parent = nullptr);
56 ~ConfigureProfileManager() override; 56 ~ConfigureProfileManager() override;
57 57
58 void ApplyConfiguration(); 58 void ApplyConfiguration();
@@ -85,7 +85,6 @@ private:
85 std::unique_ptr<Ui::ConfigureProfileManager> ui; 85 std::unique_ptr<Ui::ConfigureProfileManager> ui;
86 bool enabled = false; 86 bool enabled = false;
87 87
88 std::unique_ptr<Service::Account::ProfileManager> profile_manager; 88 Service::Account::ProfileManager& profile_manager;
89
90 const Core::System& system; 89 const Core::System& system;
91}; 90};
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index b056c3717..f31ed7ebb 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -346,7 +346,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk
346 SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); 346 SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue());
347 discord_rpc->Update(); 347 discord_rpc->Update();
348 348
349 play_time_manager = std::make_unique<PlayTime::PlayTimeManager>(); 349 play_time_manager = std::make_unique<PlayTime::PlayTimeManager>(system->GetProfileManager());
350 350
351 system->GetRoomNetwork().Init(); 351 system->GetRoomNetwork().Init();
352 352
@@ -526,8 +526,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk
526 continue; 526 continue;
527 } 527 }
528 528
529 const Service::Account::ProfileManager manager; 529 if (!system->GetProfileManager().UserExistsIndex(selected_user)) {
530 if (!manager.UserExistsIndex(selected_user)) {
531 LOG_ERROR(Frontend, "Selected user doesn't exist"); 530 LOG_ERROR(Frontend, "Selected user doesn't exist");
532 continue; 531 continue;
533 } 532 }
@@ -691,7 +690,7 @@ void GMainWindow::ControllerSelectorRequestExit() {
691 690
692void GMainWindow::ProfileSelectorSelectProfile( 691void GMainWindow::ProfileSelectorSelectProfile(
693 const Core::Frontend::ProfileSelectParameters& parameters) { 692 const Core::Frontend::ProfileSelectParameters& parameters) {
694 profile_select_applet = new QtProfileSelectionDialog(system->HIDCore(), this, parameters); 693 profile_select_applet = new QtProfileSelectionDialog(*system, this, parameters);
695 SCOPE_EXIT({ 694 SCOPE_EXIT({
696 profile_select_applet->deleteLater(); 695 profile_select_applet->deleteLater();
697 profile_select_applet = nullptr; 696 profile_select_applet = nullptr;
@@ -706,8 +705,8 @@ void GMainWindow::ProfileSelectorSelectProfile(
706 return; 705 return;
707 } 706 }
708 707
709 const Service::Account::ProfileManager manager; 708 const auto uuid = system->GetProfileManager().GetUser(
710 const auto uuid = manager.GetUser(static_cast<std::size_t>(profile_select_applet->GetIndex())); 709 static_cast<std::size_t>(profile_select_applet->GetIndex()));
711 if (!uuid.has_value()) { 710 if (!uuid.has_value()) {
712 emit ProfileSelectorFinishedSelection(std::nullopt); 711 emit ProfileSelectorFinishedSelection(std::nullopt);
713 return; 712 return;
@@ -1856,7 +1855,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
1856 1855
1857bool GMainWindow::SelectAndSetCurrentUser( 1856bool GMainWindow::SelectAndSetCurrentUser(
1858 const Core::Frontend::ProfileSelectParameters& parameters) { 1857 const Core::Frontend::ProfileSelectParameters& parameters) {
1859 QtProfileSelectionDialog dialog(system->HIDCore(), this, parameters); 1858 QtProfileSelectionDialog dialog(*system, this, parameters);
1860 dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | 1859 dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
1861 Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); 1860 Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
1862 dialog.setWindowModality(Qt::WindowModal); 1861 dialog.setWindowModality(Qt::WindowModal);
@@ -2271,7 +2270,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
2271 .display_options = {}, 2270 .display_options = {},
2272 .purpose = Service::AM::Applets::UserSelectionPurpose::General, 2271 .purpose = Service::AM::Applets::UserSelectionPurpose::General,
2273 }; 2272 };
2274 QtProfileSelectionDialog dialog(system->HIDCore(), this, parameters); 2273 QtProfileSelectionDialog dialog(*system, this, parameters);
2275 dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | 2274 dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
2276 Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); 2275 Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
2277 dialog.setWindowModality(Qt::WindowModal); 2276 dialog.setWindowModality(Qt::WindowModal);
@@ -2288,8 +2287,8 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
2288 return; 2287 return;
2289 } 2288 }
2290 2289
2291 Service::Account::ProfileManager manager; 2290 const auto user_id =
2292 const auto user_id = manager.GetUser(static_cast<std::size_t>(index)); 2291 system->GetProfileManager().GetUser(static_cast<std::size_t>(index));
2293 ASSERT(user_id); 2292 ASSERT(user_id);
2294 2293
2295 const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( 2294 const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp
index 603e9ae3d..41692c05b 100644
--- a/src/yuzu/multiplayer/lobby.cpp
+++ b/src/yuzu/multiplayer/lobby.cpp
@@ -27,9 +27,9 @@
27Lobby::Lobby(QWidget* parent, QStandardItemModel* list, 27Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
28 std::shared_ptr<Core::AnnounceMultiplayerSession> session, Core::System& system_) 28 std::shared_ptr<Core::AnnounceMultiplayerSession> session, Core::System& system_)
29 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), 29 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
30 ui(std::make_unique<Ui::Lobby>()), announce_multiplayer_session(session), 30 ui(std::make_unique<Ui::Lobby>()),
31 profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_}, 31 announce_multiplayer_session(session), system{system_}, room_network{
32 room_network{system.GetRoomNetwork()} { 32 system.GetRoomNetwork()} {
33 ui->setupUi(this); 33 ui->setupUi(this);
34 34
35 // setup the watcher for background connections 35 // setup the watcher for background connections
@@ -299,14 +299,15 @@ void Lobby::OnRefreshLobby() {
299} 299}
300 300
301std::string Lobby::GetProfileUsername() { 301std::string Lobby::GetProfileUsername() {
302 const auto& current_user = profile_manager->GetUser(Settings::values.current_user.GetValue()); 302 const auto& current_user =
303 system.GetProfileManager().GetUser(Settings::values.current_user.GetValue());
303 Service::Account::ProfileBase profile{}; 304 Service::Account::ProfileBase profile{};
304 305
305 if (!current_user.has_value()) { 306 if (!current_user.has_value()) {
306 return ""; 307 return "";
307 } 308 }
308 309
309 if (!profile_manager->GetProfileBase(*current_user, profile)) { 310 if (!system.GetProfileManager().GetProfileBase(*current_user, profile)) {
310 return ""; 311 return "";
311 } 312 }
312 313
diff --git a/src/yuzu/multiplayer/lobby.h b/src/yuzu/multiplayer/lobby.h
index 2674ae7c3..e78c9cae3 100644
--- a/src/yuzu/multiplayer/lobby.h
+++ b/src/yuzu/multiplayer/lobby.h
@@ -24,10 +24,6 @@ namespace Core {
24class System; 24class System;
25} 25}
26 26
27namespace Service::Account {
28class ProfileManager;
29}
30
31/** 27/**
32 * Listing of all public games pulled from services. The lobby should be simple enough for users to 28 * Listing of all public games pulled from services. The lobby should be simple enough for users to
33 * find the game they want to play, and join it. 29 * find the game they want to play, and join it.
@@ -103,7 +99,6 @@ private:
103 99
104 QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher; 100 QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
105 std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; 101 std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
106 std::unique_ptr<Service::Account::ProfileManager> profile_manager;
107 QFutureWatcher<void>* watcher; 102 QFutureWatcher<void>* watcher;
108 Validation validation; 103 Validation validation;
109 Core::System& system; 104 Core::System& system;
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 {
20 PlayTime play_time; 20 PlayTime play_time;
21}; 21};
22 22
23std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { 23std::optional<std::filesystem::path> GetCurrentUserPlayTimePath(
24 const Service::Account::ProfileManager manager; 24 const Service::Account::ProfileManager& manager) {
25 const auto uuid = manager.GetUser(static_cast<s32>(Settings::values.current_user)); 25 const auto uuid = manager.GetUser(static_cast<s32>(Settings::values.current_user));
26 if (!uuid.has_value()) { 26 if (!uuid.has_value()) {
27 return std::nullopt; 27 return std::nullopt;
@@ -30,8 +30,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() {
30 uuid->RawString().append(".bin"); 30 uuid->RawString().append(".bin");
31} 31}
32 32
33[[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db) { 33[[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db,
34 const auto filename = GetCurrentUserPlayTimePath(); 34 const Service::Account::ProfileManager& manager) {
35 const auto filename = GetCurrentUserPlayTimePath(manager);
35 36
36 if (!filename.has_value()) { 37 if (!filename.has_value()) {
37 LOG_ERROR(Frontend, "Failed to get current user path"); 38 LOG_ERROR(Frontend, "Failed to get current user path");
@@ -66,8 +67,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() {
66 return true; 67 return true;
67} 68}
68 69
69[[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db) { 70[[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db,
70 const auto filename = GetCurrentUserPlayTimePath(); 71 const Service::Account::ProfileManager& manager) {
72 const auto filename = GetCurrentUserPlayTimePath(manager);
71 73
72 if (!filename.has_value()) { 74 if (!filename.has_value()) {
73 LOG_ERROR(Frontend, "Failed to get current user path"); 75 LOG_ERROR(Frontend, "Failed to get current user path");
@@ -96,8 +98,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() {
96 98
97} // namespace 99} // namespace
98 100
99PlayTimeManager::PlayTimeManager() { 101PlayTimeManager::PlayTimeManager(Service::Account::ProfileManager& profile_manager)
100 if (!ReadPlayTimeFile(database)) { 102 : manager{profile_manager} {
103 if (!ReadPlayTimeFile(database, manager)) {
101 LOG_ERROR(Frontend, "Failed to read play time database! Resetting to default."); 104 LOG_ERROR(Frontend, "Failed to read play time database! Resetting to default.");
102 } 105 }
103} 106}
@@ -142,7 +145,7 @@ void PlayTimeManager::AutoTimestamp(std::stop_token stop_token) {
142} 145}
143 146
144void PlayTimeManager::Save() { 147void PlayTimeManager::Save() {
145 if (!WritePlayTimeFile(database)) { 148 if (!WritePlayTimeFile(database, manager)) {
146 LOG_ERROR(Frontend, "Failed to update play time database!"); 149 LOG_ERROR(Frontend, "Failed to update play time database!");
147 } 150 }
148} 151}
diff --git a/src/yuzu/play_time_manager.h b/src/yuzu/play_time_manager.h
index 5f96f3447..1714b9131 100644
--- a/src/yuzu/play_time_manager.h
+++ b/src/yuzu/play_time_manager.h
@@ -11,6 +11,10 @@
11#include "common/common_types.h" 11#include "common/common_types.h"
12#include "common/polyfill_thread.h" 12#include "common/polyfill_thread.h"
13 13
14namespace Service::Account {
15class ProfileManager;
16}
17
14namespace PlayTime { 18namespace PlayTime {
15 19
16using ProgramId = u64; 20using ProgramId = u64;
@@ -19,7 +23,7 @@ using PlayTimeDatabase = std::map<ProgramId, PlayTime>;
19 23
20class PlayTimeManager { 24class PlayTimeManager {
21public: 25public:
22 explicit PlayTimeManager(); 26 explicit PlayTimeManager(Service::Account::ProfileManager& profile_manager);
23 ~PlayTimeManager(); 27 ~PlayTimeManager();
24 28
25 YUZU_NON_COPYABLE(PlayTimeManager); 29 YUZU_NON_COPYABLE(PlayTimeManager);
@@ -32,11 +36,13 @@ public:
32 void Stop(); 36 void Stop();
33 37
34private: 38private:
39 void AutoTimestamp(std::stop_token stop_token);
40 void Save();
41
35 PlayTimeDatabase database; 42 PlayTimeDatabase database;
36 u64 running_program_id; 43 u64 running_program_id;
37 std::jthread play_time_thread; 44 std::jthread play_time_thread;
38 void AutoTimestamp(std::stop_token stop_token); 45 Service::Account::ProfileManager& manager;
39 void Save();
40}; 46};
41 47
42QString ReadablePlayTime(qulonglong time_seconds); 48QString ReadablePlayTime(qulonglong time_seconds);