1
1
Fork 0
forked from suyu/suyu

common,qt-config: Remove usage of forward_list

This commit is contained in:
lat9nq 2023-07-21 23:09:09 -04:00
parent 2911988b85
commit 17b9c1e171
21 changed files with 64 additions and 65 deletions

View file

@ -10,7 +10,6 @@
#include <compare>
#include <cstddef>
#include <filesystem>
#include <forward_list>
#include <functional>
#include <string_view>
#include <type_traits>

View file

@ -3,7 +3,6 @@
#pragma once
#include <forward_list>
#include <functional>
#include <map>
#include <string>

View file

@ -3,13 +3,14 @@
#include <memory>
#include <type_traits>
#include <vector>
#include "yuzu/configuration/configuration_shared.h"
namespace ConfigurationShared {
Tab::Tab(std::shared_ptr<std::forward_list<Tab*>> group, QWidget* parent) : QWidget(parent) {
Tab::Tab(std::shared_ptr<std::vector<Tab*>> group, QWidget* parent) : QWidget(parent) {
if (group != nullptr) {
group->push_front(this);
group->push_back(this);
}
}

View file

@ -3,8 +3,8 @@
#pragma once
#include <forward_list>
#include <memory>
#include <vector>
#include <QString>
#include <QWidget>
#include <qobjectdefs.h>
@ -17,7 +17,7 @@ class Tab : public QWidget {
Q_OBJECT
public:
explicit Tab(std::shared_ptr<std::forward_list<Tab*>> group, QWidget* parent = nullptr);
explicit Tab(std::shared_ptr<std::vector<Tab*>> group, QWidget* parent = nullptr);
~Tab();
virtual void ApplyConfiguration() = 0;

View file

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <forward_list>
#include <memory>
#include <vector>
#include <QComboBox>
#include "audio_core/sink/sink.h"
@ -17,7 +17,7 @@
#include "yuzu/uisettings.h"
ConfigureAudio::ConfigureAudio(const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
: Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_} {
ui->setupUi(this);
@ -31,11 +31,11 @@ ConfigureAudio::~ConfigureAudio() = default;
void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
auto& layout = *ui->audio_widget->layout();
std::forward_list<Settings::BasicSetting*> settings;
std::vector<Settings::BasicSetting*> settings;
auto push = [&](Settings::Category category) {
for (auto* setting : Settings::values.linkage.by_category[category]) {
settings.push_front(setting);
settings.push_back(setting);
}
};

View file

@ -3,9 +3,9 @@
#pragma once
#include <forward_list>
#include <functional>
#include <memory>
#include <vector>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
@ -26,7 +26,7 @@ class Builder;
class ConfigureAudio : public ConfigurationShared::Tab {
public:
explicit ConfigureAudio(const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
const ConfigurationShared::Builder& builder, QWidget* parent = nullptr);
~ConfigureAudio() override;
@ -51,7 +51,7 @@ private:
const Core::System& system;
std::forward_list<std::function<void(bool)>> apply_funcs{};
std::vector<std::function<void(bool)>> apply_funcs{};
QComboBox* sink_combo_box;
QComboBox* output_device_combo_box;

View file

@ -1,9 +1,9 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <forward_list>
#include <memory>
#include <typeinfo>
#include <vector>
#include <QComboBox>
#include "common/common_types.h"
#include "common/settings.h"
@ -15,7 +15,7 @@
#include "yuzu/configuration/configure_cpu.h"
ConfigureCpu::ConfigureCpu(const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_},
combobox_translations(builder.ComboboxTranslations()) {
@ -37,10 +37,10 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) {
auto* unsafe_layout = ui->unsafe_widget->layout();
std::map<std::string, QWidget*> unsafe_hold{};
std::forward_list<Settings::BasicSetting*> settings;
std::vector<Settings::BasicSetting*> settings;
const auto push = [&](Settings::Category category) {
for (const auto setting : Settings::values.linkage.by_category[category]) {
settings.push_front(setting);
settings.push_back(setting);
}
};

View file

@ -4,6 +4,7 @@
#pragma once
#include <memory>
#include <vector>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/shared_translation.h"
@ -25,7 +26,7 @@ class Builder;
class ConfigureCpu : public ConfigurationShared::Tab {
public:
explicit ConfigureCpu(const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
const ConfigurationShared::Builder& builder, QWidget* parent = nullptr);
~ConfigureCpu() override;
@ -45,7 +46,7 @@ private:
const Core::System& system;
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
std::forward_list<std::function<void(bool)>> apply_funcs{};
std::vector<std::function<void(bool)>> apply_funcs{};
QComboBox* accuracy_combobox;
};

View file

@ -3,7 +3,6 @@
#pragma once
#include <forward_list>
#include <memory>
#include <vector>
#include <QDialog>
@ -74,7 +73,7 @@ private:
Core::System& system;
std::unique_ptr<ConfigurationShared::Builder> builder;
std::forward_list<ConfigurationShared::Tab*> tab_group;
std::vector<ConfigurationShared::Tab*> tab_group;
std::unique_ptr<ConfigureAudio> audio_tab;
std::unique_ptr<ConfigureCpu> cpu_tab;

View file

@ -3,6 +3,7 @@
#include <functional>
#include <utility>
#include <vector>
#include <QMessageBox>
#include "common/settings.h"
#include "core/core.h"
@ -12,10 +13,9 @@
#include "yuzu/configuration/shared_widget.h"
#include "yuzu/uisettings.h"
ConfigureGeneral::ConfigureGeneral(
const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
ConfigureGeneral::ConfigureGeneral(const Core::System& system_,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} {
ui->setupUi(this);

View file

@ -5,6 +5,7 @@
#include <functional>
#include <memory>
#include <vector>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
@ -26,7 +27,7 @@ class Builder;
class ConfigureGeneral : public ConfigurationShared::Tab {
public:
explicit ConfigureGeneral(const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
const ConfigurationShared::Builder& builder,
QWidget* parent = nullptr);
~ConfigureGeneral() override;
@ -46,7 +47,7 @@ private:
std::unique_ptr<Ui::ConfigureGeneral> ui;
std::forward_list<std::function<void(bool)>> apply_funcs{};
std::vector<std::function<void(bool)>> apply_funcs{};
const Core::System& system;
};

View file

@ -77,11 +77,11 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode)
}
}
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::Builder& builder, QWidget* parent)
ConfigureGraphics::ConfigureGraphics(const Core::System& system_,
std::vector<VkDeviceInfo::Record>& records_,
const std::function<void()>& expose_compute_option_,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
: ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
records{records_}, expose_compute_option{expose_compute_option_}, system{system_},
combobox_translations{builder.ComboboxTranslations()},
@ -228,7 +228,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
QLayout& graphics_layout = *ui->graphics_widget->layout();
std::map<u32, QWidget*> hold_graphics;
std::forward_list<QWidget*> hold_api;
std::vector<QWidget*> hold_api;
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
ConfigurationShared::Widget* widget = [&]() {
@ -268,12 +268,12 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
}
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
// Keep track of vulkan_device's combobox so we can populate it
hold_api.push_front(widget);
hold_api.push_back(widget);
vulkan_device_combobox = widget->combobox;
vulkan_device_widget = widget;
} else if (setting->Id() == Settings::values.shader_backend.Id()) {
// Keep track of shader_backend's combobox so we can populate it
hold_api.push_front(widget);
hold_api.push_back(widget);
shader_backend_combobox = widget->combobox;
shader_backend_widget = widget;
} else if (setting->Id() == Settings::values.vsync_mode.Id()) {
@ -296,7 +296,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
// Background color is too specific to build into the new system, so we manage it here
// (3 settings, all collected into a single widget with a QColor to manage on top)
if (Settings::IsConfiguringGlobal()) {
apply_funcs.push_front([this](bool powered_on) {
apply_funcs.push_back([this](bool powered_on) {
Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red()));
Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green()));
Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue()));
@ -322,7 +322,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
bg_restore_button->setEnabled(true);
});
apply_funcs.push_front([bg_restore_button, this](bool powered_on) {
apply_funcs.push_back([bg_restore_button, this](bool powered_on) {
const bool using_global = !bg_restore_button->isEnabled();
Settings::values.bg_red.SetGlobal(using_global);
Settings::values.bg_green.SetGlobal(using_global);

View file

@ -46,7 +46,7 @@ public:
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,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
const ConfigurationShared::Builder& builder,
QWidget* parent = nullptr);
~ConfigureGraphics() override;
@ -80,7 +80,7 @@ private:
std::unique_ptr<Ui::ConfigureGraphics> ui;
QColor bg_color;
std::forward_list<std::function<void(bool)>> apply_funcs{};
std::vector<std::function<void(bool)>> apply_funcs{};
std::vector<VkDeviceInfo::Record>& records;
std::vector<QString> vulkan_devices;

View file

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <vector>
#include <QLabel>
#include <qnamespace.h>
#include "common/settings.h"
@ -12,8 +13,7 @@
#include "yuzu/configuration/shared_widget.h"
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const Core::System& system_, std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} {

View file

@ -4,6 +4,7 @@
#pragma once
#include <memory>
#include <vector>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
@ -22,8 +23,7 @@ class Builder;
class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab {
public:
explicit ConfigureGraphicsAdvanced(
const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
const Core::System& system_, std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
const ConfigurationShared::Builder& builder, QWidget* parent = nullptr);
~ConfigureGraphicsAdvanced() override;
@ -41,7 +41,7 @@ private:
const Core::System& system;
std::forward_list<std::function<void(bool)>> apply_funcs;
std::vector<std::function<void(bool)>> apply_funcs;
QWidget* checkbox_enable_compute_pipelines{};
};

View file

@ -44,7 +44,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_},
builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())},
tab_group{std::make_shared<std::forward_list<ConfigurationShared::Tab*>>()} {
tab_group{std::make_shared<std::vector<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())
: fmt::format("{:016X}", title_id);

View file

@ -3,7 +3,6 @@
#pragma once
#include <forward_list>
#include <memory>
#include <string>
#include <vector>
@ -77,7 +76,7 @@ private:
Core::System& system;
std::unique_ptr<ConfigurationShared::Builder> builder;
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> tab_group;
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> tab_group;
std::unique_ptr<ConfigurePerGameAddons> addons_tab;
std::unique_ptr<ConfigureAudio> audio_tab;

View file

@ -2,8 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <chrono>
#include <forward_list>
#include <optional>
#include <vector>
#include <QCheckBox>
#include <QComboBox>
@ -44,9 +44,9 @@ static bool IsValidLocale(u32 region_index, u32 language_index) {
return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0;
}
ConfigureSystem::ConfigureSystem(
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
ConfigureSystem::ConfigureSystem(Core::System& system_,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::Builder& builder, QWidget* parent)
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
ui->setupUi(this);
@ -95,10 +95,10 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
std::map<u32, QWidget*> core_hold{};
std::map<u32, QWidget*> system_hold{};
std::forward_list<Settings::BasicSetting*> settings;
std::vector<Settings::BasicSetting*> settings;
auto push = [&settings](auto& list) {
for (auto setting : list) {
settings.push_front(setting);
settings.push_back(setting);
}
};

View file

@ -3,9 +3,9 @@
#pragma once
#include <forward_list>
#include <functional>
#include <memory>
#include <vector>
#include <QWidget>
#include "yuzu/configuration/configuration_shared.h"
@ -29,7 +29,7 @@ class Builder;
class ConfigureSystem : public ConfigurationShared::Tab {
public:
explicit ConfigureSystem(Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group,
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group,
const ConfigurationShared::Builder& builder,
QWidget* parent = nullptr);
~ConfigureSystem() override;
@ -43,7 +43,7 @@ private:
void Setup(const ConfigurationShared::Builder& builder);
std::forward_list<std::function<void(bool)>> apply_funcs{};
std::vector<std::function<void(bool)>> apply_funcs{};
std::unique_ptr<Ui::ConfigureSystem> ui;
bool enabled = false;

View file

@ -547,7 +547,7 @@ Widget::~Widget() = default;
Widget::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_,
bool runtime_lock_, std::vector<std::function<void(bool)>>& apply_funcs_,
RequestType request, bool managed, float multiplier,
Settings::BasicSetting* other_setting, const QString& suffix)
: QWidget(parent_), parent{parent_}, translations{translations_},
@ -584,7 +584,7 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
return;
}
apply_funcs.push_front([load_func, setting_](bool powered_on) {
apply_funcs.push_back([load_func, setting_](bool powered_on) {
if (setting_->RuntimeModfiable() || !powered_on) {
load_func();
}
@ -607,7 +607,7 @@ Builder::Builder(QWidget* parent_, bool runtime_lock_)
Builder::~Builder() = default;
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
std::forward_list<std::function<void(bool)>>& apply_funcs,
std::vector<std::function<void(bool)>>& apply_funcs,
RequestType request, bool managed, float multiplier,
Settings::BasicSetting* other_setting, const QString& suffix) const {
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
@ -624,7 +624,7 @@ Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
}
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
std::forward_list<std::function<void(bool)>>& apply_funcs,
std::vector<std::function<void(bool)>>& apply_funcs,
Settings::BasicSetting* other_setting, RequestType request,
const QString& suffix) const {
return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, suffix);

View file

@ -3,10 +3,10 @@
#pragma once
#include <forward_list>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <QString>
#include <QStringLiteral>
#include <QWidget>
@ -62,7 +62,7 @@ public:
*/
explicit 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_,
bool runtime_lock, std::vector<std::function<void(bool)>>& apply_funcs_,
RequestType request = RequestType::Default, bool managed = true,
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
const QString& suffix = QStringLiteral(""));
@ -125,7 +125,7 @@ private:
const TranslationMap& translations;
const ComboboxTranslationMap& combobox_enumerations;
Settings::BasicSetting& setting;
std::forward_list<std::function<void(bool)>>& apply_funcs;
std::vector<std::function<void(bool)>>& apply_funcs;
bool created{false};
bool runtime_lock{false};
@ -137,13 +137,13 @@ public:
~Builder();
Widget* BuildWidget(Settings::BasicSetting* setting,
std::forward_list<std::function<void(bool)>>& apply_funcs,
std::vector<std::function<void(bool)>>& apply_funcs,
RequestType request = RequestType::Default, bool managed = true,
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
const QString& suffix = QStringLiteral("")) const;
Widget* BuildWidget(Settings::BasicSetting* setting,
std::forward_list<std::function<void(bool)>>& apply_funcs,
std::vector<std::function<void(bool)>>& apply_funcs,
Settings::BasicSetting* other_setting,
RequestType request = RequestType::Default,
const QString& suffix = QStringLiteral("")) const;