summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2023-06-22 03:41:15 +0200
committerlat9nq <22451773+lat9nq@users.noreply.github.com>2023-07-21 16:56:55 +0200
commitca8509d205d20d034c548489d729f65656da611d (patch)
treeb8bc14772ae15b2bd8314692819814f96d514017 /src
parentsettings: Give indices to enums (diff)
downloadyuzu-ca8509d205d20d034c548489d729f65656da611d.tar
yuzu-ca8509d205d20d034c548489d729f65656da611d.tar.gz
yuzu-ca8509d205d20d034c548489d729f65656da611d.tar.bz2
yuzu-ca8509d205d20d034c548489d729f65656da611d.tar.lz
yuzu-ca8509d205d20d034c548489d729f65656da611d.tar.xz
yuzu-ca8509d205d20d034c548489d729f65656da611d.tar.zst
yuzu-ca8509d205d20d034c548489d729f65656da611d.zip
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_cpu.cpp4
-rw-r--r--src/yuzu/configuration/configure_graphics.cpp13
-rw-r--r--src/yuzu/configuration/configure_graphics.h2
-rw-r--r--src/yuzu/configuration/shared_translation.cpp34
-rw-r--r--src/yuzu/configuration/shared_translation.h2
-rw-r--r--src/yuzu/configuration/shared_widget.cpp2
6 files changed, 31 insertions, 26 deletions
diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp
index 57cdc4c63..7d122906e 100644
--- a/src/yuzu/configuration/configure_cpu.cpp
+++ b/src/yuzu/configuration/configure_cpu.cpp
@@ -7,6 +7,7 @@
#include <QComboBox>
#include "common/common_types.h"
#include "common/settings.h"
+#include "common/settings_enums.h"
#include "configuration/shared_widget.h"
#include "core/core.h"
#include "ui_configure_cpu.h"
@@ -76,7 +77,8 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) {
void ConfigureCpu::UpdateGroup(int index) {
const auto accuracy = static_cast<Settings::CpuAccuracy>(
- combobox_translations.at(typeid(Settings::CpuAccuracy))[index].first);
+ combobox_translations.at(Settings::EnumMetadata<Settings::CpuAccuracy>::Index())[index]
+ .first);
ui->unsafe_group->setVisible(accuracy == Settings::CpuAccuracy::Unsafe);
}
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp
index 7263af13f..31e87ccf5 100644
--- a/src/yuzu/configuration/configure_graphics.cpp
+++ b/src/yuzu/configuration/configure_graphics.cpp
@@ -85,7 +85,8 @@ ConfigureGraphics::ConfigureGraphics(
: ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
records{records_}, expose_compute_option{expose_compute_option_}, system{system_},
combobox_translations{builder.ComboboxTranslations()},
- shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} {
+ shader_mapping{
+ combobox_translations.at(Settings::EnumMetadata<Settings::ShaderBackend>::Index())} {
vulkan_device = Settings::values.vulkan_device.GetValue();
RetrieveVulkanDevices();
@@ -356,7 +357,7 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
}
}
-int ConfigureGraphics::FindIndex(std::type_index enumeration, int value) const {
+int ConfigureGraphics::FindIndex(u32 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;
@@ -383,7 +384,8 @@ void ConfigureGraphics::ApplyConfiguration() {
(!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) {
auto backend = static_cast<Settings::RendererBackend>(
combobox_translations
- .at(typeid(Settings::RendererBackend))[api_combobox->currentIndex()]
+ .at(Settings::EnumMetadata<
+ Settings::RendererBackend>::Index())[api_combobox->currentIndex()]
.first);
switch (backend) {
case Settings::RendererBackend::OpenGL:
@@ -440,7 +442,8 @@ void ConfigureGraphics::UpdateAPILayout() {
if (is_opengl) {
shader_backend_combobox->setCurrentIndex(
- FindIndex(typeid(Settings::ShaderBackend), static_cast<int>(shader_backend)));
+ FindIndex(Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
+ static_cast<int>(shader_backend)));
} else if (is_vulkan && static_cast<int>(vulkan_device) < vulkan_device_combobox->count()) {
vulkan_device_combobox->setCurrentIndex(vulkan_device);
}
@@ -466,7 +469,7 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
return Settings::values.renderer_backend.GetValue(true);
}
return static_cast<Settings::RendererBackend>(
- combobox_translations.at(typeid(Settings::RendererBackend))
+ combobox_translations.at(Settings::EnumMetadata<Settings::RendererBackend>::Index())
.at(api_combobox->currentIndex())
.first);
}
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h
index 1848b1593..633a28414 100644
--- a/src/yuzu/configuration/configure_graphics.h
+++ b/src/yuzu/configuration/configure_graphics.h
@@ -75,7 +75,7 @@ private:
Settings::RendererBackend GetCurrentGraphicsBackend() const;
- int FindIndex(std::type_index enumeration, int value) const;
+ int FindIndex(u32 enumeration, int value) const;
std::unique_ptr<Ui::ConfigureGraphics> ui;
QColor bg_color;
diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp
index f120a632c..d51286b0e 100644
--- a/src/yuzu/configuration/shared_translation.cpp
+++ b/src/yuzu/configuration/shared_translation.cpp
@@ -182,19 +182,19 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
// Intentionally skipping VSyncMode to let the UI fill that one out
- translations->insert({typeid(Settings::AstcDecodeMode),
+ translations->insert({Settings::EnumMetadata<Settings::AstcDecodeMode>::Index(),
{
PAIR(AstcDecodeMode, Cpu, "CPU"),
PAIR(AstcDecodeMode, Gpu, "GPU"),
PAIR(AstcDecodeMode, CpuAsynchronous, "CPU Asynchronous"),
}});
- translations->insert({typeid(Settings::AstcRecompression),
+ translations->insert({Settings::EnumMetadata<Settings::AstcRecompression>::Index(),
{
PAIR(AstcRecompression, Uncompressed, "Uncompressed (Best quality)"),
PAIR(AstcRecompression, Bc1, "BC1 (Low quality)"),
PAIR(AstcRecompression, Bc3, "BC3 (Medium quality)"),
}});
- translations->insert({typeid(Settings::RendererBackend),
+ translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(),
{
#ifdef HAS_OPENGL
PAIR(RendererBackend, OpenGL, "OpenGL"),
@@ -202,37 +202,37 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(RendererBackend, Vulkan, "Vulkan"),
PAIR(RendererBackend, Null, "Null"),
}});
- translations->insert({typeid(Settings::ShaderBackend),
+ translations->insert({Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
{
PAIR(ShaderBackend, Glsl, "GLSL"),
PAIR(ShaderBackend, Glasm, "GLASM (Assembly Shaders, NVIDIA Only)"),
PAIR(ShaderBackend, SpirV, "SPIR-V (Experimental, Mesa Only)"),
}});
- translations->insert({typeid(Settings::GpuAccuracy),
+ translations->insert({Settings::EnumMetadata<Settings::GpuAccuracy>::Index(),
{
PAIR(GpuAccuracy, Normal, "Normal"),
PAIR(GpuAccuracy, High, "High"),
PAIR(GpuAccuracy, Extreme, "Extreme"),
}});
- translations->insert({typeid(Settings::CpuAccuracy),
+ translations->insert({Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
{
PAIR(CpuAccuracy, Auto, "Auto"),
PAIR(CpuAccuracy, Accurate, "Accurate"),
PAIR(CpuAccuracy, Unsafe, "Unsafe"),
PAIR(CpuAccuracy, Paranoid, "Paranoid (disables most optimizations)"),
}});
- translations->insert({typeid(Settings::FullscreenMode),
+ translations->insert({Settings::EnumMetadata<Settings::FullscreenMode>::Index(),
{
PAIR(FullscreenMode, Borderless, "Borderless Windowed"),
PAIR(FullscreenMode, Exclusive, "Exclusive Fullscreen"),
}});
- translations->insert({typeid(Settings::NvdecEmulation),
+ translations->insert({Settings::EnumMetadata<Settings::NvdecEmulation>::Index(),
{
PAIR(NvdecEmulation, Off, "No Video Output"),
PAIR(NvdecEmulation, Cpu, "CPU Video Decoding"),
PAIR(NvdecEmulation, Gpu, "GPU Video Decoding (Default)"),
}});
- translations->insert({typeid(Settings::ResolutionSetup),
+ translations->insert({Settings::EnumMetadata<Settings::ResolutionSetup>::Index(),
{
PAIR(ResolutionSetup, Res1_2X, "0.5X (360p/540p) [EXPERIMENTAL]"),
PAIR(ResolutionSetup, Res3_4X, "0.75X (540p/810p) [EXPERIMENTAL]"),
@@ -246,7 +246,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(ResolutionSetup, Res7X, "7X (5040p/7560p)"),
PAIR(ResolutionSetup, Res8X, "8X (5760p/8640p)"),
}});
- translations->insert({typeid(Settings::ScalingFilter),
+ translations->insert({Settings::EnumMetadata<Settings::ScalingFilter>::Index(),
{
PAIR(ScalingFilter, NearestNeighbor, "Nearest Neighbor"),
PAIR(ScalingFilter, Bilinear, "Bilinear"),
@@ -255,13 +255,13 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(ScalingFilter, ScaleForce, "ScaleForce"),
PAIR(ScalingFilter, Fsr, "AMD FidelityFX™️ Super Resolution"),
}});
- translations->insert({typeid(Settings::AntiAliasing),
+ translations->insert({Settings::EnumMetadata<Settings::AntiAliasing>::Index(),
{
PAIR(AntiAliasing, None, "None"),
PAIR(AntiAliasing, Fxaa, "FXAA"),
PAIR(AntiAliasing, Smaa, "SMAA"),
}});
- translations->insert({typeid(Settings::AspectRatio),
+ translations->insert({Settings::EnumMetadata<Settings::AspectRatio>::Index(),
{
PAIR(AspectRatio, R16_9, "Default (16:9)"),
PAIR(AspectRatio, R4_3, "Force 4:3"),
@@ -269,7 +269,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(AspectRatio, R16_10, "Force 16:10"),
PAIR(AspectRatio, Stretch, "Stretch to Window"),
}});
- translations->insert({typeid(Settings::AnisotropyMode),
+ translations->insert({Settings::EnumMetadata<Settings::AnisotropyMode>::Index(),
{
PAIR(AnisotropyMode, Automatic, "Automatic"),
PAIR(AnisotropyMode, Default, "Default"),
@@ -279,7 +279,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(AnisotropyMode, X16, "16x"),
}});
translations->insert(
- {typeid(Settings::Language),
+ {Settings::EnumMetadata<Settings::Language>::Index(),
{
PAIR(Language, Japanese, "Japanese (日本語)"),
PAIR(Language, EnglishAmerican, "American English"),
@@ -300,7 +300,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(Language, ChineseTraditional, "Traditional Chinese (正體中文)"),
PAIR(Language, PortugueseBrazilian, "Brazilian Portuguese (português do Brasil)"),
}});
- translations->insert({typeid(Settings::Region),
+ translations->insert({Settings::EnumMetadata<Settings::Region>::Index(),
{
PAIR(Region, Japan, "Japan"),
PAIR(Region, Usa, "USA"),
@@ -311,7 +311,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(Region, Taiwan, "Taiwan"),
}});
translations->insert(
- {typeid(Settings::TimeZone),
+ {Settings::EnumMetadata<Settings::TimeZone>::Index(),
{
{static_cast<u32>(Settings::TimeZone::Auto),
tr("Auto (%1)", "Auto select time zone")
@@ -361,7 +361,7 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
PAIR(TimeZone, Wet, "WET"),
PAIR(TimeZone, Zulu, "Zulu"),
}});
- translations->insert({typeid(Settings::AudioMode),
+ translations->insert({Settings::EnumMetadata<Settings::AudioMode>::Index(),
{
PAIR(AudioMode, Mono, "Mono"),
PAIR(AudioMode, Stereo, "Stereo"),
diff --git a/src/yuzu/configuration/shared_translation.h b/src/yuzu/configuration/shared_translation.h
index cc8419e03..99a0e808c 100644
--- a/src/yuzu/configuration/shared_translation.h
+++ b/src/yuzu/configuration/shared_translation.h
@@ -16,7 +16,7 @@ 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>;
+using ComboboxTranslationMap = std::map<u32, ComboboxTranslations>;
std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent);
diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp
index 978bfa590..ba7f60c2d 100644
--- a/src/yuzu/configuration/shared_widget.cpp
+++ b/src/yuzu/configuration/shared_widget.cpp
@@ -125,7 +125,7 @@ QWidget* Widget::CreateCheckBox(Settings::BasicSetting* bool_setting, const QStr
QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer,
std::function<void()>& restore_func,
const std::function<void()>& touch) {
- const auto type = setting.TypeId();
+ const auto type = setting.EnumIndex();
combobox = new QComboBox(this);
combobox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);