From 466960c8ab3c10091058e4472d7d2b3aa3c808f0 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Tue, 9 Oct 2018 21:53:26 -0400 Subject: qt: Allow user to select emu user on open save data --- src/yuzu/main.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index be9896614..1de3b817f 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -757,12 +757,33 @@ 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}; + + QStringList list{}; + std::transform(Settings::values.users.begin(), Settings::values.users.end(), + std::back_inserter(list), + [](const auto& user) { return QString::fromStdString(user.first); }); + + 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); + + const auto user_id = Settings::values.users[index].second.uuid; path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, program_id, user_id, 0); + + if (!FileUtil::Exists(path)) { + FileUtil::CreateFullPath(path); + FileUtil::CreateDir(path); + } + break; } case GameListOpenTarget::ModData: { -- cgit v1.2.3 From 702622b8f1eaa1b297a27a305ac56faeadf542d7 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 10 Oct 2018 21:49:20 -0400 Subject: profile_manager: Load user icons, names, and UUIDs from system save --- src/yuzu/main.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 1de3b817f..9a3535e77 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. @@ -758,10 +759,22 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); ASSERT(program_id != 0); - QStringList list{}; - std::transform(Settings::values.users.begin(), Settings::values.users.end(), - std::back_inserter(list), - [](const auto& user) { return QString::fromStdString(user.first); }); + Service::Account::ProfileManager manager{}; + const auto user_ids = manager.GetAllUsers(); + QStringList list; + std::transform( + user_ids.begin(), user_ids.end(), std::back_inserter(list), + [&manager](const auto& user_id) -> QString { + if (user_id == Service::Account::UUID{}) + return ""; + Service::Account::ProfileBase base; + if (!manager.GetProfileBase(user_id, base)) + return ""; + + return QString::fromStdString(Common::StringFromFixedZeroTerminatedBuffer( + reinterpret_cast(base.username.data()), base.username.size())); + }); + list.removeAll(""); bool ok = false; const auto index_string = @@ -772,12 +785,12 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target return; const auto index = list.indexOf(index_string); - ASSERT(index != -1); + ASSERT(index != -1 && index < 8); - const auto user_id = Settings::values.users[index].second.uuid; + const auto user_id = manager.GetAllUsers()[index]; 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); -- cgit v1.2.3 From 45f2a2fe29373f261144c097d169dad8b65fe012 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 13 Oct 2018 13:02:33 -0400 Subject: acc: Fix account UUID duplication error --- src/yuzu/main.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 9a3535e77..47f494841 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -762,19 +762,16 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target Service::Account::ProfileManager manager{}; const auto user_ids = manager.GetAllUsers(); QStringList list; - std::transform( - user_ids.begin(), user_ids.end(), std::back_inserter(list), - [&manager](const auto& user_id) -> QString { - if (user_id == Service::Account::UUID{}) - return ""; - Service::Account::ProfileBase base; - if (!manager.GetProfileBase(user_id, base)) - return ""; - - return QString::fromStdString(Common::StringFromFixedZeroTerminatedBuffer( - reinterpret_cast(base.username.data()), base.username.size())); - }); - list.removeAll(""); + 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(base.username.data()), base.username.size()))); + } bool ok = false; const auto index_string = @@ -787,10 +784,11 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target const auto index = list.indexOf(index_string); ASSERT(index != -1 && index < 8); - const auto user_id = manager.GetAllUsers()[index]; + 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.uuid, 0); + program_id, user_id->uuid, 0); if (!FileUtil::Exists(path)) { FileUtil::CreateFullPath(path); -- cgit v1.2.3