diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2018-08-08 15:41:12 +0200 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2018-08-08 15:41:12 +0200 |
commit | 03d7faf58390216729eb828b08be7e5f0ef82727 (patch) | |
tree | 07fd1fb940cf6893bf66a000f495807ba637d9eb /src/core/hle/service/acc/profile_manager.cpp | |
parent | began initial implementation of "ProfileManager" (diff) | |
download | yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.tar yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.tar.gz yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.tar.bz2 yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.tar.lz yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.tar.xz yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.tar.zst yuzu-03d7faf58390216729eb828b08be7e5f0ef82727.zip |
Diffstat (limited to 'src/core/hle/service/acc/profile_manager.cpp')
-rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 8819c5703..925022018 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -43,10 +43,13 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, std::array<u8, 0x20> usernam prof_inf.username = username; prof_inf.data = std::array<u8, MAX_DATA>(); prof_inf.creation_time = 0x0; + prof_inf.is_open = false; return AddUser(prof_inf); } size_t ProfileManager::GetUserIndex(UUID uuid) { + if (!uuid) + return -1; for (unsigned i = 0; i < user_count; i++) if (profiles[i].user_uuid == uuid) return i; @@ -86,4 +89,61 @@ bool ProfileManager::UserExists(UUID uuid) { return (GetUserIndex(uuid) != -1); } +void ProfileManager::OpenUser(UUID uuid) { + auto idx = GetUserIndex(uuid); + if (idx == -1) + return; + profiles[idx].is_open = true; + last_openned_user = uuid; +} + +void ProfileManager::CloseUser(UUID uuid) { + auto idx = GetUserIndex(uuid); + if (idx == -1) + return; + profiles[idx].is_open = false; +} + +std::array<UUID, MAX_USERS> ProfileManager::GetAllUsers() { + std::array<UUID, MAX_USERS> output; + for (unsigned i = 0; i < user_count; i++) { + output[i] = profiles[i].user_uuid; + } + return output; +} + +std::array<UUID, MAX_USERS> ProfileManager::GetOpenUsers() { + std::array<UUID, MAX_USERS> output; + unsigned user_idx = 0; + for (unsigned i = 0; i < user_count; i++) { + if (profiles[i].is_open) { + output[i++] = profiles[i].user_uuid; + } + } + return output; +} + +const UUID& ProfileManager::GetLastOpennedUser() { + return last_openned_user; +} + +bool ProfileManager::GetProfileBaseAndData(size_t index, ProfileBase& profile, + std::array<u8, MAX_DATA>& data) { + if (GetProfileBase(index, profile)) { + std::memcpy(data.data(), profiles[index].data.data(), MAX_DATA); + return true; + } + return false; +} +bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile, + std::array<u8, MAX_DATA>& data) { + auto idx = GetUserIndex(uuid); + return GetProfileBaseAndData(idx, profile, data); +} + +bool ProfileManager::GetProfileBaseAndData(ProfileInfo user, ProfileBase& profile, + std::array<u8, MAX_DATA>& data) { + return GetProfileBaseAndData(user.user_uuid, profile, data); +} + }; // namespace Service::Account |