[XAM] ProfileManager: Renamed GetProfiles to GetAccounts
This is to prevent confusion between signed-in accounts (aka. Profiles) and all entries (Accounts) Also added GetAccount to get specific instead of all of them when not needed
This commit is contained in:
parent
b17faf84f2
commit
2b49fc2ddc
|
@ -263,7 +263,7 @@ void EmulatorWindow::OnEmulatorInitialized() {
|
|||
if (!emulator_->kernel_state()
|
||||
->xam_state()
|
||||
->profile_manager()
|
||||
->GetProfilesCount()) {
|
||||
->GetAccountCount()) {
|
||||
new NoProfileDialog(imgui_drawer_.get(), this);
|
||||
disable_hotkeys_ = true;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void CreateProfileDialog::OnDraw(ImGuiIO& io) {
|
|||
|
||||
ImGui::BeginDisabled(!valid);
|
||||
if (ImGui::Button("Create")) {
|
||||
bool autologin = (profile_manager->GetProfilesCount() == 0);
|
||||
bool autologin = (profile_manager->GetAccountCount() == 0);
|
||||
if (profile_manager->CreateProfile(gamertag_string, autologin,
|
||||
migration_) &&
|
||||
migration_) {
|
||||
|
@ -89,7 +89,7 @@ void NoProfileDialog::OnDraw(ImGuiIO& io) {
|
|||
->xam_state()
|
||||
->profile_manager();
|
||||
|
||||
if (profile_manager->GetProfilesCount()) {
|
||||
if (profile_manager->GetAccountCount()) {
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ void ProfileConfigDialog::OnDraw(ImGuiIO& io) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto profiles = profile_manager->GetProfiles();
|
||||
auto profiles = profile_manager->GetAccounts();
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(40, 40), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowBgAlpha(0.8f);
|
||||
|
|
|
@ -466,6 +466,14 @@ bool ProfileManager::CreateProfile(const std::string gamertag, bool autologin,
|
|||
return is_account_created;
|
||||
}
|
||||
|
||||
const X_XAMACCOUNTINFO* ProfileManager::GetAccount(const uint64_t xuid) {
|
||||
if (!accounts_.count(xuid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &accounts_[xuid];
|
||||
}
|
||||
|
||||
bool ProfileManager::CreateAccount(const uint64_t xuid,
|
||||
const std::string gamertag) {
|
||||
X_XAMACCOUNTINFO account = {};
|
||||
|
|
|
@ -103,9 +103,12 @@ class ProfileManager {
|
|||
UserProfile* GetProfile(const uint8_t user_index) const;
|
||||
uint8_t GetUserIndexAssignedToProfile(const uint64_t xuid) const;
|
||||
|
||||
std::map<uint64_t, X_XAMACCOUNTINFO>* GetProfiles() { return &accounts_; }
|
||||
const std::map<uint64_t, X_XAMACCOUNTINFO>* GetAccounts() {
|
||||
return &accounts_;
|
||||
}
|
||||
const X_XAMACCOUNTINFO* GetAccount(const uint64_t xuid);
|
||||
|
||||
uint32_t GetProfilesCount() const {
|
||||
uint32_t GetAccountCount() const {
|
||||
return static_cast<uint32_t>(accounts_.size());
|
||||
}
|
||||
bool IsAnyProfileSignedIn() const { return !logged_profiles_.empty(); }
|
||||
|
|
|
@ -137,10 +137,10 @@ dword_result_t XamProfileCreateEnumerator_entry(dword_t device_id,
|
|||
return result;
|
||||
}
|
||||
|
||||
const auto& profiles =
|
||||
kernel_state()->xam_state()->profile_manager()->GetProfiles();
|
||||
const auto& accounts =
|
||||
kernel_state()->xam_state()->profile_manager()->GetAccounts();
|
||||
|
||||
for (const auto& [xuid, account] : *profiles) {
|
||||
for (const auto& [xuid, account] : *accounts) {
|
||||
X_PROFILEENUMRESULT* profile = e->AppendItem();
|
||||
|
||||
profile->xuid_offline = xuid;
|
||||
|
|
|
@ -1051,7 +1051,6 @@ class SigninDialog : public XamDialog {
|
|||
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
auto profile_manager = kernel_state()->xam_state()->profile_manager();
|
||||
auto profiles = profile_manager->GetProfiles();
|
||||
|
||||
for (uint32_t i = 0; i < users_needed_; i++) {
|
||||
ImGui::BeginGroup();
|
||||
|
@ -1136,12 +1135,12 @@ class SigninDialog : public XamDialog {
|
|||
// Draw profile badge.
|
||||
uint8_t slot = chosen_slots_[i];
|
||||
uint64_t xuid = chosen_xuids_[i];
|
||||
const auto account = profile_manager->GetAccount(xuid);
|
||||
|
||||
if (slot == 0xFF || xuid == 0 || profiles->count(xuid) == 0) {
|
||||
if (slot == 0xFF || xuid == 0 || !account) {
|
||||
float ypos = ImGui::GetCursorPosY();
|
||||
ImGui::SetCursorPosY(ypos + ImGui::GetTextLineHeight() * 5);
|
||||
} else {
|
||||
const X_XAMACCOUNTINFO* account = &profiles->at(xuid);
|
||||
xeDrawProfileContent(imgui_drawer(), xuid, slot, account, nullptr);
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1228,7 @@ class SigninDialog : public XamDialog {
|
|||
|
||||
void ReloadProfiles(bool first_draw) {
|
||||
auto profile_manager = kernel_state()->xam_state()->profile_manager();
|
||||
auto profiles = profile_manager->GetProfiles();
|
||||
auto profiles = profile_manager->GetAccounts();
|
||||
|
||||
profile_data_.clear();
|
||||
for (auto& [xuid, account] : *profiles) {
|
||||
|
|
|
@ -787,26 +787,26 @@ dword_result_t XamUserCreateStatsEnumerator_entry(
|
|||
}
|
||||
DECLARE_XAM_EXPORT1(XamUserCreateStatsEnumerator, kUserProfiles, kSketchy);
|
||||
|
||||
dword_result_t XamProfileFindAccount_entry(qword_t offline_xuid,
|
||||
pointer_t<X_XAMACCOUNTINFO> account,
|
||||
lpdword_t device_id) {
|
||||
if (!account) {
|
||||
dword_result_t XamProfileFindAccount_entry(
|
||||
qword_t offline_xuid, pointer_t<X_XAMACCOUNTINFO> account_ptr,
|
||||
lpdword_t device_id) {
|
||||
if (!account_ptr) {
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
account.Zero();
|
||||
account_ptr.Zero();
|
||||
|
||||
const auto& profiles =
|
||||
kernel_state()->xam_state()->profile_manager()->GetProfiles();
|
||||
const auto& account =
|
||||
kernel_state()->xam_state()->profile_manager()->GetAccount(offline_xuid);
|
||||
|
||||
if (!profiles->count(offline_xuid)) {
|
||||
if (!account) {
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
|
||||
memcpy(account, &profiles->at(offline_xuid), sizeof(X_XAMACCOUNTINFO));
|
||||
std::memcpy(account_ptr, &account, sizeof(X_XAMACCOUNTINFO));
|
||||
|
||||
xe::string_util::copy_and_swap_truncating(
|
||||
account->gamertag, account->gamertag, sizeof(account->gamertag));
|
||||
account_ptr->gamertag, account->gamertag, sizeof(account->gamertag));
|
||||
|
||||
if (device_id) {
|
||||
*device_id = 1;
|
||||
|
|
Loading…
Reference in New Issue