address comments and style issues
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "common/file_util.h"
|
||||
#include "core/core.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;
|
||||
|
||||
std::string GetTimeZoneString() {
|
||||
|
||||
@@ -390,6 +390,10 @@ public:
|
||||
Setting() {
|
||||
use_global = true;
|
||||
}
|
||||
Setting(Type val) {
|
||||
use_global = true;
|
||||
global = val;
|
||||
}
|
||||
~Setting() = default;
|
||||
void SetGlobal(bool to_global) {
|
||||
use_global = to_global;
|
||||
@@ -398,15 +402,17 @@ public:
|
||||
return use_global;
|
||||
};
|
||||
Type GetValue() const {
|
||||
if (use_global)
|
||||
if (use_global) {
|
||||
return global;
|
||||
}
|
||||
return local;
|
||||
};
|
||||
void SetValue(const Type& value) {
|
||||
if (use_global)
|
||||
if (use_global) {
|
||||
global = value;
|
||||
else
|
||||
} else {
|
||||
local = value;
|
||||
}
|
||||
};
|
||||
operator Type() const {
|
||||
return GetValue();
|
||||
@@ -441,7 +447,7 @@ struct Values {
|
||||
Setting<bool> renderer_debug;
|
||||
Setting<int> vulkan_device;
|
||||
|
||||
Setting<u16> resolution_factor;
|
||||
Setting<u16> resolution_factor = Setting(static_cast<u16>(1));
|
||||
Setting<int> aspect_ratio;
|
||||
Setting<int> max_anisotropy;
|
||||
Setting<bool> use_frame_limit;
|
||||
|
||||
@@ -52,7 +52,7 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor
|
||||
u16 GetResolutionScaleFactor(const RendererBase& renderer) {
|
||||
return static_cast<u16>(
|
||||
Settings::values.resolution_factor != 0
|
||||
? Settings::values.resolution_factor
|
||||
? Settings::values.resolution_factor.GetValue()
|
||||
: renderer.GetRenderWindow().GetFramebufferLayout().GetScalingRatio());
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
|
||||
// disable vsync for any shared contexts
|
||||
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->setShareContext(share_context);
|
||||
|
||||
@@ -24,8 +24,9 @@ Config::Config(const std::string& config_file, bool is_global) {
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
if (global)
|
||||
if (global) {
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
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.use_frame_limit =
|
||||
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 =
|
||||
ReadSetting(QStringLiteral("use_disk_shader_cache"), true).toBool();
|
||||
const int gpu_accuracy_level = ReadSetting(QStringLiteral("gpu_accuracy"), 0).toInt();
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
|
||||
const QCheckBox* checkbox) {
|
||||
if (checkbox->checkState() == Qt::PartiallyChecked)
|
||||
if (checkbox->checkState() == Qt::PartiallyChecked) {
|
||||
setting->SetGlobal(true);
|
||||
else {
|
||||
} else {
|
||||
setting->SetGlobal(false);
|
||||
setting->SetValue(checkbox->checkState() == Qt::Checked);
|
||||
}
|
||||
@@ -19,9 +19,9 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
|
||||
|
||||
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting,
|
||||
const QComboBox* combobox) {
|
||||
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX)
|
||||
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||
setting->SetGlobal(true);
|
||||
else {
|
||||
} else {
|
||||
setting->SetGlobal(false);
|
||||
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,
|
||||
const QComboBox* combobox) {
|
||||
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX)
|
||||
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||
setting->SetGlobal(true);
|
||||
else {
|
||||
} else {
|
||||
setting->SetGlobal(false);
|
||||
setting->SetValue(static_cast<Settings::RendererBackend>(
|
||||
combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET));
|
||||
@@ -40,10 +40,11 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<Settings::Render
|
||||
|
||||
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
|
||||
const Settings::Setting<bool>* setting) {
|
||||
if (setting->UsingGlobal())
|
||||
if (setting->UsingGlobal()) {
|
||||
checkbox->setCheckState(Qt::PartiallyChecked);
|
||||
else
|
||||
} else {
|
||||
checkbox->setCheckState(setting->GetValue() ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationShared::SetPerGameSetting(QComboBox* combobox,
|
||||
|
||||
@@ -155,8 +155,9 @@ void ConfigureAudio::RetranslateUI() {
|
||||
}
|
||||
|
||||
void ConfigureAudio::SetupPerGameUI() {
|
||||
if (Settings::configuring_global)
|
||||
if (Settings::configuring_global) {
|
||||
return;
|
||||
}
|
||||
|
||||
connect(ui->volume_combo_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
|
||||
this, [this](int index) { ui->volume_slider->setEnabled(index == 1); });
|
||||
|
||||
@@ -39,8 +39,9 @@ void ConfigureGeneral::SetConfiguration() {
|
||||
ui->toggle_frame_limit->setChecked(Settings::values.use_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->frame_limit->setEnabled(ui->toggle_frame_limit->checkState() == Qt::Checked);
|
||||
}
|
||||
@@ -80,8 +81,9 @@ void ConfigureGeneral::RetranslateUI() {
|
||||
}
|
||||
|
||||
void ConfigureGeneral::SetupPerGameUI() {
|
||||
if (Settings::configuring_global)
|
||||
if (Settings::configuring_global) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui->toggle_check_exit->setVisible(false);
|
||||
ui->toggle_user_on_boot->setVisible(false);
|
||||
|
||||
@@ -183,8 +183,9 @@ void ConfigureGraphics::RetrieveVulkanDevices() {
|
||||
}
|
||||
|
||||
Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
||||
if (Settings::configuring_global)
|
||||
if (Settings::configuring_global) {
|
||||
return static_cast<Settings::RendererBackend>(ui->api->currentIndex());
|
||||
}
|
||||
|
||||
if (ui->api->currentIndex() == 0) {
|
||||
Settings::values.renderer_backend.SetGlobal(true);
|
||||
@@ -195,8 +196,9 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
||||
}
|
||||
|
||||
void ConfigureGraphics::SetupPerGameUI() {
|
||||
if (Settings::configuring_global)
|
||||
if (Settings::configuring_global) {
|
||||
return;
|
||||
}
|
||||
|
||||
connect(ui->bg_combobox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
|
||||
[this](int index) { ui->bg_button->setEnabled(index == 1); });
|
||||
|
||||
@@ -96,8 +96,9 @@ void ConfigureGraphicsAdvanced::RetranslateUI() {
|
||||
}
|
||||
|
||||
void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||
if (Settings::configuring_global)
|
||||
if (Settings::configuring_global) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationShared::InsertGlobalItem(ui->gpu_accuracy);
|
||||
ui->use_vsync->setTristate(true);
|
||||
|
||||
@@ -88,22 +88,24 @@ void ConfigureSystem::SetConfiguration() {
|
||||
&Settings::values.time_zone_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);
|
||||
else {
|
||||
} else {
|
||||
ui->rng_seed_checkbox->setCheckState(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings::values.custom_rtc.UsingGlobal())
|
||||
if (Settings::values.custom_rtc.UsingGlobal()) {
|
||||
ui->custom_rtc_checkbox->setCheckState(Qt::PartiallyChecked);
|
||||
else {
|
||||
} else {
|
||||
ui->custom_rtc_checkbox->setCheckState(
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,8 +192,9 @@ void ConfigureSystem::RefreshConsoleID() {
|
||||
}
|
||||
|
||||
void ConfigureSystem::SetupPerGameUI() {
|
||||
if (Settings::configuring_global)
|
||||
if (Settings::configuring_global) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationShared::InsertGlobalItem(ui->combo_language);
|
||||
ConfigurationShared::InsertGlobalItem(ui->combo_region);
|
||||
|
||||
Reference in New Issue
Block a user