2019-08-10 04:08:18 +02:00
|
|
|
// Copyright 2019 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QColorDialog>
|
|
|
|
#include "citra_qt/configuration/configure_enhancements.h"
|
2022-12-08 12:27:25 +01:00
|
|
|
#include "common/settings.h"
|
2019-08-17 04:34:22 +02:00
|
|
|
#include "core/core.h"
|
2019-08-10 04:08:02 +02:00
|
|
|
#include "ui_configure_enhancements.h"
|
2019-08-10 04:08:18 +02:00
|
|
|
#include "video_core/renderer_opengl/post_processing_opengl.h"
|
2020-04-03 05:42:50 +02:00
|
|
|
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
2019-08-10 04:08:02 +02:00
|
|
|
|
2019-08-10 04:08:18 +02:00
|
|
|
ConfigureEnhancements::ConfigureEnhancements(QWidget* parent)
|
2020-10-01 03:23:01 +02:00
|
|
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureEnhancements>()) {
|
2019-08-10 04:08:02 +02:00
|
|
|
ui->setupUi(this);
|
2020-03-16 15:42:05 +01:00
|
|
|
|
2020-04-03 05:42:50 +02:00
|
|
|
for (const auto& filter : OpenGL::TextureFilterer::GetFilterNames())
|
|
|
|
ui->texture_filter_combobox->addItem(QString::fromStdString(filter.data()));
|
2020-03-16 15:42:05 +01:00
|
|
|
|
2019-08-10 04:08:18 +02:00
|
|
|
SetConfiguration();
|
|
|
|
|
|
|
|
ui->layoutBox->setEnabled(!Settings::values.custom_layout);
|
|
|
|
|
2022-12-08 12:27:25 +01:00
|
|
|
ui->resolution_factor_combobox->setEnabled(Settings::values.use_hw_renderer.GetValue());
|
2019-08-10 04:08:18 +02:00
|
|
|
|
|
|
|
connect(ui->render_3d_combobox,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
|
|
[this](int currentIndex) {
|
2019-12-06 08:43:06 +01:00
|
|
|
updateShaders(static_cast<Settings::StereoRenderOption>(currentIndex));
|
2019-08-10 04:08:18 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->bg_button, &QPushButton::clicked, this, [this] {
|
|
|
|
const QColor new_bg_color = QColorDialog::getColor(bg_color);
|
|
|
|
if (!new_bg_color.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bg_color = new_bg_color;
|
|
|
|
QPixmap pixmap(ui->bg_button->size());
|
|
|
|
pixmap.fill(bg_color);
|
|
|
|
const QIcon color_icon(pixmap);
|
|
|
|
ui->bg_button->setIcon(color_icon);
|
|
|
|
});
|
|
|
|
|
|
|
|
ui->toggle_preload_textures->setEnabled(ui->toggle_custom_textures->isChecked());
|
|
|
|
connect(ui->toggle_custom_textures, &QCheckBox::toggled, this, [this] {
|
|
|
|
ui->toggle_preload_textures->setEnabled(ui->toggle_custom_textures->isChecked());
|
|
|
|
if (!ui->toggle_preload_textures->isEnabled())
|
|
|
|
ui->toggle_preload_textures->setChecked(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureEnhancements::SetConfiguration() {
|
2022-12-08 12:27:25 +01:00
|
|
|
ui->resolution_factor_combobox->setCurrentIndex(Settings::values.resolution_factor.GetValue());
|
|
|
|
ui->render_3d_combobox->setCurrentIndex(
|
|
|
|
static_cast<int>(Settings::values.render_3d.GetValue()));
|
|
|
|
ui->factor_3d->setValue(Settings::values.factor_3d.GetValue());
|
2022-12-24 03:17:49 +01:00
|
|
|
ui->mono_rendering_eye->setCurrentIndex(
|
|
|
|
static_cast<int>(Settings::values.mono_render_option.GetValue()));
|
2022-12-08 12:27:25 +01:00
|
|
|
updateShaders(Settings::values.render_3d.GetValue());
|
|
|
|
ui->toggle_linear_filter->setChecked(Settings::values.filter_mode.GetValue());
|
2020-03-16 15:42:05 +01:00
|
|
|
int tex_filter_idx = ui->texture_filter_combobox->findText(
|
2022-12-08 12:27:25 +01:00
|
|
|
QString::fromStdString(Settings::values.texture_filter_name.GetValue()));
|
2020-03-16 15:42:05 +01:00
|
|
|
if (tex_filter_idx == -1) {
|
|
|
|
ui->texture_filter_combobox->setCurrentIndex(0);
|
|
|
|
} else {
|
|
|
|
ui->texture_filter_combobox->setCurrentIndex(tex_filter_idx);
|
|
|
|
}
|
2022-12-08 12:27:25 +01:00
|
|
|
ui->layout_combobox->setCurrentIndex(
|
|
|
|
static_cast<int>(Settings::values.layout_option.GetValue()));
|
|
|
|
ui->swap_screen->setChecked(Settings::values.swap_screen.GetValue());
|
|
|
|
ui->upright_screen->setChecked(Settings::values.upright_screen.GetValue());
|
|
|
|
ui->toggle_dump_textures->setChecked(Settings::values.dump_textures.GetValue());
|
|
|
|
ui->toggle_custom_textures->setChecked(Settings::values.custom_textures.GetValue());
|
|
|
|
ui->toggle_preload_textures->setChecked(Settings::values.preload_textures.GetValue());
|
|
|
|
bg_color =
|
|
|
|
QColor::fromRgbF(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
|
|
|
|
Settings::values.bg_blue.GetValue());
|
2019-08-10 04:08:18 +02:00
|
|
|
QPixmap pixmap(ui->bg_button->size());
|
|
|
|
pixmap.fill(bg_color);
|
|
|
|
const QIcon color_icon(pixmap);
|
|
|
|
ui->bg_button->setIcon(color_icon);
|
|
|
|
}
|
|
|
|
|
2019-12-06 08:43:06 +01:00
|
|
|
void ConfigureEnhancements::updateShaders(Settings::StereoRenderOption stereo_option) {
|
2019-08-10 04:08:18 +02:00
|
|
|
ui->shader_combobox->clear();
|
|
|
|
|
2019-12-06 08:43:06 +01:00
|
|
|
if (stereo_option == Settings::StereoRenderOption::Anaglyph)
|
2020-02-11 13:12:09 +01:00
|
|
|
ui->shader_combobox->addItem(QStringLiteral("dubois (builtin)"));
|
2020-10-16 18:41:08 +02:00
|
|
|
else if (stereo_option == Settings::StereoRenderOption::Interlaced ||
|
|
|
|
stereo_option == Settings::StereoRenderOption::ReverseInterlaced)
|
2020-02-11 13:12:09 +01:00
|
|
|
ui->shader_combobox->addItem(QStringLiteral("horizontal (builtin)"));
|
2019-08-10 04:08:18 +02:00
|
|
|
else
|
2020-02-11 13:12:09 +01:00
|
|
|
ui->shader_combobox->addItem(QStringLiteral("none (builtin)"));
|
2019-08-10 04:08:18 +02:00
|
|
|
|
|
|
|
ui->shader_combobox->setCurrentIndex(0);
|
|
|
|
|
2019-12-06 08:43:06 +01:00
|
|
|
for (const auto& shader : OpenGL::GetPostProcessingShaderList(
|
|
|
|
stereo_option == Settings::StereoRenderOption::Anaglyph)) {
|
2019-08-10 04:08:18 +02:00
|
|
|
ui->shader_combobox->addItem(QString::fromStdString(shader));
|
2022-12-08 12:27:25 +01:00
|
|
|
if (Settings::values.pp_shader_name.GetValue() == shader)
|
2019-08-10 04:08:18 +02:00
|
|
|
ui->shader_combobox->setCurrentIndex(ui->shader_combobox->count() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureEnhancements::RetranslateUI() {
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureEnhancements::ApplyConfiguration() {
|
|
|
|
Settings::values.resolution_factor =
|
|
|
|
static_cast<u16>(ui->resolution_factor_combobox->currentIndex());
|
|
|
|
Settings::values.render_3d =
|
|
|
|
static_cast<Settings::StereoRenderOption>(ui->render_3d_combobox->currentIndex());
|
|
|
|
Settings::values.factor_3d = ui->factor_3d->value();
|
2022-12-24 03:17:49 +01:00
|
|
|
Settings::values.mono_render_option =
|
|
|
|
static_cast<Settings::MonoRenderOption>(ui->mono_rendering_eye->currentIndex());
|
2019-08-10 04:08:18 +02:00
|
|
|
Settings::values.pp_shader_name =
|
|
|
|
ui->shader_combobox->itemText(ui->shader_combobox->currentIndex()).toStdString();
|
|
|
|
Settings::values.filter_mode = ui->toggle_linear_filter->isChecked();
|
2020-03-16 15:42:05 +01:00
|
|
|
Settings::values.texture_filter_name = ui->texture_filter_combobox->currentText().toStdString();
|
2019-08-10 04:08:18 +02:00
|
|
|
Settings::values.layout_option =
|
|
|
|
static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());
|
|
|
|
Settings::values.swap_screen = ui->swap_screen->isChecked();
|
2019-10-26 01:21:10 +02:00
|
|
|
Settings::values.upright_screen = ui->upright_screen->isChecked();
|
2019-08-10 04:08:18 +02:00
|
|
|
Settings::values.dump_textures = ui->toggle_dump_textures->isChecked();
|
|
|
|
Settings::values.custom_textures = ui->toggle_custom_textures->isChecked();
|
|
|
|
Settings::values.preload_textures = ui->toggle_preload_textures->isChecked();
|
|
|
|
Settings::values.bg_red = static_cast<float>(bg_color.redF());
|
|
|
|
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
|
|
|
|
Settings::values.bg_blue = static_cast<float>(bg_color.blueF());
|
2019-08-10 04:08:02 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 03:23:01 +02:00
|
|
|
ConfigureEnhancements::~ConfigureEnhancements() {}
|