From d88fc204349494bbc6d2d6e8f9e5d7c2e6d1f843 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 3 Jan 2020 17:51:58 +1000 Subject: [PATCH] Qt: GPU settings tab --- src/duckstation-qt/duckstation-qt.vcxproj | 8 ++ .../duckstation-qt.vcxproj.filters | 7 +- src/duckstation-qt/gpusettingswidget.cpp | 35 +++++ src/duckstation-qt/gpusettingswidget.h | 23 ++++ src/duckstation-qt/gpusettingswidget.ui | 126 ++++++++++++++++++ src/duckstation-qt/mainwindow.cpp | 1 - src/duckstation-qt/mainwindow.ui | 1 - src/duckstation-qt/settingsdialog.cpp | 9 +- src/duckstation-qt/settingsdialog.h | 1 - src/duckstation-qt/settingsdialog.ui | 9 -- src/duckstation-qt/settingwidgetbinder.h | 15 +++ 11 files changed, 217 insertions(+), 18 deletions(-) create mode 100644 src/duckstation-qt/gpusettingswidget.cpp create mode 100644 src/duckstation-qt/gpusettingswidget.h create mode 100644 src/duckstation-qt/gpusettingswidget.ui diff --git a/src/duckstation-qt/duckstation-qt.vcxproj b/src/duckstation-qt/duckstation-qt.vcxproj index a76a235b6..9672b9354 100644 --- a/src/duckstation-qt/duckstation-qt.vcxproj +++ b/src/duckstation-qt/duckstation-qt.vcxproj @@ -36,6 +36,7 @@ + @@ -51,6 +52,7 @@ + @@ -102,6 +104,7 @@ + @@ -113,6 +116,11 @@ + + + Document + + {28F14272-0EC4-41BB-849F-182ADB81AF70} Win32Proj diff --git a/src/duckstation-qt/duckstation-qt.vcxproj.filters b/src/duckstation-qt/duckstation-qt.vcxproj.filters index 23c854f39..8fc04a2da 100644 --- a/src/duckstation-qt/duckstation-qt.vcxproj.filters +++ b/src/duckstation-qt/duckstation-qt.vcxproj.filters @@ -22,12 +22,14 @@ + + + - @@ -46,12 +48,15 @@ + + + diff --git a/src/duckstation-qt/gpusettingswidget.cpp b/src/duckstation-qt/gpusettingswidget.cpp new file mode 100644 index 000000000..c2bf7512f --- /dev/null +++ b/src/duckstation-qt/gpusettingswidget.cpp @@ -0,0 +1,35 @@ +#include "gpusettingswidget.h" +#include "core/gpu.h" +#include "core/settings.h" +#include "settingwidgetbinder.h" + +GPUSettingsWidget::GPUSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */) + : QWidget(parent), m_host_interface(host_interface) +{ + m_ui.setupUi(this); + setupAdditionalUi(); + + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.renderer, &Settings::gpu_renderer); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.fullscreen, &Settings::display_fullscreen); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.displayLinearFiltering, + &Settings::display_linear_filtering); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.vsync, &Settings::video_sync_enabled); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.resolutionScale, &Settings::gpu_resolution_scale); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.trueColor, &Settings::gpu_true_color); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.linearTextureFiltering, + &Settings::gpu_texture_filtering); + SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.forceProgressiveScan, + &Settings::gpu_force_progressive_scan); +} + +GPUSettingsWidget::~GPUSettingsWidget() = default; + +void GPUSettingsWidget::setupAdditionalUi() +{ + for (u32 i = 0; i < static_cast(GPURenderer::Count); i++) + m_ui.renderer->addItem(QString::fromLocal8Bit(Settings::GetRendererDisplayName(static_cast(i)))); + + m_ui.resolutionScale->addItem(tr("Automatic based on window size")); + for (u32 i = 1; i <= 16; i++) + m_ui.resolutionScale->addItem(tr("%1x (%2x%3)").arg(i).arg(GPU::VRAM_WIDTH * i).arg(GPU::VRAM_HEIGHT * i)); +} diff --git a/src/duckstation-qt/gpusettingswidget.h b/src/duckstation-qt/gpusettingswidget.h new file mode 100644 index 000000000..5847de7fc --- /dev/null +++ b/src/duckstation-qt/gpusettingswidget.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +#include "ui_gpusettingswidget.h" + +class QtHostInterface; + +class GPUSettingsWidget : public QWidget +{ + Q_OBJECT + +public: + GPUSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr); + ~GPUSettingsWidget(); + +private: + void setupAdditionalUi(); + + Ui::GPUSettingsWidget m_ui; + + QtHostInterface* m_host_interface; +}; diff --git a/src/duckstation-qt/gpusettingswidget.ui b/src/duckstation-qt/gpusettingswidget.ui new file mode 100644 index 000000000..09099e829 --- /dev/null +++ b/src/duckstation-qt/gpusettingswidget.ui @@ -0,0 +1,126 @@ + + + GPUSettingsWidget + + + + 0 + 0 + 1350 + 788 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Basic + + + + + + Renderer: + + + + + + + + + + Fullscreen + + + + + + + Linear Upscaling + + + + + + + VSync + + + + + + + + + + Enhancements + + + + + + Resolution Scale: + + + + + + + + + + True Color Rendering (24-bit, disables dithering) + + + + + + + Bilinear Texture Filtering + + + + + + + Force Progressive Scan + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index bca619558..2d8d4a249 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -161,7 +161,6 @@ void MainWindow::connectSignals() [this]() { doSettings(SettingsDialog::Category::GameListSettings); }); connect(m_ui.actionPortSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::PortSettings); }); - connect(m_ui.actionCPUSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::CPUSettings); }); connect(m_ui.actionGPUSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::GPUSettings); }); connect(m_ui.actionAudioSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::AudioSettings); }); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index 70c5b5438..8d5510876 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -75,7 +75,6 @@ - diff --git a/src/duckstation-qt/settingsdialog.cpp b/src/duckstation-qt/settingsdialog.cpp index 4d574e6a3..99e8ca69a 100644 --- a/src/duckstation-qt/settingsdialog.cpp +++ b/src/duckstation-qt/settingsdialog.cpp @@ -1,6 +1,7 @@ #include "settingsdialog.h" #include "consolesettingswidget.h" #include "gamelistsettingswidget.h" +#include "gpusettingswidget.h" #include "portsettingswidget.h" #include "qthostinterface.h" #include @@ -13,16 +14,14 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer); m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer); m_port_settings = new PortSettingsWidget(host_interface, m_ui.settingsContainer); - m_cpu_settings = new QWidget(m_ui.settingsContainer); - m_gpu_settings = new QWidget(m_ui.settingsContainer); + m_gpu_settings = new GPUSettingsWidget(host_interface, m_ui.settingsContainer); m_audio_settings = new QWidget(m_ui.settingsContainer); m_ui.settingsContainer->insertWidget(0, m_console_settings); m_ui.settingsContainer->insertWidget(1, m_game_list_settings); m_ui.settingsContainer->insertWidget(2, m_port_settings); - m_ui.settingsContainer->insertWidget(3, m_cpu_settings); - m_ui.settingsContainer->insertWidget(4, m_gpu_settings); - m_ui.settingsContainer->insertWidget(5, m_audio_settings); + m_ui.settingsContainer->insertWidget(3, m_gpu_settings); + m_ui.settingsContainer->insertWidget(4, m_audio_settings); m_ui.settingsCategory->setCurrentRow(0); m_ui.settingsContainer->setCurrentIndex(0); diff --git a/src/duckstation-qt/settingsdialog.h b/src/duckstation-qt/settingsdialog.h index 80b7ffcb9..77f0066d2 100644 --- a/src/duckstation-qt/settingsdialog.h +++ b/src/duckstation-qt/settingsdialog.h @@ -17,7 +17,6 @@ public: ConsoleSettings, GameListSettings, PortSettings, - CPUSettings, GPUSettings, AudioSettings, Count diff --git a/src/duckstation-qt/settingsdialog.ui b/src/duckstation-qt/settingsdialog.ui index fe1c8af51..9602a22d3 100644 --- a/src/duckstation-qt/settingsdialog.ui +++ b/src/duckstation-qt/settingsdialog.ui @@ -67,15 +67,6 @@ :/icons/input-gaming.png:/icons/input-gaming.png - - - CPU Settings - - - - :/icons/applications-other.png:/icons/applications-other.png - - GPU Settings diff --git a/src/duckstation-qt/settingwidgetbinder.h b/src/duckstation-qt/settingwidgetbinder.h index 574e18801..b4ce89086 100644 --- a/src/duckstation-qt/settingwidgetbinder.h +++ b/src/duckstation-qt/settingwidgetbinder.h @@ -136,4 +136,19 @@ void BindWidgetToSetting(QtHostInterface* hi, WidgetType* widget, DataType Setti }); } +template +void BindWidgetToSetting(QtHostInterface* hi, WidgetType* widget, DataType Settings::*settings_ptr, + std::enable_if_t, int>* v = nullptr) +{ + using Accessor = SettingAccessor; + + Accessor::setIntValue(widget, static_cast(hi->GetCoreSettings().*settings_ptr)); + + Accessor::connectValueChanged(widget, [hi, widget, settings_ptr](int) { + const int value = Accessor::getIntValue(widget); + (hi->GetCoreSettings().*settings_ptr) = static_cast(value); + hi->updateQSettings(); + }); +} + } // namespace SettingWidgetBinder \ No newline at end of file