reorganization + don't rebuild everything on changing the user manager + save user manager state on setter functions

This commit is contained in:
kalaposfos13 2026-03-03 14:38:59 +01:00
parent d20df93f31
commit 83ad83c8ef
4 changed files with 8 additions and 4 deletions

View File

@ -13,7 +13,6 @@
#include <nlohmann/json.hpp>
#include "common/logging/log.h"
#include "common/types.h"
#include "core/user_manager.h"
#define EmulatorSettings (*EmulatorSettingsImpl::GetInstance())

View File

@ -27,6 +27,7 @@ bool UserManager::AddUser(const User& user) {
std::filesystem::create_directory(user_dir / "inputs", ec);
}
Save();
return true;
}
@ -44,6 +45,7 @@ bool UserManager::RemoveUser(s32 user_id) {
}
m_users.user.erase(it, m_users.user.end());
Save();
return true;
}
@ -58,6 +60,7 @@ bool UserManager::RenameUser(s32 user_id, const std::string& new_name) {
return true;
}
}
Save();
return false;
}
@ -100,7 +103,7 @@ bool UserManager::SetDefaultUser(u32 user_id) {
m_users.default_user_id = user_id;
SetControllerPort(user_id, 1); // Set default user to port 1
return true;
return Save();
}
User UserManager::GetDefaultUser() {
@ -114,6 +117,7 @@ void UserManager::SetControllerPort(u32 user_id, int port) {
if (u.user_id == user_id)
u.controller_port = port;
}
Save();
}
// Returns a list of users that have valid home directories
std::vector<User> UserManager::GetValidUsers() const {

View File

@ -6,6 +6,7 @@
#include <string>
#include <vector>
#include "common/types.h"
#include <nlohmann/json.hpp>
struct User {
s32 user_id;
@ -18,6 +19,8 @@ struct Users {
int default_user_id = 1;
std::vector<User> user;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(User, user_id, user_color, user_name, controller_port)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Users, default_user_id, user)
class UserManager {
public:

View File

@ -22,8 +22,6 @@
// -------------------------------
// User settings
// -------------------------------
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(User, user_id, user_color, user_name, controller_port)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Users, default_user_id, user)
class UserSettingsImpl {
public: