mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-24 14:25:47 +01:00
settings: Add users and current_user settings and remove username
This commit is contained in:
parent
50e4e81fd3
commit
e7e3d5898e
@ -8,6 +8,7 @@
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@ -114,7 +115,8 @@ struct Values {
|
||||
// System
|
||||
bool use_docked_mode;
|
||||
bool enable_nfc;
|
||||
std::string username;
|
||||
int current_user;
|
||||
std::vector<std::pair<std::string, Service::Account::UUID>> users;
|
||||
int language_index;
|
||||
|
||||
// Controls
|
||||
|
@ -123,7 +123,25 @@ void Config::ReadValues() {
|
||||
qt_config->beginGroup("System");
|
||||
Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool();
|
||||
Settings::values.enable_nfc = qt_config->value("enable_nfc", true).toBool();
|
||||
Settings::values.username = qt_config->value("username", "yuzu").toString().toStdString();
|
||||
|
||||
Settings::values.users.clear();
|
||||
const auto size = qt_config->beginReadArray("users");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
qt_config->setArrayIndex(i);
|
||||
const Service::Account::UUID uuid(qt_config->value("uuid_low").toULongLong(),
|
||||
qt_config->value("uuid_high").toULongLong());
|
||||
Settings::values.users.emplace_back(qt_config->value("username").toString().toStdString(),
|
||||
uuid);
|
||||
}
|
||||
|
||||
qt_config->endArray();
|
||||
|
||||
if (Settings::values.users.empty())
|
||||
Settings::values.users.emplace_back("yuzu", Service::Account::UUID{}.Generate());
|
||||
|
||||
Settings::values.current_user =
|
||||
std::clamp(qt_config->value("current_user", 0).toInt(), 0, size);
|
||||
|
||||
Settings::values.language_index = qt_config->value("language_index", 1).toInt();
|
||||
qt_config->endGroup();
|
||||
|
||||
@ -260,7 +278,19 @@ void Config::SaveValues() {
|
||||
qt_config->beginGroup("System");
|
||||
qt_config->setValue("use_docked_mode", Settings::values.use_docked_mode);
|
||||
qt_config->setValue("enable_nfc", Settings::values.enable_nfc);
|
||||
qt_config->setValue("username", QString::fromStdString(Settings::values.username));
|
||||
qt_config->setValue("current_user", Settings::values.current_user);
|
||||
|
||||
qt_config->beginWriteArray("users", Settings::values.users.size());
|
||||
for (std::size_t i = 0; i < Settings::values.users.size(); ++i) {
|
||||
qt_config->setArrayIndex(i);
|
||||
const auto& user = Settings::values.users[i];
|
||||
qt_config->setValue("uuid_low", user.second.uuid[0]);
|
||||
qt_config->setValue("uuid_high", user.second.uuid[1]);
|
||||
qt_config->setValue("username", QString::fromStdString(user.first));
|
||||
}
|
||||
|
||||
qt_config->endArray();
|
||||
|
||||
qt_config->setValue("language_index", Settings::values.language_index);
|
||||
qt_config->endGroup();
|
||||
|
||||
|
@ -126,9 +126,25 @@ void Config::ReadValues() {
|
||||
// System
|
||||
Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false);
|
||||
Settings::values.enable_nfc = sdl2_config->GetBoolean("System", "enable_nfc", true);
|
||||
Settings::values.username = sdl2_config->Get("System", "username", "yuzu");
|
||||
if (Settings::values.username.empty()) {
|
||||
Settings::values.username = "yuzu";
|
||||
const auto size = sdl2_config->GetInteger("System", "users_size", 0);
|
||||
|
||||
Settings::values.users.clear();
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
const auto uuid_low = std::stoull(
|
||||
sdl2_config->Get("System", fmt::format("users_{}_uuid_low", i), "0"), nullptr, 0);
|
||||
const auto uuid_high = std::stoull(
|
||||
sdl2_config->Get("System", fmt::format("users_{}_uuid_high", i), "0"), nullptr, 0);
|
||||
Settings::values.users.emplace_back(
|
||||
sdl2_config->Get("System", fmt::format("users_{}_username", i), ""),
|
||||
Service::Account::UUID{uuid_low, uuid_high});
|
||||
}
|
||||
|
||||
if (Settings::values.users.empty()) {
|
||||
Settings::values.users.emplace_back("yuzu", Service::Account::UUID{1, 0});
|
||||
LOG_WARNING(
|
||||
Config,
|
||||
"You are using the default UUID of {1, 0}! This might cause issues down the road! "
|
||||
"Please consider randomizing a UUID and adding it to the sdl2_config.ini file.");
|
||||
}
|
||||
|
||||
// Miscellaneous
|
||||
|
Loading…
Reference in New Issue
Block a user