diff options
Diffstat (limited to 'src')
18 files changed, 206 insertions, 209 deletions
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 8c5378925..6db47fd61 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -16,23 +16,19 @@ | |||
| 16 | #include "yuzu/configuration/shared_widget.h" | 16 | #include "yuzu/configuration/shared_widget.h" |
| 17 | #include "yuzu/uisettings.h" | 17 | #include "yuzu/uisettings.h" |
| 18 | 18 | ||
| 19 | ConfigureAudio::ConfigureAudio( | 19 | ConfigureAudio::ConfigureAudio(const Core::System& system_, |
| 20 | const Core::System& system_, | 20 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, |
| 21 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, | 21 | const ConfigurationShared::Builder& builder, QWidget* parent) |
| 22 | const ConfigurationShared::TranslationMap& translations_, | 22 | : Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_} { |
| 23 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) | ||
| 24 | : Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_}, | ||
| 25 | translations{translations_}, combobox_translations{combobox_translations_} { | ||
| 26 | ui->setupUi(this); | 23 | ui->setupUi(this); |
| 27 | Setup(); | 24 | Setup(builder); |
| 28 | 25 | ||
| 29 | SetConfiguration(); | 26 | SetConfiguration(); |
| 30 | } | 27 | } |
| 31 | 28 | ||
| 32 | ConfigureAudio::~ConfigureAudio() = default; | 29 | ConfigureAudio::~ConfigureAudio() = default; |
| 33 | 30 | ||
| 34 | void ConfigureAudio::Setup() { | 31 | void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { |
| 35 | const bool runtime_lock = !system.IsPoweredOn(); | ||
| 36 | auto& layout = *ui->audio_widget->layout(); | 32 | auto& layout = *ui->audio_widget->layout(); |
| 37 | 33 | ||
| 38 | std::forward_list<Settings::BasicSetting*> settings; | 34 | std::forward_list<Settings::BasicSetting*> settings; |
| @@ -47,31 +43,27 @@ void ConfigureAudio::Setup() { | |||
| 47 | push(Settings::Category::SystemAudio); | 43 | push(Settings::Category::SystemAudio); |
| 48 | 44 | ||
| 49 | for (auto* setting : settings) { | 45 | for (auto* setting : settings) { |
| 50 | if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { | ||
| 51 | continue; | ||
| 52 | } | ||
| 53 | |||
| 54 | auto* widget = [&]() { | 46 | auto* widget = [&]() { |
| 55 | if (setting->Id() == Settings::values.volume.Id()) { | 47 | if (setting->Id() == Settings::values.volume.Id()) { |
| 56 | // volume needs to be a slider (default is line edit) | 48 | // volume needs to be a slider (default is line edit) |
| 57 | return new ConfigurationShared::Widget(setting, translations, combobox_translations, | 49 | return builder.BuildWidget(setting, apply_funcs, nullptr, |
| 58 | this, runtime_lock, apply_funcs, nullptr, | 50 | ConfigurationShared::RequestType::Slider, |
| 59 | ConfigurationShared::RequestType::Slider, | 51 | tr("%1%", "Volume percentage (e.g. 50%)")); |
| 60 | tr("%1%", "Volume percentage (e.g. 50%)")); | ||
| 61 | } else if (setting->Id() == Settings::values.audio_output_device_id.Id() || | 52 | } else if (setting->Id() == Settings::values.audio_output_device_id.Id() || |
| 62 | setting->Id() == Settings::values.audio_input_device_id.Id() || | 53 | setting->Id() == Settings::values.audio_input_device_id.Id() || |
| 63 | setting->Id() == Settings::values.sink_id.Id()) { | 54 | setting->Id() == Settings::values.sink_id.Id()) { |
| 64 | // These need to be unmanaged comboboxes, so we can populate them ourselves | 55 | // These need to be unmanaged comboboxes, so we can populate them ourselves |
| 65 | // TODO (lat9nq): Let it manage sink_id | 56 | // TODO (lat9nq): Let it manage sink_id |
| 66 | return new ConfigurationShared::Widget( | 57 | return builder.BuildWidget(setting, apply_funcs, |
| 67 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs, | 58 | ConfigurationShared::RequestType::ComboBox, false); |
| 68 | ConfigurationShared::RequestType::ComboBox, false); | ||
| 69 | } else { | 59 | } else { |
| 70 | return new ConfigurationShared::Widget(setting, translations, combobox_translations, | 60 | return builder.BuildWidget(setting, apply_funcs); |
| 71 | this, runtime_lock, apply_funcs); | ||
| 72 | } | 61 | } |
| 73 | }(); | 62 | }(); |
| 74 | 63 | ||
| 64 | if (widget == nullptr) { | ||
| 65 | continue; | ||
| 66 | } | ||
| 75 | if (!widget->Valid()) { | 67 | if (!widget->Valid()) { |
| 76 | delete widget; | 68 | delete widget; |
| 77 | continue; | 69 | continue; |
diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 31cf682e0..94606f210 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <QWidget> | 9 | #include <QWidget> |
| 10 | #include "yuzu/configuration/configuration_shared.h" | 10 | #include "yuzu/configuration/configuration_shared.h" |
| 11 | #include "yuzu/configuration/shared_translation.h" | ||
| 12 | 11 | ||
| 13 | class QComboBox; | 12 | class QComboBox; |
| 14 | 13 | ||
| @@ -20,14 +19,15 @@ namespace Ui { | |||
| 20 | class ConfigureAudio; | 19 | class ConfigureAudio; |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 22 | namespace ConfigurationShared { | ||
| 23 | class Builder; | ||
| 24 | } | ||
| 25 | |||
| 23 | class ConfigureAudio : public ConfigurationShared::Tab { | 26 | class ConfigureAudio : public ConfigurationShared::Tab { |
| 24 | public: | 27 | public: |
| 25 | explicit ConfigureAudio( | 28 | explicit ConfigureAudio(const Core::System& system_, |
| 26 | const Core::System& system_, | 29 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 27 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 30 | const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); |
| 28 | const ConfigurationShared::TranslationMap& translations_, | ||
| 29 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, | ||
| 30 | QWidget* parent = nullptr); | ||
| 31 | ~ConfigureAudio() override; | 31 | ~ConfigureAudio() override; |
| 32 | 32 | ||
| 33 | void ApplyConfiguration() override; | 33 | void ApplyConfiguration() override; |
| @@ -45,13 +45,11 @@ private: | |||
| 45 | void SetOutputSinkFromSinkID(); | 45 | void SetOutputSinkFromSinkID(); |
| 46 | void SetAudioDevicesFromDeviceID(); | 46 | void SetAudioDevicesFromDeviceID(); |
| 47 | 47 | ||
| 48 | void Setup(); | 48 | void Setup(const ConfigurationShared::Builder& builder); |
| 49 | 49 | ||
| 50 | std::unique_ptr<Ui::ConfigureAudio> ui; | 50 | std::unique_ptr<Ui::ConfigureAudio> ui; |
| 51 | 51 | ||
| 52 | const Core::System& system; | 52 | const Core::System& system; |
| 53 | const ConfigurationShared::TranslationMap& translations; | ||
| 54 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | ||
| 55 | 53 | ||
| 56 | std::forward_list<std::function<void(bool)>> apply_funcs{}; | 54 | std::forward_list<std::function<void(bool)>> apply_funcs{}; |
| 57 | 55 | ||
diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 210af146d..57cdc4c63 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp | |||
| @@ -13,16 +13,14 @@ | |||
| 13 | #include "yuzu/configuration/configuration_shared.h" | 13 | #include "yuzu/configuration/configuration_shared.h" |
| 14 | #include "yuzu/configuration/configure_cpu.h" | 14 | #include "yuzu/configuration/configure_cpu.h" |
| 15 | 15 | ||
| 16 | ConfigureCpu::ConfigureCpu( | 16 | ConfigureCpu::ConfigureCpu(const Core::System& system_, |
| 17 | const Core::System& system_, | 17 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, |
| 18 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, | 18 | const ConfigurationShared::Builder& builder, QWidget* parent) |
| 19 | const ConfigurationShared::TranslationMap& translations_, | ||
| 20 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) | ||
| 21 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_}, | 19 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_}, |
| 22 | translations{translations_}, combobox_translations{combobox_translations_} { | 20 | combobox_translations(builder.ComboboxTranslations()) { |
| 23 | ui->setupUi(this); | 21 | ui->setupUi(this); |
| 24 | 22 | ||
| 25 | Setup(); | 23 | Setup(builder); |
| 26 | 24 | ||
| 27 | SetConfiguration(); | 25 | SetConfiguration(); |
| 28 | 26 | ||
| @@ -33,8 +31,7 @@ ConfigureCpu::ConfigureCpu( | |||
| 33 | ConfigureCpu::~ConfigureCpu() = default; | 31 | ConfigureCpu::~ConfigureCpu() = default; |
| 34 | 32 | ||
| 35 | void ConfigureCpu::SetConfiguration() {} | 33 | void ConfigureCpu::SetConfiguration() {} |
| 36 | void ConfigureCpu::Setup() { | 34 | void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { |
| 37 | const bool runtime_lock = !system.IsPoweredOn(); | ||
| 38 | auto* accuracy_layout = ui->widget_accuracy->layout(); | 35 | auto* accuracy_layout = ui->widget_accuracy->layout(); |
| 39 | auto* unsafe_layout = ui->unsafe_widget->layout(); | 36 | auto* unsafe_layout = ui->unsafe_widget->layout(); |
| 40 | std::map<std::string, QWidget*> unsafe_hold{}; | 37 | std::map<std::string, QWidget*> unsafe_hold{}; |
| @@ -50,13 +47,11 @@ void ConfigureCpu::Setup() { | |||
| 50 | push(Settings::Category::CpuUnsafe); | 47 | push(Settings::Category::CpuUnsafe); |
| 51 | 48 | ||
| 52 | for (const auto setting : settings) { | 49 | for (const auto setting : settings) { |
| 53 | if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { | 50 | auto* widget = builder.BuildWidget(setting, apply_funcs); |
| 51 | |||
| 52 | if (widget == nullptr) { | ||
| 54 | continue; | 53 | continue; |
| 55 | } | 54 | } |
| 56 | |||
| 57 | auto* widget = new ConfigurationShared::Widget(setting, translations, combobox_translations, | ||
| 58 | this, runtime_lock, apply_funcs); | ||
| 59 | |||
| 60 | if (!widget->Valid()) { | 55 | if (!widget->Valid()) { |
| 61 | delete widget; | 56 | delete widget; |
| 62 | continue; | 57 | continue; |
diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index 57603e5c9..ab19c0ba1 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h | |||
| @@ -18,13 +18,15 @@ namespace Ui { | |||
| 18 | class ConfigureCpu; | 18 | class ConfigureCpu; |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | namespace ConfigurationShared { | ||
| 22 | class Builder; | ||
| 23 | } | ||
| 24 | |||
| 21 | class ConfigureCpu : public ConfigurationShared::Tab { | 25 | class ConfigureCpu : public ConfigurationShared::Tab { |
| 22 | public: | 26 | public: |
| 23 | explicit ConfigureCpu(const Core::System& system_, | 27 | explicit ConfigureCpu(const Core::System& system_, |
| 24 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 28 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 25 | const ConfigurationShared::TranslationMap& translations, | 29 | const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); |
| 26 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations, | ||
| 27 | QWidget* parent = nullptr); | ||
| 28 | ~ConfigureCpu() override; | 30 | ~ConfigureCpu() override; |
| 29 | 31 | ||
| 30 | void ApplyConfiguration() override; | 32 | void ApplyConfiguration() override; |
| @@ -36,15 +38,13 @@ private: | |||
| 36 | 38 | ||
| 37 | void UpdateGroup(int index); | 39 | void UpdateGroup(int index); |
| 38 | 40 | ||
| 39 | void Setup(); | 41 | void Setup(const ConfigurationShared::Builder& builder); |
| 40 | 42 | ||
| 41 | std::unique_ptr<Ui::ConfigureCpu> ui; | 43 | std::unique_ptr<Ui::ConfigureCpu> ui; |
| 42 | 44 | ||
| 43 | const Core::System& system; | 45 | const Core::System& system; |
| 44 | 46 | ||
| 45 | const ConfigurationShared::TranslationMap& translations; | ||
| 46 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | 47 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; |
| 47 | |||
| 48 | std::forward_list<std::function<void(bool)>> apply_funcs{}; | 48 | std::forward_list<std::function<void(bool)>> apply_funcs{}; |
| 49 | 49 | ||
| 50 | QComboBox* accuracy_combobox; | 50 | QComboBox* accuracy_combobox; |
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index c7d132fc8..183555acd 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -32,28 +32,23 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, | |||
| 32 | std::vector<VkDeviceInfo::Record>& vk_device_records, | 32 | std::vector<VkDeviceInfo::Record>& vk_device_records, |
| 33 | Core::System& system_, bool enable_web_config) | 33 | Core::System& system_, bool enable_web_config) |
| 34 | : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, | 34 | : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, |
| 35 | registry(registry_), system{system_}, | 35 | registry(registry_), system{system_}, builder{std::make_unique<ConfigurationShared::Builder>( |
| 36 | translations{ConfigurationShared::InitializeTranslations(this)}, | 36 | this, !system_.IsPoweredOn())}, |
| 37 | combobox_translations{ConfigurationShared::ComboboxEnumeration(this)}, | 37 | audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *builder, this)}, |
| 38 | audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *translations, | 38 | cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *builder, this)}, |
| 39 | *combobox_translations, this)}, | ||
| 40 | cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *translations, | ||
| 41 | *combobox_translations, this)}, | ||
| 42 | debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, | 39 | debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, |
| 43 | filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, | 40 | filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, |
| 44 | general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *translations, | 41 | general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *builder, this)}, |
| 45 | *combobox_translations, this)}, | 42 | graphics_advanced_tab{ |
| 46 | graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>( | 43 | std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *builder, this)}, |
| 47 | system_, nullptr, *translations, *combobox_translations, this)}, | ||
| 48 | graphics_tab{std::make_unique<ConfigureGraphics>( | 44 | graphics_tab{std::make_unique<ConfigureGraphics>( |
| 49 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, | 45 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, |
| 50 | nullptr, *translations, *combobox_translations, this)}, | 46 | nullptr, *builder, this)}, |
| 51 | hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, | 47 | hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, |
| 52 | input_tab{std::make_unique<ConfigureInput>(system_, this)}, | 48 | input_tab{std::make_unique<ConfigureInput>(system_, this)}, |
| 53 | network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, | 49 | network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, |
| 54 | profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, | 50 | profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, |
| 55 | system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *translations, | 51 | system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)}, |
| 56 | *combobox_translations, this)}, | ||
| 57 | ui_tab{std::make_unique<ConfigureUi>(system_, this)}, web_tab{std::make_unique<ConfigureWeb>( | 52 | ui_tab{std::make_unique<ConfigureUi>(system_, this)}, web_tab{std::make_unique<ConfigureWeb>( |
| 58 | this)} { | 53 | this)} { |
| 59 | Settings::SetConfiguringGlobal(true); | 54 | Settings::SetConfiguringGlobal(true); |
diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 931900b7d..1bfc9f9d0 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include <QDialog> | 9 | #include <QDialog> |
| 10 | #include "configuration/shared_widget.h" | ||
| 10 | #include "yuzu/configuration/configuration_shared.h" | 11 | #include "yuzu/configuration/configuration_shared.h" |
| 11 | #include "yuzu/configuration/shared_translation.h" | 12 | #include "yuzu/configuration/shared_translation.h" |
| 12 | #include "yuzu/vk_device_info.h" | 13 | #include "yuzu/vk_device_info.h" |
| @@ -72,8 +73,7 @@ private: | |||
| 72 | HotkeyRegistry& registry; | 73 | HotkeyRegistry& registry; |
| 73 | 74 | ||
| 74 | Core::System& system; | 75 | Core::System& system; |
| 75 | std::unique_ptr<ConfigurationShared::TranslationMap> translations; | 76 | std::unique_ptr<ConfigurationShared::Builder> builder; |
| 76 | std::unique_ptr<ConfigurationShared::ComboboxTranslationMap> combobox_translations; | ||
| 77 | std::forward_list<ConfigurationShared::Tab*> tab_group; | 77 | std::forward_list<ConfigurationShared::Tab*> tab_group; |
| 78 | 78 | ||
| 79 | std::unique_ptr<ConfigureAudio> audio_tab; | 79 | std::unique_ptr<ConfigureAudio> audio_tab; |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index ca5b92bc0..54113543a 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -15,12 +15,12 @@ | |||
| 15 | ConfigureGeneral::ConfigureGeneral( | 15 | ConfigureGeneral::ConfigureGeneral( |
| 16 | const Core::System& system_, | 16 | const Core::System& system_, |
| 17 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, | 17 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, |
| 18 | const ConfigurationShared::TranslationMap& translations_, | 18 | const ConfigurationShared::Builder& builder, QWidget* parent) |
| 19 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) | 19 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} { |
| 20 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_}, | ||
| 21 | translations{translations_}, combobox_translations{combobox_translations_} { | ||
| 22 | ui->setupUi(this); | 20 | ui->setupUi(this); |
| 23 | 21 | ||
| 22 | Setup(builder); | ||
| 23 | |||
| 24 | SetConfiguration(); | 24 | SetConfiguration(); |
| 25 | 25 | ||
| 26 | connect(ui->button_reset_defaults, &QPushButton::clicked, this, | 26 | connect(ui->button_reset_defaults, &QPushButton::clicked, this, |
| @@ -33,17 +33,20 @@ ConfigureGeneral::ConfigureGeneral( | |||
| 33 | 33 | ||
| 34 | ConfigureGeneral::~ConfigureGeneral() = default; | 34 | ConfigureGeneral::~ConfigureGeneral() = default; |
| 35 | 35 | ||
| 36 | void ConfigureGeneral::SetConfiguration() { | 36 | void ConfigureGeneral::SetConfiguration() {} |
| 37 | const bool runtime_lock = !system.IsPoweredOn(); | 37 | |
| 38 | void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) { | ||
| 38 | QLayout& layout = *ui->general_widget->layout(); | 39 | QLayout& layout = *ui->general_widget->layout(); |
| 39 | 40 | ||
| 40 | std::map<u32, QWidget*> hold{}; | 41 | std::map<u32, QWidget*> hold{}; |
| 41 | 42 | ||
| 42 | for (const auto setting : | 43 | for (const auto setting : |
| 43 | UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) { | 44 | UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) { |
| 44 | auto* widget = new ConfigurationShared::Widget(setting, translations, combobox_translations, | 45 | auto* widget = builder.BuildWidget(setting, apply_funcs); |
| 45 | this, runtime_lock, apply_funcs); | ||
| 46 | 46 | ||
| 47 | if (widget == nullptr) { | ||
| 48 | continue; | ||
| 49 | } | ||
| 47 | if (!widget->Valid()) { | 50 | if (!widget->Valid()) { |
| 48 | delete widget; | 51 | delete widget; |
| 49 | continue; | 52 | continue; |
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 864dc3d2e..f8ed3f8ab 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <QWidget> | 8 | #include <QWidget> |
| 9 | #include "yuzu/configuration/configuration_shared.h" | 9 | #include "yuzu/configuration/configuration_shared.h" |
| 10 | #include "yuzu/configuration/shared_widget.h" | ||
| 11 | 10 | ||
| 12 | namespace Core { | 11 | namespace Core { |
| 13 | class System; | 12 | class System; |
| @@ -20,14 +19,16 @@ namespace Ui { | |||
| 20 | class ConfigureGeneral; | 19 | class ConfigureGeneral; |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 22 | namespace ConfigurationShared { | ||
| 23 | class Builder; | ||
| 24 | } | ||
| 25 | |||
| 23 | class ConfigureGeneral : public ConfigurationShared::Tab { | 26 | class ConfigureGeneral : public ConfigurationShared::Tab { |
| 24 | public: | 27 | public: |
| 25 | explicit ConfigureGeneral( | 28 | explicit ConfigureGeneral(const Core::System& system_, |
| 26 | const Core::System& system_, | 29 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 27 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 30 | const ConfigurationShared::Builder& builder, |
| 28 | const ConfigurationShared::TranslationMap& translations_, | 31 | QWidget* parent = nullptr); |
| 29 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, | ||
| 30 | QWidget* parent = nullptr); | ||
| 31 | ~ConfigureGeneral() override; | 32 | ~ConfigureGeneral() override; |
| 32 | 33 | ||
| 33 | void SetResetCallback(std::function<void()> callback); | 34 | void SetResetCallback(std::function<void()> callback); |
| @@ -36,6 +37,8 @@ public: | |||
| 36 | void SetConfiguration() override; | 37 | void SetConfiguration() override; |
| 37 | 38 | ||
| 38 | private: | 39 | private: |
| 40 | void Setup(const ConfigurationShared::Builder& builder); | ||
| 41 | |||
| 39 | void changeEvent(QEvent* event) override; | 42 | void changeEvent(QEvent* event) override; |
| 40 | void RetranslateUI(); | 43 | void RetranslateUI(); |
| 41 | 44 | ||
| @@ -46,6 +49,4 @@ private: | |||
| 46 | std::forward_list<std::function<void(bool)>> apply_funcs{}; | 49 | std::forward_list<std::function<void(bool)>> apply_funcs{}; |
| 47 | 50 | ||
| 48 | const Core::System& system; | 51 | const Core::System& system; |
| 49 | const ConfigurationShared::TranslationMap& translations; | ||
| 50 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | ||
| 51 | }; | 52 | }; |
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 2f041cba6..18872fa69 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -81,18 +81,17 @@ ConfigureGraphics::ConfigureGraphics( | |||
| 81 | const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_, | 81 | const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_, |
| 82 | const std::function<void()>& expose_compute_option_, | 82 | const std::function<void()>& expose_compute_option_, |
| 83 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, | 83 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, |
| 84 | const ConfigurationShared::TranslationMap& translations_, | 84 | const ConfigurationShared::Builder& builder, QWidget* parent) |
| 85 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) | ||
| 86 | : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, | 85 | : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, |
| 87 | records{records_}, expose_compute_option{expose_compute_option_}, system{system_}, | 86 | records{records_}, expose_compute_option{expose_compute_option_}, system{system_}, |
| 88 | translations{translations_}, combobox_translations{combobox_translations_}, | 87 | combobox_translations{builder.ComboboxTranslations()}, |
| 89 | shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} { | 88 | shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} { |
| 90 | vulkan_device = Settings::values.vulkan_device.GetValue(); | 89 | vulkan_device = Settings::values.vulkan_device.GetValue(); |
| 91 | RetrieveVulkanDevices(); | 90 | RetrieveVulkanDevices(); |
| 92 | 91 | ||
| 93 | ui->setupUi(this); | 92 | ui->setupUi(this); |
| 94 | 93 | ||
| 95 | Setup(); | 94 | Setup(builder); |
| 96 | 95 | ||
| 97 | for (const auto& device : vulkan_devices) { | 96 | for (const auto& device : vulkan_devices) { |
| 98 | vulkan_device_combobox->addItem(device); | 97 | vulkan_device_combobox->addItem(device); |
| @@ -218,8 +217,7 @@ ConfigureGraphics::~ConfigureGraphics() = default; | |||
| 218 | 217 | ||
| 219 | void ConfigureGraphics::SetConfiguration() {} | 218 | void ConfigureGraphics::SetConfiguration() {} |
| 220 | 219 | ||
| 221 | void ConfigureGraphics::Setup() { | 220 | void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { |
| 222 | const bool runtime_lock = !system.IsPoweredOn(); | ||
| 223 | QLayout* api_layout = ui->api_widget->layout(); | 221 | QLayout* api_layout = ui->api_widget->layout(); |
| 224 | QWidget* api_grid_widget = new QWidget(this); | 222 | QWidget* api_grid_widget = new QWidget(this); |
| 225 | QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget); | 223 | QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget); |
| @@ -232,30 +230,26 @@ void ConfigureGraphics::Setup() { | |||
| 232 | std::forward_list<QWidget*> hold_api; | 230 | std::forward_list<QWidget*> hold_api; |
| 233 | 231 | ||
| 234 | for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { | 232 | for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { |
| 235 | if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { | ||
| 236 | continue; | ||
| 237 | } | ||
| 238 | |||
| 239 | ConfigurationShared::Widget* widget = [&]() { | 233 | ConfigurationShared::Widget* widget = [&]() { |
| 240 | // Set managed to false on these and set up the comboboxes ourselves | 234 | // Set managed to false on these and set up the comboboxes ourselves |
| 241 | if (setting->Id() == Settings::values.vulkan_device.Id() || | 235 | if (setting->Id() == Settings::values.vulkan_device.Id() || |
| 242 | setting->Id() == Settings::values.shader_backend.Id() || | 236 | setting->Id() == Settings::values.shader_backend.Id() || |
| 243 | setting->Id() == Settings::values.vsync_mode.Id()) { | 237 | setting->Id() == Settings::values.vsync_mode.Id()) { |
| 244 | return new ConfigurationShared::Widget( | 238 | return builder.BuildWidget(setting, apply_funcs, |
| 245 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs, | 239 | ConfigurationShared::RequestType::ComboBox, false); |
| 246 | ConfigurationShared::RequestType::ComboBox, false); | ||
| 247 | } else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) { | 240 | } else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) { |
| 248 | // FSR needs a reversed slider | 241 | // FSR needs a reversed slider |
| 249 | return new ConfigurationShared::Widget( | 242 | return builder.BuildWidget( |
| 250 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs, | 243 | setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true, |
| 251 | ConfigurationShared::RequestType::ReverseSlider, true, 0.5f, nullptr, | 244 | 0.5f, nullptr, tr("%1%", "FSR sharpening percentage (e.g. 50%)")); |
| 252 | tr("%1%", "FSR sharpening percentage (e.g. 50%)")); | ||
| 253 | } else { | 245 | } else { |
| 254 | return new ConfigurationShared::Widget(setting, translations, combobox_translations, | 246 | return builder.BuildWidget(setting, apply_funcs); |
| 255 | this, runtime_lock, apply_funcs); | ||
| 256 | } | 247 | } |
| 257 | }(); | 248 | }(); |
| 258 | 249 | ||
| 250 | if (widget == nullptr) { | ||
| 251 | continue; | ||
| 252 | } | ||
| 259 | if (!widget->Valid()) { | 253 | if (!widget->Valid()) { |
| 260 | delete widget; | 254 | delete widget; |
| 261 | continue; | 255 | continue; |
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 718ba54f5..1848b1593 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <functional> | 6 | #include <functional> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <type_traits> | 8 | #include <type_traits> |
| 9 | #include <typeindex> | ||
| 9 | #include <vector> | 10 | #include <vector> |
| 10 | #include <QColor> | 11 | #include <QColor> |
| 11 | #include <QString> | 12 | #include <QString> |
| @@ -13,9 +14,9 @@ | |||
| 13 | #include <qobjectdefs.h> | 14 | #include <qobjectdefs.h> |
| 14 | #include <vulkan/vulkan_core.h> | 15 | #include <vulkan/vulkan_core.h> |
| 15 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "configuration/shared_translation.h" | ||
| 16 | #include "vk_device_info.h" | 18 | #include "vk_device_info.h" |
| 17 | #include "yuzu/configuration/configuration_shared.h" | 19 | #include "yuzu/configuration/configuration_shared.h" |
| 18 | #include "yuzu/configuration/shared_translation.h" | ||
| 19 | 20 | ||
| 20 | class QPushButton; | 21 | class QPushButton; |
| 21 | class QEvent; | 22 | class QEvent; |
| @@ -36,15 +37,18 @@ namespace Ui { | |||
| 36 | class ConfigureGraphics; | 37 | class ConfigureGraphics; |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 40 | namespace ConfigurationShared { | ||
| 41 | class Builder; | ||
| 42 | } | ||
| 43 | |||
| 39 | class ConfigureGraphics : public ConfigurationShared::Tab { | 44 | class ConfigureGraphics : public ConfigurationShared::Tab { |
| 40 | public: | 45 | public: |
| 41 | explicit ConfigureGraphics( | 46 | explicit ConfigureGraphics(const Core::System& system_, |
| 42 | const Core::System& system_, std::vector<VkDeviceInfo::Record>& records, | 47 | std::vector<VkDeviceInfo::Record>& records, |
| 43 | const std::function<void()>& expose_compute_option_, | 48 | const std::function<void()>& expose_compute_option_, |
| 44 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 49 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 45 | const ConfigurationShared::TranslationMap& translations_, | 50 | const ConfigurationShared::Builder& builder, |
| 46 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, | 51 | QWidget* parent = nullptr); |
| 47 | QWidget* parent = nullptr); | ||
| 48 | ~ConfigureGraphics() override; | 52 | ~ConfigureGraphics() override; |
| 49 | 53 | ||
| 50 | void ApplyConfiguration() override; | 54 | void ApplyConfiguration() override; |
| @@ -54,7 +58,7 @@ private: | |||
| 54 | void changeEvent(QEvent* event) override; | 58 | void changeEvent(QEvent* event) override; |
| 55 | void RetranslateUI(); | 59 | void RetranslateUI(); |
| 56 | 60 | ||
| 57 | void Setup(); | 61 | void Setup(const ConfigurationShared::Builder& builder); |
| 58 | 62 | ||
| 59 | void PopulateVSyncModeSelection(); | 63 | void PopulateVSyncModeSelection(); |
| 60 | void UpdateBackgroundColorButton(QColor color); | 64 | void UpdateBackgroundColorButton(QColor color); |
| @@ -89,7 +93,6 @@ private: | |||
| 89 | const std::function<void()>& expose_compute_option; | 93 | const std::function<void()>& expose_compute_option; |
| 90 | 94 | ||
| 91 | const Core::System& system; | 95 | const Core::System& system; |
| 92 | const ConfigurationShared::TranslationMap& translations; | ||
| 93 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | 96 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; |
| 94 | const std::vector<std::pair<u32, QString>>& shader_mapping; | 97 | const std::vector<std::pair<u32, QString>>& shader_mapping; |
| 95 | 98 | ||
diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index e2f7d284d..757e4659d 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp | |||
| @@ -14,13 +14,13 @@ | |||
| 14 | ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( | 14 | ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( |
| 15 | const Core::System& system_, | 15 | const Core::System& system_, |
| 16 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, | 16 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, |
| 17 | const ConfigurationShared::TranslationMap& translations_, | 17 | const ConfigurationShared::Builder& builder, QWidget* parent) |
| 18 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) | 18 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} { |
| 19 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_}, | ||
| 20 | translations{translations_}, combobox_translations{combobox_translations_} { | ||
| 21 | 19 | ||
| 22 | ui->setupUi(this); | 20 | ui->setupUi(this); |
| 23 | 21 | ||
| 22 | Setup(builder); | ||
| 23 | |||
| 24 | SetConfiguration(); | 24 | SetConfiguration(); |
| 25 | 25 | ||
| 26 | checkbox_enable_compute_pipelines->setVisible(false); | 26 | checkbox_enable_compute_pipelines->setVisible(false); |
| @@ -28,20 +28,19 @@ ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( | |||
| 28 | 28 | ||
| 29 | ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; | 29 | ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; |
| 30 | 30 | ||
| 31 | void ConfigureGraphicsAdvanced::SetConfiguration() { | 31 | void ConfigureGraphicsAdvanced::SetConfiguration() {} |
| 32 | const bool runtime_lock = !system.IsPoweredOn(); | 32 | |
| 33 | void ConfigureGraphicsAdvanced::Setup(const ConfigurationShared::Builder& builder) { | ||
| 33 | auto& layout = *ui->populate_target->layout(); | 34 | auto& layout = *ui->populate_target->layout(); |
| 34 | std::map<u32, QWidget*> hold{}; // A map will sort the data for us | 35 | std::map<u32, QWidget*> hold{}; // A map will sort the data for us |
| 35 | 36 | ||
| 36 | for (auto setting : | 37 | for (auto setting : |
| 37 | Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) { | 38 | Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) { |
| 38 | if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { | 39 | ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs); |
| 40 | |||
| 41 | if (widget == nullptr) { | ||
| 39 | continue; | 42 | continue; |
| 40 | } | 43 | } |
| 41 | |||
| 42 | ConfigurationShared::Widget* widget = new ConfigurationShared::Widget( | ||
| 43 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs); | ||
| 44 | |||
| 45 | if (!widget->Valid()) { | 44 | if (!widget->Valid()) { |
| 46 | delete widget; | 45 | delete widget; |
| 47 | continue; | 46 | continue; |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index 90b79f786..5530827d1 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <QWidget> | 7 | #include <QWidget> |
| 8 | #include "yuzu/configuration/configuration_shared.h" | 8 | #include "yuzu/configuration/configuration_shared.h" |
| 9 | #include "yuzu/configuration/shared_translation.h" | ||
| 10 | 9 | ||
| 11 | namespace Core { | 10 | namespace Core { |
| 12 | class System; | 11 | class System; |
| @@ -16,14 +15,16 @@ namespace Ui { | |||
| 16 | class ConfigureGraphicsAdvanced; | 15 | class ConfigureGraphicsAdvanced; |
| 17 | } | 16 | } |
| 18 | 17 | ||
| 18 | namespace ConfigurationShared { | ||
| 19 | class Builder; | ||
| 20 | } | ||
| 21 | |||
| 19 | class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab { | 22 | class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab { |
| 20 | public: | 23 | public: |
| 21 | explicit ConfigureGraphicsAdvanced( | 24 | explicit ConfigureGraphicsAdvanced( |
| 22 | const Core::System& system_, | 25 | const Core::System& system_, |
| 23 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 26 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 24 | const ConfigurationShared::TranslationMap& translations_, | 27 | const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); |
| 25 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, | ||
| 26 | QWidget* parent = nullptr); | ||
| 27 | ~ConfigureGraphicsAdvanced() override; | 28 | ~ConfigureGraphicsAdvanced() override; |
| 28 | 29 | ||
| 29 | void ApplyConfiguration() override; | 30 | void ApplyConfiguration() override; |
| @@ -32,14 +33,14 @@ public: | |||
| 32 | void ExposeComputeOption(); | 33 | void ExposeComputeOption(); |
| 33 | 34 | ||
| 34 | private: | 35 | private: |
| 36 | void Setup(const ConfigurationShared::Builder& builder); | ||
| 35 | void changeEvent(QEvent* event) override; | 37 | void changeEvent(QEvent* event) override; |
| 36 | void RetranslateUI(); | 38 | void RetranslateUI(); |
| 37 | 39 | ||
| 38 | std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; | 40 | std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; |
| 39 | 41 | ||
| 40 | const Core::System& system; | 42 | const Core::System& system; |
| 41 | const ConfigurationShared::TranslationMap& translations; | 43 | |
| 42 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | ||
| 43 | std::forward_list<std::function<void(bool)>> apply_funcs; | 44 | std::forward_list<std::function<void(bool)>> apply_funcs; |
| 44 | 45 | ||
| 45 | QWidget* checkbox_enable_compute_pipelines{}; | 46 | QWidget* checkbox_enable_compute_pipelines{}; |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 5863beca0..cee8e726d 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <QTimer> | 17 | #include <QTimer> |
| 18 | 18 | ||
| 19 | #include "common/fs/fs_util.h" | 19 | #include "common/fs/fs_util.h" |
| 20 | #include "configuration/shared_widget.h" | ||
| 20 | #include "core/core.h" | 21 | #include "core/core.h" |
| 21 | #include "core/file_sys/control_metadata.h" | 22 | #include "core/file_sys/control_metadata.h" |
| 22 | #include "core/file_sys/patch_manager.h" | 23 | #include "core/file_sys/patch_manager.h" |
| @@ -42,8 +43,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st | |||
| 42 | Core::System& system_) | 43 | Core::System& system_) |
| 43 | : QDialog(parent), | 44 | : QDialog(parent), |
| 44 | ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_}, | 45 | ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_}, |
| 45 | translations{ConfigurationShared::InitializeTranslations(this)}, | 46 | builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())}, |
| 46 | combobox_translations{ConfigurationShared::ComboboxEnumeration(this)}, | ||
| 47 | tab_group{std::make_shared<std::forward_list<ConfigurationShared::Tab*>>()} { | 47 | tab_group{std::make_shared<std::forward_list<ConfigurationShared::Tab*>>()} { |
| 48 | const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); | 48 | const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); |
| 49 | const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) | 49 | const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) |
| @@ -51,18 +51,15 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st | |||
| 51 | game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig); | 51 | game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig); |
| 52 | 52 | ||
| 53 | addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); | 53 | addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); |
| 54 | audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *translations, | 54 | audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *builder, this); |
| 55 | *combobox_translations, this); | 55 | cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *builder, this); |
| 56 | cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *translations, | 56 | graphics_advanced_tab = |
| 57 | *combobox_translations, this); | 57 | std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this); |
| 58 | graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>( | ||
| 59 | system_, tab_group, *translations, *combobox_translations, this); | ||
| 60 | graphics_tab = std::make_unique<ConfigureGraphics>( | 58 | graphics_tab = std::make_unique<ConfigureGraphics>( |
| 61 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, | 59 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, |
| 62 | tab_group, *translations, *combobox_translations, this); | 60 | tab_group, *builder, this); |
| 63 | input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); | 61 | input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); |
| 64 | system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *translations, | 62 | system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *builder, this); |
| 65 | *combobox_translations, this); | ||
| 66 | 63 | ||
| 67 | ui->setupUi(this); | 64 | ui->setupUi(this); |
| 68 | 65 | ||
diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 4849ac291..4ddd18c1f 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <QDialog> | 11 | #include <QDialog> |
| 12 | #include <QList> | 12 | #include <QList> |
| 13 | 13 | ||
| 14 | #include "configuration/shared_widget.h" | ||
| 14 | #include "core/file_sys/vfs_types.h" | 15 | #include "core/file_sys/vfs_types.h" |
| 15 | #include "vk_device_info.h" | 16 | #include "vk_device_info.h" |
| 16 | #include "yuzu/configuration/config.h" | 17 | #include "yuzu/configuration/config.h" |
| @@ -75,8 +76,7 @@ private: | |||
| 75 | std::unique_ptr<Config> game_config; | 76 | std::unique_ptr<Config> game_config; |
| 76 | 77 | ||
| 77 | Core::System& system; | 78 | Core::System& system; |
| 78 | std::unique_ptr<ConfigurationShared::TranslationMap> translations; | 79 | std::unique_ptr<ConfigurationShared::Builder> builder; |
| 79 | std::unique_ptr<ConfigurationShared::ComboboxTranslationMap> combobox_translations; | ||
| 80 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> tab_group; | 80 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> tab_group; |
| 81 | 81 | ||
| 82 | std::unique_ptr<ConfigurePerGameAddons> addons_tab; | 82 | std::unique_ptr<ConfigurePerGameAddons> addons_tab; |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 6a985c515..9be09244a 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -46,13 +46,11 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { | |||
| 46 | 46 | ||
| 47 | ConfigureSystem::ConfigureSystem( | 47 | ConfigureSystem::ConfigureSystem( |
| 48 | Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, | 48 | Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_, |
| 49 | const ConfigurationShared::TranslationMap& translations_, | 49 | const ConfigurationShared::Builder& builder, QWidget* parent) |
| 50 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) | 50 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} { |
| 51 | : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_}, | ||
| 52 | translations{translations_}, combobox_translations{combobox_translations_} { | ||
| 53 | ui->setupUi(this); | 51 | ui->setupUi(this); |
| 54 | 52 | ||
| 55 | Setup(); | 53 | Setup(builder); |
| 56 | 54 | ||
| 57 | connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { | 55 | connect(rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { |
| 58 | rng_seed_edit->setEnabled(state == Qt::Checked); | 56 | rng_seed_edit->setEnabled(state == Qt::Checked); |
| @@ -104,8 +102,7 @@ void ConfigureSystem::RetranslateUI() { | |||
| 104 | ui->retranslateUi(this); | 102 | ui->retranslateUi(this); |
| 105 | } | 103 | } |
| 106 | 104 | ||
| 107 | void ConfigureSystem::Setup() { | 105 | void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { |
| 108 | const bool runtime_lock = !system.IsPoweredOn(); | ||
| 109 | auto& core_layout = *ui->core_widget->layout(); | 106 | auto& core_layout = *ui->core_widget->layout(); |
| 110 | auto& system_layout = *ui->system_widget->layout(); | 107 | auto& system_layout = *ui->system_widget->layout(); |
| 111 | 108 | ||
| @@ -123,37 +120,31 @@ void ConfigureSystem::Setup() { | |||
| 123 | push(Settings::values.linkage.by_category[Settings::Category::System]); | 120 | push(Settings::values.linkage.by_category[Settings::Category::System]); |
| 124 | 121 | ||
| 125 | for (auto setting : settings) { | 122 | for (auto setting : settings) { |
| 126 | if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { | 123 | ConfigurationShared::Widget* widget = [this, setting, &builder]() { |
| 127 | continue; | ||
| 128 | } | ||
| 129 | |||
| 130 | [[maybe_unused]] std::string label = setting->GetLabel(); | ||
| 131 | ConfigurationShared::Widget* widget = [this, setting, runtime_lock]() { | ||
| 132 | if (setting->Id() == Settings::values.custom_rtc.Id()) { | 124 | if (setting->Id() == Settings::values.custom_rtc.Id()) { |
| 133 | // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage | 125 | // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage |
| 134 | // it and custom_rtc_enabled | 126 | // it and custom_rtc_enabled |
| 135 | return new ConfigurationShared::Widget( | 127 | return builder.BuildWidget(setting, apply_funcs, |
| 136 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs, | 128 | &Settings::values.custom_rtc_enabled, |
| 137 | &Settings::values.custom_rtc_enabled, | 129 | ConfigurationShared::RequestType::DateTimeEdit); |
| 138 | ConfigurationShared::RequestType::DateTimeEdit); | ||
| 139 | } else if (setting->Id() == Settings::values.rng_seed.Id()) { | 130 | } else if (setting->Id() == Settings::values.rng_seed.Id()) { |
| 140 | // rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage | 131 | // rng_seed needs a HexEdit (default is LineEdit), and a checkbox to manage |
| 141 | // it and rng_seed_enabled | 132 | // it and rng_seed_enabled |
| 142 | return new ConfigurationShared::Widget( | 133 | return builder.BuildWidget(setting, apply_funcs, &Settings::values.rng_seed_enabled, |
| 143 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs, | 134 | ConfigurationShared::RequestType::HexEdit); |
| 144 | &Settings::values.rng_seed_enabled, ConfigurationShared::RequestType::HexEdit); | ||
| 145 | } else if (setting->Id() == Settings::values.speed_limit.Id()) { | 135 | } else if (setting->Id() == Settings::values.speed_limit.Id()) { |
| 146 | // speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox | 136 | // speed_limit needs a checkbox to set use_speed_limit, as well as a spinbox |
| 147 | return new ConfigurationShared::Widget( | 137 | return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit, |
| 148 | setting, translations, combobox_translations, this, runtime_lock, apply_funcs, | 138 | ConfigurationShared::RequestType::SpinBox, |
| 149 | &Settings::values.use_speed_limit, ConfigurationShared::RequestType::SpinBox, | 139 | tr("%", "Limit speed percentage (e.g. 50%)")); |
| 150 | tr("%", "Limit speed percentage (e.g. 50%)")); | ||
| 151 | } else { | 140 | } else { |
| 152 | return new ConfigurationShared::Widget(setting, translations, combobox_translations, | 141 | return builder.BuildWidget(setting, apply_funcs); |
| 153 | this, runtime_lock, apply_funcs); | ||
| 154 | } | 142 | } |
| 155 | }(); | 143 | }(); |
| 156 | 144 | ||
| 145 | if (widget == nullptr) { | ||
| 146 | continue; | ||
| 147 | } | ||
| 157 | if (!widget->Valid()) { | 148 | if (!widget->Valid()) { |
| 158 | delete widget; | 149 | delete widget; |
| 159 | continue; | 150 | continue; |
diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h index 4457ccc21..7f4259698 100644 --- a/src/yuzu/configuration/configure_system.h +++ b/src/yuzu/configuration/configure_system.h | |||
| @@ -9,13 +9,11 @@ | |||
| 9 | 9 | ||
| 10 | #include <QWidget> | 10 | #include <QWidget> |
| 11 | #include "yuzu/configuration/configuration_shared.h" | 11 | #include "yuzu/configuration/configuration_shared.h" |
| 12 | #include "yuzu/configuration/shared_translation.h" | ||
| 13 | 12 | ||
| 14 | class QCheckBox; | 13 | class QCheckBox; |
| 15 | class QLineEdit; | 14 | class QLineEdit; |
| 16 | class QComboBox; | 15 | class QComboBox; |
| 17 | class QDateTimeEdit; | 16 | class QDateTimeEdit; |
| 18 | |||
| 19 | namespace Core { | 17 | namespace Core { |
| 20 | class System; | 18 | class System; |
| 21 | } | 19 | } |
| @@ -24,13 +22,16 @@ namespace Ui { | |||
| 24 | class ConfigureSystem; | 22 | class ConfigureSystem; |
| 25 | } | 23 | } |
| 26 | 24 | ||
| 25 | namespace ConfigurationShared { | ||
| 26 | class Builder; | ||
| 27 | } | ||
| 28 | |||
| 27 | class ConfigureSystem : public ConfigurationShared::Tab { | 29 | class ConfigureSystem : public ConfigurationShared::Tab { |
| 28 | public: | 30 | public: |
| 29 | explicit ConfigureSystem( | 31 | explicit ConfigureSystem(Core::System& system_, |
| 30 | Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 32 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 31 | const ConfigurationShared::TranslationMap& translations, | 33 | const ConfigurationShared::Builder& builder, |
| 32 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations, | 34 | QWidget* parent = nullptr); |
| 33 | QWidget* parent = nullptr); | ||
| 34 | ~ConfigureSystem() override; | 35 | ~ConfigureSystem() override; |
| 35 | 36 | ||
| 36 | void ApplyConfiguration() override; | 37 | void ApplyConfiguration() override; |
| @@ -40,7 +41,7 @@ private: | |||
| 40 | void changeEvent(QEvent* event) override; | 41 | void changeEvent(QEvent* event) override; |
| 41 | void RetranslateUI(); | 42 | void RetranslateUI(); |
| 42 | 43 | ||
| 43 | void Setup(); | 44 | void Setup(const ConfigurationShared::Builder& builder); |
| 44 | 45 | ||
| 45 | std::forward_list<std::function<void(bool)>> apply_funcs{}; | 46 | std::forward_list<std::function<void(bool)>> apply_funcs{}; |
| 46 | 47 | ||
| @@ -48,8 +49,6 @@ private: | |||
| 48 | bool enabled = false; | 49 | bool enabled = false; |
| 49 | 50 | ||
| 50 | Core::System& system; | 51 | Core::System& system; |
| 51 | const ConfigurationShared::TranslationMap& translations; | ||
| 52 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | ||
| 53 | 52 | ||
| 54 | QCheckBox* rng_seed_checkbox; | 53 | QCheckBox* rng_seed_checkbox; |
| 55 | QLineEdit* rng_seed_edit; | 54 | QLineEdit* rng_seed_edit; |
diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index d153d8d6b..dc8b31238 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp | |||
| @@ -529,11 +529,34 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati | |||
| 529 | this->setToolTip(tooltip); | 529 | this->setToolTip(tooltip); |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, | 532 | Builder::Builder(QWidget* parent_, bool runtime_lock_) |
| 533 | const ComboboxTranslationMap& combobox_translations, QWidget* parent_, | 533 | : translations{InitializeTranslations(parent_)}, |
| 534 | bool runtime_lock_, std::forward_list<std::function<void(bool)>>& apply_funcs_, | 534 | combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{ |
| 535 | Settings::BasicSetting* other_setting, RequestType request, const QString& string) | 535 | runtime_lock_} {} |
| 536 | : Widget(setting_, translations_, combobox_translations, parent_, runtime_lock_, apply_funcs_, | 536 | |
| 537 | request, true, 1.0f, other_setting, string) {} | 537 | Builder::~Builder() = default; |
| 538 | |||
| 539 | Widget* Builder::BuildWidget(Settings::BasicSetting* setting, | ||
| 540 | std::forward_list<std::function<void(bool)>>& apply_funcs, | ||
| 541 | RequestType request, bool managed, float multiplier, | ||
| 542 | Settings::BasicSetting* other_setting, const QString& string) const { | ||
| 543 | if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { | ||
| 544 | return nullptr; | ||
| 545 | } | ||
| 546 | |||
| 547 | return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock, | ||
| 548 | apply_funcs, request, managed, multiplier, other_setting, string); | ||
| 549 | } | ||
| 550 | |||
| 551 | Widget* Builder::BuildWidget(Settings::BasicSetting* setting, | ||
| 552 | std::forward_list<std::function<void(bool)>>& apply_funcs, | ||
| 553 | Settings::BasicSetting* other_setting, RequestType request, | ||
| 554 | const QString& string) const { | ||
| 555 | return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, string); | ||
| 556 | } | ||
| 557 | |||
| 558 | const ComboboxTranslationMap& Builder::ComboboxTranslations() const { | ||
| 559 | return *combobox_translations; | ||
| 560 | } | ||
| 538 | 561 | ||
| 539 | } // namespace ConfigurationShared | 562 | } // namespace ConfigurationShared |
diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 10d2d353e..e8c281b81 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <forward_list> | 6 | #include <forward_list> |
| 7 | #include <functional> | 7 | #include <functional> |
| 8 | #include <memory> | ||
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include <QString> | 10 | #include <QString> |
| 10 | #include <QStringLiteral> | 11 | #include <QStringLiteral> |
| @@ -45,28 +46,6 @@ class Widget : public QWidget { | |||
| 45 | 46 | ||
| 46 | public: | 47 | public: |
| 47 | /** | 48 | /** |
| 48 | * Shorter-hand version of the constructor | ||
| 49 | * | ||
| 50 | * @param setting The primary Setting to create the Widget for | ||
| 51 | * @param translations Map of translations to display on the left side label/checkbox | ||
| 52 | * @param combobox_translations Map of translations for enumerating combo boxes | ||
| 53 | * @param parent Qt parent | ||
| 54 | * @param runtime_lock Emulated guest powered on state, for use on settings that should be | ||
| 55 | * configured during guest execution | ||
| 56 | * @param apply_funcs_ List to append, functions to run to apply the widget state to the setting | ||
| 57 | * @param other_setting Second setting to modify, to replace the label with a checkbox | ||
| 58 | * @param request What type of data representation component to create -- not always respected | ||
| 59 | * for the Setting data type | ||
| 60 | * @param string Set to specify formats for Slider feedback labels or SpinBox | ||
| 61 | */ | ||
| 62 | explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations, | ||
| 63 | const ComboboxTranslationMap& combobox_translations, QWidget* parent, | ||
| 64 | bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs_, | ||
| 65 | Settings::BasicSetting* other_setting, | ||
| 66 | RequestType request = RequestType::Default, | ||
| 67 | const QString& string = QStringLiteral("")); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * @param setting The primary Setting to create the Widget for | 49 | * @param setting The primary Setting to create the Widget for |
| 71 | * @param translations Map of translations to display on the left side label/checkbox | 50 | * @param translations Map of translations to display on the left side label/checkbox |
| 72 | * @param combobox_translations Map of translations for enumerating combo boxes | 51 | * @param combobox_translations Map of translations for enumerating combo boxes |
| @@ -152,4 +131,31 @@ private: | |||
| 152 | bool runtime_lock{false}; | 131 | bool runtime_lock{false}; |
| 153 | }; | 132 | }; |
| 154 | 133 | ||
| 134 | class Builder { | ||
| 135 | public: | ||
| 136 | explicit Builder(QWidget* parent, bool runtime_lock); | ||
| 137 | ~Builder(); | ||
| 138 | |||
| 139 | Widget* BuildWidget(Settings::BasicSetting* setting, | ||
| 140 | std::forward_list<std::function<void(bool)>>& apply_funcs, | ||
| 141 | RequestType request = RequestType::Default, bool managed = true, | ||
| 142 | float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, | ||
| 143 | const QString& string = QStringLiteral("")) const; | ||
| 144 | |||
| 145 | Widget* BuildWidget(Settings::BasicSetting* setting, | ||
| 146 | std::forward_list<std::function<void(bool)>>& apply_funcs, | ||
| 147 | Settings::BasicSetting* other_setting, | ||
| 148 | RequestType request = RequestType::Default, | ||
| 149 | const QString& string = QStringLiteral("")) const; | ||
| 150 | |||
| 151 | const ComboboxTranslationMap& ComboboxTranslations() const; | ||
| 152 | |||
| 153 | private: | ||
| 154 | std::unique_ptr<TranslationMap> translations; | ||
| 155 | std::unique_ptr<ComboboxTranslationMap> combobox_translations; | ||
| 156 | |||
| 157 | QWidget* parent; | ||
| 158 | const bool runtime_lock; | ||
| 159 | }; | ||
| 160 | |||
| 155 | } // namespace ConfigurationShared | 161 | } // namespace ConfigurationShared |