yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

configuration: Use IDs to sort holds

This commit is contained in:
lat9nq 2023-06-06 22:30:02 -04:00
parent f7948b7b64
commit 9e3c94bb3d
4 changed files with 16 additions and 27 deletions

View File

@ -37,7 +37,7 @@ void ConfigureGeneral::SetConfiguration() {
const bool runtime_lock = !system.IsPoweredOn(); const bool runtime_lock = !system.IsPoweredOn();
QLayout& layout = *ui->general_widget->layout(); QLayout& layout = *ui->general_widget->layout();
std::map<std::string, QWidget*> hold{}; std::map<u32, QWidget*> hold{};
for (const auto setting : for (const auto setting :
UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) { UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) {
@ -49,10 +49,10 @@ void ConfigureGeneral::SetConfiguration() {
continue; 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); layout.addWidget(widget);
} }
} }

View File

@ -226,12 +226,10 @@ void ConfigureGraphics::Setup() {
QLayout& graphics_layout = *ui->graphics_widget->layout(); QLayout& graphics_layout = *ui->graphics_widget->layout();
std::map<bool, std::map<std::string, QWidget*>> hold_graphics; std::map<u32, QWidget*> hold_graphics;
std::forward_list<QWidget*> hold_api; std::forward_list<QWidget*> hold_api;
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
const auto& setting_label = setting->GetLabel();
ConfigurationShared::Widget* widget = [&]() { ConfigurationShared::Widget* widget = [&]() {
if (setting->Id() == Settings::values.vulkan_device.Id() || if (setting->Id() == Settings::values.vulkan_device.Id() ||
setting->Id() == Settings::values.shader_backend.Id() || setting->Id() == Settings::values.shader_backend.Id() ||
@ -284,16 +282,14 @@ void ConfigureGraphics::Setup() {
shader_backend_widget = widget; shader_backend_widget = widget;
} else if (setting->Id() == Settings::values.vsync_mode.Id()) { } else if (setting->Id() == Settings::values.vsync_mode.Id()) {
vsync_mode_combobox = widget->combobox; vsync_mode_combobox = widget->combobox;
hold_graphics[setting->IsEnum()][setting_label] = widget; hold_graphics.emplace(setting->Id(), widget);
} else { } else {
hold_graphics[setting->IsEnum()][setting_label] = widget; hold_graphics.emplace(setting->Id(), widget);
} }
} }
for (const auto& [_, settings] : hold_graphics) { for (const auto& [id, widget] : hold_graphics) {
for (const auto& [label, widget] : settings) { graphics_layout.addWidget(widget);
graphics_layout.addWidget(widget);
}
} }
for (auto widget : hold_api) { for (auto widget : hold_api) {

View File

@ -31,7 +31,7 @@ ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default;
void ConfigureGraphicsAdvanced::SetConfiguration() { void ConfigureGraphicsAdvanced::SetConfiguration() {
const bool runtime_lock = !system.IsPoweredOn(); const bool runtime_lock = !system.IsPoweredOn();
auto& layout = *ui->populate_target->layout(); auto& layout = *ui->populate_target->layout();
std::map<std::string, QWidget*> hold{}; // A map will sort the data for us std::map<u32, QWidget*> hold{}; // A map will sort the data for us
for (auto setting : for (auto setting :
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) { Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
@ -43,17 +43,13 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
continue; continue;
} }
if (!setting->IsEnum()) { hold.emplace(setting->Id(), widget);
hold.emplace(setting->GetLabel(), widget);
} else {
layout.addWidget(widget);
}
if (setting->Id() == Settings::values.enable_compute_pipelines.Id()) { if (setting->Id() == Settings::values.enable_compute_pipelines.Id()) {
checkbox_enable_compute_pipelines = widget; checkbox_enable_compute_pipelines = widget;
} }
} }
for (const auto& [label, widget] : hold) { for (const auto& [id, widget] : hold) {
layout.addWidget(widget); layout.addWidget(widget);
} }
} }

View File

@ -109,8 +109,8 @@ void ConfigureSystem::Setup() {
auto& core_layout = *ui->core_widget->layout(); auto& core_layout = *ui->core_widget->layout();
auto& system_layout = *ui->system_widget->layout(); auto& system_layout = *ui->system_widget->layout();
std::map<std::string, QWidget*> core_hold{}; std::map<u32, QWidget*> core_hold{};
std::map<bool, std::map<std::string, QWidget*>> system_hold{}; std::map<u32, QWidget*> system_hold{};
std::forward_list<Settings::BasicSetting*> settings; std::forward_list<Settings::BasicSetting*> settings;
auto push = [&settings](std::forward_list<Settings::BasicSetting*>& list) { auto push = [&settings](std::forward_list<Settings::BasicSetting*>& list) {
@ -165,10 +165,10 @@ void ConfigureSystem::Setup() {
switch (setting->Category()) { switch (setting->Category()) {
case Settings::Category::Core: case Settings::Category::Core:
core_hold[setting->GetLabel()] = widget; core_hold.emplace(setting->Id(), widget);
break; break;
case Settings::Category::System: case Settings::Category::System:
system_hold[setting->IsEnum()].insert(std::pair{setting->GetLabel(), widget}); system_hold.emplace(setting->Id(), widget);
break; break;
default: default:
delete widget; delete widget;
@ -177,10 +177,7 @@ void ConfigureSystem::Setup() {
for (const auto& [label, widget] : core_hold) { for (const auto& [label, widget] : core_hold) {
core_layout.addWidget(widget); core_layout.addWidget(widget);
} }
for (const auto& [label, widget] : system_hold[true]) { for (const auto& [id, widget] : system_hold) {
system_layout.addWidget(widget);
}
for (const auto& [label, widget] : system_hold[false]) {
system_layout.addWidget(widget); system_layout.addWidget(widget);
} }
} }