diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/acc/acc.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 24 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 29 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_system.cpp | 86 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 28 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 5 |
8 files changed, 106 insertions, 80 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index cee309cb1..cf065c2e0 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -106,6 +106,8 @@ private: | |||
| 106 | const FileUtil::IOFile image(GetImagePath(user_id), "rb"); | 106 | const FileUtil::IOFile image(GetImagePath(user_id), "rb"); |
| 107 | 107 | ||
| 108 | if (!image.IsOpen()) { | 108 | if (!image.IsOpen()) { |
| 109 | LOG_WARNING(Service_ACC, | ||
| 110 | "Failed to load user provided image! Falling back to built-in backup..."); | ||
| 109 | ctx.WriteBuffer(backup_jpeg); | 111 | ctx.WriteBuffer(backup_jpeg); |
| 110 | rb.Push<u32>(backup_jpeg_size); | 112 | rb.Push<u32>(backup_jpeg_size); |
| 111 | } else { | 113 | } else { |
| @@ -126,10 +128,13 @@ private: | |||
| 126 | 128 | ||
| 127 | const FileUtil::IOFile image(GetImagePath(user_id), "rb"); | 129 | const FileUtil::IOFile image(GetImagePath(user_id), "rb"); |
| 128 | 130 | ||
| 129 | if (!image.IsOpen()) | 131 | if (!image.IsOpen()) { |
| 132 | LOG_WARNING(Service_ACC, | ||
| 133 | "Failed to load user provided image! Falling back to built-in backup..."); | ||
| 130 | rb.Push<u32>(backup_jpeg_size); | 134 | rb.Push<u32>(backup_jpeg_size); |
| 131 | else | 135 | } else { |
| 132 | rb.Push<u32>(std::min<u32>(image.GetSize(), MAX_JPEG_IMAGE_SIZE)); | 136 | rb.Push<u32>(std::min<u32>(image.GetSize(), MAX_JPEG_IMAGE_SIZE)); |
| 137 | } | ||
| 133 | } | 138 | } |
| 134 | 139 | ||
| 135 | const ProfileManager& profile_manager; | 140 | const ProfileManager& profile_manager; |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 43743d39e..e6f1a0ae8 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -30,6 +30,8 @@ constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1); | |||
| 30 | constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, -2); | 30 | constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, -2); |
| 31 | constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20); | 31 | constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20); |
| 32 | 32 | ||
| 33 | constexpr const char* ACC_SAVE_AVATORS_BASE_PATH = "/system/save/8000000000000010/su/avators/"; | ||
| 34 | |||
| 33 | const UUID& UUID::Generate() { | 35 | const UUID& UUID::Generate() { |
| 34 | std::random_device device; | 36 | std::random_device device; |
| 35 | std::mt19937 gen(device()); | 37 | std::mt19937 gen(device()); |
| @@ -45,11 +47,11 @@ ProfileManager::ProfileManager() { | |||
| 45 | if (user_count == 0) | 47 | if (user_count == 0) |
| 46 | CreateNewUser(UUID{}.Generate(), "yuzu"); | 48 | CreateNewUser(UUID{}.Generate(), "yuzu"); |
| 47 | 49 | ||
| 48 | auto current = Settings::values.current_user; | 50 | auto current = std::clamp<int>(Settings::values.current_user, 0, MAX_USERS - 1); |
| 49 | if (!GetAllUsers()[current]) | 51 | if (UserExistsIndex(current)) |
| 50 | current = 0; | 52 | current = 0; |
| 51 | 53 | ||
| 52 | OpenUser(GetAllUsers()[current]); | 54 | OpenUser(*GetUser(current)); |
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | ProfileManager::~ProfileManager() { | 57 | ProfileManager::~ProfileManager() { |
| @@ -126,6 +128,12 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) | |||
| 126 | return CreateNewUser(uuid, username_output); | 128 | return CreateNewUser(uuid, username_output); |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 131 | boost::optional<UUID> ProfileManager::GetUser(std::size_t index) const { | ||
| 132 | if (index >= MAX_USERS) | ||
| 133 | return boost::none; | ||
| 134 | return profiles[index].user_uuid; | ||
| 135 | } | ||
| 136 | |||
| 129 | /// Returns a users profile index based on their user id. | 137 | /// Returns a users profile index based on their user id. |
| 130 | boost::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { | 138 | boost::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { |
| 131 | if (!uuid) { | 139 | if (!uuid) { |
| @@ -189,6 +197,12 @@ bool ProfileManager::UserExists(UUID uuid) const { | |||
| 189 | return (GetUserIndex(uuid) != boost::none); | 197 | return (GetUserIndex(uuid) != boost::none); |
| 190 | } | 198 | } |
| 191 | 199 | ||
| 200 | bool ProfileManager::UserExistsIndex(std::size_t index) const { | ||
| 201 | if (index >= MAX_USERS) | ||
| 202 | return false; | ||
| 203 | return profiles[index].user_uuid.uuid != INVALID_UUID; | ||
| 204 | } | ||
| 205 | |||
| 192 | /// Opens a specific user | 206 | /// Opens a specific user |
| 193 | void ProfileManager::OpenUser(UUID uuid) { | 207 | void ProfileManager::OpenUser(UUID uuid) { |
| 194 | auto idx = GetUserIndex(uuid); | 208 | auto idx = GetUserIndex(uuid); |
| @@ -292,7 +306,7 @@ bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { | |||
| 292 | 306 | ||
| 293 | void ProfileManager::ParseUserSaveFile() { | 307 | void ProfileManager::ParseUserSaveFile() { |
| 294 | FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + | 308 | FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + |
| 295 | "/system/save/8000000000000010/su/avators/profiles.dat", | 309 | ACC_SAVE_AVATORS_BASE_PATH + "profiles.dat", |
| 296 | "rb"); | 310 | "rb"); |
| 297 | 311 | ||
| 298 | ProfileDataRaw data; | 312 | ProfileDataRaw data; |
| @@ -322,7 +336,7 @@ void ProfileManager::WriteUserSaveFile() { | |||
| 322 | } | 336 | } |
| 323 | 337 | ||
| 324 | FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + | 338 | FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + |
| 325 | "/system/save/8000000000000010/su/avators/profiles.dat", | 339 | ACC_SAVE_AVATORS_BASE_PATH + "profiles.dat", |
| 326 | "wb"); | 340 | "wb"); |
| 327 | 341 | ||
| 328 | save.Resize(sizeof(ProfileDataRaw)); | 342 | save.Resize(sizeof(ProfileDataRaw)); |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 1e5c2460e..482c1d8a9 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -96,6 +96,7 @@ public: | |||
| 96 | ResultCode AddUser(const ProfileInfo& user); | 96 | ResultCode AddUser(const ProfileInfo& user); |
| 97 | ResultCode CreateNewUser(UUID uuid, const ProfileUsername& username); | 97 | ResultCode CreateNewUser(UUID uuid, const ProfileUsername& username); |
| 98 | ResultCode CreateNewUser(UUID uuid, const std::string& username); | 98 | ResultCode CreateNewUser(UUID uuid, const std::string& username); |
| 99 | boost::optional<UUID> GetUser(std::size_t index) const; | ||
| 99 | boost::optional<std::size_t> GetUserIndex(const UUID& uuid) const; | 100 | boost::optional<std::size_t> GetUserIndex(const UUID& uuid) const; |
| 100 | boost::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; | 101 | boost::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; |
| 101 | bool GetProfileBase(boost::optional<std::size_t> index, ProfileBase& profile) const; | 102 | bool GetProfileBase(boost::optional<std::size_t> index, ProfileBase& profile) const; |
| @@ -109,6 +110,7 @@ public: | |||
| 109 | std::size_t GetUserCount() const; | 110 | std::size_t GetUserCount() const; |
| 110 | std::size_t GetOpenUserCount() const; | 111 | std::size_t GetOpenUserCount() const; |
| 111 | bool UserExists(UUID uuid) const; | 112 | bool UserExists(UUID uuid) const; |
| 113 | bool UserExistsIndex(std::size_t index) const; | ||
| 112 | void OpenUser(UUID uuid); | 114 | void OpenUser(UUID uuid); |
| 113 | void CloseUser(UUID uuid); | 115 | void CloseUser(UUID uuid); |
| 114 | UserIDArray GetOpenUsers() const; | 116 | UserIDArray GetOpenUsers() const; |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 9dfcec59b..4ed66d817 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -28,7 +28,15 @@ | |||
| 28 | 28 | ||
| 29 | namespace Service::AM { | 29 | namespace Service::AM { |
| 30 | 30 | ||
| 31 | constexpr std::size_t POP_LAUNCH_PARAMETER_BUFFER_SIZE = 0x88; | 31 | constexpr u32 POP_LAUNCH_PARAMETER_MAGIC = 0xC79497CA; |
| 32 | |||
| 33 | struct LaunchParameters { | ||
| 34 | u32_le magic; | ||
| 35 | u32_le is_account_selected; | ||
| 36 | u128 current_user; | ||
| 37 | INSERT_PADDING_BYTES(0x70); | ||
| 38 | }; | ||
| 39 | static_assert(sizeof(LaunchParameters) == 0x88); | ||
| 32 | 40 | ||
| 33 | IWindowController::IWindowController() : ServiceFramework("IWindowController") { | 41 | IWindowController::IWindowController() : ServiceFramework("IWindowController") { |
| 34 | // clang-format off | 42 | // clang-format off |
| @@ -728,22 +736,23 @@ void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx | |||
| 728 | } | 736 | } |
| 729 | 737 | ||
| 730 | void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { | 738 | void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { |
| 731 | constexpr std::array<u8, 0x8> header_data{ | 739 | LaunchParameters params{}; |
| 732 | 0xca, 0x97, 0x94, 0xc7, // Magic | ||
| 733 | 1, 0, 0, 0, // IsAccountSelected (bool) | ||
| 734 | }; | ||
| 735 | 740 | ||
| 736 | std::vector<u8> buffer(POP_LAUNCH_PARAMETER_BUFFER_SIZE); | 741 | params.magic = POP_LAUNCH_PARAMETER_MAGIC; |
| 737 | 742 | params.is_account_selected = 1; | |
| 738 | std::memcpy(buffer.data(), header_data.data(), header_data.size()); | ||
| 739 | 743 | ||
| 740 | Account::ProfileManager profile_manager{}; | 744 | Account::ProfileManager profile_manager{}; |
| 741 | const auto uuid = profile_manager.GetAllUsers()[Settings::values.current_user].uuid; | 745 | const auto uuid = profile_manager.GetUser(Settings::values.current_user); |
| 742 | std::memcpy(buffer.data() + header_data.size(), uuid.data(), sizeof(u128)); | 746 | ASSERT(uuid != boost::none); |
| 747 | params.current_user = uuid->uuid; | ||
| 743 | 748 | ||
| 744 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 749 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 745 | 750 | ||
| 746 | rb.Push(RESULT_SUCCESS); | 751 | rb.Push(RESULT_SUCCESS); |
| 752 | |||
| 753 | std::vector<u8> buffer(sizeof(LaunchParameters)); | ||
| 754 | std::memcpy(buffer.data(), ¶ms, buffer.size()); | ||
| 755 | |||
| 747 | rb.PushIpcInterface<AM::IStorage>(buffer); | 756 | rb.PushIpcInterface<AM::IStorage>(buffer); |
| 748 | 757 | ||
| 749 | LOG_DEBUG(Service_AM, "called"); | 758 | LOG_DEBUG(Service_AM, "called"); |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index f7a9a8dd4..1fe9a7edd 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -125,7 +125,8 @@ void Config::ReadValues() { | |||
| 125 | Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool(); | 125 | Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool(); |
| 126 | Settings::values.enable_nfc = qt_config->value("enable_nfc", true).toBool(); | 126 | Settings::values.enable_nfc = qt_config->value("enable_nfc", true).toBool(); |
| 127 | 127 | ||
| 128 | Settings::values.current_user = std::clamp(qt_config->value("current_user", 0).toInt(), 0, 7); | 128 | Settings::values.current_user = std::clamp<int>(qt_config->value("current_user", 0).toInt(), 0, |
| 129 | Service::Account::MAX_USERS - 1); | ||
| 129 | 130 | ||
| 130 | Settings::values.language_index = qt_config->value("language_index", 1).toInt(); | 131 | Settings::values.language_index = qt_config->value("language_index", 1).toInt(); |
| 131 | qt_config->endGroup(); | 132 | qt_config->endGroup(); |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 87301b5a2..02e061ebc 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -131,38 +131,33 @@ static QPixmap GetIcon(Service::Account::UUID uuid) { | |||
| 131 | 131 | ||
| 132 | void ConfigureSystem::PopulateUserList() { | 132 | void ConfigureSystem::PopulateUserList() { |
| 133 | const auto& profiles = profile_manager->GetAllUsers(); | 133 | const auto& profiles = profile_manager->GetAllUsers(); |
| 134 | std::transform( | 134 | for (const auto& user : profiles) { |
| 135 | profiles.begin(), profiles.end(), std::back_inserter(list_items), | 135 | Service::Account::ProfileBase profile; |
| 136 | [this](const Service::Account::UUID& user) { | 136 | if (!profile_manager->GetProfileBase(user, profile)) |
| 137 | Service::Account::ProfileBase profile; | 137 | continue; |
| 138 | if (!profile_manager->GetProfileBase(user, profile)) | 138 | |
| 139 | return QList<QStandardItem*>{}; | 139 | const auto username = Common::StringFromFixedZeroTerminatedBuffer( |
| 140 | const auto username = Common::StringFromFixedZeroTerminatedBuffer( | 140 | reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); |
| 141 | reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); | 141 | |
| 142 | 142 | list_items.push_back(QList<QStandardItem*>{new QStandardItem{ | |
| 143 | return QList<QStandardItem*>{new QStandardItem{ | 143 | GetIcon(user).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), |
| 144 | GetIcon(user).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), | 144 | QString::fromStdString(username + '\n' + user.FormatSwitch())}}); |
| 145 | QString::fromStdString(username + '\n' + user.FormatSwitch())}}; | 145 | } |
| 146 | }); | ||
| 147 | |||
| 148 | list_items.erase( | ||
| 149 | std::remove_if(list_items.begin(), list_items.end(), | ||
| 150 | [](const auto& list) { return list == QList<QStandardItem*>{}; }), | ||
| 151 | list_items.end()); | ||
| 152 | 146 | ||
| 153 | for (const auto& item : list_items) | 147 | for (const auto& item : list_items) |
| 154 | item_model->appendRow(item); | 148 | item_model->appendRow(item); |
| 155 | } | 149 | } |
| 156 | 150 | ||
| 157 | void ConfigureSystem::UpdateCurrentUser() { | 151 | void ConfigureSystem::UpdateCurrentUser() { |
| 158 | ui->pm_add->setEnabled(profile_manager->GetUserCount() < 8); | 152 | ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS); |
| 159 | 153 | ||
| 160 | const auto& current_user = profile_manager->GetAllUsers()[Settings::values.current_user]; | 154 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user); |
| 161 | const auto username = GetAccountUsername(current_user); | 155 | ASSERT(current_user != boost::none); |
| 156 | const auto username = GetAccountUsername(*current_user); | ||
| 162 | 157 | ||
| 163 | scene->clear(); | 158 | scene->clear(); |
| 164 | scene->addPixmap( | 159 | scene->addPixmap( |
| 165 | GetIcon(current_user).scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); | 160 | GetIcon(*current_user).scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); |
| 166 | ui->current_user_username->setText(QString::fromStdString(username)); | 161 | ui->current_user_username->setText(QString::fromStdString(username)); |
| 167 | } | 162 | } |
| 168 | 163 | ||
| @@ -255,13 +250,12 @@ void ConfigureSystem::AddUser() { | |||
| 255 | 250 | ||
| 256 | void ConfigureSystem::RenameUser() { | 251 | void ConfigureSystem::RenameUser() { |
| 257 | const auto user = tree_view->currentIndex().row(); | 252 | const auto user = tree_view->currentIndex().row(); |
| 258 | ASSERT(user < 8); | 253 | const auto uuid = profile_manager->GetUser(user); |
| 259 | 254 | ASSERT(uuid != boost::none); | |
| 260 | const auto uuid = profile_manager->GetAllUsers()[user]; | 255 | const auto username = GetAccountUsername(*uuid); |
| 261 | const auto username = GetAccountUsername(uuid); | ||
| 262 | 256 | ||
| 263 | Service::Account::ProfileBase profile; | 257 | Service::Account::ProfileBase profile; |
| 264 | if (!profile_manager->GetProfileBase(uuid, profile)) | 258 | if (!profile_manager->GetProfileBase(*uuid, profile)) |
| 265 | return; | 259 | return; |
| 266 | 260 | ||
| 267 | bool ok = false; | 261 | bool ok = false; |
| @@ -273,26 +267,28 @@ void ConfigureSystem::RenameUser() { | |||
| 273 | return; | 267 | return; |
| 274 | 268 | ||
| 275 | const auto username_std = new_username.toStdString(); | 269 | const auto username_std = new_username.toStdString(); |
| 276 | if (username_std.size() > profile.username.size()) | 270 | if (username_std.size() > profile.username.size()) { |
| 277 | std::copy_n(username_std.begin(), profile.username.size(), profile.username.begin()); | 271 | std::copy_n(username_std.begin(), std::min(profile.username.size(), username_std.size()), |
| 278 | else | 272 | profile.username.begin()); |
| 273 | } else { | ||
| 279 | std::copy(username_std.begin(), username_std.end(), profile.username.begin()); | 274 | std::copy(username_std.begin(), username_std.end(), profile.username.begin()); |
| 275 | } | ||
| 280 | 276 | ||
| 281 | profile_manager->SetProfileBase(uuid, profile); | 277 | profile_manager->SetProfileBase(*uuid, profile); |
| 282 | 278 | ||
| 283 | item_model->setItem( | 279 | item_model->setItem( |
| 284 | user, 0, | 280 | user, 0, |
| 285 | new QStandardItem{ | 281 | new QStandardItem{ |
| 286 | GetIcon(uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), | 282 | GetIcon(*uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), |
| 287 | QString::fromStdString(username_std + '\n' + uuid.FormatSwitch())}); | 283 | QString::fromStdString(username_std + '\n' + uuid->FormatSwitch())}); |
| 288 | UpdateCurrentUser(); | 284 | UpdateCurrentUser(); |
| 289 | } | 285 | } |
| 290 | 286 | ||
| 291 | void ConfigureSystem::DeleteUser() { | 287 | void ConfigureSystem::DeleteUser() { |
| 292 | const auto index = tree_view->currentIndex().row(); | 288 | const auto index = tree_view->currentIndex().row(); |
| 293 | ASSERT(index < 8); | 289 | const auto uuid = profile_manager->GetUser(index); |
| 294 | const auto uuid = profile_manager->GetAllUsers()[index]; | 290 | ASSERT(uuid != boost::none); |
| 295 | const auto username = GetAccountUsername(uuid); | 291 | const auto username = GetAccountUsername(*uuid); |
| 296 | 292 | ||
| 297 | const auto confirm = QMessageBox::question( | 293 | const auto confirm = QMessageBox::question( |
| 298 | this, tr("Confirm Delete"), | 294 | this, tr("Confirm Delete"), |
| @@ -305,7 +301,7 @@ void ConfigureSystem::DeleteUser() { | |||
| 305 | Settings::values.current_user = 0; | 301 | Settings::values.current_user = 0; |
| 306 | UpdateCurrentUser(); | 302 | UpdateCurrentUser(); |
| 307 | 303 | ||
| 308 | if (!profile_manager->RemoveUser(uuid)) | 304 | if (!profile_manager->RemoveUser(*uuid)) |
| 309 | return; | 305 | return; |
| 310 | 306 | ||
| 311 | item_model->removeRows(tree_view->currentIndex().row(), 1); | 307 | item_model->removeRows(tree_view->currentIndex().row(), 1); |
| @@ -317,9 +313,9 @@ void ConfigureSystem::DeleteUser() { | |||
| 317 | 313 | ||
| 318 | void ConfigureSystem::SetUserImage() { | 314 | void ConfigureSystem::SetUserImage() { |
| 319 | const auto index = tree_view->currentIndex().row(); | 315 | const auto index = tree_view->currentIndex().row(); |
| 320 | ASSERT(index < 8); | 316 | const auto uuid = profile_manager->GetUser(index); |
| 321 | const auto uuid = profile_manager->GetAllUsers()[index]; | 317 | ASSERT(uuid != boost::none); |
| 322 | const auto username = GetAccountUsername(uuid); | 318 | const auto username = GetAccountUsername(*uuid); |
| 323 | 319 | ||
| 324 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), | 320 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), |
| 325 | "JPEG Images (*.jpg *.jpeg)"); | 321 | "JPEG Images (*.jpg *.jpeg)"); |
| @@ -327,20 +323,20 @@ void ConfigureSystem::SetUserImage() { | |||
| 327 | if (file.isEmpty()) | 323 | if (file.isEmpty()) |
| 328 | return; | 324 | return; |
| 329 | 325 | ||
| 330 | FileUtil::Delete(GetImagePath(uuid)); | 326 | FileUtil::Delete(GetImagePath(*uuid)); |
| 331 | 327 | ||
| 332 | const auto raw_path = | 328 | const auto raw_path = |
| 333 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010"; | 329 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010"; |
| 334 | if (FileUtil::Exists(raw_path) && !FileUtil::IsDirectory(raw_path)) | 330 | if (FileUtil::Exists(raw_path) && !FileUtil::IsDirectory(raw_path)) |
| 335 | FileUtil::Delete(raw_path); | 331 | FileUtil::Delete(raw_path); |
| 336 | 332 | ||
| 337 | FileUtil::CreateFullPath(GetImagePath(uuid)); | 333 | FileUtil::CreateFullPath(GetImagePath(*uuid)); |
| 338 | FileUtil::Copy(file.toStdString(), GetImagePath(uuid)); | 334 | FileUtil::Copy(file.toStdString(), GetImagePath(*uuid)); |
| 339 | 335 | ||
| 340 | item_model->setItem( | 336 | item_model->setItem( |
| 341 | index, 0, | 337 | index, 0, |
| 342 | new QStandardItem{ | 338 | new QStandardItem{ |
| 343 | GetIcon(uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), | 339 | GetIcon(*uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), |
| 344 | QString::fromStdString(username + '\n' + uuid.FormatSwitch())}); | 340 | QString::fromStdString(username + '\n' + uuid->FormatSwitch())}); |
| 345 | UpdateCurrentUser(); | 341 | UpdateCurrentUser(); |
| 346 | } | 342 | } |
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 | |||
| 762 | Service::Account::ProfileManager manager{}; | 762 | Service::Account::ProfileManager manager{}; |
| 763 | const auto user_ids = manager.GetAllUsers(); | 763 | const auto user_ids = manager.GetAllUsers(); |
| 764 | QStringList list; | 764 | QStringList list; |
| 765 | std::transform( | 765 | for (const auto& user_id : user_ids) { |
| 766 | user_ids.begin(), user_ids.end(), std::back_inserter(list), | 766 | if (user_id == Service::Account::UUID{}) |
| 767 | [&manager](const auto& user_id) -> QString { | 767 | continue; |
| 768 | if (user_id == Service::Account::UUID{}) | 768 | Service::Account::ProfileBase base; |
| 769 | return ""; | 769 | if (!manager.GetProfileBase(user_id, base)) |
| 770 | Service::Account::ProfileBase base; | 770 | continue; |
| 771 | if (!manager.GetProfileBase(user_id, base)) | 771 | |
| 772 | return ""; | 772 | list.push_back(QString::fromStdString(Common::StringFromFixedZeroTerminatedBuffer( |
| 773 | 773 | reinterpret_cast<const char*>(base.username.data()), base.username.size()))); | |
| 774 | return QString::fromStdString(Common::StringFromFixedZeroTerminatedBuffer( | 774 | } |
| 775 | reinterpret_cast<const char*>(base.username.data()), base.username.size())); | ||
| 776 | }); | ||
| 777 | list.removeAll(""); | ||
| 778 | 775 | ||
| 779 | bool ok = false; | 776 | bool ok = false; |
| 780 | const auto index_string = | 777 | const auto index_string = |
| @@ -787,10 +784,11 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 787 | const auto index = list.indexOf(index_string); | 784 | const auto index = list.indexOf(index_string); |
| 788 | ASSERT(index != -1 && index < 8); | 785 | ASSERT(index != -1 && index < 8); |
| 789 | 786 | ||
| 790 | const auto user_id = manager.GetAllUsers()[index]; | 787 | const auto user_id = manager.GetUser(index); |
| 788 | ASSERT(user_id != boost::none); | ||
| 791 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, | 789 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, |
| 792 | FileSys::SaveDataType::SaveData, | 790 | FileSys::SaveDataType::SaveData, |
| 793 | program_id, user_id.uuid, 0); | 791 | program_id, user_id->uuid, 0); |
| 794 | 792 | ||
| 795 | if (!FileUtil::Exists(path)) { | 793 | if (!FileUtil::Exists(path)) { |
| 796 | FileUtil::CreateFullPath(path); | 794 | FileUtil::CreateFullPath(path); |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index f6083dcb3..b456266a6 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/file_util.h" | 8 | #include "common/file_util.h" |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/param_package.h" | 10 | #include "common/param_package.h" |
| 11 | #include "core/hle/service/acc/profile_manager.h" | ||
| 11 | #include "core/settings.h" | 12 | #include "core/settings.h" |
| 12 | #include "input_common/main.h" | 13 | #include "input_common/main.h" |
| 13 | #include "yuzu_cmd/config.h" | 14 | #include "yuzu_cmd/config.h" |
| @@ -128,8 +129,8 @@ void Config::ReadValues() { | |||
| 128 | Settings::values.enable_nfc = sdl2_config->GetBoolean("System", "enable_nfc", true); | 129 | Settings::values.enable_nfc = sdl2_config->GetBoolean("System", "enable_nfc", true); |
| 129 | const auto size = sdl2_config->GetInteger("System", "users_size", 0); | 130 | const auto size = sdl2_config->GetInteger("System", "users_size", 0); |
| 130 | 131 | ||
| 131 | Settings::values.current_user = | 132 | Settings::values.current_user = std::clamp<int>( |
| 132 | std::clamp<int>(sdl2_config->GetInteger("System", "current_user", 0), 0, 7); | 133 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); |
| 133 | 134 | ||
| 134 | // Miscellaneous | 135 | // Miscellaneous |
| 135 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); | 136 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); |