mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 22:57:22 +00:00
configuration: Use a mapping of setting value to name
Makes comboboxes always correspond to the value of the setting they're modifying.
This commit is contained in:
parent
86ed82cdde
commit
c5a3642cb6
18 changed files with 354 additions and 228 deletions
|
@ -15,12 +15,13 @@
|
|||
#include "yuzu/configuration/shared_widget.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
|
||||
ConfigureAudio::ConfigureAudio(const Core::System& system_,
|
||||
ConfigureAudio::ConfigureAudio(
|
||||
const Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
QWidget* parent)
|
||||
: Tab(group, parent),
|
||||
ui(std::make_unique<Ui::ConfigureAudio>()), system{system_}, translations{translations_} {
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
||||
: Tab(group, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_},
|
||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
||||
ui->setupUi(this);
|
||||
Setup();
|
||||
|
||||
|
@ -48,18 +49,18 @@ void ConfigureAudio::Setup() {
|
|||
auto* widget = [&]() {
|
||||
if (setting->Id() == Settings::values.volume.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::Slider, true, 1.0f, nullptr,
|
||||
tr("%1%", "Volume percentage (e.g. 50%)"));
|
||||
} else if (setting->Id() == Settings::values.audio_output_device_id.Id() ||
|
||||
setting->Id() == Settings::values.audio_input_device_id.Id() ||
|
||||
setting->Id() == Settings::values.sink_id.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::ComboBox, false);
|
||||
} else {
|
||||
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
||||
apply_funcs);
|
||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
||||
this, runtime_lock, apply_funcs);
|
||||
}
|
||||
}();
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ class ConfigureAudio;
|
|||
|
||||
class ConfigureAudio : public ConfigurationShared::Tab {
|
||||
public:
|
||||
explicit ConfigureAudio(const Core::System& system_,
|
||||
explicit ConfigureAudio(
|
||||
const Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
||||
QWidget* parent = nullptr);
|
||||
~ConfigureAudio() override;
|
||||
|
||||
|
@ -49,6 +51,7 @@ private:
|
|||
|
||||
const Core::System& system;
|
||||
const ConfigurationShared::TranslationMap& translations;
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||
|
||||
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
||||
|
||||
|
|
|
@ -34,21 +34,25 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
|
|||
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()},
|
||||
registry(registry_), system{system_},
|
||||
translations{ConfigurationShared::InitializeTranslations(this)},
|
||||
audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *translations, this)},
|
||||
combobox_translations{ConfigurationShared::ComboboxEnumeration(this)},
|
||||
audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *translations,
|
||||
*combobox_translations, this)},
|
||||
cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, this)},
|
||||
debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)},
|
||||
filesystem_tab{std::make_unique<ConfigureFilesystem>(this)},
|
||||
general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *translations, this)},
|
||||
graphics_advanced_tab{
|
||||
std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *translations, this)},
|
||||
general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *translations,
|
||||
*combobox_translations, this)},
|
||||
graphics_advanced_tab{std::make_unique<ConfigureGraphicsAdvanced>(
|
||||
system_, nullptr, *translations, *combobox_translations, this)},
|
||||
graphics_tab{std::make_unique<ConfigureGraphics>(
|
||||
system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); },
|
||||
nullptr, *translations, this)},
|
||||
nullptr, *translations, *combobox_translations, this)},
|
||||
hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)},
|
||||
input_tab{std::make_unique<ConfigureInput>(system_, this)},
|
||||
network_tab{std::make_unique<ConfigureNetwork>(system_, this)},
|
||||
profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)},
|
||||
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *translations, this)},
|
||||
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *translations,
|
||||
*combobox_translations, this)},
|
||||
ui_tab{std::make_unique<ConfigureUi>(system_, this)}, web_tab{std::make_unique<ConfigureWeb>(
|
||||
this)} {
|
||||
Settings::SetConfiguringGlobal(true);
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
|
||||
Core::System& system;
|
||||
std::unique_ptr<ConfigurationShared::TranslationMap> translations;
|
||||
std::unique_ptr<ConfigurationShared::ComboboxTranslationMap> combobox_translations;
|
||||
std::forward_list<ConfigurationShared::Tab*> tab_group;
|
||||
|
||||
std::unique_ptr<ConfigureAudio> audio_tab;
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
ConfigureGeneral::ConfigureGeneral(
|
||||
const Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_, QWidget* parent)
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
||||
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_},
|
||||
translations{translations_} {
|
||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
||||
ui->setupUi(this);
|
||||
|
||||
SetConfiguration();
|
||||
|
@ -40,8 +41,8 @@ void ConfigureGeneral::SetConfiguration() {
|
|||
|
||||
for (const auto setting :
|
||||
UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) {
|
||||
auto* widget =
|
||||
new ConfigurationShared::Widget(setting, translations, this, runtime_lock, apply_funcs);
|
||||
auto* widget = new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
||||
this, runtime_lock, apply_funcs);
|
||||
|
||||
if (!widget->Valid()) {
|
||||
delete widget;
|
||||
|
|
|
@ -22,9 +22,11 @@ class ConfigureGeneral;
|
|||
|
||||
class ConfigureGeneral : public ConfigurationShared::Tab {
|
||||
public:
|
||||
explicit ConfigureGeneral(const Core::System& system_,
|
||||
explicit ConfigureGeneral(
|
||||
const Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
||||
QWidget* parent = nullptr);
|
||||
~ConfigureGeneral() override;
|
||||
|
||||
|
@ -45,4 +47,5 @@ private:
|
|||
|
||||
const Core::System& system;
|
||||
const ConfigurationShared::TranslationMap& translations;
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||
};
|
||||
|
|
|
@ -79,10 +79,12 @@ ConfigureGraphics::ConfigureGraphics(
|
|||
const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_,
|
||||
const std::function<void()>& expose_compute_option_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_, QWidget* parent)
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
||||
: ConfigurationShared::Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
|
||||
records{records_}, expose_compute_option{expose_compute_option_}, system{system_},
|
||||
translations{translations_} {
|
||||
translations{translations_}, combobox_translations{combobox_translations_},
|
||||
shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} {
|
||||
vulkan_device = Settings::values.vulkan_device.GetValue();
|
||||
RetrieveVulkanDevices();
|
||||
|
||||
|
@ -235,22 +237,22 @@ void ConfigureGraphics::Setup() {
|
|||
setting->Id() == Settings::values.shader_backend.Id() ||
|
||||
setting->Id() == Settings::values.vsync_mode.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::ComboBox, false);
|
||||
} else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::ReverseSlider, true, 0.5f, nullptr,
|
||||
tr("%1%", "FSR sharpening percentage (e.g. 50%)"));
|
||||
} else if (setting->Id() == Settings::values.speed_limit.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::SpinBox, true, 1.0f,
|
||||
&Settings::values.use_speed_limit,
|
||||
tr("%", "Limit speed percentage (e.g. 50%)"));
|
||||
} else {
|
||||
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
||||
apply_funcs);
|
||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
||||
this, runtime_lock, apply_funcs);
|
||||
}
|
||||
}();
|
||||
|
||||
|
@ -360,6 +362,15 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
|
|||
}
|
||||
}
|
||||
|
||||
int ConfigureGraphics::FindIndex(std::type_index enumeration, int value) const {
|
||||
for (u32 i = 0; i < combobox_translations.at(enumeration).size(); i++) {
|
||||
if (combobox_translations.at(enumeration)[i].first == static_cast<u32>(value)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ConfigureGraphics::ApplyConfiguration() {
|
||||
const bool powered_on = system.IsPoweredOn();
|
||||
for (const auto& func : apply_funcs) {
|
||||
|
@ -374,13 +385,17 @@ void ConfigureGraphics::ApplyConfiguration() {
|
|||
|
||||
Settings::values.shader_backend.SetGlobal(true);
|
||||
Settings::values.vulkan_device.SetGlobal(true);
|
||||
if (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled()) {
|
||||
auto backend = static_cast<Settings::RendererBackend>(api_combobox->currentIndex());
|
||||
if (Settings::IsConfiguringGlobal() ||
|
||||
(!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) {
|
||||
auto backend = static_cast<Settings::RendererBackend>(
|
||||
combobox_translations
|
||||
.at(typeid(Settings::RendererBackend))[api_combobox->currentIndex()]
|
||||
.first);
|
||||
switch (backend) {
|
||||
case Settings::RendererBackend::OpenGL:
|
||||
Settings::values.shader_backend.SetGlobal(false);
|
||||
Settings::values.shader_backend.SetValue(
|
||||
static_cast<Settings::ShaderBackend>(shader_backend_combobox->currentIndex()));
|
||||
Settings::values.shader_backend.SetValue(static_cast<Settings::ShaderBackend>(
|
||||
shader_mapping[shader_backend_combobox->currentIndex()].first));
|
||||
break;
|
||||
case Settings::RendererBackend::Vulkan:
|
||||
Settings::values.vulkan_device.SetGlobal(false);
|
||||
|
@ -430,7 +445,8 @@ void ConfigureGraphics::UpdateAPILayout() {
|
|||
|
||||
switch (GetCurrentGraphicsBackend()) {
|
||||
case Settings::RendererBackend::OpenGL:
|
||||
shader_backend_combobox->setCurrentIndex(static_cast<u32>(shader_backend));
|
||||
shader_backend_combobox->setCurrentIndex(
|
||||
FindIndex(typeid(Settings::ShaderBackend), static_cast<int>(shader_backend)));
|
||||
vulkan_device_widget->setVisible(false);
|
||||
shader_backend_widget->setVisible(true);
|
||||
break;
|
||||
|
@ -467,5 +483,8 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
|||
if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) {
|
||||
return Settings::values.renderer_backend.GetValue(true);
|
||||
}
|
||||
return static_cast<Settings::RendererBackend>(api_combobox->currentIndex());
|
||||
return static_cast<Settings::RendererBackend>(
|
||||
combobox_translations.at(typeid(Settings::RendererBackend))
|
||||
.at(api_combobox->currentIndex())
|
||||
.first);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,12 @@ class ConfigureGraphics;
|
|||
|
||||
class ConfigureGraphics : public ConfigurationShared::Tab {
|
||||
public:
|
||||
explicit ConfigureGraphics(const Core::System& system_,
|
||||
std::vector<VkDeviceInfo::Record>& records,
|
||||
explicit ConfigureGraphics(
|
||||
const Core::System& system_, std::vector<VkDeviceInfo::Record>& records,
|
||||
const std::function<void()>& expose_compute_option_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
||||
QWidget* parent = nullptr);
|
||||
~ConfigureGraphics() override;
|
||||
|
||||
|
@ -68,6 +69,8 @@ private:
|
|||
|
||||
Settings::RendererBackend GetCurrentGraphicsBackend() const;
|
||||
|
||||
int FindIndex(std::type_index enumeration, int value) const;
|
||||
|
||||
std::unique_ptr<Ui::ConfigureGraphics> ui;
|
||||
QColor bg_color;
|
||||
|
||||
|
@ -85,6 +88,8 @@ private:
|
|||
|
||||
const Core::System& system;
|
||||
const ConfigurationShared::TranslationMap& translations;
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||
const std::vector<std::pair<u32, QString>>& shader_mapping;
|
||||
|
||||
QPushButton* api_restore_global_button;
|
||||
QComboBox* vulkan_device_combobox;
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
|
||||
const Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_, QWidget* parent)
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
||||
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_},
|
||||
translations{translations_} {
|
||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -33,8 +34,8 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
|||
|
||||
for (auto setting :
|
||||
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
||||
ConfigurationShared::Widget* widget =
|
||||
new ConfigurationShared::Widget(setting, translations, this, runtime_lock, apply_funcs);
|
||||
ConfigurationShared::Widget* widget = new ConfigurationShared::Widget(
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs);
|
||||
|
||||
if (!widget->Valid()) {
|
||||
delete widget;
|
||||
|
|
|
@ -20,7 +20,9 @@ public:
|
|||
explicit ConfigureGraphicsAdvanced(
|
||||
const Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations_, QWidget* parent = nullptr);
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_,
|
||||
QWidget* parent = nullptr);
|
||||
~ConfigureGraphicsAdvanced() override;
|
||||
|
||||
void ApplyConfiguration() override;
|
||||
|
@ -36,6 +38,7 @@ private:
|
|||
|
||||
const Core::System& system;
|
||||
const ConfigurationShared::TranslationMap& translations;
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||
std::forward_list<std::function<void(bool)>> apply_funcs;
|
||||
|
||||
QWidget* checkbox_enable_compute_pipelines{};
|
||||
|
|
|
@ -43,6 +43,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
|
|||
: QDialog(parent),
|
||||
ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_},
|
||||
translations{ConfigurationShared::InitializeTranslations(this)},
|
||||
combobox_translations{ConfigurationShared::ComboboxEnumeration(this)},
|
||||
tab_group{std::make_shared<std::forward_list<ConfigurationShared::Tab*>>()} {
|
||||
const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name));
|
||||
const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename())
|
||||
|
@ -50,15 +51,17 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
|
|||
game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig);
|
||||
|
||||
addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this);
|
||||
audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *translations, this);
|
||||
audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *translations,
|
||||
*combobox_translations, this);
|
||||
cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, this);
|
||||
graphics_advanced_tab =
|
||||
std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *translations, this);
|
||||
graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(
|
||||
system_, tab_group, *translations, *combobox_translations, this);
|
||||
graphics_tab = std::make_unique<ConfigureGraphics>(
|
||||
system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); },
|
||||
tab_group, *translations, this);
|
||||
tab_group, *translations, *combobox_translations, this);
|
||||
input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this);
|
||||
system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *translations, this);
|
||||
system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *translations,
|
||||
*combobox_translations, this);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
|
||||
Core::System& system;
|
||||
std::unique_ptr<ConfigurationShared::TranslationMap> translations;
|
||||
std::unique_ptr<ConfigurationShared::ComboboxTranslationMap> combobox_translations;
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> tab_group;
|
||||
|
||||
std::unique_ptr<ConfigurePerGameAddons> addons_tab;
|
||||
|
|
|
@ -44,9 +44,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) {
|
|||
|
||||
ConfigureSystem::ConfigureSystem(
|
||||
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
ConfigurationShared::TranslationMap& translations_, QWidget* parent)
|
||||
const ConfigurationShared::TranslationMap& translations_,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
|
||||
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_},
|
||||
translations{translations_} {
|
||||
translations{translations_}, combobox_translations{combobox_translations_} {
|
||||
ui->setupUi(this);
|
||||
|
||||
Setup();
|
||||
|
@ -121,18 +122,17 @@ void ConfigureSystem::Setup() {
|
|||
ConfigurationShared::Widget* widget = [=]() {
|
||||
if (setting->Id() == Settings::values.custom_rtc.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::DateTimeEdit, true, 1.0f,
|
||||
&Settings::values.custom_rtc_enabled);
|
||||
} else if (setting->Id() == Settings::values.rng_seed.Id()) {
|
||||
return new ConfigurationShared::Widget(
|
||||
setting, translations, this, runtime_lock, apply_funcs,
|
||||
setting, translations, combobox_translations, this, runtime_lock, apply_funcs,
|
||||
ConfigurationShared::RequestType::HexEdit, true, 1.0f,
|
||||
&Settings::values.rng_seed_enabled);
|
||||
} else {
|
||||
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
||||
|
||||
apply_funcs);
|
||||
return new ConfigurationShared::Widget(setting, translations, combobox_translations,
|
||||
this, runtime_lock, apply_funcs);
|
||||
}
|
||||
}();
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ class ConfigureSystem;
|
|||
|
||||
class ConfigureSystem : public ConfigurationShared::Tab {
|
||||
public:
|
||||
explicit ConfigureSystem(Core::System& system_,
|
||||
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
ConfigurationShared::TranslationMap& translations,
|
||||
explicit ConfigureSystem(
|
||||
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
|
||||
const ConfigurationShared::TranslationMap& translations,
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations,
|
||||
QWidget* parent = nullptr);
|
||||
~ConfigureSystem() override;
|
||||
|
||||
|
@ -46,7 +47,8 @@ private:
|
|||
ConfigurationShared::CheckState use_unsafe_extended_memory_layout;
|
||||
|
||||
Core::System& system;
|
||||
ConfigurationShared::TranslationMap& translations;
|
||||
const ConfigurationShared::TranslationMap& translations;
|
||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
||||
|
||||
QCheckBox* rng_seed_checkbox;
|
||||
QLineEdit* rng_seed_edit;
|
||||
|
|
|
@ -152,134 +152,204 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
|||
return translations;
|
||||
}
|
||||
|
||||
std::forward_list<QString> ComboboxEnumeration(std::type_index type, QWidget* parent) {
|
||||
std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
||||
std::unique_ptr<ComboboxTranslationMap> translations =
|
||||
std::make_unique<ComboboxTranslationMap>();
|
||||
const auto& tr = [&](const char* text) { return parent->tr(text); };
|
||||
|
||||
// Intentionally skipping VSyncMode to let the UI fill that one out
|
||||
|
||||
if (type == typeid(Settings::AstcDecodeMode)) {
|
||||
return {
|
||||
tr("CPU"),
|
||||
tr("GPU"),
|
||||
tr("CPU Asynchronous"),
|
||||
};
|
||||
} else if (type == typeid(Settings::RendererBackend)) {
|
||||
return {
|
||||
tr("OpenGL"),
|
||||
tr("Vulkan"),
|
||||
tr("Null"),
|
||||
};
|
||||
} else if (type == typeid(Settings::ShaderBackend)) {
|
||||
return {
|
||||
tr("GLSL"),
|
||||
tr("GLASM (Assembly Shaders, NVIDIA Only)"),
|
||||
tr("SPIR-V (Experimental, Mesa Only)"),
|
||||
};
|
||||
} else if (type == typeid(Settings::GPUAccuracy)) {
|
||||
return {
|
||||
tr("Normal"),
|
||||
tr("High"),
|
||||
tr("Extreme"),
|
||||
};
|
||||
} else if (type == typeid(Settings::CPUAccuracy)) {
|
||||
return {
|
||||
tr("Auto"),
|
||||
tr("Accurate"),
|
||||
tr("Unsafe"),
|
||||
tr("Paranoid (disables most optimizations)"),
|
||||
};
|
||||
} else if (type == typeid(Settings::FullscreenMode)) {
|
||||
return {
|
||||
tr("Borderless Windowed"),
|
||||
tr("Exclusive Fullscreen"),
|
||||
};
|
||||
} else if (type == typeid(Settings::NvdecEmulation)) {
|
||||
return {
|
||||
tr("No Video Output"),
|
||||
tr("CPU Video Decoding"),
|
||||
tr("GPU Video Decoding (Default)"),
|
||||
};
|
||||
} else if (type == typeid(Settings::ResolutionSetup)) {
|
||||
return {
|
||||
tr("0.5X (360p/540p) [EXPERIMENTAL]"),
|
||||
tr("0.75X (540p/810p) [EXPERIMENTAL]"),
|
||||
tr("1X (720p/1080p)"),
|
||||
tr("1.5X (1080p/1620p) [EXPERIMENTAL]"),
|
||||
tr("2X (1440p/2160p)"),
|
||||
tr("3X (2160p/3240p)"),
|
||||
tr("4X (2880p/4320p)"),
|
||||
tr("5X (3600p/5400p)"),
|
||||
tr("6X (4320p/6480p)"),
|
||||
tr("7X (5040p/7560p)"),
|
||||
tr("8X (5760p/8640p)"),
|
||||
};
|
||||
} else if (type == typeid(Settings::ScalingFilter)) {
|
||||
return {
|
||||
tr("Nearest Neighbor"), tr("Bilinear"), tr("Bicubic"),
|
||||
tr("Gaussian"), tr("ScaleForce"), tr("AMD FidelityFX™️ Super Resolution"),
|
||||
};
|
||||
} else if (type == typeid(Settings::AntiAliasing)) {
|
||||
return {
|
||||
tr("None"),
|
||||
tr("FXAA"),
|
||||
tr("SMAA"),
|
||||
};
|
||||
} else if (type == typeid(Settings::AspectRatio)) {
|
||||
return {
|
||||
tr("Default (16:9)"), tr("Force 4:3"), tr("Force 21:9"),
|
||||
tr("Force 16:10"), tr("Stretch to Window"),
|
||||
};
|
||||
} else if (type == typeid(Settings::AnisotropyMode)) {
|
||||
return {
|
||||
tr("Automatic"), tr("Default"), tr("2x"), tr("4x"), tr("8x"), tr("16x"),
|
||||
};
|
||||
} else if (type == typeid(Settings::Language)) {
|
||||
return {
|
||||
tr("Japanese (日本語)"),
|
||||
tr("American English"),
|
||||
tr("French (français)"),
|
||||
tr("German (Deutsch)"),
|
||||
tr("Italian (italiano)"),
|
||||
tr("Spanish (español)"),
|
||||
tr("Chinese"),
|
||||
tr("Korean (한국어)"),
|
||||
tr("Dutch (Nederlands)"),
|
||||
tr("Portuguese (português)"),
|
||||
tr("Russian (Русский)"),
|
||||
tr("Taiwanese"),
|
||||
tr("British English"),
|
||||
tr("Canadian French"),
|
||||
tr("Latin American Spanish"),
|
||||
tr("Simplified Chinese"),
|
||||
tr("Traditional Chinese (正體中文)"),
|
||||
tr("Brazilian Portuguese (português do Brasil)"),
|
||||
};
|
||||
} else if (type == typeid(Settings::Region)) {
|
||||
return {
|
||||
tr("Japan"), tr("USA"), tr("Europe"), tr("Australia"),
|
||||
tr("China"), tr("Korea"), tr("Taiwan"),
|
||||
};
|
||||
} else if (type == typeid(Settings::TimeZone)) {
|
||||
return {
|
||||
tr("Auto"), tr("Default"), tr("CET"), tr("CST6CDT"), tr("Cuba"),
|
||||
tr("EET"), tr("Egypt"), tr("Eire"), tr("EST"), tr("EST5EDT"),
|
||||
tr("GB"), tr("GB-Eire"), tr("GMT"), tr("GMT+0"), tr("GMT-0"),
|
||||
tr("GMT0"), tr("Greenwich"), tr("Hongkong"), tr("HST"), tr("Iceland"),
|
||||
tr("Iran"), tr("Israel"), tr("Jamaica"), tr("Kwajalein"), tr("Libya"),
|
||||
tr("MET"), tr("MST"), tr("MST7MDT"), tr("Navajo"), tr("NZ"),
|
||||
tr("NZ-CHAT"), tr("Poland"), tr("Portugal"), tr("PRC"), tr("PST8PDT"),
|
||||
tr("ROC"), tr("ROK"), tr("Singapore"), tr("Turkey"), tr("UCT"),
|
||||
tr("W-SU"), tr("WET"), tr("Zulu"),
|
||||
};
|
||||
} else if (type == typeid(Settings::AudioMode)) {
|
||||
return {
|
||||
tr("Mono"),
|
||||
tr("Stereo"),
|
||||
tr("Surround"),
|
||||
};
|
||||
}
|
||||
translations->insert(
|
||||
{typeid(Settings::AstcDecodeMode),
|
||||
{
|
||||
{static_cast<u32>(Settings::AstcDecodeMode::CPU), tr("CPU")},
|
||||
{static_cast<u32>(Settings::AstcDecodeMode::GPU), tr("GPU")},
|
||||
{static_cast<u32>(Settings::AstcDecodeMode::CPUAsynchronous), tr("CPU Asynchronous")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::RendererBackend),
|
||||
{
|
||||
#ifdef HAS_OPENGL
|
||||
{static_cast<u32>(Settings::RendererBackend::OpenGL), tr("OpenGL")},
|
||||
#endif
|
||||
{static_cast<u32>(Settings::RendererBackend::Vulkan), tr("Vulkan")},
|
||||
{static_cast<u32>(Settings::RendererBackend::Null), tr("Null")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::ShaderBackend),
|
||||
{
|
||||
{static_cast<u32>(Settings::ShaderBackend::GLSL), tr("GLSL")},
|
||||
{static_cast<u32>(Settings::ShaderBackend::GLASM),
|
||||
tr("GLASM (Assembly Shaders, NVIDIA Only)")},
|
||||
{static_cast<u32>(Settings::ShaderBackend::SPIRV),
|
||||
tr("SPIR-V (Experimental, Mesa Only)")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::GPUAccuracy),
|
||||
{
|
||||
{static_cast<u32>(Settings::GPUAccuracy::Normal), tr("Normal")},
|
||||
{static_cast<u32>(Settings::GPUAccuracy::High), tr("High")},
|
||||
{static_cast<u32>(Settings::GPUAccuracy::Extreme), tr("Extreme")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::CPUAccuracy),
|
||||
{
|
||||
{static_cast<u32>(Settings::CPUAccuracy::Auto), tr("Auto")},
|
||||
{static_cast<u32>(Settings::CPUAccuracy::Accurate), tr("Accurate")},
|
||||
{static_cast<u32>(Settings::CPUAccuracy::Unsafe), tr("Unsafe")},
|
||||
{static_cast<u32>(Settings::CPUAccuracy::Paranoid),
|
||||
tr("Paranoid (disables most optimizations)")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::FullscreenMode),
|
||||
{
|
||||
{static_cast<u32>(Settings::FullscreenMode::Borderless), tr("Borderless Windowed")},
|
||||
{static_cast<u32>(Settings::FullscreenMode::Exclusive), tr("Exclusive Fullscreen")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::NvdecEmulation),
|
||||
{
|
||||
{static_cast<u32>(Settings::NvdecEmulation::Off), tr("No Video Output")},
|
||||
{static_cast<u32>(Settings::NvdecEmulation::CPU), tr("CPU Video Decoding")},
|
||||
{static_cast<u32>(Settings::NvdecEmulation::GPU), tr("GPU Video Decoding (Default)")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::ResolutionSetup),
|
||||
{
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res1_2X),
|
||||
tr("0.5X (360p/540p) [EXPERIMENTAL]")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res3_4X),
|
||||
tr("0.75X (540p/810p) [EXPERIMENTAL]")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res1X), tr("1X (720p/1080p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res3_2X),
|
||||
tr("1.5X (1080p/1620p) [EXPERIMENTAL]")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res2X), tr("2X (1440p/2160p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res3X), tr("3X (2160p/3240p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res4X), tr("4X (2880p/4320p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res5X), tr("5X (3600p/5400p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res6X), tr("6X (4320p/6480p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res7X), tr("7X (5040p/7560p)")},
|
||||
{static_cast<u32>(Settings::ResolutionSetup::Res8X), tr("8X (5760p/8640p)")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::ScalingFilter),
|
||||
{
|
||||
{static_cast<u32>(Settings::ScalingFilter::NearestNeighbor), tr("Nearest Neighbor")},
|
||||
{static_cast<u32>(Settings::ScalingFilter::Bilinear), tr("Bilinear")},
|
||||
{static_cast<u32>(Settings::ScalingFilter::Bicubic), tr("Bicubic")},
|
||||
{static_cast<u32>(Settings::ScalingFilter::Gaussian), tr("Gaussian")},
|
||||
{static_cast<u32>(Settings::ScalingFilter::ScaleForce), tr("ScaleForce")},
|
||||
{static_cast<u32>(Settings::ScalingFilter::Fsr),
|
||||
tr("AMD FidelityFX™️ Super Resolution")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::AntiAliasing),
|
||||
{
|
||||
{static_cast<u32>(Settings::AntiAliasing::None), tr("None")},
|
||||
{static_cast<u32>(Settings::AntiAliasing::Fxaa), tr("FXAA")},
|
||||
{static_cast<u32>(Settings::AntiAliasing::Smaa), tr("SMAA")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::AspectRatio),
|
||||
{
|
||||
{static_cast<u32>(Settings::AspectRatio::R16_9), tr("Default (16:9)")},
|
||||
{static_cast<u32>(Settings::AspectRatio::R4_3), tr("Force 4:3")},
|
||||
{static_cast<u32>(Settings::AspectRatio::R21_9), tr("Force 21:9")},
|
||||
{static_cast<u32>(Settings::AspectRatio::R16_10), tr("Force 16:10")},
|
||||
{static_cast<u32>(Settings::AspectRatio::Stretch), tr("Stretch to Window")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::AnisotropyMode),
|
||||
{
|
||||
{static_cast<u32>(Settings::AnisotropyMode::Automatic), tr("Automatic")},
|
||||
{static_cast<u32>(Settings::AnisotropyMode::Default), tr("Default")},
|
||||
{static_cast<u32>(Settings::AnisotropyMode::X2), tr("2x")},
|
||||
{static_cast<u32>(Settings::AnisotropyMode::X4), tr("4x")},
|
||||
{static_cast<u32>(Settings::AnisotropyMode::X8), tr("8x")},
|
||||
{static_cast<u32>(Settings::AnisotropyMode::X16), tr("16x")},
|
||||
}});
|
||||
translations->insert(
|
||||
{typeid(Settings::Language),
|
||||
{
|
||||
{static_cast<u32>(Settings::Language::Japanese), tr("Japanese (日本語)")},
|
||||
{static_cast<u32>(Settings::Language::EnglishAmerican), tr("American English")},
|
||||
{static_cast<u32>(Settings::Language::French), tr("French (français)")},
|
||||
{static_cast<u32>(Settings::Language::German), tr("German (Deutsch)")},
|
||||
{static_cast<u32>(Settings::Language::Italian), tr("Italian (italiano)")},
|
||||
{static_cast<u32>(Settings::Language::Spanish), tr("Spanish (español)")},
|
||||
{static_cast<u32>(Settings::Language::Chinese), tr("Chinese")},
|
||||
{static_cast<u32>(Settings::Language::Korean), tr("Korean (한국어)")},
|
||||
{static_cast<u32>(Settings::Language::Dutch), tr("Dutch (Nederlands)")},
|
||||
{static_cast<u32>(Settings::Language::Portuguese), tr("Portuguese (português)")},
|
||||
{static_cast<u32>(Settings::Language::Russian), tr("Russian (Русский)")},
|
||||
{static_cast<u32>(Settings::Language::Taiwanese), tr("Taiwanese")},
|
||||
{static_cast<u32>(Settings::Language::EnglishBritish), tr("British English")},
|
||||
{static_cast<u32>(Settings::Language::FrenchCanadian), tr("Canadian French")},
|
||||
{static_cast<u32>(Settings::Language::SpanishLatin), tr("Latin American Spanish")},
|
||||
{static_cast<u32>(Settings::Language::ChineseSimplified), tr("Simplified Chinese")},
|
||||
{static_cast<u32>(Settings::Language::ChineseTraditional),
|
||||
tr("Traditional Chinese (正體中文)")},
|
||||
{static_cast<u32>(Settings::Language::PortugueseBrazilian),
|
||||
tr("Brazilian Portuguese (português do Brasil)")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::Region),
|
||||
{
|
||||
{static_cast<u32>(Settings::Region::Japan), tr("Japan")},
|
||||
{static_cast<u32>(Settings::Region::USA), tr("USA")},
|
||||
{static_cast<u32>(Settings::Region::Europe), tr("Europe")},
|
||||
{static_cast<u32>(Settings::Region::Australia), tr("Australia")},
|
||||
{static_cast<u32>(Settings::Region::China), tr("China")},
|
||||
{static_cast<u32>(Settings::Region::Korea), tr("Korea")},
|
||||
{static_cast<u32>(Settings::Region::Taiwan), tr("Taiwan")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::TimeZone),
|
||||
{
|
||||
{static_cast<u32>(Settings::TimeZone::Auto), tr("Auto")},
|
||||
{static_cast<u32>(Settings::TimeZone::Default), tr("Default")},
|
||||
{static_cast<u32>(Settings::TimeZone::CET), tr("CET")},
|
||||
{static_cast<u32>(Settings::TimeZone::CST6CDT), tr("CST6CDT")},
|
||||
{static_cast<u32>(Settings::TimeZone::Cuba), tr("Cuba")},
|
||||
{static_cast<u32>(Settings::TimeZone::EET), tr("EET")},
|
||||
{static_cast<u32>(Settings::TimeZone::Egypt), tr("Egypt")},
|
||||
{static_cast<u32>(Settings::TimeZone::Eire), tr("Eire")},
|
||||
{static_cast<u32>(Settings::TimeZone::EST), tr("EST")},
|
||||
{static_cast<u32>(Settings::TimeZone::EST5EDT), tr("EST5EDT")},
|
||||
{static_cast<u32>(Settings::TimeZone::GB), tr("GB")},
|
||||
{static_cast<u32>(Settings::TimeZone::GBEire), tr("GB-Eire")},
|
||||
{static_cast<u32>(Settings::TimeZone::GMT), tr("GMT")},
|
||||
{static_cast<u32>(Settings::TimeZone::GMTPlusZero), tr("GMT+0")},
|
||||
{static_cast<u32>(Settings::TimeZone::GMTMinusZero), tr("GMT-0")},
|
||||
{static_cast<u32>(Settings::TimeZone::GMTZero), tr("GMT0")},
|
||||
{static_cast<u32>(Settings::TimeZone::Greenwich), tr("Greenwich")},
|
||||
{static_cast<u32>(Settings::TimeZone::Hongkong), tr("Hongkong")},
|
||||
{static_cast<u32>(Settings::TimeZone::HST), tr("HST")},
|
||||
{static_cast<u32>(Settings::TimeZone::Iceland), tr("Iceland")},
|
||||
{static_cast<u32>(Settings::TimeZone::Iran), tr("Iran")},
|
||||
{static_cast<u32>(Settings::TimeZone::Israel), tr("Israel")},
|
||||
{static_cast<u32>(Settings::TimeZone::Jamaica), tr("Jamaica")},
|
||||
{static_cast<u32>(Settings::TimeZone::Kwajalein), tr("Kwajalein")},
|
||||
{static_cast<u32>(Settings::TimeZone::Libya), tr("Libya")},
|
||||
{static_cast<u32>(Settings::TimeZone::MET), tr("MET")},
|
||||
{static_cast<u32>(Settings::TimeZone::MST), tr("MST")},
|
||||
{static_cast<u32>(Settings::TimeZone::MST7MDT), tr("MST7MDT")},
|
||||
{static_cast<u32>(Settings::TimeZone::Navajo), tr("Navajo")},
|
||||
{static_cast<u32>(Settings::TimeZone::NZ), tr("NZ")},
|
||||
{static_cast<u32>(Settings::TimeZone::NZCHAT), tr("NZ-CHAT")},
|
||||
{static_cast<u32>(Settings::TimeZone::Poland), tr("Poland")},
|
||||
{static_cast<u32>(Settings::TimeZone::Portugal), tr("Portugal")},
|
||||
{static_cast<u32>(Settings::TimeZone::PRC), tr("PRC")},
|
||||
{static_cast<u32>(Settings::TimeZone::PST8PDT), tr("PST8PDT")},
|
||||
{static_cast<u32>(Settings::TimeZone::ROC), tr("ROC")},
|
||||
{static_cast<u32>(Settings::TimeZone::ROK), tr("ROK")},
|
||||
{static_cast<u32>(Settings::TimeZone::Singapore), tr("Singapore")},
|
||||
{static_cast<u32>(Settings::TimeZone::Turkey), tr("Turkey")},
|
||||
{static_cast<u32>(Settings::TimeZone::UCT), tr("UCT")},
|
||||
{static_cast<u32>(Settings::TimeZone::W_SU), tr("W-SU")},
|
||||
{static_cast<u32>(Settings::TimeZone::WET), tr("WET")},
|
||||
{static_cast<u32>(Settings::TimeZone::Zulu), tr("Zulu")},
|
||||
}});
|
||||
translations->insert({typeid(Settings::AudioMode),
|
||||
{
|
||||
{static_cast<u32>(Settings::AudioMode::Mono), tr("Mono")},
|
||||
{static_cast<u32>(Settings::AudioMode::Stereo), tr("Stereo")},
|
||||
{static_cast<u32>(Settings::AudioMode::Surround), tr("Surround")},
|
||||
}});
|
||||
|
||||
return {};
|
||||
return translations;
|
||||
}
|
||||
|
||||
} // namespace ConfigurationShared
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <forward_list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace ConfigurationShared {
|
||||
using TranslationMap = std::map<u32, std::pair<QString, QString>>;
|
||||
using ComboboxTranslations = std::vector<std::pair<u32, QString>>;
|
||||
using ComboboxTranslationMap = std::map<std::type_index, ComboboxTranslations>;
|
||||
|
||||
std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent);
|
||||
|
||||
std::forward_list<QString> ComboboxEnumeration(std::type_index type, QWidget* parent);
|
||||
std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent);
|
||||
|
||||
} // namespace ConfigurationShared
|
||||
|
|
|
@ -113,40 +113,51 @@ void Widget::CreateCombobox(const QString& label, std::function<void()>& load_fu
|
|||
QLabel* qt_label = new QLabel(label, this);
|
||||
combobox = new QComboBox(this);
|
||||
|
||||
std::forward_list<QString> combobox_enumerations = ComboboxEnumeration(type, this);
|
||||
for (const auto& item : combobox_enumerations) {
|
||||
combobox->addItem(item);
|
||||
}
|
||||
|
||||
layout->addWidget(qt_label);
|
||||
layout->addWidget(combobox);
|
||||
|
||||
layout->setSpacing(6);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
if (!managed) {
|
||||
const ComboboxTranslations* enumeration{nullptr};
|
||||
if (combobox_enumerations.contains(type)) {
|
||||
enumeration = &combobox_enumerations.at(type);
|
||||
for (const auto& [id, name] : *enumeration) {
|
||||
combobox->addItem(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!managed || enumeration == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Remove audio engine specialization
|
||||
if (setting.TypeId() != typeid(Settings::AudioEngine)) {
|
||||
combobox->setCurrentIndex(std::stoi(setting.ToString()));
|
||||
} else {
|
||||
combobox->setCurrentIndex(
|
||||
static_cast<u32>(Settings::ToEnum<Settings::AudioEngine>(setting.ToString())));
|
||||
const auto find_index = [=](u32 value) -> int {
|
||||
for (u32 i = 0; i < enumeration->size(); i++) {
|
||||
if (enumeration->at(i).first == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
const u32 setting_value = std::stoi(setting.ToString());
|
||||
combobox->setCurrentIndex(find_index(setting_value));
|
||||
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
load_func = [=]() { setting.LoadString(std::to_string(combobox->currentIndex())); };
|
||||
load_func = [=]() {
|
||||
int current = combobox->currentIndex();
|
||||
setting.LoadString(std::to_string(enumeration->at(current).first));
|
||||
};
|
||||
} else {
|
||||
restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this);
|
||||
layout->addWidget(restore_button);
|
||||
|
||||
QObject::connect(restore_button, &QAbstractButton::clicked, [&](bool) {
|
||||
QObject::connect(restore_button, &QAbstractButton::clicked, [=](bool) {
|
||||
restore_button->setEnabled(false);
|
||||
restore_button->setVisible(false);
|
||||
|
||||
combobox->setCurrentIndex(std::stoi(setting.ToStringGlobal()));
|
||||
const u32 global_value = std::stoi(setting.ToStringGlobal());
|
||||
combobox->setCurrentIndex(find_index(global_value));
|
||||
});
|
||||
|
||||
QObject::connect(combobox, QOverload<int>::of(&QComboBox::activated), [=](int) {
|
||||
|
@ -158,7 +169,8 @@ void Widget::CreateCombobox(const QString& label, std::function<void()>& load_fu
|
|||
bool using_global = !restore_button->isEnabled();
|
||||
setting.SetGlobal(using_global);
|
||||
if (!using_global) {
|
||||
setting.LoadString(std::to_string(combobox->currentIndex()));
|
||||
int current = combobox->currentIndex();
|
||||
setting.LoadString(std::to_string(enumeration->at(current).first));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -523,17 +535,13 @@ bool Widget::Valid() {
|
|||
Widget::~Widget() = default;
|
||||
|
||||
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
||||
QWidget* parent_, std::forward_list<std::function<void(bool)>>& apply_funcs_)
|
||||
: QWidget(parent_), parent{parent_}, translations{translations_}, setting{*setting_},
|
||||
apply_funcs{apply_funcs_} {}
|
||||
|
||||
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
||||
QWidget* parent_, bool runtime_lock_,
|
||||
std::forward_list<std::function<void(bool)>>& apply_funcs_, RequestType request,
|
||||
bool managed, float multiplier, Settings::BasicSetting* other_setting,
|
||||
const QString& string)
|
||||
: QWidget(parent_), parent{parent_}, translations{translations_}, setting{*setting_},
|
||||
apply_funcs{apply_funcs_}, runtime_lock{runtime_lock_} {
|
||||
const ComboboxTranslationMap& combobox_translations_, QWidget* parent_,
|
||||
bool runtime_lock_, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
||||
RequestType request, bool managed, float multiplier,
|
||||
Settings::BasicSetting* other_setting, const QString& string)
|
||||
: QWidget(parent_), parent{parent_}, translations{translations_},
|
||||
combobox_enumerations{combobox_translations_}, setting{*setting_}, apply_funcs{apply_funcs_},
|
||||
runtime_lock{runtime_lock_} {
|
||||
if (!Settings::IsConfiguringGlobal() && !setting.Switchable()) {
|
||||
LOG_DEBUG(Frontend, "\"{}\" is not switchable, skipping...", setting.GetLabel());
|
||||
return;
|
||||
|
@ -632,5 +640,4 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
|||
|
||||
this->setToolTip(tooltip);
|
||||
}
|
||||
|
||||
} // namespace ConfigurationShared
|
||||
|
|
|
@ -35,13 +35,12 @@ class Widget : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
|
||||
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
||||
Widget(Settings::BasicSetting* setting, const TranslationMap& translations,
|
||||
const ComboboxTranslationMap& combobox_translations, QWidget* parent, bool runtime_lock,
|
||||
std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
||||
RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f,
|
||||
Settings::BasicSetting* other_setting = nullptr,
|
||||
const QString& string = QStringLiteral(""));
|
||||
Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, QWidget* parent_,
|
||||
std::forward_list<std::function<void(bool)>>& apply_funcs_);
|
||||
virtual ~Widget();
|
||||
|
||||
bool Valid();
|
||||
|
@ -77,6 +76,7 @@ private:
|
|||
|
||||
QWidget* parent;
|
||||
const TranslationMap& translations;
|
||||
const ComboboxTranslationMap& combobox_enumerations;
|
||||
Settings::BasicSetting& setting;
|
||||
std::forward_list<std::function<void(bool)>>& apply_funcs;
|
||||
|
||||
|
|
Loading…
Reference in a new issue