configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is overwritten by a per game setting.
This commit is contained in:
@@ -156,6 +156,9 @@ void ConfigureAudio::RetranslateUI() {
|
||||
|
||||
void ConfigureAudio::SetupPerGameUI() {
|
||||
if (Settings::configuring_global) {
|
||||
ui->volume_slider->setEnabled(Settings::values.volume.UsingGlobal());
|
||||
ui->toggle_audio_stretching->setEnabled(Settings::values.enable_audio_stretching.UsingGlobal());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ void ConfigureGeneral::SetConfiguration() {
|
||||
ui->toggle_frame_limit->setCheckState(Qt::PartiallyChecked);
|
||||
}
|
||||
|
||||
ui->frame_limit->setEnabled(ui->toggle_frame_limit->checkState() == Qt::Checked);
|
||||
ui->frame_limit->setEnabled(ui->toggle_frame_limit->checkState() == Qt::Checked && ui->toggle_frame_limit->isEnabled());
|
||||
}
|
||||
|
||||
void ConfigureGeneral::ApplyConfiguration() {
|
||||
@@ -60,11 +60,16 @@ void ConfigureGeneral::ApplyConfiguration() {
|
||||
Settings::values.use_frame_limit.SetGlobal(false);
|
||||
Settings::values.frame_limit.SetGlobal(false);
|
||||
}
|
||||
if (ui->toggle_frame_limit->isEnabled()) {
|
||||
Settings::values.use_frame_limit = ui->toggle_frame_limit->checkState() == Qt::Checked;
|
||||
Settings::values.frame_limit = ui->frame_limit->value();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Settings::values.use_frame_limit.SetGlobal(ui->toggle_frame_limit->checkState() == Qt::PartiallyChecked);
|
||||
Settings::values.frame_limit.SetGlobal(ui->toggle_frame_limit->checkState() == Qt::PartiallyChecked);
|
||||
Settings::values.use_frame_limit = ui->toggle_frame_limit->checkState() == Qt::Checked;
|
||||
Settings::values.frame_limit = ui->frame_limit->value();
|
||||
} else {
|
||||
Settings::values.use_frame_limit.SetGlobal(true);
|
||||
Settings::values.frame_limit.SetGlobal(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +87,9 @@ void ConfigureGeneral::RetranslateUI() {
|
||||
|
||||
void ConfigureGeneral::SetupPerGameUI() {
|
||||
if (Settings::configuring_global) {
|
||||
ui->toggle_frame_limit->setEnabled(Settings::values.use_frame_limit.UsingGlobal());
|
||||
ui->frame_limit->setEnabled(Settings::values.frame_limit.UsingGlobal());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,15 +85,27 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
|
||||
void ConfigureGraphics::ApplyConfiguration() {
|
||||
if (Settings::configuring_global) {
|
||||
Settings::values.renderer_backend = GetCurrentGraphicsBackend();
|
||||
Settings::values.vulkan_device = vulkan_device;
|
||||
Settings::values.aspect_ratio = ui->aspect_ratio_combobox->currentIndex();
|
||||
Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked();
|
||||
Settings::values.use_asynchronous_gpu_emulation =
|
||||
ui->use_asynchronous_gpu_emulation->isChecked();
|
||||
Settings::values.bg_red = static_cast<float>(bg_color.redF());
|
||||
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
|
||||
Settings::values.bg_blue = static_cast<float>(bg_color.blueF());
|
||||
if (ui->api->isEnabled()) {
|
||||
Settings::values.renderer_backend = GetCurrentGraphicsBackend();
|
||||
}
|
||||
if (ui->device->isEnabled()) {
|
||||
Settings::values.vulkan_device = vulkan_device;
|
||||
}
|
||||
if (ui->aspect_ratio_combobox->isEnabled()) {
|
||||
Settings::values.aspect_ratio = ui->aspect_ratio_combobox->currentIndex();
|
||||
}
|
||||
if (ui->use_disk_shader_cache->isEnabled()) {
|
||||
Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked();
|
||||
}
|
||||
if (ui->use_asynchronous_gpu_emulation->isEnabled()) {
|
||||
Settings::values.use_asynchronous_gpu_emulation =
|
||||
ui->use_asynchronous_gpu_emulation->isChecked();
|
||||
}
|
||||
if (ui->bg_button->isEnabled()) {
|
||||
Settings::values.bg_red = static_cast<float>(bg_color.redF());
|
||||
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
|
||||
Settings::values.bg_blue = static_cast<float>(bg_color.blueF());
|
||||
}
|
||||
} else {
|
||||
if (ui->api->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX)
|
||||
Settings::values.renderer_backend.SetGlobal(true);
|
||||
@@ -197,6 +209,13 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
||||
|
||||
void ConfigureGraphics::SetupPerGameUI() {
|
||||
if (Settings::configuring_global) {
|
||||
ui->api->setEnabled(Settings::values.renderer_backend.UsingGlobal());
|
||||
ui->device->setEnabled(Settings::values.renderer_backend.UsingGlobal());
|
||||
ui->aspect_ratio_combobox->setEnabled(Settings::values.aspect_ratio.UsingGlobal());
|
||||
ui->use_asynchronous_gpu_emulation->setEnabled(Settings::values.use_asynchronous_gpu_emulation.UsingGlobal());
|
||||
ui->use_disk_shader_cache->setEnabled(Settings::values.use_disk_shader_cache.UsingGlobal());
|
||||
ui->bg_button->setEnabled(Settings::values.bg_red.UsingGlobal());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,12 +55,26 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||
ui->gpu_accuracy->currentIndex() - ((Settings::configuring_global) ? 0 : 2));
|
||||
|
||||
if (Settings::configuring_global) {
|
||||
Settings::values.gpu_accuracy = gpu_accuracy;
|
||||
Settings::values.use_vsync = ui->use_vsync->isChecked();
|
||||
Settings::values.use_assembly_shaders = ui->use_assembly_shaders->isChecked();
|
||||
Settings::values.use_fast_gpu_time = ui->use_fast_gpu_time->isChecked();
|
||||
Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked();
|
||||
Settings::values.max_anisotropy = ui->anisotropic_filtering_combobox->currentIndex();
|
||||
// Must guard if they aren't enabled in case of a in-game configuration of settings while
|
||||
// already set to be game-specific.
|
||||
if (ui->gpu_accuracy->isEnabled()) {
|
||||
Settings::values.gpu_accuracy = gpu_accuracy;
|
||||
}
|
||||
if (ui->use_vsync->isEnabled()) {
|
||||
Settings::values.use_vsync = ui->use_vsync->isChecked();
|
||||
}
|
||||
if (ui->use_assembly_shaders->isEnabled()) {
|
||||
Settings::values.use_assembly_shaders = ui->use_assembly_shaders->isChecked();
|
||||
}
|
||||
if (ui->use_fast_gpu_time->isEnabled()) {
|
||||
Settings::values.use_fast_gpu_time = ui->use_fast_gpu_time->isChecked();
|
||||
}
|
||||
if (ui->force_30fps_mode->isEnabled()) {
|
||||
Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked();
|
||||
}
|
||||
if (ui->anisotropic_filtering_combobox->isEnabled()) {
|
||||
Settings::values.max_anisotropy = ui->anisotropic_filtering_combobox->currentIndex();
|
||||
}
|
||||
} else {
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
|
||||
ui->anisotropic_filtering_combobox);
|
||||
@@ -96,7 +110,15 @@ void ConfigureGraphicsAdvanced::RetranslateUI() {
|
||||
}
|
||||
|
||||
void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||
// Disable if not global (only happens during game)
|
||||
if (Settings::configuring_global) {
|
||||
ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal());
|
||||
ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal());
|
||||
ui->use_assembly_shaders->setEnabled(Settings::values.use_assembly_shaders.UsingGlobal());
|
||||
ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal());
|
||||
ui->force_30fps_mode->setEnabled(Settings::values.force_30fps_mode.UsingGlobal());
|
||||
ui->anisotropic_filtering_combobox->setEnabled(Settings::values.max_anisotropy.UsingGlobal());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "common/common_paths.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/control_metadata.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/xts_archive.h"
|
||||
@@ -29,7 +30,6 @@
|
||||
|
||||
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) {
|
||||
// REMOVE: Settings::SwapConfigValues(Settings::ValuesSwapTarget::ToGame);
|
||||
game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id) + ".ini", false);
|
||||
|
||||
Settings::configuring_global = false;
|
||||
@@ -46,9 +46,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
|
||||
LoadConfiguration();
|
||||
}
|
||||
|
||||
ConfigurePerGame::~ConfigurePerGame(){
|
||||
// REMOVE: Settings::SwapConfigValues(Settings::ValuesSwapTarget::ToGlobal);
|
||||
};
|
||||
ConfigurePerGame::~ConfigurePerGame() = default;
|
||||
|
||||
void ConfigurePerGame::ApplyConfiguration() {
|
||||
ui->addonsTab->ApplyConfiguration();
|
||||
@@ -57,12 +55,15 @@ void ConfigurePerGame::ApplyConfiguration() {
|
||||
ui->graphicsTab->ApplyConfiguration();
|
||||
ui->graphicsAdvancedTab->ApplyConfiguration();
|
||||
ui->audioTab->ApplyConfiguration();
|
||||
// ui->inputTab->ApplyConfiguration();
|
||||
|
||||
game_config->Save();
|
||||
|
||||
Settings::Apply();
|
||||
Settings::LogSettings();
|
||||
|
||||
if (!Core::System::GetInstance().IsPoweredOn()) {
|
||||
Settings::RestoreGlobalState();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurePerGame::changeEvent(QEvent* event) {
|
||||
@@ -140,15 +141,4 @@ void ConfigurePerGame::LoadConfiguration() {
|
||||
|
||||
const auto valueText = ReadableByteSize(file->GetSize());
|
||||
ui->display_size->setText(valueText);
|
||||
|
||||
// FIXME: UpdateVisibleTabs();
|
||||
}
|
||||
|
||||
void ConfigurePerGame::UpdateVisibleTabs(bool visible) {
|
||||
ui->generalTab->setEnabled(visible);
|
||||
ui->systemTab->setEnabled(visible);
|
||||
ui->graphicsTab->setEnabled(visible);
|
||||
ui->graphicsAdvancedTab->setEnabled(visible);
|
||||
ui->audioTab->setEnabled(visible);
|
||||
// FIXME: ui->inputTab->setEnabled(visible);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ private:
|
||||
|
||||
void LoadConfiguration();
|
||||
|
||||
void UpdateVisibleTabs(bool visible);
|
||||
|
||||
std::unique_ptr<Ui::ConfigurePerGame> ui;
|
||||
FileSys::VirtualFile file;
|
||||
u64 title_id;
|
||||
|
||||
@@ -74,11 +74,11 @@ void ConfigureSystem::SetConfiguration() {
|
||||
ui->combo_sound->setCurrentIndex(Settings::values.sound_index);
|
||||
|
||||
ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value());
|
||||
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value());
|
||||
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() && Settings::values.rng_seed.UsingGlobal());
|
||||
ui->rng_seed_edit->setText(rng_seed);
|
||||
|
||||
ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.GetValue().has_value());
|
||||
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value());
|
||||
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value() && Settings::values.rng_seed.UsingGlobal());
|
||||
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
|
||||
} else {
|
||||
ConfigurationShared::SetPerGameSetting(ui->combo_language,
|
||||
@@ -93,6 +93,7 @@ void ConfigureSystem::SetConfiguration() {
|
||||
} else {
|
||||
ui->rng_seed_checkbox->setCheckState(
|
||||
Settings::values.rng_seed.GetValue().has_value() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value());
|
||||
if (Settings::values.rng_seed.GetValue().has_value()) {
|
||||
ui->rng_seed_edit->setText(rng_seed);
|
||||
}
|
||||
@@ -103,6 +104,7 @@ void ConfigureSystem::SetConfiguration() {
|
||||
} else {
|
||||
ui->custom_rtc_checkbox->setCheckState(
|
||||
Settings::values.custom_rtc.GetValue().has_value() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value());
|
||||
if (Settings::values.custom_rtc.GetValue().has_value()) {
|
||||
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
|
||||
}
|
||||
@@ -118,22 +120,34 @@ void ConfigureSystem::ApplyConfiguration() {
|
||||
}
|
||||
|
||||
if (Settings::configuring_global) {
|
||||
Settings::values.language_index = ui->combo_language->currentIndex();
|
||||
Settings::values.region_index = ui->combo_region->currentIndex();
|
||||
Settings::values.time_zone_index = ui->combo_time_zone->currentIndex();
|
||||
Settings::values.sound_index = ui->combo_sound->currentIndex();
|
||||
|
||||
if (ui->rng_seed_checkbox->isChecked()) {
|
||||
Settings::values.rng_seed = ui->rng_seed_edit->text().toULongLong(nullptr, 16);
|
||||
} else {
|
||||
Settings::values.rng_seed = std::nullopt;
|
||||
if (ui->combo_language->isEnabled()) {
|
||||
Settings::values.language_index = ui->combo_language->currentIndex();
|
||||
}
|
||||
if (ui->combo_region->isEnabled()) {
|
||||
Settings::values.region_index = ui->combo_region->currentIndex();
|
||||
}
|
||||
if (ui->combo_time_zone->isEnabled()) {
|
||||
Settings::values.time_zone_index = ui->combo_time_zone->currentIndex();
|
||||
}
|
||||
if (ui->combo_sound->isEnabled()) {
|
||||
Settings::values.sound_index = ui->combo_sound->currentIndex();
|
||||
}
|
||||
|
||||
if (ui->custom_rtc_checkbox->isChecked()) {
|
||||
Settings::values.custom_rtc =
|
||||
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
|
||||
} else {
|
||||
Settings::values.custom_rtc = std::nullopt;
|
||||
if (ui->rng_seed_checkbox->isEnabled()) {
|
||||
if (ui->rng_seed_checkbox->isChecked()) {
|
||||
Settings::values.rng_seed = ui->rng_seed_edit->text().toULongLong(nullptr, 16);
|
||||
} else {
|
||||
Settings::values.rng_seed = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->custom_rtc_checkbox->isEnabled()) {
|
||||
if (ui->custom_rtc_checkbox->isChecked()) {
|
||||
Settings::values.custom_rtc =
|
||||
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
|
||||
} else {
|
||||
Settings::values.custom_rtc = std::nullopt;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.language_index,
|
||||
@@ -193,6 +207,15 @@ void ConfigureSystem::RefreshConsoleID() {
|
||||
|
||||
void ConfigureSystem::SetupPerGameUI() {
|
||||
if (Settings::configuring_global) {
|
||||
ui->combo_language->setEnabled(Settings::values.language_index.UsingGlobal());
|
||||
ui->combo_region->setEnabled(Settings::values.region_index.UsingGlobal());
|
||||
ui->combo_time_zone->setEnabled(Settings::values.time_zone_index.UsingGlobal());
|
||||
ui->combo_sound->setEnabled(Settings::values.sound_index.UsingGlobal());
|
||||
ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal());
|
||||
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal());
|
||||
ui->custom_rtc_checkbox->setEnabled(Settings::values.custom_rtc.UsingGlobal());
|
||||
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.UsingGlobal());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user