mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-19 19:09:58 +00:00
configuration: Use enum index
This commit is contained in:
parent
e7f01128f1
commit
ca8509d205
6 changed files with 31 additions and 26 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue