address comments and style issues

This commit is contained in:
lat9nq
2020-06-23 16:05:07 -04:00
parent 08018d985c
commit e2886132d9
11 changed files with 47 additions and 32 deletions

View File

@@ -2,8 +2,6 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cstring>
#include "common/file_util.h" #include "common/file_util.h"
#include "core/core.h" #include "core/core.h"
#include "core/gdbstub/gdbstub.h" #include "core/gdbstub/gdbstub.h"
@@ -63,7 +61,7 @@ const std::array<const char*, NumMouseButtons> mapping = {{
}}; }};
} }
Values values; Values values = {};
bool configuring_global = true; bool configuring_global = true;
std::string GetTimeZoneString() { std::string GetTimeZoneString() {

View File

@@ -390,6 +390,10 @@ public:
Setting() { Setting() {
use_global = true; use_global = true;
} }
Setting(Type val) {
use_global = true;
global = val;
}
~Setting() = default; ~Setting() = default;
void SetGlobal(bool to_global) { void SetGlobal(bool to_global) {
use_global = to_global; use_global = to_global;
@@ -398,15 +402,17 @@ public:
return use_global; return use_global;
}; };
Type GetValue() const { Type GetValue() const {
if (use_global) if (use_global) {
return global; return global;
}
return local; return local;
}; };
void SetValue(const Type& value) { void SetValue(const Type& value) {
if (use_global) if (use_global) {
global = value; global = value;
else } else {
local = value; local = value;
}
}; };
operator Type() const { operator Type() const {
return GetValue(); return GetValue();
@@ -441,7 +447,7 @@ struct Values {
Setting<bool> renderer_debug; Setting<bool> renderer_debug;
Setting<int> vulkan_device; Setting<int> vulkan_device;
Setting<u16> resolution_factor; Setting<u16> resolution_factor = Setting(static_cast<u16>(1));
Setting<int> aspect_ratio; Setting<int> aspect_ratio;
Setting<int> max_anisotropy; Setting<int> max_anisotropy;
Setting<bool> use_frame_limit; Setting<bool> use_frame_limit;

View File

@@ -52,7 +52,7 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor
u16 GetResolutionScaleFactor(const RendererBase& renderer) { u16 GetResolutionScaleFactor(const RendererBase& renderer) {
return static_cast<u16>( return static_cast<u16>(
Settings::values.resolution_factor != 0 Settings::values.resolution_factor != 0
? Settings::values.resolution_factor ? Settings::values.resolution_factor.GetValue()
: renderer.GetRenderWindow().GetFramebufferLayout().GetScalingRatio()); : renderer.GetRenderWindow().GetFramebufferLayout().GetScalingRatio());
} }

View File

@@ -145,7 +145,7 @@ public:
// disable vsync for any shared contexts // disable vsync for any shared contexts
auto format = share_context->format(); auto format = share_context->format();
format.setSwapInterval(main_surface ? Settings::values.use_vsync : 0); format.setSwapInterval(main_surface ? Settings::values.use_vsync.GetValue() : 0);
context = std::make_unique<QOpenGLContext>(); context = std::make_unique<QOpenGLContext>();
context->setShareContext(share_context); context->setShareContext(share_context);

View File

@@ -24,8 +24,9 @@ Config::Config(const std::string& config_file, bool is_global) {
} }
Config::~Config() { Config::~Config() {
if (global) if (global) {
Save(); Save();
}
} }
const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = {
@@ -640,7 +641,7 @@ void Config::ReadRendererValues() {
Settings::values.max_anisotropy = ReadSetting(QStringLiteral("max_anisotropy"), 0).toInt(); Settings::values.max_anisotropy = ReadSetting(QStringLiteral("max_anisotropy"), 0).toInt();
Settings::values.use_frame_limit = Settings::values.use_frame_limit =
ReadSetting(QStringLiteral("use_frame_limit"), true).toBool(); ReadSetting(QStringLiteral("use_frame_limit"), true).toBool();
Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toInt(); Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toUInt();
Settings::values.use_disk_shader_cache = Settings::values.use_disk_shader_cache =
ReadSetting(QStringLiteral("use_disk_shader_cache"), true).toBool(); ReadSetting(QStringLiteral("use_disk_shader_cache"), true).toBool();
const int gpu_accuracy_level = ReadSetting(QStringLiteral("gpu_accuracy"), 0).toInt(); const int gpu_accuracy_level = ReadSetting(QStringLiteral("gpu_accuracy"), 0).toInt();

View File

@@ -9,9 +9,9 @@
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting, void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
const QCheckBox* checkbox) { const QCheckBox* checkbox) {
if (checkbox->checkState() == Qt::PartiallyChecked) if (checkbox->checkState() == Qt::PartiallyChecked) {
setting->SetGlobal(true); setting->SetGlobal(true);
else { } else {
setting->SetGlobal(false); setting->SetGlobal(false);
setting->SetValue(checkbox->checkState() == Qt::Checked); setting->SetValue(checkbox->checkState() == Qt::Checked);
} }
@@ -19,9 +19,9 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting, void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting,
const QComboBox* combobox) { const QComboBox* combobox) {
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
setting->SetGlobal(true); setting->SetGlobal(true);
else { } else {
setting->SetGlobal(false); setting->SetGlobal(false);
setting->SetValue(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET); setting->SetValue(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET);
} }
@@ -29,9 +29,9 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting,
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<Settings::RendererBackend>* setting, void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<Settings::RendererBackend>* setting,
const QComboBox* combobox) { const QComboBox* combobox) {
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
setting->SetGlobal(true); setting->SetGlobal(true);
else { } else {
setting->SetGlobal(false); setting->SetGlobal(false);
setting->SetValue(static_cast<Settings::RendererBackend>( setting->SetValue(static_cast<Settings::RendererBackend>(
combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET)); combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET));
@@ -40,10 +40,11 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<Settings::Render
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox, void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
const Settings::Setting<bool>* setting) { const Settings::Setting<bool>* setting) {
if (setting->UsingGlobal()) if (setting->UsingGlobal()) {
checkbox->setCheckState(Qt::PartiallyChecked); checkbox->setCheckState(Qt::PartiallyChecked);
else } else {
checkbox->setCheckState(setting->GetValue() ? Qt::Checked : Qt::Unchecked); checkbox->setCheckState(setting->GetValue() ? Qt::Checked : Qt::Unchecked);
}
} }
void ConfigurationShared::SetPerGameSetting(QComboBox* combobox, void ConfigurationShared::SetPerGameSetting(QComboBox* combobox,

View File

@@ -155,8 +155,9 @@ void ConfigureAudio::RetranslateUI() {
} }
void ConfigureAudio::SetupPerGameUI() { void ConfigureAudio::SetupPerGameUI() {
if (Settings::configuring_global) if (Settings::configuring_global) {
return; return;
}
connect(ui->volume_combo_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), connect(ui->volume_combo_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
this, [this](int index) { ui->volume_slider->setEnabled(index == 1); }); this, [this](int index) { ui->volume_slider->setEnabled(index == 1); });

View File

@@ -39,8 +39,9 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
ui->frame_limit->setValue(Settings::values.frame_limit); ui->frame_limit->setValue(Settings::values.frame_limit);
if (!Settings::configuring_global && Settings::values.use_frame_limit.UsingGlobal()) if (!Settings::configuring_global && Settings::values.use_frame_limit.UsingGlobal()) {
ui->toggle_frame_limit->setCheckState(Qt::PartiallyChecked); 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);
} }
@@ -80,8 +81,9 @@ void ConfigureGeneral::RetranslateUI() {
} }
void ConfigureGeneral::SetupPerGameUI() { void ConfigureGeneral::SetupPerGameUI() {
if (Settings::configuring_global) if (Settings::configuring_global) {
return; return;
}
ui->toggle_check_exit->setVisible(false); ui->toggle_check_exit->setVisible(false);
ui->toggle_user_on_boot->setVisible(false); ui->toggle_user_on_boot->setVisible(false);

View File

@@ -183,8 +183,9 @@ void ConfigureGraphics::RetrieveVulkanDevices() {
} }
Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
if (Settings::configuring_global) if (Settings::configuring_global) {
return static_cast<Settings::RendererBackend>(ui->api->currentIndex()); return static_cast<Settings::RendererBackend>(ui->api->currentIndex());
}
if (ui->api->currentIndex() == 0) { if (ui->api->currentIndex() == 0) {
Settings::values.renderer_backend.SetGlobal(true); Settings::values.renderer_backend.SetGlobal(true);
@@ -195,8 +196,9 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
} }
void ConfigureGraphics::SetupPerGameUI() { void ConfigureGraphics::SetupPerGameUI() {
if (Settings::configuring_global) if (Settings::configuring_global) {
return; return;
}
connect(ui->bg_combobox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, connect(ui->bg_combobox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
[this](int index) { ui->bg_button->setEnabled(index == 1); }); [this](int index) { ui->bg_button->setEnabled(index == 1); });

View File

@@ -96,8 +96,9 @@ void ConfigureGraphicsAdvanced::RetranslateUI() {
} }
void ConfigureGraphicsAdvanced::SetupPerGameUI() { void ConfigureGraphicsAdvanced::SetupPerGameUI() {
if (Settings::configuring_global) if (Settings::configuring_global) {
return; return;
}
ConfigurationShared::InsertGlobalItem(ui->gpu_accuracy); ConfigurationShared::InsertGlobalItem(ui->gpu_accuracy);
ui->use_vsync->setTristate(true); ui->use_vsync->setTristate(true);

View File

@@ -88,22 +88,24 @@ void ConfigureSystem::SetConfiguration() {
&Settings::values.time_zone_index); &Settings::values.time_zone_index);
ConfigurationShared::SetPerGameSetting(ui->combo_sound, &Settings::values.sound_index); ConfigurationShared::SetPerGameSetting(ui->combo_sound, &Settings::values.sound_index);
if (Settings::values.rng_seed.UsingGlobal()) if (Settings::values.rng_seed.UsingGlobal()) {
ui->rng_seed_checkbox->setCheckState(Qt::PartiallyChecked); ui->rng_seed_checkbox->setCheckState(Qt::PartiallyChecked);
else { } else {
ui->rng_seed_checkbox->setCheckState( ui->rng_seed_checkbox->setCheckState(
Settings::values.rng_seed.GetValue().has_value() ? Qt::Checked : Qt::Unchecked); Settings::values.rng_seed.GetValue().has_value() ? Qt::Checked : Qt::Unchecked);
if (Settings::values.rng_seed.GetValue().has_value()) if (Settings::values.rng_seed.GetValue().has_value()) {
ui->rng_seed_edit->setText(rng_seed); ui->rng_seed_edit->setText(rng_seed);
}
} }
if (Settings::values.custom_rtc.UsingGlobal()) if (Settings::values.custom_rtc.UsingGlobal()) {
ui->custom_rtc_checkbox->setCheckState(Qt::PartiallyChecked); ui->custom_rtc_checkbox->setCheckState(Qt::PartiallyChecked);
else { } else {
ui->custom_rtc_checkbox->setCheckState( ui->custom_rtc_checkbox->setCheckState(
Settings::values.custom_rtc.GetValue().has_value() ? Qt::Checked : Qt::Unchecked); Settings::values.custom_rtc.GetValue().has_value() ? Qt::Checked : Qt::Unchecked);
if (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())); ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
}
} }
} }
} }
@@ -190,8 +192,9 @@ void ConfigureSystem::RefreshConsoleID() {
} }
void ConfigureSystem::SetupPerGameUI() { void ConfigureSystem::SetupPerGameUI() {
if (Settings::configuring_global) if (Settings::configuring_global) {
return; return;
}
ConfigurationShared::InsertGlobalItem(ui->combo_language); ConfigurationShared::InsertGlobalItem(ui->combo_language);
ConfigurationShared::InsertGlobalItem(ui->combo_region); ConfigurationShared::InsertGlobalItem(ui->combo_region);