From 466960c8ab3c10091058e4472d7d2b3aa3c808f0 Mon Sep 17 00:00:00 2001
From: Zach Hilman <zachhilman@gmail.com>
Date: Tue, 9 Oct 2018 21:53:26 -0400
Subject: [PATCH] qt: Allow user to select emu user on open save data

---
 src/yuzu/main.cpp | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index be98966145..1de3b817f8 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: {
-- 
GitLab