forked from ShuriZma/suyu
1
0
Fork 0

configuration_shared: Break up tracker structs to respective classes

One less global variable.
This commit is contained in:
lat9nq 2020-07-14 13:55:47 -04:00
parent e483ed21eb
commit 0d462f5608
12 changed files with 58 additions and 49 deletions

View File

@ -10,10 +10,6 @@
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_per_game.h"
namespace ConfigurationShared {
Trackers trackers = {};
}
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
const QCheckBox* checkbox) {
if (checkbox->checkState() == Qt::PartiallyChecked) {

View File

@ -22,25 +22,6 @@ enum CheckState {
Count,
};
struct Trackers {
CheckState use_frame_limit;
CheckState use_multi_core;
CheckState enable_audio_stretching;
CheckState use_disk_shader_cache;
CheckState use_asynchronous_gpu_emulation;
CheckState use_vsync;
CheckState use_assembly_shaders;
CheckState use_asynchronous_shaders;
CheckState use_fast_gpu_time;
CheckState force_30fps_mode;
CheckState use_rng_seed;
CheckState use_custom_rtc;
} extern trackers;
// Global-aware apply and set functions
void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox,

View File

@ -120,7 +120,7 @@ void ConfigureAudio::ApplyConfiguration() {
} else {
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.enable_audio_stretching, ui->toggle_audio_stretching,
ConfigurationShared::trackers.enable_audio_stretching);
trackers.enable_audio_stretching);
if (ui->volume_combo_box->currentIndex() == 0) {
Settings::values.volume.SetGlobal(true);
} else {
@ -175,7 +175,7 @@ void ConfigureAudio::SetupPerGameUI() {
ConfigurationShared::SetColoredTristate(ui->toggle_audio_stretching, "toggle_audio_stretching",
Settings::values.enable_audio_stretching,
ConfigurationShared::trackers.enable_audio_stretching);
trackers.enable_audio_stretching);
connect(ui->volume_combo_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
this, [this](int index) {
ui->volume_slider->setEnabled(index == 1);

View File

@ -6,6 +6,7 @@
#include <memory>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Ui {
class ConfigureAudio;
@ -37,4 +38,8 @@ private:
void SetupPerGameUI();
std::unique_ptr<Ui::ConfigureAudio> ui;
struct Trackers {
ConfigurationShared::CheckState enable_audio_stretching;
} trackers;
};

View File

@ -45,7 +45,7 @@ void ConfigureGeneral::SetConfiguration() {
ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue());
} else {
ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue() &&
ConfigurationShared::trackers.use_frame_limit !=
trackers.use_frame_limit !=
ConfigurationShared::CheckState::Global);
}
}
@ -69,9 +69,9 @@ void ConfigureGeneral::ApplyConfiguration() {
} else {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core,
ui->use_multi_core,
ConfigurationShared::trackers.use_multi_core);
trackers.use_multi_core);
bool global_frame_limit = ConfigurationShared::trackers.use_frame_limit ==
bool global_frame_limit = trackers.use_frame_limit ==
ConfigurationShared::CheckState::Global;
Settings::values.use_frame_limit.SetGlobal(global_frame_limit);
Settings::values.frame_limit.SetGlobal(global_frame_limit);
@ -110,14 +110,14 @@ void ConfigureGeneral::SetupPerGameUI() {
ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, "toggle_frame_limit",
Settings::values.use_frame_limit,
ConfigurationShared::trackers.use_frame_limit);
trackers.use_frame_limit);
ConfigurationShared::SetColoredTristate(ui->use_multi_core, "use_multi_core",
Settings::values.use_multi_core,
ConfigurationShared::trackers.use_multi_core);
trackers.use_multi_core);
connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, [this]() {
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked() &&
(ConfigurationShared::trackers.use_frame_limit !=
(trackers.use_frame_limit !=
ConfigurationShared::CheckState::Global));
});
}

View File

@ -6,6 +6,7 @@
#include <memory>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
class HotkeyRegistry;
@ -31,4 +32,9 @@ private:
void SetupPerGameUI();
std::unique_ptr<Ui::ConfigureGeneral> ui;
struct Trackers {
ConfigurationShared::CheckState use_frame_limit;
ConfigurationShared::CheckState use_multi_core;
} trackers;
};

View File

@ -143,10 +143,10 @@ void ConfigureGraphics::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.use_disk_shader_cache, ui->use_disk_shader_cache,
ConfigurationShared::trackers.use_disk_shader_cache);
trackers.use_disk_shader_cache);
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.use_asynchronous_gpu_emulation, ui->use_asynchronous_gpu_emulation,
ConfigurationShared::trackers.use_asynchronous_gpu_emulation);
trackers.use_asynchronous_gpu_emulation);
if (ui->bg_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
Settings::values.bg_red.SetGlobal(true);
@ -257,11 +257,11 @@ void ConfigureGraphics::SetupPerGameUI() {
ConfigurationShared::SetColoredTristate(ui->use_disk_shader_cache, "use_disk_shader_cache",
Settings::values.use_disk_shader_cache,
ConfigurationShared::trackers.use_disk_shader_cache);
trackers.use_disk_shader_cache);
ConfigurationShared::SetColoredTristate(
ui->use_asynchronous_gpu_emulation, "use_asynchronous_gpu_emulation",
Settings::values.use_asynchronous_gpu_emulation,
ConfigurationShared::trackers.use_asynchronous_gpu_emulation);
trackers.use_asynchronous_gpu_emulation);
ConfigurationShared::SetColoredComboBox(ui->aspect_ratio_combobox, ui->ar_label, "ar_label",
Settings::values.aspect_ratio.GetValue(true));

View File

@ -9,6 +9,7 @@
#include <QString>
#include <QWidget>
#include "core/settings.h"
#include "yuzu/configuration/configuration_shared.h"
namespace Ui {
class ConfigureGraphics;
@ -42,6 +43,11 @@ private:
std::unique_ptr<Ui::ConfigureGraphics> ui;
QColor bg_color;
struct Trackers {
ConfigurationShared::CheckState use_disk_shader_cache;
ConfigurationShared::CheckState use_asynchronous_gpu_emulation;
} trackers;
std::vector<QString> vulkan_devices;
u32 vulkan_device{};
};

View File

@ -89,19 +89,19 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
ui->anisotropic_filtering_combobox);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync,
ConfigurationShared::trackers.use_vsync);
trackers.use_vsync);
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.use_assembly_shaders, ui->use_assembly_shaders,
ConfigurationShared::trackers.use_assembly_shaders);
trackers.use_assembly_shaders);
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.use_asynchronous_shaders, ui->use_asynchronous_shaders,
ConfigurationShared::trackers.use_asynchronous_shaders);
trackers.use_asynchronous_shaders);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time,
ui->use_fast_gpu_time,
ConfigurationShared::trackers.use_fast_gpu_time);
trackers.use_fast_gpu_time);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.force_30fps_mode,
ui->force_30fps_mode,
ConfigurationShared::trackers.force_30fps_mode);
trackers.force_30fps_mode);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
ui->anisotropic_filtering_combobox);
@ -143,19 +143,19 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
}
ConfigurationShared::SetColoredTristate(ui->use_vsync, "use_vsync", Settings::values.use_vsync,
ConfigurationShared::trackers.use_vsync);
trackers.use_vsync);
ConfigurationShared::SetColoredTristate(ui->use_assembly_shaders, "use_assembly_shaders",
Settings::values.use_assembly_shaders,
ConfigurationShared::trackers.use_assembly_shaders);
trackers.use_assembly_shaders);
ConfigurationShared::SetColoredTristate(ui->use_assembly_shaders, "use_asynchronous_shaders",
Settings::values.use_asynchronous_shaders,
ConfigurationShared::trackers.use_asynchronous_shaders);
trackers.use_asynchronous_shaders);
ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time, "use_fast_gpu_time",
Settings::values.use_fast_gpu_time,
ConfigurationShared::trackers.use_fast_gpu_time);
trackers.use_fast_gpu_time);
ConfigurationShared::SetColoredTristate(ui->force_30fps_mode, "force_30fps_mode",
Settings::values.force_30fps_mode,
ConfigurationShared::trackers.force_30fps_mode);
trackers.force_30fps_mode);
ConfigurationShared::SetColoredComboBox(
ui->gpu_accuracy, ui->label_gpu_accuracy, "label_gpu_accuracy",
static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));

View File

@ -6,6 +6,7 @@
#include <memory>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Ui {
class ConfigureGraphicsAdvanced;
@ -29,4 +30,12 @@ private:
void SetupPerGameUI();
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
struct Trackers {
ConfigurationShared::CheckState use_vsync;
ConfigurationShared::CheckState use_assembly_shaders;
ConfigurationShared::CheckState use_asynchronous_shaders;
ConfigurationShared::CheckState use_fast_gpu_time;
ConfigurationShared::CheckState force_30fps_mode;
} trackers;
};

View File

@ -148,7 +148,7 @@ void ConfigureSystem::ApplyConfiguration() {
ui->combo_time_zone);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.sound_index, ui->combo_sound);
switch (ConfigurationShared::trackers.use_rng_seed) {
switch (trackers.use_rng_seed) {
case ConfigurationShared::CheckState::On:
case ConfigurationShared::CheckState::Off:
Settings::values.rng_seed.SetGlobal(false);
@ -168,7 +168,7 @@ void ConfigureSystem::ApplyConfiguration() {
break;
}
switch (ConfigurationShared::trackers.use_custom_rtc) {
switch (trackers.use_custom_rtc) {
case ConfigurationShared::CheckState::On:
case ConfigurationShared::CheckState::Off:
Settings::values.custom_rtc.SetGlobal(false);
@ -238,10 +238,10 @@ void ConfigureSystem::SetupPerGameUI() {
Settings::values.rng_seed.UsingGlobal(),
Settings::values.rng_seed.GetValue().has_value(),
Settings::values.rng_seed.GetValue(true).has_value(),
ConfigurationShared::trackers.use_rng_seed);
trackers.use_rng_seed);
ConfigurationShared::SetColoredTristate(ui->custom_rtc_checkbox, "custom_rtc_checkbox",
Settings::values.custom_rtc.UsingGlobal(),
Settings::values.custom_rtc.GetValue().has_value(),
Settings::values.custom_rtc.GetValue(true).has_value(),
ConfigurationShared::trackers.use_custom_rtc);
trackers.use_custom_rtc);
}

View File

@ -8,6 +8,7 @@
#include <QList>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
namespace Ui {
class ConfigureSystem;
@ -41,4 +42,9 @@ private:
int region_index = 0;
int time_zone_index = 0;
int sound_index = 0;
struct Trackers {
ConfigurationShared::CheckState use_rng_seed;
ConfigurationShared::CheckState use_custom_rtc;
} trackers;
};