mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
[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()
|
if (!emulator_->kernel_state()
|
||||||
->xam_state()
|
->xam_state()
|
||||||
->profile_manager()
|
->profile_manager()
|
||||||
->GetProfilesCount()) {
|
->GetAccountCount()) {
|
||||||
new NoProfileDialog(imgui_drawer_.get(), this);
|
new NoProfileDialog(imgui_drawer_.get(), this);
|
||||||
disable_hotkeys_ = true;
|
disable_hotkeys_ = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ void CreateProfileDialog::OnDraw(ImGuiIO& io) {
|
||||||
|
|
||||||
ImGui::BeginDisabled(!valid);
|
ImGui::BeginDisabled(!valid);
|
||||||
if (ImGui::Button("Create")) {
|
if (ImGui::Button("Create")) {
|
||||||
bool autologin = (profile_manager->GetProfilesCount() == 0);
|
bool autologin = (profile_manager->GetAccountCount() == 0);
|
||||||
if (profile_manager->CreateProfile(gamertag_string, autologin,
|
if (profile_manager->CreateProfile(gamertag_string, autologin,
|
||||||
migration_) &&
|
migration_) &&
|
||||||
migration_) {
|
migration_) {
|
||||||
|
|
@ -89,7 +89,7 @@ void NoProfileDialog::OnDraw(ImGuiIO& io) {
|
||||||
->xam_state()
|
->xam_state()
|
||||||
->profile_manager();
|
->profile_manager();
|
||||||
|
|
||||||
if (profile_manager->GetProfilesCount()) {
|
if (profile_manager->GetAccountCount()) {
|
||||||
delete this;
|
delete this;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +164,7 @@ void ProfileConfigDialog::OnDraw(ImGuiIO& io) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto profiles = profile_manager->GetProfiles();
|
auto profiles = profile_manager->GetAccounts();
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(40, 40), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(40, 40), ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowBgAlpha(0.8f);
|
ImGui::SetNextWindowBgAlpha(0.8f);
|
||||||
|
|
|
||||||
|
|
@ -466,6 +466,14 @@ bool ProfileManager::CreateProfile(const std::string gamertag, bool autologin,
|
||||||
return is_account_created;
|
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,
|
bool ProfileManager::CreateAccount(const uint64_t xuid,
|
||||||
const std::string gamertag) {
|
const std::string gamertag) {
|
||||||
X_XAMACCOUNTINFO account = {};
|
X_XAMACCOUNTINFO account = {};
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,12 @@ class ProfileManager {
|
||||||
UserProfile* GetProfile(const uint8_t user_index) const;
|
UserProfile* GetProfile(const uint8_t user_index) const;
|
||||||
uint8_t GetUserIndexAssignedToProfile(const uint64_t xuid) 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());
|
return static_cast<uint32_t>(accounts_.size());
|
||||||
}
|
}
|
||||||
bool IsAnyProfileSignedIn() const { return !logged_profiles_.empty(); }
|
bool IsAnyProfileSignedIn() const { return !logged_profiles_.empty(); }
|
||||||
|
|
|
||||||
|
|
@ -137,10 +137,10 @@ dword_result_t XamProfileCreateEnumerator_entry(dword_t device_id,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& profiles =
|
const auto& accounts =
|
||||||
kernel_state()->xam_state()->profile_manager()->GetProfiles();
|
kernel_state()->xam_state()->profile_manager()->GetAccounts();
|
||||||
|
|
||||||
for (const auto& [xuid, account] : *profiles) {
|
for (const auto& [xuid, account] : *accounts) {
|
||||||
X_PROFILEENUMRESULT* profile = e->AppendItem();
|
X_PROFILEENUMRESULT* profile = e->AppendItem();
|
||||||
|
|
||||||
profile->xuid_offline = xuid;
|
profile->xuid_offline = xuid;
|
||||||
|
|
|
||||||
|
|
@ -1051,7 +1051,6 @@ class SigninDialog : public XamDialog {
|
||||||
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
|
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
auto profile_manager = kernel_state()->xam_state()->profile_manager();
|
auto profile_manager = kernel_state()->xam_state()->profile_manager();
|
||||||
auto profiles = profile_manager->GetProfiles();
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < users_needed_; i++) {
|
for (uint32_t i = 0; i < users_needed_; i++) {
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
|
|
@ -1136,12 +1135,12 @@ class SigninDialog : public XamDialog {
|
||||||
// Draw profile badge.
|
// Draw profile badge.
|
||||||
uint8_t slot = chosen_slots_[i];
|
uint8_t slot = chosen_slots_[i];
|
||||||
uint64_t xuid = chosen_xuids_[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();
|
float ypos = ImGui::GetCursorPosY();
|
||||||
ImGui::SetCursorPosY(ypos + ImGui::GetTextLineHeight() * 5);
|
ImGui::SetCursorPosY(ypos + ImGui::GetTextLineHeight() * 5);
|
||||||
} else {
|
} else {
|
||||||
const X_XAMACCOUNTINFO* account = &profiles->at(xuid);
|
|
||||||
xeDrawProfileContent(imgui_drawer(), xuid, slot, account, nullptr);
|
xeDrawProfileContent(imgui_drawer(), xuid, slot, account, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1229,7 +1228,7 @@ class SigninDialog : public XamDialog {
|
||||||
|
|
||||||
void ReloadProfiles(bool first_draw) {
|
void ReloadProfiles(bool first_draw) {
|
||||||
auto profile_manager = kernel_state()->xam_state()->profile_manager();
|
auto profile_manager = kernel_state()->xam_state()->profile_manager();
|
||||||
auto profiles = profile_manager->GetProfiles();
|
auto profiles = profile_manager->GetAccounts();
|
||||||
|
|
||||||
profile_data_.clear();
|
profile_data_.clear();
|
||||||
for (auto& [xuid, account] : *profiles) {
|
for (auto& [xuid, account] : *profiles) {
|
||||||
|
|
|
||||||
|
|
@ -787,26 +787,26 @@ dword_result_t XamUserCreateStatsEnumerator_entry(
|
||||||
}
|
}
|
||||||
DECLARE_XAM_EXPORT1(XamUserCreateStatsEnumerator, kUserProfiles, kSketchy);
|
DECLARE_XAM_EXPORT1(XamUserCreateStatsEnumerator, kUserProfiles, kSketchy);
|
||||||
|
|
||||||
dword_result_t XamProfileFindAccount_entry(qword_t offline_xuid,
|
dword_result_t XamProfileFindAccount_entry(
|
||||||
pointer_t<X_XAMACCOUNTINFO> account,
|
qword_t offline_xuid, pointer_t<X_XAMACCOUNTINFO> account_ptr,
|
||||||
lpdword_t device_id) {
|
lpdword_t device_id) {
|
||||||
if (!account) {
|
if (!account_ptr) {
|
||||||
return X_ERROR_INVALID_PARAMETER;
|
return X_ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
account.Zero();
|
account_ptr.Zero();
|
||||||
|
|
||||||
const auto& profiles =
|
const auto& account =
|
||||||
kernel_state()->xam_state()->profile_manager()->GetProfiles();
|
kernel_state()->xam_state()->profile_manager()->GetAccount(offline_xuid);
|
||||||
|
|
||||||
if (!profiles->count(offline_xuid)) {
|
if (!account) {
|
||||||
return X_ERROR_NO_SUCH_USER;
|
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(
|
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) {
|
if (device_id) {
|
||||||
*device_id = 1;
|
*device_id = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue