diff options
| author | 2024-01-17 09:06:45 -0800 | |
|---|---|---|
| committer | 2024-01-17 10:31:00 -0800 | |
| commit | dff0a7c52a73a3989b788b5328a782e995f07c8c (patch) | |
| tree | 810018315b3a2399de10e952095adaabb28cc7ad /src/core | |
| parent | Merge pull request #12689 from liamwhite/remove-format (diff) | |
| download | yuzu-dff0a7c52a73a3989b788b5328a782e995f07c8c.tar.gz yuzu-dff0a7c52a73a3989b788b5328a782e995f07c8c.tar.xz yuzu-dff0a7c52a73a3989b788b5328a782e995f07c8c.zip | |
Allow -u to accept a username string in addition to index, and suppress the User selector even if settings requires it to be shown for one instance only.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 17 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 683f44e27..aff97b999 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/fs/path_util.h" | 11 | #include "common/fs/path_util.h" |
| 12 | #include "common/polyfill_ranges.h" | 12 | #include "common/polyfill_ranges.h" |
| 13 | #include "common/settings.h" | 13 | #include "common/settings.h" |
| 14 | #include "common/string_util.h" | ||
| 14 | #include "core/hle/service/acc/profile_manager.h" | 15 | #include "core/hle/service/acc/profile_manager.h" |
| 15 | 16 | ||
| 16 | namespace Service::Account { | 17 | namespace Service::Account { |
| @@ -164,6 +165,22 @@ std::optional<std::size_t> ProfileManager::GetUserIndex(const ProfileInfo& user) | |||
| 164 | return GetUserIndex(user.user_uuid); | 165 | return GetUserIndex(user.user_uuid); |
| 165 | } | 166 | } |
| 166 | 167 | ||
| 168 | /// Returns the first user profile seen based on username (which does not enforce uniqueness) | ||
| 169 | std::optional<std::size_t> ProfileManager::GetUserIndex(const std::string& username) const { | ||
| 170 | const auto iter = | ||
| 171 | std::find_if(profiles.begin(), profiles.end(), [&username](const ProfileInfo& p) { | ||
| 172 | const std::string pusername = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 173 | reinterpret_cast<const char*>(p.username.data()), p.username.size()); | ||
| 174 | |||
| 175 | return username.compare(pusername) == 0; | ||
| 176 | }); | ||
| 177 | if (iter == profiles.end()) { | ||
| 178 | return std::nullopt; | ||
| 179 | } | ||
| 180 | |||
| 181 | return static_cast<std::size_t>(std::distance(profiles.begin(), iter)); | ||
| 182 | } | ||
| 183 | |||
| 167 | /// Returns the data structure used by the switch when GetProfileBase is called on acc:* | 184 | /// Returns the data structure used by the switch when GetProfileBase is called on acc:* |
| 168 | bool ProfileManager::GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const { | 185 | bool ProfileManager::GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const { |
| 169 | if (!index || index >= MAX_USERS) { | 186 | if (!index || index >= MAX_USERS) { |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index e21863e64..f94157300 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -70,6 +70,7 @@ public: | |||
| 70 | std::optional<Common::UUID> GetUser(std::size_t index) const; | 70 | std::optional<Common::UUID> GetUser(std::size_t index) const; |
| 71 | std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const; | 71 | std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const; |
| 72 | std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; | 72 | std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; |
| 73 | std::optional<std::size_t> GetUserIndex(const std::string& username) const; | ||
| 73 | bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const; | 74 | bool GetProfileBase(std::optional<std::size_t> index, ProfileBase& profile) const; |
| 74 | bool GetProfileBase(Common::UUID uuid, ProfileBase& profile) const; | 75 | bool GetProfileBase(Common::UUID uuid, ProfileBase& profile) const; |
| 75 | bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const; | 76 | bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const; |