configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct. Swapping bewteen structs now also includes copying the necessary global configs that cannot be changed nor saved in per-game settings. General and System config menus now update based on whether it is viewing the global or per-game settings.
This commit is contained in:
@@ -92,7 +92,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
|
||||
|
||||
const auto& installed = Core::System::GetInstance().GetContentProvider();
|
||||
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
const auto update_disabled =
|
||||
std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend();
|
||||
|
||||
@@ -140,7 +140,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
|
||||
|
||||
std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualDir>& patch_dirs,
|
||||
const std::string& build_id) const {
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
|
||||
std::vector<VirtualFile> out;
|
||||
out.reserve(patch_dirs.size());
|
||||
@@ -302,7 +302,7 @@ std::vector<Core::Memory::CheatEntry> PatchManager::CreateCheatList(
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
auto patch_dirs = load_dir->GetSubdirectories();
|
||||
std::sort(patch_dirs.begin(), patch_dirs.end(),
|
||||
[](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
|
||||
@@ -344,7 +344,7 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
auto patch_dirs = load_dir->GetSubdirectories();
|
||||
std::sort(patch_dirs.begin(), patch_dirs.end(),
|
||||
[](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
|
||||
@@ -409,7 +409,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content
|
||||
const auto update_tid = GetUpdateTitleID(title_id);
|
||||
const auto update = installed.GetEntryRaw(update_tid, type);
|
||||
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
const auto update_disabled =
|
||||
std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend();
|
||||
|
||||
@@ -453,7 +453,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
|
||||
return {};
|
||||
std::map<std::string, std::string, std::less<>> out;
|
||||
const auto& installed = Core::System::GetInstance().GetContentProvider();
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
|
||||
// Game Updates
|
||||
const auto update_tid = GetUpdateTitleID(title_id);
|
||||
|
||||
@@ -91,7 +91,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
const auto current = system.CurrentProcess()->GetTitleID();
|
||||
|
||||
const auto& disabled = Settings::values->disabled_addons[current];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[current];
|
||||
if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
|
||||
rb.Push<u32>(0);
|
||||
return;
|
||||
@@ -119,7 +119,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
|
||||
const auto current = system.CurrentProcess()->GetTitleID();
|
||||
|
||||
std::vector<u32> out;
|
||||
const auto& disabled = Settings::values->disabled_addons[current];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[current];
|
||||
if (std::find(disabled.begin(), disabled.end(), "DLC") == disabled.end()) {
|
||||
for (u64 content_id : add_on_content) {
|
||||
if ((content_id & DLC_BASE_TITLE_ID_MASK) != current) {
|
||||
|
||||
@@ -67,12 +67,50 @@ Values global_values;
|
||||
Values game_values;
|
||||
Values *values = &global_values;
|
||||
|
||||
void SwapValues(bool global) {
|
||||
if (global) {
|
||||
void CopyValues(Values& dst, const Values& src) {
|
||||
dst.udp_input_address = src.udp_input_address;
|
||||
dst.udp_input_port = src.udp_input_port;
|
||||
dst.udp_pad_index = src.udp_pad_index;
|
||||
|
||||
dst.use_virtual_sd = src.use_virtual_sd;
|
||||
dst.gamecard_inserted = src.gamecard_inserted;
|
||||
dst.gamecard_current_game = src.gamecard_current_game;
|
||||
dst.gamecard_path = src.gamecard_path;
|
||||
dst.nand_total_size = src.nand_total_size;
|
||||
dst.nand_system_size = src.nand_system_size;
|
||||
dst.nand_user_size = src.nand_user_size;
|
||||
dst.sdmc_size = src.sdmc_size;
|
||||
|
||||
dst.log_filter = src.log_filter;
|
||||
|
||||
dst.use_dev_keys = src.use_dev_keys;
|
||||
|
||||
dst.record_frame_times = src.record_frame_times;
|
||||
dst.use_gdbstub = src.use_gdbstub;
|
||||
dst.gdbstub_port = src.gdbstub_port;
|
||||
dst.program_args = src.program_args;
|
||||
dst.dump_exefs = src.dump_exefs;
|
||||
dst.dump_nso = src.dump_nso;
|
||||
dst.reporting_services = src.reporting_services;
|
||||
dst.quest_flag = src.quest_flag;
|
||||
dst.disable_cpu_opt = src.disable_cpu_opt;
|
||||
dst.disable_macro_jit = src.disable_macro_jit;
|
||||
|
||||
dst.bcat_backend = src.bcat_backend;
|
||||
dst.bcat_boxcat_local = src.bcat_boxcat_local;
|
||||
|
||||
dst.enable_telemetry = src.enable_telemetry;
|
||||
dst.web_api_url = src.web_api_url;
|
||||
dst.yuzu_username = src.yuzu_username;
|
||||
dst.yuzu_token = src.yuzu_token;
|
||||
}
|
||||
|
||||
void SwapValues(ValuesSwapTarget target) {
|
||||
if (target == ValuesSwapTarget::ToGlobal) {
|
||||
values = &global_values;
|
||||
}
|
||||
else {
|
||||
std::memcpy(&game_values, &global_values, sizeof(global_values));
|
||||
CopyValues(game_values, global_values);
|
||||
values = &game_values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,7 +499,14 @@ extern Values game_values;
|
||||
extern Values *values;
|
||||
|
||||
float Volume();
|
||||
void SwapValues(bool global);
|
||||
void CopyValues(Values& dst, const Values& src);
|
||||
|
||||
enum class ValuesSwapTarget {
|
||||
ToGlobal,
|
||||
ToGame,
|
||||
};
|
||||
|
||||
void SwapValues(ValuesSwapTarget target);
|
||||
|
||||
bool IsGPULevelExtreme();
|
||||
bool IsGPULevelHigh();
|
||||
|
||||
@@ -24,7 +24,8 @@ Config::Config(const std::string& config_file, bool is_global) {
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
Save();
|
||||
if (global)
|
||||
Save();
|
||||
}
|
||||
|
||||
const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = {
|
||||
@@ -566,7 +567,7 @@ void Config::ReadDisabledAddOnValues() {
|
||||
ReadSetting(QStringLiteral("d"), QStringLiteral("")).toString().toStdString());
|
||||
}
|
||||
qt_config->endArray();
|
||||
Settings::values->disabled_addons.insert_or_assign(title_id, out);
|
||||
Settings::global_values.disabled_addons.insert_or_assign(title_id, out);
|
||||
}
|
||||
|
||||
qt_config->endArray();
|
||||
@@ -581,8 +582,7 @@ void Config::ReadMiscellaneousValues() {
|
||||
.toStdString();
|
||||
Settings::values->use_dev_keys = ReadSetting(QStringLiteral("use_dev_keys"), false).toBool();
|
||||
Settings::values->use_global_values =
|
||||
ReadSetting(QStringLiteral("use_global_values"), true).toBool() ||
|
||||
Settings::values == &Settings::global_values;
|
||||
ReadSetting(QStringLiteral("use_global_values"), true).toBool();
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
@@ -1037,7 +1037,7 @@ void Config::SaveDisabledAddOnValues() {
|
||||
qt_config->beginWriteArray(QStringLiteral("DisabledAddOns"));
|
||||
|
||||
int i = 0;
|
||||
for (const auto& elem : Settings::values->disabled_addons) {
|
||||
for (const auto& elem : Settings::global_values.disabled_addons) {
|
||||
qt_config->setArrayIndex(i);
|
||||
WriteSetting(QStringLiteral("title_id"), QVariant::fromValue<u64>(elem.first), 0);
|
||||
qt_config->beginWriteArray(QStringLiteral("disabled"));
|
||||
@@ -1059,8 +1059,7 @@ void Config::SaveMiscellaneousValues() {
|
||||
WriteSetting(QStringLiteral("log_filter"), QString::fromStdString(Settings::values->log_filter),
|
||||
QStringLiteral("*:Info"));
|
||||
WriteSetting(QStringLiteral("use_dev_keys"), Settings::values->use_dev_keys, false);
|
||||
WriteSetting(QStringLiteral("use_global_values"), Settings::values->use_global_values ||
|
||||
Settings::values == &Settings::global_values, true);
|
||||
WriteSetting(QStringLiteral("use_global_values"), Settings::values->use_global_values, true);
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
|
||||
@@ -28,10 +28,16 @@ void ConfigureGeneral::SetConfiguration() {
|
||||
ui->use_multi_core->setEnabled(runtime_lock);
|
||||
ui->use_multi_core->setChecked(Settings::values.use_multi_core);
|
||||
|
||||
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
|
||||
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
|
||||
ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
|
||||
ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse);
|
||||
if (Settings::values == &Settings::global_values) {
|
||||
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
|
||||
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
|
||||
ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
|
||||
ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse);
|
||||
}
|
||||
ui->toggle_check_exit->setVisible(Settings::values == &Settings::global_values);
|
||||
ui->toggle_user_on_boot->setVisible(Settings::values == &Settings::global_values);
|
||||
ui->toggle_background_pause->setVisible(Settings::values == &Settings::global_values);
|
||||
ui->toggle_hide_mouse->setVisible(Settings::values == &Settings::global_values);
|
||||
|
||||
ui->toggle_frame_limit->setChecked(Settings::values->use_frame_limit);
|
||||
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
|
||||
@@ -39,10 +45,12 @@ void ConfigureGeneral::SetConfiguration() {
|
||||
}
|
||||
|
||||
void ConfigureGeneral::ApplyConfiguration() {
|
||||
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
|
||||
UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
|
||||
UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
|
||||
if (Settings::values == &Settings::global_values) {
|
||||
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
|
||||
UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
|
||||
UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
|
||||
}
|
||||
|
||||
Settings::values->use_frame_limit = ui->toggle_frame_limit->isChecked();
|
||||
Settings::values->frame_limit = ui->frame_limit->value();
|
||||
|
||||
@@ -30,27 +30,30 @@
|
||||
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) {
|
||||
|
||||
Settings::SwapValues(Settings::ValuesSwapTarget::ToGame);
|
||||
game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id) + ".ini", false);
|
||||
|
||||
ui->setupUi(this);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
setWindowTitle(tr("Properties"));
|
||||
|
||||
Settings::SwapValues(true);
|
||||
game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id) + ".ini", false);
|
||||
|
||||
ui->addonsTab->SetTitleId(title_id);
|
||||
|
||||
scene = new QGraphicsScene;
|
||||
ui->icon_view->setScene(scene);
|
||||
|
||||
connect(ui->checkGlobal, &QCheckBox::stateChanged, this, &ConfigurePerGame::UpdateVisibleTabs);
|
||||
connect(ui->check_global, &QCheckBox::stateChanged, this, &ConfigurePerGame::UpdateVisibleTabs);
|
||||
|
||||
LoadConfiguration();
|
||||
}
|
||||
|
||||
ConfigurePerGame::~ConfigurePerGame() {
|
||||
}
|
||||
Settings::SwapValues(Settings::ValuesSwapTarget::ToGlobal);
|
||||
};
|
||||
|
||||
void ConfigurePerGame::ApplyConfiguration() {
|
||||
Settings::values->use_global_values = ui->check_global->isChecked();
|
||||
|
||||
ui->addonsTab->ApplyConfiguration();
|
||||
ui->generalTab->ApplyConfiguration();
|
||||
ui->systemTab->ApplyConfiguration();
|
||||
@@ -58,6 +61,10 @@ void ConfigurePerGame::ApplyConfiguration() {
|
||||
ui->graphicsAdvancedTab->ApplyConfiguration();
|
||||
ui->audioTab->ApplyConfiguration();
|
||||
ui->inputTab->ApplyConfiguration();
|
||||
|
||||
game_config->Save();
|
||||
Settings::SwapValues(Settings::ValuesSwapTarget::ToGlobal);
|
||||
|
||||
Settings::Apply();
|
||||
Settings::LogSettings();
|
||||
}
|
||||
@@ -84,7 +91,7 @@ void ConfigurePerGame::LoadConfiguration() {
|
||||
return;
|
||||
}
|
||||
|
||||
ui->checkGlobal->setChecked(Settings::values->use_global_values);
|
||||
ui->check_global->setChecked(Settings::values->use_global_values);
|
||||
|
||||
ui->addonsTab->LoadFromFile(file);
|
||||
|
||||
@@ -144,7 +151,7 @@ void ConfigurePerGame::LoadConfiguration() {
|
||||
}
|
||||
|
||||
void ConfigurePerGame::UpdateVisibleTabs() {
|
||||
bool visible = !ui->checkGlobal->isChecked();
|
||||
bool visible = !ui->check_global->isChecked();
|
||||
ui->generalTab->setEnabled(visible);
|
||||
ui->systemTab->setEnabled(visible);
|
||||
ui->graphicsTab->setEnabled(visible);
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkGlobal">
|
||||
<widget class="QCheckBox" name="check_global">
|
||||
<property name="text">
|
||||
<string>Use global configuration</string>
|
||||
</property>
|
||||
|
||||
@@ -72,7 +72,7 @@ void ConfigurePerGameAddons::ApplyConfiguration() {
|
||||
disabled_addons.push_back(item.front()->text().toStdString());
|
||||
}
|
||||
|
||||
auto current = Settings::values->disabled_addons[title_id];
|
||||
auto current = Settings::global_values.disabled_addons[title_id];
|
||||
std::sort(disabled_addons.begin(), disabled_addons.end());
|
||||
std::sort(current.begin(), current.end());
|
||||
if (disabled_addons != current) {
|
||||
@@ -80,7 +80,7 @@ void ConfigurePerGameAddons::ApplyConfiguration() {
|
||||
"game_list" + DIR_SEP + fmt::format("{:016X}.pv.txt", title_id));
|
||||
}
|
||||
|
||||
Settings::values->disabled_addons[title_id] = disabled_addons;
|
||||
Settings::global_values.disabled_addons[title_id] = disabled_addons;
|
||||
}
|
||||
|
||||
void ConfigurePerGameAddons::LoadFromFile(FileSys::VirtualFile file) {
|
||||
@@ -115,7 +115,7 @@ void ConfigurePerGameAddons::LoadConfiguration() {
|
||||
FileSys::VirtualFile update_raw;
|
||||
loader->ReadUpdateRaw(update_raw);
|
||||
|
||||
const auto& disabled = Settings::values->disabled_addons[title_id];
|
||||
const auto& disabled = Settings::global_values.disabled_addons[title_id];
|
||||
|
||||
for (const auto& patch : pm.GetPatchVersionNames(update_raw)) {
|
||||
const auto name =
|
||||
|
||||
@@ -55,6 +55,9 @@ void ConfigureSystem::RetranslateUI() {
|
||||
void ConfigureSystem::SetConfiguration() {
|
||||
enabled = !Core::System::GetInstance().IsPoweredOn();
|
||||
|
||||
ui->label_console_id->setVisible(Settings::values == &Settings::global_values);
|
||||
ui->button_regenerate_console_id->setVisible(Settings::values == &Settings::global_values);
|
||||
|
||||
ui->combo_language->setCurrentIndex(Settings::values->language_index);
|
||||
ui->combo_region->setCurrentIndex(Settings::values->region_index);
|
||||
ui->combo_time_zone->setCurrentIndex(Settings::values->time_zone_index);
|
||||
|
||||
@@ -447,7 +447,7 @@ void Config::ReadValues() {
|
||||
out.push_back(inner_line);
|
||||
}
|
||||
|
||||
Settings::values->disabled_addons.insert_or_assign(title_id, out);
|
||||
Settings::global_values.disabled_addons.insert_or_assign(title_id, out);
|
||||
}
|
||||
|
||||
// Web Service
|
||||
|
||||
@@ -168,7 +168,7 @@ void Config::ReadValues() {
|
||||
out.push_back(inner_line);
|
||||
}
|
||||
|
||||
Settings::values->disabled_addons.insert_or_assign(title_id, out);
|
||||
Settings::global_values.disabled_addons.insert_or_assign(title_id, out);
|
||||
}
|
||||
|
||||
// Web Service
|
||||
|
||||
Reference in New Issue
Block a user