From 9e3c94bb3dd1a9065977930a985be43f6052044c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 6 Jun 2023 22:30:02 -0400 Subject: [PATCH] configuration: Use IDs to sort holds --- src/yuzu/configuration/configure_general.cpp | 6 +++--- src/yuzu/configuration/configure_graphics.cpp | 14 +++++--------- .../configuration/configure_graphics_advanced.cpp | 10 +++------- src/yuzu/configuration/configure_system.cpp | 13 +++++-------- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index fdae83c64..625dd75dd 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -37,7 +37,7 @@ void ConfigureGeneral::SetConfiguration() { const bool runtime_lock = !system.IsPoweredOn(); QLayout& layout = *ui->general_widget->layout(); - std::map hold{}; + std::map hold{}; for (const auto setting : UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) { @@ -49,10 +49,10 @@ void ConfigureGeneral::SetConfiguration() { continue; } - hold.insert({setting->GetLabel(), widget}); + hold.emplace(setting->Id(), widget); } - for (const auto& [label, widget] : hold) { + for (const auto& [id, widget] : hold) { layout.addWidget(widget); } } diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index a4dac659f..59702603a 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -226,12 +226,10 @@ void ConfigureGraphics::Setup() { QLayout& graphics_layout = *ui->graphics_widget->layout(); - std::map> hold_graphics; + std::map hold_graphics; std::forward_list hold_api; for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { - const auto& setting_label = setting->GetLabel(); - ConfigurationShared::Widget* widget = [&]() { if (setting->Id() == Settings::values.vulkan_device.Id() || setting->Id() == Settings::values.shader_backend.Id() || @@ -284,16 +282,14 @@ void ConfigureGraphics::Setup() { shader_backend_widget = widget; } else if (setting->Id() == Settings::values.vsync_mode.Id()) { vsync_mode_combobox = widget->combobox; - hold_graphics[setting->IsEnum()][setting_label] = widget; + hold_graphics.emplace(setting->Id(), widget); } else { - hold_graphics[setting->IsEnum()][setting_label] = widget; + hold_graphics.emplace(setting->Id(), widget); } } - for (const auto& [_, settings] : hold_graphics) { - for (const auto& [label, widget] : settings) { - graphics_layout.addWidget(widget); - } + for (const auto& [id, widget] : hold_graphics) { + graphics_layout.addWidget(widget); } for (auto widget : hold_api) { diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index c5e21da02..8c932f10a 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -31,7 +31,7 @@ ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; void ConfigureGraphicsAdvanced::SetConfiguration() { const bool runtime_lock = !system.IsPoweredOn(); auto& layout = *ui->populate_target->layout(); - std::map hold{}; // A map will sort the data for us + std::map hold{}; // A map will sort the data for us for (auto setting : Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) { @@ -43,17 +43,13 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { continue; } - if (!setting->IsEnum()) { - hold.emplace(setting->GetLabel(), widget); - } else { - layout.addWidget(widget); - } + hold.emplace(setting->Id(), widget); if (setting->Id() == Settings::values.enable_compute_pipelines.Id()) { checkbox_enable_compute_pipelines = widget; } } - for (const auto& [label, widget] : hold) { + for (const auto& [id, widget] : hold) { layout.addWidget(widget); } } diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index ae59d2ee7..4b0e0a649 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -109,8 +109,8 @@ void ConfigureSystem::Setup() { auto& core_layout = *ui->core_widget->layout(); auto& system_layout = *ui->system_widget->layout(); - std::map core_hold{}; - std::map> system_hold{}; + std::map core_hold{}; + std::map system_hold{}; std::forward_list settings; auto push = [&settings](std::forward_list& list) { @@ -165,10 +165,10 @@ void ConfigureSystem::Setup() { switch (setting->Category()) { case Settings::Category::Core: - core_hold[setting->GetLabel()] = widget; + core_hold.emplace(setting->Id(), widget); break; case Settings::Category::System: - system_hold[setting->IsEnum()].insert(std::pair{setting->GetLabel(), widget}); + system_hold.emplace(setting->Id(), widget); break; default: delete widget; @@ -177,10 +177,7 @@ void ConfigureSystem::Setup() { for (const auto& [label, widget] : core_hold) { core_layout.addWidget(widget); } - for (const auto& [label, widget] : system_hold[true]) { - system_layout.addWidget(widget); - } - for (const auto& [label, widget] : system_hold[false]) { + for (const auto& [id, widget] : system_hold) { system_layout.addWidget(widget); } }