diff options
author | Mat M <mathew1800@gmail.com> | 2018-10-24 10:10:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-24 10:10:29 -0400 |
commit | 77e705a8fa0a70dac2eb81b95fedc5e98d7c274e (patch) | |
tree | 29bf11e757a34d608652b901f9c58ce4ad25aeaf /src/yuzu/main.cpp | |
parent | a94e5d9e68619a90c9171a5198162bc74fb88f22 (diff) | |
parent | e7ac42677be6c13e5286fb42004aa94b0da45391 (diff) |
Merge pull request #1468 from DarkLordZach/profile-manager-ui
qt: Add UI to manage emulated user profiles
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index be9896614..47f494841 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -10,6 +10,7 @@ // VFS includes must be before glad as they will conflict with Windows file api, which uses defines. #include "core/file_sys/vfs.h" #include "core/file_sys/vfs_real.h" +#include "core/hle/service/acc/profile_manager.h" // These are wrappers to avoid the calls to CreateDirectory and CreateFile becuase of the Windows // defines. @@ -757,12 +758,43 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target open_target = "Save Data"; const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); ASSERT(program_id != 0); - // TODO(tech4me): Update this to work with arbitrary user profile - // Refer to core/hle/service/acc/profile_manager.cpp ProfileManager constructor - constexpr u128 user_id = {1, 0}; + + Service::Account::ProfileManager manager{}; + const auto user_ids = manager.GetAllUsers(); + QStringList list; + for (const auto& user_id : user_ids) { + if (user_id == Service::Account::UUID{}) + continue; + Service::Account::ProfileBase base; + if (!manager.GetProfileBase(user_id, base)) + continue; + + list.push_back(QString::fromStdString(Common::StringFromFixedZeroTerminatedBuffer( + reinterpret_cast<const char*>(base.username.data()), base.username.size()))); + } + + bool ok = false; + const auto index_string = + QInputDialog::getItem(this, tr("Select User"), + tr("Please select the user's save data you would like to open."), + list, Settings::values.current_user, false, &ok); + if (!ok) + return; + + const auto index = list.indexOf(index_string); + ASSERT(index != -1 && index < 8); + + const auto user_id = manager.GetUser(index); + ASSERT(user_id != boost::none); path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, - program_id, user_id, 0); + program_id, user_id->uuid, 0); + + if (!FileUtil::Exists(path)) { + FileUtil::CreateFullPath(path); + FileUtil::CreateDir(path); + } + break; } case GameListOpenTarget::ModData: { |