mirror of
https://github.com/PabloMK7/citra.git
synced 2024-12-29 11:06:12 +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
|
@ -168,9 +168,12 @@ factor_3d =
|
|||
|
||||
# The name of the post processing shader to apply.
|
||||
# Loaded from shaders if render_3d is off or side by side.
|
||||
# Loaded from shaders/anaglyph if render_3d is anaglyph
|
||||
pp_shader_name =
|
||||
|
||||
# The name of the shader to apply when render_3d is anaglyph.
|
||||
# Loaded from shaders/anaglyph
|
||||
anaglyph_shader_name =
|
||||
|
||||
# Whether to enable linear filtering or not
|
||||
# This is required for some shaders to work correctly
|
||||
# 0: Nearest, 1 (default): Linear
|
||||
|
|
|
@ -139,15 +139,10 @@ void Config::ReadValues() {
|
|||
sdl2_config->GetInteger("Renderer", "render_3d", 0));
|
||||
Settings::values.factor_3d =
|
||||
static_cast<u8>(sdl2_config->GetInteger("Renderer", "factor_3d", 0));
|
||||
std::string default_shader = "none (builtin)";
|
||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Anaglyph)
|
||||
default_shader = "dubois (builtin)";
|
||||
else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Interlaced ||
|
||||
Settings::values.render_3d.GetValue() ==
|
||||
Settings::StereoRenderOption::ReverseInterlaced)
|
||||
default_shader = "horizontal (builtin)";
|
||||
Settings::values.pp_shader_name =
|
||||
sdl2_config->GetString("Renderer", "pp_shader_name", default_shader);
|
||||
sdl2_config->GetString("Renderer", "pp_shader_name", "none (builtin)");
|
||||
Settings::values.anaglyph_shader_name =
|
||||
sdl2_config->GetString("Renderer", "anaglyph_shader_name", "dubois (builtin)");
|
||||
Settings::values.filter_mode = sdl2_config->GetBoolean("Renderer", "filter_mode", true);
|
||||
|
||||
Settings::values.bg_red = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0));
|
||||
|
|
|
@ -172,9 +172,12 @@ mono_render_option =
|
|||
|
||||
# The name of the post processing shader to apply.
|
||||
# Loaded from shaders if render_3d is off or side by side.
|
||||
# Loaded from shaders/anaglyph if render_3d is anaglyph
|
||||
pp_shader_name =
|
||||
|
||||
# The name of the shader to apply when render_3d is anaglyph.
|
||||
# Loaded from shaders/anaglyph
|
||||
anaglyph_shader_name =
|
||||
|
||||
# Whether to enable linear filtering or not
|
||||
# This is required for some shaders to work correctly
|
||||
# 0: Nearest, 1 (default): Linear
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -115,6 +115,9 @@ void LogSettings() {
|
|||
log_setting("Stereoscopy_Render3d", values.render_3d.GetValue());
|
||||
log_setting("Stereoscopy_Factor3d", values.factor_3d.GetValue());
|
||||
log_setting("Stereoscopy_MonoRenderOption", values.mono_render_option.GetValue());
|
||||
if (values.render_3d.GetValue() == StereoRenderOption::Anaglyph) {
|
||||
log_setting("Renderer_AnaglyphShader", values.anaglyph_shader_name.GetValue());
|
||||
}
|
||||
log_setting("Layout_LayoutOption", values.layout_option.GetValue());
|
||||
log_setting("Layout_SwapScreen", values.swap_screen.GetValue());
|
||||
log_setting("Layout_UprightScreen", values.upright_screen.GetValue());
|
||||
|
@ -203,6 +206,7 @@ void RestoreGlobalState(bool is_powered_on) {
|
|||
values.factor_3d.SetGlobal(true);
|
||||
values.filter_mode.SetGlobal(true);
|
||||
values.pp_shader_name.SetGlobal(true);
|
||||
values.anaglyph_shader_name.SetGlobal(true);
|
||||
}
|
||||
|
||||
void LoadProfile(int index) {
|
||||
|
|
|
@ -483,6 +483,7 @@ struct Values {
|
|||
|
||||
SwitchableSetting<bool> filter_mode{true, "filter_mode"};
|
||||
SwitchableSetting<std::string> pp_shader_name{"none (builtin)", "pp_shader_name"};
|
||||
SwitchableSetting<std::string> anaglyph_shader_name{"dubois (builtin)", "anaglyph_shader_name"};
|
||||
|
||||
Setting<bool> dump_textures{false, "dump_textures"};
|
||||
Setting<bool> custom_textures{false, "custom_textures"};
|
||||
|
|
|
@ -687,11 +687,11 @@ void RendererOpenGL::ReloadShader() {
|
|||
}
|
||||
|
||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Anaglyph) {
|
||||
if (Settings::values.pp_shader_name.GetValue() == "dubois (builtin)") {
|
||||
if (Settings::values.anaglyph_shader_name.GetValue() == "dubois (builtin)") {
|
||||
shader_data += fragment_shader_anaglyph;
|
||||
} else {
|
||||
std::string shader_text = OpenGL::GetPostProcessingShaderCode(
|
||||
true, Settings::values.pp_shader_name.GetValue());
|
||||
true, Settings::values.anaglyph_shader_name.GetValue());
|
||||
if (shader_text.empty()) {
|
||||
// Should probably provide some information that the shader couldn't load
|
||||
shader_data += fragment_shader_anaglyph;
|
||||
|
@ -702,18 +702,7 @@ void RendererOpenGL::ReloadShader() {
|
|||
} else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Interlaced ||
|
||||
Settings::values.render_3d.GetValue() ==
|
||||
Settings::StereoRenderOption::ReverseInterlaced) {
|
||||
if (Settings::values.pp_shader_name.GetValue() == "horizontal (builtin)") {
|
||||
shader_data += fragment_shader_interlaced;
|
||||
} else {
|
||||
std::string shader_text = OpenGL::GetPostProcessingShaderCode(
|
||||
false, Settings::values.pp_shader_name.GetValue());
|
||||
if (shader_text.empty()) {
|
||||
// Should probably provide some information that the shader couldn't load
|
||||
shader_data += fragment_shader_interlaced;
|
||||
} else {
|
||||
shader_data += shader_text;
|
||||
}
|
||||
}
|
||||
shader_data += fragment_shader_interlaced;
|
||||
} else {
|
||||
if (Settings::values.pp_shader_name.GetValue() == "none (builtin)") {
|
||||
shader_data += fragment_shader;
|
||||
|
|
Loading…
Reference in a new issue