mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-12 05:40:04 +00:00
citra-qt: fixes to per game settings (#6298)
* citra-qt config: small misc changes Remove unused ReadSettingGlobal Remove unused WriteSetting overload ReadGlobalSetting: rename default value variable * qt config: fix u16 values being written as QMetaType * qt config: rework post processing shader setting handles post processing setting properly when per-game settings are used. the anaglyph shader is given its own setting, separate from the post processing name. * qt config: use u32 instead of unsigned int when casting
This commit is contained in:
parent
49acfe428a
commit
6fbc54b0c5
9 changed files with 74 additions and 85 deletions
|
@ -149,14 +149,14 @@ void Config::ReadGlobalSetting(Settings::SwitchableSetting<Type, ranged>& settin
|
|||
const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool();
|
||||
setting.SetGlobal(use_global);
|
||||
if (global || !use_global) {
|
||||
QVariant value{};
|
||||
QVariant default_value{};
|
||||
if constexpr (std::is_enum_v<Type>) {
|
||||
using TypeU = std::underlying_type_t<Type>;
|
||||
value = QVariant::fromValue<TypeU>(static_cast<TypeU>(setting.GetDefault()));
|
||||
setting.SetValue(static_cast<Type>(ReadSetting(name, value).value<TypeU>()));
|
||||
default_value = QVariant::fromValue<TypeU>(static_cast<TypeU>(setting.GetDefault()));
|
||||
setting.SetValue(static_cast<Type>(ReadSetting(name, default_value).value<TypeU>()));
|
||||
} else {
|
||||
value = QVariant::fromValue<Type>(setting.GetDefault());
|
||||
setting.SetValue(ReadSetting(name, value).value<Type>());
|
||||
default_value = QVariant::fromValue<Type>(setting.GetDefault());
|
||||
setting.SetValue(ReadSetting(name, default_value).value<Type>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +182,15 @@ void Config::WriteBasicSetting(const Settings::Setting<std::string>& setting) {
|
|||
qt_config->setValue(name, QString::fromStdString(value));
|
||||
}
|
||||
|
||||
// Explicit u16 definition: Qt would store it as QMetaType otherwise, which is not human-readable
|
||||
template <>
|
||||
void Config::WriteBasicSetting(const Settings::Setting<u16>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const u16& value = setting.GetValue();
|
||||
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||
qt_config->setValue(name, static_cast<u32>(value));
|
||||
}
|
||||
|
||||
template <typename Type, bool ranged>
|
||||
void Config::WriteBasicSetting(const Settings::Setting<Type, ranged>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
|
@ -224,6 +233,20 @@ void Config::WriteGlobalSetting(const Settings::SwitchableSetting<std::string>&
|
|||
}
|
||||
}
|
||||
|
||||
// Explicit u16 definition: Qt would store it as QMetaType otherwise, which is not human-readable
|
||||
template <>
|
||||
void Config::WriteGlobalSetting(const Settings::SwitchableSetting<u16, true>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const u16& value = setting.GetValue(global);
|
||||
if (!global) {
|
||||
qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal());
|
||||
}
|
||||
if (global || !setting.UsingGlobal()) {
|
||||
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||
qt_config->setValue(name, static_cast<u32>(value));
|
||||
}
|
||||
}
|
||||
|
||||
void Config::ReadValues() {
|
||||
if (global) {
|
||||
ReadControlValues();
|
||||
|
@ -474,13 +497,8 @@ void Config::ReadLayoutValues() {
|
|||
|
||||
ReadGlobalSetting(Settings::values.render_3d);
|
||||
ReadGlobalSetting(Settings::values.factor_3d);
|
||||
Settings::values.pp_shader_name =
|
||||
ReadSetting(QStringLiteral("pp_shader_name"), (Settings::values.render_3d.GetValue() ==
|
||||
Settings::StereoRenderOption::Anaglyph)
|
||||
? QStringLiteral("dubois (builtin)")
|
||||
: QStringLiteral("none (builtin)"))
|
||||
.toString()
|
||||
.toStdString();
|
||||
ReadGlobalSetting(Settings::values.pp_shader_name);
|
||||
ReadGlobalSetting(Settings::values.anaglyph_shader_name);
|
||||
ReadGlobalSetting(Settings::values.filter_mode);
|
||||
ReadGlobalSetting(Settings::values.layout_option);
|
||||
ReadGlobalSetting(Settings::values.swap_screen);
|
||||
|
@ -989,11 +1007,8 @@ void Config::SaveLayoutValues() {
|
|||
|
||||
WriteGlobalSetting(Settings::values.render_3d);
|
||||
WriteGlobalSetting(Settings::values.factor_3d);
|
||||
WriteSetting(QStringLiteral("pp_shader_name"),
|
||||
QString::fromStdString(Settings::values.pp_shader_name.GetValue()),
|
||||
(Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Anaglyph)
|
||||
? QStringLiteral("dubois (builtin)")
|
||||
: QStringLiteral("none (builtin)"));
|
||||
WriteGlobalSetting(Settings::values.pp_shader_name);
|
||||
WriteGlobalSetting(Settings::values.anaglyph_shader_name);
|
||||
WriteGlobalSetting(Settings::values.filter_mode);
|
||||
WriteGlobalSetting(Settings::values.layout_option);
|
||||
WriteGlobalSetting(Settings::values.swap_screen);
|
||||
|
@ -1276,15 +1291,6 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value)
|
|||
return result;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void Config::ReadSettingGlobal(Type& setting, const QString& name,
|
||||
const QVariant& default_value) const {
|
||||
const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool();
|
||||
if (global || !use_global) {
|
||||
setting = ReadSetting(name, default_value).value<Type>();
|
||||
}
|
||||
}
|
||||
|
||||
void Config::WriteSetting(const QString& name, const QVariant& value) {
|
||||
qt_config->setValue(name, value);
|
||||
}
|
||||
|
@ -1295,17 +1301,6 @@ void Config::WriteSetting(const QString& name, const QVariant& value,
|
|||
qt_config->setValue(name, value);
|
||||
}
|
||||
|
||||
void Config::WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value,
|
||||
bool use_global) {
|
||||
if (!global) {
|
||||
qt_config->setValue(name + QStringLiteral("/use_global"), use_global);
|
||||
}
|
||||
if (global || !use_global) {
|
||||
qt_config->setValue(name + QStringLiteral("/default"), value == default_value);
|
||||
qt_config->setValue(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
void Config::Reload() {
|
||||
ReadValues();
|
||||
// To apply default value changes
|
||||
|
|
|
@ -84,31 +84,15 @@ private:
|
|||
QVariant ReadSetting(const QString& name) const;
|
||||
QVariant ReadSetting(const QString& name, const QVariant& default_value) const;
|
||||
|
||||
/**
|
||||
* Only reads a setting from the qt_config if the current config is a global config, or if the
|
||||
* current config is a custom config and the setting is overriding the global setting. Otherwise
|
||||
* it does nothing.
|
||||
*
|
||||
* @param setting The variable to be modified
|
||||
* @param name The setting's identifier
|
||||
* @param default_value The value to use when the setting is not already present in the config
|
||||
*/
|
||||
template <typename Type>
|
||||
void ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const;
|
||||
|
||||
/**
|
||||
* Writes a setting to the qt_config.
|
||||
*
|
||||
* @param name The setting's idetentifier
|
||||
* @param value Value of the setting
|
||||
* @param default_value Default of the setting if not present in qt_config
|
||||
* @param use_global Specifies if the custom or global config should be in use, for custom
|
||||
* configs
|
||||
*/
|
||||
void WriteSetting(const QString& name, const QVariant& value);
|
||||
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
|
||||
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value,
|
||||
bool use_global);
|
||||
|
||||
/**
|
||||
* Reads a value from the qt_config and applies it to the setting, using its label and default
|
||||
|
|
|
@ -84,21 +84,31 @@ void ConfigureEnhancements::SetConfiguration() {
|
|||
|
||||
void ConfigureEnhancements::updateShaders(Settings::StereoRenderOption stereo_option) {
|
||||
ui->shader_combobox->clear();
|
||||
ui->shader_combobox->setEnabled(true);
|
||||
|
||||
if (stereo_option == Settings::StereoRenderOption::Anaglyph)
|
||||
ui->shader_combobox->addItem(QStringLiteral("dubois (builtin)"));
|
||||
else if (stereo_option == Settings::StereoRenderOption::Interlaced ||
|
||||
stereo_option == Settings::StereoRenderOption::ReverseInterlaced)
|
||||
if (stereo_option == Settings::StereoRenderOption::Interlaced ||
|
||||
stereo_option == Settings::StereoRenderOption::ReverseInterlaced) {
|
||||
ui->shader_combobox->addItem(QStringLiteral("horizontal (builtin)"));
|
||||
else
|
||||
ui->shader_combobox->setCurrentIndex(0);
|
||||
ui->shader_combobox->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string current_shader;
|
||||
if (stereo_option == Settings::StereoRenderOption::Anaglyph) {
|
||||
ui->shader_combobox->addItem(QStringLiteral("dubois (builtin)"));
|
||||
current_shader = Settings::values.anaglyph_shader_name.GetValue();
|
||||
} else {
|
||||
ui->shader_combobox->addItem(QStringLiteral("none (builtin)"));
|
||||
current_shader = Settings::values.pp_shader_name.GetValue();
|
||||
}
|
||||
|
||||
ui->shader_combobox->setCurrentIndex(0);
|
||||
|
||||
for (const auto& shader : OpenGL::GetPostProcessingShaderList(
|
||||
stereo_option == Settings::StereoRenderOption::Anaglyph)) {
|
||||
ui->shader_combobox->addItem(QString::fromStdString(shader));
|
||||
if (Settings::values.pp_shader_name.GetValue() == shader)
|
||||
if (current_shader == shader)
|
||||
ui->shader_combobox->setCurrentIndex(ui->shader_combobox->count() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -115,8 +125,13 @@ void ConfigureEnhancements::ApplyConfiguration() {
|
|||
Settings::values.factor_3d = ui->factor_3d->value();
|
||||
Settings::values.mono_render_option =
|
||||
static_cast<Settings::MonoRenderOption>(ui->mono_rendering_eye->currentIndex());
|
||||
Settings::values.pp_shader_name =
|
||||
ui->shader_combobox->itemText(ui->shader_combobox->currentIndex()).toStdString();
|
||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Anaglyph) {
|
||||
Settings::values.anaglyph_shader_name =
|
||||
ui->shader_combobox->itemText(ui->shader_combobox->currentIndex()).toStdString();
|
||||
} else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Off) {
|
||||
Settings::values.pp_shader_name =
|
||||
ui->shader_combobox->itemText(ui->shader_combobox->currentIndex()).toStdString();
|
||||
}
|
||||
Settings::values.filter_mode = ui->toggle_linear_filter->isChecked();
|
||||
Settings::values.texture_filter_name = ui->texture_filter_combobox->currentText().toStdString();
|
||||
Settings::values.layout_option =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue