mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-03 11:37:52 -06:00
reorganization + don't rebuild everything on changing the user manager + save user manager state on setter functions
This commit is contained in:
parent
d20df93f31
commit
83ad83c8ef
@ -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())
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user