diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 8d33993fc1..0e08a4ed98 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -131,6 +131,8 @@ add_executable(dolphin-emu Config/Graphics/SoftwareRendererWidget.h Config/GraphicsModListWidget.cpp Config/GraphicsModListWidget.h + Config/GraphicsModWarningWidget.cpp + Config/GraphicsModWarningWidget.h Config/InfoWidget.cpp Config/InfoWidget.h Config/LogConfigWidget.cpp diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index b9f81b4746..7a2570f97c 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -20,6 +20,7 @@ #include "DolphinQt/Config/Graphics/GraphicsInteger.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" #include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" +#include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/Settings.h" #include "VideoCommon/VideoConfig.h" @@ -72,7 +73,7 @@ void AdvancedWidget::CreateWidgets() m_dump_xfb_target = new GraphicsBool(tr("Dump XFB Target"), Config::GFX_DUMP_XFB_TARGET); m_disable_vram_copies = new GraphicsBool(tr("Disable EFB VRAM Copies"), Config::GFX_HACK_DISABLE_COPY_TO_VRAM); - m_enable_graphics_mods = new GraphicsBool(tr("Enable Graphics Mods"), Config::GFX_MODS_ENABLE); + m_enable_graphics_mods = new ToolTipCheckBox(tr("Enable Graphics Mods")); utility_layout->addWidget(m_load_custom_textures, 0, 0); utility_layout->addWidget(m_prefetch_custom_textures, 0, 1); @@ -167,6 +168,7 @@ void AdvancedWidget::ConnectWidgets() connect(m_dump_use_ffv1, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_enable_prog_scan, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_dump_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); + connect(m_enable_graphics_mods, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); } void AdvancedWidget::LoadSettings() @@ -177,6 +179,8 @@ void AdvancedWidget::LoadSettings() m_enable_prog_scan->setChecked(Config::Get(Config::SYSCONF_PROGRESSIVE_SCAN)); m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); + + SignalBlocking(m_enable_graphics_mods)->setChecked(Settings::Instance().GetGraphicModsEnabled()); } void AdvancedWidget::SaveSettings() @@ -187,6 +191,7 @@ void AdvancedWidget::SaveSettings() Config::SetBase(Config::SYSCONF_PROGRESSIVE_SCAN, m_enable_prog_scan->isChecked()); m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); + Settings::Instance().SetGraphicModsEnabled(m_enable_graphics_mods->isChecked()); } void AdvancedWidget::OnBackendChanged() diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h index 1c469cbc62..4530db5fcf 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h @@ -42,7 +42,7 @@ private: GraphicsBool* m_dump_xfb_target; GraphicsBool* m_disable_vram_copies; GraphicsBool* m_load_custom_textures; - GraphicsBool* m_enable_graphics_mods; + ToolTipCheckBox* m_enable_graphics_mods; // Texture dumping GraphicsBool* m_dump_textures; diff --git a/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp b/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp index 8782bbc97d..712a18a558 100644 --- a/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp +++ b/Source/Core/DolphinQt/Config/GraphicsModListWidget.cpp @@ -15,6 +15,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "DolphinQt/Config/GraphicsModWarningWidget.h" #include "DolphinQt/Settings.h" #include "UICommon/GameFile.h" #include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h" @@ -45,7 +46,9 @@ GraphicsModListWidget::~GraphicsModListWidget() void GraphicsModListWidget::CreateWidgets() { - auto* main_layout = new QHBoxLayout(this); + auto* main_v_layout = new QVBoxLayout(this); + + auto* main_layout = new QHBoxLayout; auto* left_v_layout = new QVBoxLayout; @@ -71,15 +74,23 @@ void GraphicsModListWidget::CreateWidgets() m_mod_meta_layout = new QVBoxLayout; right_v_layout->addLayout(m_mod_meta_layout); + right_v_layout->addStretch(); main_layout->addLayout(left_v_layout); main_layout->addLayout(right_v_layout, 1); - setLayout(main_layout); + m_warning = new GraphicsModWarningWidget(this); + main_v_layout->addWidget(m_warning); + main_v_layout->addLayout(main_layout); + + setLayout(main_v_layout); } void GraphicsModListWidget::ConnectWidgets() { + connect(m_warning, &GraphicsModWarningWidget::GraphicsModEnableSettings, this, + &GraphicsModListWidget::OpenGraphicsSettings); + connect(m_mod_list, &QListWidget::itemSelectionChanged, this, &GraphicsModListWidget::ModSelectionChanged); diff --git a/Source/Core/DolphinQt/Config/GraphicsModListWidget.h b/Source/Core/DolphinQt/Config/GraphicsModListWidget.h index b8b1f5969c..b2ea082f12 100644 --- a/Source/Core/DolphinQt/Config/GraphicsModListWidget.h +++ b/Source/Core/DolphinQt/Config/GraphicsModListWidget.h @@ -11,6 +11,7 @@ #include "Common/CommonTypes.h" #include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h" +class GraphicsModWarningWidget; class QHBoxLayout; class QLabel; class QListWidget; @@ -31,6 +32,7 @@ class GameFile; class GraphicsModListWidget : public QWidget { + Q_OBJECT public: explicit GraphicsModListWidget(const UICommon::GameFile& game); ~GraphicsModListWidget(); @@ -39,6 +41,9 @@ public: const GraphicsModGroupConfig& GetGraphicsModConfig() const; +signals: + void OpenGraphicsSettings(); + private: void CreateWidgets(); void ConnectWidgets(); @@ -63,6 +68,7 @@ private: QVBoxLayout* m_mod_meta_layout; QPushButton* m_refresh; + GraphicsModWarningWidget* m_warning; std::string m_game_id; GraphicsModGroupConfig m_mod_group; diff --git a/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp b/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp new file mode 100644 index 0000000000..281836073c --- /dev/null +++ b/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.cpp @@ -0,0 +1,70 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "DolphinQt/Config/GraphicsModWarningWidget.h" + +#include +#include +#include +#include +#include + +#include "DolphinQt/Settings.h" + +GraphicsModWarningWidget::GraphicsModWarningWidget(QWidget* parent) : QWidget(parent) +{ + CreateWidgets(); + ConnectWidgets(); + + connect(&Settings::Instance(), &Settings::EnableGfxModsChanged, this, + &GraphicsModWarningWidget::Update); + Update(); +} + +void GraphicsModWarningWidget::CreateWidgets() +{ + auto* icon = new QLabel; + + const auto size = 1.5 * QFontMetrics(font()).height(); + + QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size); + + icon->setPixmap(warning_icon); + + m_text = new QLabel(); + m_config_button = new QPushButton(tr("Configure Dolphin")); + + m_config_button->setHidden(true); + + auto* layout = new QHBoxLayout; + + layout->addWidget(icon); + layout->addWidget(m_text, 1); + layout->addWidget(m_config_button); + + layout->setContentsMargins(0, 0, 0, 0); + + setLayout(layout); +} + +void GraphicsModWarningWidget::Update() +{ + bool hide_widget = true; + bool hide_config_button = true; + + if (!Settings::Instance().GetGraphicModsEnabled()) + { + hide_widget = false; + hide_config_button = false; + m_text->setText(tr("Graphics mods are currently disabled.")); + } + + setHidden(hide_widget); + m_config_button->setHidden(hide_config_button); +} + +void GraphicsModWarningWidget::ConnectWidgets() +{ + connect(m_config_button, &QPushButton::clicked, this, + &GraphicsModWarningWidget::GraphicsModEnableSettings); +} diff --git a/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.h b/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.h new file mode 100644 index 0000000000..964ba0f862 --- /dev/null +++ b/Source/Core/DolphinQt/Config/GraphicsModWarningWidget.h @@ -0,0 +1,28 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +class QLabel; +class QPushButton; + +class GraphicsModWarningWidget final : public QWidget +{ + Q_OBJECT +public: + explicit GraphicsModWarningWidget(QWidget* parent); + +signals: + void GraphicsModEnableSettings(); + +private: + void CreateWidgets(); + void ConnectWidgets(); + + void Update(); + + QLabel* m_text; + QPushButton* m_config_button; +}; diff --git a/Source/Core/DolphinQt/Config/PropertiesDialog.cpp b/Source/Core/DolphinQt/Config/PropertiesDialog.cpp index 5ecb9d87bf..b72e950862 100644 --- a/Source/Core/DolphinQt/Config/PropertiesDialog.cpp +++ b/Source/Core/DolphinQt/Config/PropertiesDialog.cpp @@ -52,6 +52,9 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings); + connect(graphics_mod_list, &GraphicsModListWidget::OpenGraphicsSettings, this, + &PropertiesDialog::OpenGraphicsSettings); + const int padding_width = 120; const int padding_height = 100; tab_widget->addTab(GetWrappedWidget(game_config, this, padding_width, padding_height), diff --git a/Source/Core/DolphinQt/Config/PropertiesDialog.h b/Source/Core/DolphinQt/Config/PropertiesDialog.h index b31dbbb391..2135be8948 100644 --- a/Source/Core/DolphinQt/Config/PropertiesDialog.h +++ b/Source/Core/DolphinQt/Config/PropertiesDialog.h @@ -18,4 +18,5 @@ public: signals: void OpenGeneralSettings(); + void OpenGraphicsSettings(); }; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 4808009b73..cde2161e7b 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -77,6 +77,7 @@ + @@ -272,6 +273,7 @@ + diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index b2fdb46df2..abbe3b5ca8 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -540,6 +540,8 @@ void GameList::OpenProperties() properties->setAttribute(Qt::WA_DeleteOnClose, true); connect(properties, &PropertiesDialog::OpenGeneralSettings, this, &GameList::OpenGeneralSettings); + connect(properties, &PropertiesDialog::OpenGraphicsSettings, this, + &GameList::OpenGraphicsSettings); properties->show(); } diff --git a/Source/Core/DolphinQt/GameList/GameList.h b/Source/Core/DolphinQt/GameList/GameList.h index e65f2e06e5..ebe2ec7152 100644 --- a/Source/Core/DolphinQt/GameList/GameList.h +++ b/Source/Core/DolphinQt/GameList/GameList.h @@ -55,6 +55,7 @@ signals: void NetPlayHost(const UICommon::GameFile& game); void SelectionChanged(std::shared_ptr game_file); void OpenGeneralSettings(); + void OpenGraphicsSettings(); private: void ShowHeaderContextMenu(const QPoint& pos); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index d2dea76787..dab8f45c24 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -672,6 +672,7 @@ void MainWindow::ConnectGameList() &MainWindow::ShowRiivolutionBootWidget); connect(m_game_list, &GameList::OpenGeneralSettings, this, &MainWindow::ShowGeneralWindow); + connect(m_game_list, &GameList::OpenGraphicsSettings, this, &MainWindow::ShowGraphicsWindow); } void MainWindow::ConnectRenderWidget() diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index e08e32c0ad..a6580acbaa 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -29,6 +29,7 @@ #include "Common/FileUtil.h" #include "Common/StringUtil.h" +#include "Core/Config/GraphicsSettings.h" #include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -351,6 +352,22 @@ bool Settings::IsKeepWindowOnTopEnabled() const return Config::Get(Config::MAIN_KEEP_WINDOW_ON_TOP); } +bool Settings::GetGraphicModsEnabled() const +{ + return Config::Get(Config::GFX_MODS_ENABLE); +} + +void Settings::SetGraphicModsEnabled(bool enabled) +{ + if (GetGraphicModsEnabled() == enabled) + { + return; + } + + Config::SetBaseOrCurrent(Config::GFX_MODS_ENABLE, enabled); + emit EnableGfxModsChanged(enabled); +} + int Settings::GetVolume() const { return Config::Get(Config::MAIN_AUDIO_VOLUME); diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index 335cef9a76..30ab757753 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -108,6 +108,8 @@ public: bool GetLockCursor() const; void SetKeepWindowOnTop(bool top); bool IsKeepWindowOnTopEnabled() const; + bool GetGraphicModsEnabled() const; + void SetGraphicModsEnabled(bool enabled); // Audio int GetVolume() const; @@ -200,6 +202,7 @@ signals: void DevicesChanged(); void SDCardInsertionChanged(bool inserted); void USBKeyboardConnectionChanged(bool connected); + void EnableGfxModsChanged(bool enabled); private: Settings();