mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
user_manager: megamouse fixes 3
This commit is contained in:
parent
9ca8ec8ec7
commit
e58b7cbe1f
@ -282,10 +282,6 @@ void Emulator::Init()
|
||||
const std::string dev_hdd1 = fmt::replace_all(g_cfg.vfs.dev_hdd1, "$(EmulatorDir)", emu_dir);
|
||||
const std::string dev_usb = fmt::replace_all(g_cfg.vfs.dev_usb000, "$(EmulatorDir)", emu_dir);
|
||||
|
||||
// Set selected user.
|
||||
m_usr = g_cfg.usr.selected_usr;
|
||||
m_usrid = static_cast<u32>(std::stoul(m_usr));
|
||||
|
||||
fs::create_path(dev_hdd0);
|
||||
fs::create_path(dev_hdd1);
|
||||
fs::create_path(dev_usb);
|
||||
@ -409,6 +405,34 @@ void Emulator::Init()
|
||||
}
|
||||
}
|
||||
|
||||
const bool Emulator::SetUsr(const std::string& user)
|
||||
{
|
||||
if (user.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 id;
|
||||
|
||||
try
|
||||
{
|
||||
id = static_cast<u32>(std::stoul(user));
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
id = 0;
|
||||
}
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_usrid = id;
|
||||
m_usr = user;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Emulator::BootRsxCapture(const std::string& path)
|
||||
{
|
||||
if (!fs::is_file(path))
|
||||
|
@ -209,8 +209,8 @@ class Emulator final
|
||||
std::string m_title;
|
||||
std::string m_cat;
|
||||
std::string m_dir;
|
||||
std::string m_usr;
|
||||
u32 m_usrid;
|
||||
std::string m_usr{"00000001"};
|
||||
u32 m_usrid{1};
|
||||
|
||||
bool m_force_boot = false;
|
||||
|
||||
@ -291,6 +291,8 @@ public:
|
||||
return m_usrid;
|
||||
}
|
||||
|
||||
const bool SetUsr(const std::string& user);
|
||||
|
||||
u64 GetPauseTime()
|
||||
{
|
||||
return m_pause_amend_time;
|
||||
@ -505,14 +507,6 @@ struct cfg_root : cfg::node
|
||||
|
||||
} net{this};
|
||||
|
||||
struct node_usr : cfg::node
|
||||
{
|
||||
node_usr(cfg::node* _this) : cfg::node(_this, "User") {}
|
||||
|
||||
cfg::string selected_usr{ this, "Selected User", "00000001" };
|
||||
|
||||
} usr{this};
|
||||
|
||||
struct node_misc : cfg::node
|
||||
{
|
||||
node_misc(cfg::node* _this) : cfg::node(_this, "Miscellaneous") {}
|
||||
|
@ -72,11 +72,12 @@ void rpcs3_app::Init()
|
||||
setApplicationName("RPCS3");
|
||||
setWindowIcon(QIcon(":/rpcs3.ico"));
|
||||
|
||||
Emu.Init();
|
||||
|
||||
guiSettings.reset(new gui_settings());
|
||||
emuSettings.reset(new emu_settings());
|
||||
|
||||
// Force init the emulator
|
||||
InitializeEmulator(guiSettings->GetCurrentUser().toStdString(), true);
|
||||
|
||||
// Create the main window
|
||||
RPCS3MainWin = new main_window(guiSettings, emuSettings, nullptr);
|
||||
|
||||
@ -113,6 +114,21 @@ void rpcs3_app::Init()
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Emu.Init() wrapper for user manager */
|
||||
bool rpcs3_app::InitializeEmulator(const std::string& user, bool force_init)
|
||||
{
|
||||
// try to set a new user
|
||||
const bool user_was_set = Emu.SetUsr(user);
|
||||
|
||||
// only init the emulation if forced or a user was set
|
||||
if (user_was_set || force_init)
|
||||
{
|
||||
Emu.Init();
|
||||
}
|
||||
|
||||
return user_was_set;
|
||||
}
|
||||
|
||||
/** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here.
|
||||
*/
|
||||
void rpcs3_app::InitializeCallbacks()
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
/** Call this method before calling app.exec
|
||||
*/
|
||||
void Init();
|
||||
|
||||
/** Emu.Init() wrapper for user manager */
|
||||
static bool InitializeEmulator(const std::string& user, bool force_init);
|
||||
Q_SIGNALS:
|
||||
void OnEmulatorRun();
|
||||
void OnEmulatorPause();
|
||||
|
@ -110,9 +110,6 @@ public:
|
||||
// Network
|
||||
ConnectionStatus,
|
||||
|
||||
// User
|
||||
SelectedUser,
|
||||
|
||||
// Language
|
||||
Language,
|
||||
EnableHostRoot,
|
||||
@ -290,9 +287,6 @@ private:
|
||||
// Networking
|
||||
{ ConnectionStatus, { "Net", "Connection status"}},
|
||||
|
||||
// User
|
||||
{SelectedUser, {"User", "Selected User"}},
|
||||
|
||||
// System
|
||||
{ Language, { "System", "Language"}},
|
||||
{ EnableHostRoot, { "VFS", "Enable /host_root/"}},
|
||||
|
@ -18,6 +18,23 @@ gui_settings::~gui_settings()
|
||||
m_settings.sync();
|
||||
}
|
||||
|
||||
QString gui_settings::GetCurrentUser()
|
||||
{
|
||||
// load user
|
||||
bool is_valid_user;
|
||||
const QString user = GetValue(gui::um_active_user).toString();
|
||||
const u32 user_id = user.toInt(&is_valid_user);
|
||||
|
||||
// set user if valid
|
||||
if (is_valid_user && user_id > 0)
|
||||
{
|
||||
return user;
|
||||
}
|
||||
|
||||
LOG_FATAL(GENERAL, "Could not parse user setting: '%s' = '%d'.", user.toStdString(), user_id);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString gui_settings::GetSettingsDir()
|
||||
{
|
||||
return m_settingsDir.absolutePath();
|
||||
|
@ -218,7 +218,8 @@ namespace gui
|
||||
|
||||
const gui_save sd_geometry = gui_save(savedata, "geometry", QByteArray());
|
||||
|
||||
const gui_save um_geometry = gui_save(users, "geometry", QByteArray());
|
||||
const gui_save um_geometry = gui_save(users, "geometry", QByteArray());
|
||||
const gui_save um_active_user = gui_save(users, "active_user", "00000001");
|
||||
}
|
||||
|
||||
/** Class for GUI settings..
|
||||
@ -231,6 +232,7 @@ public:
|
||||
explicit gui_settings(QObject* parent = nullptr);
|
||||
~gui_settings();
|
||||
|
||||
QString GetCurrentUser();
|
||||
QString GetSettingsDir();
|
||||
|
||||
/** Changes the settings file to the destination preset*/
|
||||
|
@ -1269,7 +1269,7 @@ void main_window::CreateConnects()
|
||||
|
||||
connect(ui->actionManage_Users, &QAction::triggered, [=]
|
||||
{
|
||||
user_manager_dialog* user_manager = new user_manager_dialog(guiSettings, emuSettings, this);
|
||||
user_manager_dialog* user_manager = new user_manager_dialog(guiSettings, this);
|
||||
user_manager->show();
|
||||
});
|
||||
|
||||
|
@ -501,9 +501,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionManage_Users">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User Accounts</string>
|
||||
</property>
|
||||
|
@ -146,7 +146,6 @@ void save_manager_dialog::UpdateList()
|
||||
{
|
||||
if (m_dir == "")
|
||||
{
|
||||
// fmt::format(%shome ... is harder to read than straight concatenation.
|
||||
m_dir = Emu.GetHddDir() + "home/" + Emu.GetUsr() + "/savedata/";
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
|
||||
std::string GetUserId() { return m_user_id; };
|
||||
std::string GetUserDir() { return m_user_dir; };
|
||||
std::string GetUserName() { return m_username; };
|
||||
std::string GetUsername() { return m_username; };
|
||||
~UserAccount();
|
||||
|
||||
private:
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "user_manager_dialog.h"
|
||||
#include "table_item_delegate.h"
|
||||
#include "rpcs3_app.h"
|
||||
|
||||
#include "Utilities/StrUtil.h"
|
||||
|
||||
@ -43,14 +44,13 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
user_manager_dialog::user_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, QWidget* parent)
|
||||
: QDialog(parent), m_user_list(), m_sort_column(1), m_sort_ascending(true), m_gui_settings(gui_settings), m_emu_settings(emu_settings)
|
||||
user_manager_dialog::user_manager_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget* parent)
|
||||
: QDialog(parent), m_user_list(), m_sort_column(1), m_sort_ascending(true), m_gui_settings(gui_settings)
|
||||
{
|
||||
setWindowTitle(tr("User Manager"));
|
||||
setMinimumSize(QSize(400, 400));
|
||||
setModal(true);
|
||||
|
||||
m_emu_settings->LoadSettings();
|
||||
Init();
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ void user_manager_dialog::Init()
|
||||
vbox_main->addLayout(hbox_buttons);
|
||||
setLayout(vbox_main);
|
||||
|
||||
m_active_user = m_emu_settings->GetSetting(emu_settings::SelectedUser);
|
||||
m_active_user = m_gui_settings->GetValue(gui::um_active_user).toString().toStdString();
|
||||
UpdateTable();
|
||||
|
||||
restoreGeometry(m_gui_settings->GetValue(gui::um_geometry).toByteArray());
|
||||
@ -173,7 +173,7 @@ void user_manager_dialog::UpdateTable(bool mark_only)
|
||||
user_id_item->setFlags(user_id_item->flags() & ~Qt::ItemIsEditable);
|
||||
m_table->setItem(row, 0, user_id_item);
|
||||
|
||||
QTableWidgetItem* username_item = new QTableWidgetItem(qstr(user.second.GetUserName()));
|
||||
QTableWidgetItem* username_item = new QTableWidgetItem(qstr(user.second.GetUsername()));
|
||||
username_item->setData(Qt::UserRole, user.first); // For sorting to work properly
|
||||
username_item->setFlags(username_item->flags() & ~Qt::ItemIsEditable);
|
||||
m_table->setItem(row, 1, username_item);
|
||||
@ -210,7 +210,7 @@ void user_manager_dialog::OnUserRemove()
|
||||
return;
|
||||
}
|
||||
|
||||
const QString username = qstr(m_user_list[key].GetUserName());
|
||||
const QString username = qstr(m_user_list[key].GetUsername());
|
||||
const QString user_id = qstr(m_user_list[key].GetUserId());
|
||||
const std::string user_dir = m_user_list[key].GetUserDir();
|
||||
|
||||
@ -256,7 +256,7 @@ void user_manager_dialog::OnUserRename()
|
||||
}
|
||||
|
||||
const std::string user_id = m_user_list[key].GetUserId();
|
||||
const std::string username = m_user_list[key].GetUserName();
|
||||
const std::string username = m_user_list[key].GetUsername();
|
||||
|
||||
QInputDialog* dialog = new QInputDialog(this);
|
||||
dialog->setWindowTitle(tr("Rename User"));
|
||||
@ -334,17 +334,26 @@ void user_manager_dialog::OnUserCreate()
|
||||
|
||||
void user_manager_dialog::OnUserLogin()
|
||||
{
|
||||
u32 key = GetUserKey();
|
||||
if (key == 0)
|
||||
if (!Emu.IsStopped() && QMessageBox::question(this, tr("Stop emulator?"),
|
||||
tr("In order to change the user you have to stop the emulator first.\n\nStop the emulator now?"),
|
||||
QMessageBox::Yes | QMessageBox::Abort) != QMessageBox::Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string selected_user_id = m_user_list[key].GetUserId();
|
||||
Emu.Stop();
|
||||
|
||||
m_active_user = selected_user_id;
|
||||
m_emu_settings->SetSetting(emu_settings::SelectedUser, m_active_user);
|
||||
m_emu_settings->SaveSettings();
|
||||
const u32 key = GetUserKey();
|
||||
const std::string new_user = m_user_list[key].GetUserId();
|
||||
|
||||
if (!rpcs3_app::InitializeEmulator(new_user, false))
|
||||
{
|
||||
LOG_FATAL(GENERAL, "Failed to login user! username=%s key=%d", new_user, key);
|
||||
return;
|
||||
}
|
||||
|
||||
m_active_user = new_user;
|
||||
m_gui_settings->SetValue(gui::um_active_user, qstr(m_active_user));
|
||||
UpdateTable(true);
|
||||
Q_EMIT OnUserLoginSuccess();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class user_manager_dialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit user_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, QWidget* parent = nullptr);
|
||||
explicit user_manager_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget* parent = nullptr);
|
||||
Q_SIGNALS:
|
||||
void OnUserLoginSuccess();
|
||||
private Q_SLOTS:
|
||||
@ -50,7 +50,6 @@ private:
|
||||
std::map<u32, UserAccount> m_user_list;
|
||||
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
std::shared_ptr<emu_settings> m_emu_settings;
|
||||
|
||||
int m_sort_column;
|
||||
bool m_sort_ascending;
|
||||
|
Loading…
Reference in New Issue
Block a user