From e9da2a48324191421fd29325820e9b50fa8bcd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Sun, 11 Jan 2026 21:48:03 +0100 Subject: [PATCH] Settings: Simplify debug mode We now just pass a signal to tell the UI that hardcore mode has been turned on/off, and we replace Settings::IsDebugModeEnabled with Config::IsDebuggingEnabled, which always returns false if hardcore is on. --- .../AchievementSettingsWidget.cpp | 3 + .../Config/ToolTipControls/ToolTipWidget.h | 1 + .../DolphinQt/Debugger/AssemblerWidget.cpp | 3 +- .../DolphinQt/Debugger/BreakpointWidget.cpp | 3 +- Source/Core/DolphinQt/Debugger/CodeWidget.cpp | 2 +- Source/Core/DolphinQt/Debugger/JITWidget.cpp | 2 +- .../Core/DolphinQt/Debugger/MemoryWidget.cpp | 2 +- .../Core/DolphinQt/Debugger/NetworkWidget.cpp | 2 +- .../DolphinQt/Debugger/RegisterWidget.cpp | 3 +- .../Core/DolphinQt/Debugger/ThreadWidget.cpp | 2 +- .../Core/DolphinQt/Debugger/WatchWidget.cpp | 2 +- Source/Core/DolphinQt/MainWindow.cpp | 4 -- Source/Core/DolphinQt/MenuBar.cpp | 2 +- Source/Core/DolphinQt/Settings.cpp | 25 +++----- Source/Core/DolphinQt/Settings.h | 3 +- .../Core/DolphinQt/Settings/InterfacePane.cpp | 64 +++++++++---------- .../Core/DolphinQt/Settings/InterfacePane.h | 1 + Source/Core/DolphinQt/ToolBar.cpp | 2 +- 18 files changed, 57 insertions(+), 69 deletions(-) diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp index 7806127bfe..fee72a1e71 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp @@ -296,6 +296,8 @@ void AchievementSettingsWidget::ToggleRAIntegration() instance.Init(reinterpret_cast(winId())); else instance.Shutdown(); + emit Settings::Instance().HardcoreModeChanged(Config::Get(Config::RA_ENABLED) && + Config::Get(Config::RA_HARDCORE_ENABLED)); } void AchievementSettingsWidget::Login() @@ -333,6 +335,7 @@ void AchievementSettingsWidget::ToggleHardcore() } } SaveSettings(); + emit Settings::Instance().HardcoreModeChanged(Config::Get(Config::RA_HARDCORE_ENABLED)); } void AchievementSettingsWidget::ToggleUnofficial() diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h index cbcbccefd7..2dac9c6560 100644 --- a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h @@ -26,6 +26,7 @@ public: void SetTitle(QString title) { m_title = std::move(title); } void SetDescription(QString description) { m_description = std::move(description); } + QString GetDescription() { return m_description; } private: void enterEvent(QEnterEvent* const event) override diff --git a/Source/Core/DolphinQt/Debugger/AssemblerWidget.cpp b/Source/Core/DolphinQt/Debugger/AssemblerWidget.cpp index 958e731c0d..35098b03af 100644 --- a/Source/Core/DolphinQt/Debugger/AssemblerWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/AssemblerWidget.cpp @@ -234,8 +234,7 @@ AssemblerWidget::AssemblerWidget(QWidget* parent) setWindowTitle(tr("Assembler")); setObjectName(QStringLiteral("assemblerwidget")); - setHidden(!Settings::Instance().IsAssemblerVisible() || - !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsAssemblerVisible() || !Config::IsDebuggingEnabled()); this->setVisible(true); CreateWidgets(); diff --git a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp index 797086082d..5bb11fd632 100644 --- a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp @@ -98,8 +98,7 @@ BreakpointWidget::BreakpointWidget(QWidget* parent) setWindowTitle(tr("Breakpoints")); setObjectName(QStringLiteral("breakpoints")); - setHidden(!Settings::Instance().IsBreakpointsVisible() || - !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsBreakpointsVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp index 559b540451..faf7e358c2 100644 --- a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp @@ -47,7 +47,7 @@ CodeWidget::CodeWidget(QWidget* parent) setWindowTitle(tr("Code")); setObjectName(QStringLiteral("code")); - setHidden(!Settings::Instance().IsCodeVisible() || !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsCodeVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/Debugger/JITWidget.cpp b/Source/Core/DolphinQt/Debugger/JITWidget.cpp index 9a9fdff058..fd500ee63b 100644 --- a/Source/Core/DolphinQt/Debugger/JITWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/JITWidget.cpp @@ -285,7 +285,7 @@ void JITWidget::LoadQSettings() auto& settings = Settings::GetQSettings(); restoreGeometry(settings.value(QStringLiteral("jitwidget/geometry")).toByteArray()); - setHidden(!Settings::Instance().IsJITVisible() || !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsJITVisible() || !Config::IsDebuggingEnabled()); // macOS: setFloating() needs to be after setHidden() for proper window presentation // according to Settings setFloating(settings.value(QStringLiteral("jitwidget/floating")).toBool()); diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index 575c1facba..e68731c6ef 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -45,7 +45,7 @@ MemoryWidget::MemoryWidget(Core::System& system, QWidget* parent) setWindowTitle(tr("Memory")); setObjectName(QStringLiteral("memory")); - setHidden(!Settings::Instance().IsMemoryVisible() || !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsMemoryVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp b/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp index c32f55c1b5..5478555946 100644 --- a/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp @@ -194,7 +194,7 @@ NetworkWidget::NetworkWidget(QWidget* parent) : QDockWidget(parent) setWindowTitle(tr("Network")); setObjectName(QStringLiteral("network")); - setHidden(!Settings::Instance().IsNetworkVisible() || !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsNetworkVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp index 4f391f4698..ed904e9e20 100644 --- a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp @@ -29,8 +29,7 @@ RegisterWidget::RegisterWidget(QWidget* parent) setWindowTitle(tr("Registers")); setObjectName(QStringLiteral("registers")); - setHidden(!Settings::Instance().IsRegistersVisible() || - !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsRegistersVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp index 1ecb64cb04..60cacec2df 100644 --- a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp @@ -26,7 +26,7 @@ ThreadWidget::ThreadWidget(QWidget* parent) : QDockWidget(parent) setWindowTitle(tr("Threads")); setObjectName(QStringLiteral("threads")); - setHidden(!Settings::Instance().IsThreadsVisible() || !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsThreadsVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp index 35107c0ccc..862676c5fb 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp @@ -31,7 +31,7 @@ WatchWidget::WatchWidget(QWidget* parent) setWindowTitle(tr("Watch")); setObjectName(QStringLiteral("watch")); - setHidden(!Settings::Instance().IsWatchVisible() || !Settings::Instance().IsDebugModeEnabled()); + setHidden(!Settings::Instance().IsWatchVisible() || !Config::IsDebuggingEnabled()); setAllowedAreas(Qt::AllDockWidgetAreas); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 7905402013..64a166efba 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -263,8 +263,6 @@ MainWindow::MainWindow(Core::System& system, std::unique_ptr boo #ifdef USE_RETRO_ACHIEVEMENTS AchievementManager::GetInstance().Init(reinterpret_cast(winId())); - if (AchievementManager::GetInstance().IsHardcoreModeActive()) - Settings::Instance().SetDebugModeEnabled(false); // This needs to trigger on both RA_HARDCORE_ENABLED and RA_ENABLED m_config_changed_callback_id = Config::AddConfigChangedCallback( [this] { QueueOnObject(this, [this] { this->OnHardcoreChanged(); }); }); @@ -2085,8 +2083,6 @@ void MainWindow::ShowAchievementSettings() void MainWindow::OnHardcoreChanged() { bool hardcore_active = AchievementManager::GetInstance().IsHardcoreModeActive(); - if (hardcore_active) - Settings::Instance().SetDebugModeEnabled(false); // EmulationStateChanged causes several dialogs to redraw, including anything affected by hardcore // mode. Every dialog that depends on hardcore mode is redrawn by EmulationStateChanged. if (hardcore_active != m_former_hardcore_setting) diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index f0ad6d2c78..9221e474fb 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -166,7 +166,7 @@ void MenuBar::OnEmulationStateChanged(Core::State state) UpdateStateSlotMenu(); UpdateToolsMenu(state); - OnDebugModeToggled(Settings::Instance().IsDebugModeEnabled()); + OnDebugModeToggled(Config::IsDebuggingEnabled()); } void MenuBar::OnConfigChanged() diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index 5a99e5dd22..aedc45457f 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -90,6 +90,13 @@ Settings::Settings() QueueOnObject(this, [this] { emit DevicesChanged(); }); } }); + + connect(this, &Settings::HardcoreModeChanged, this, [this](bool hardcore) { + if (hardcore) + emit DebugModeToggled(false); + else if (Config::IsDebuggingEnabled()) + emit DebugModeToggled(true); + }); } Settings::~Settings() @@ -699,22 +706,6 @@ bool Settings::GetCheatsEnabled() const return Config::Get(Config::MAIN_ENABLE_CHEATS); } -void Settings::SetDebugModeEnabled(bool enabled) -{ - if (AchievementManager::GetInstance().IsHardcoreModeActive()) - enabled = false; - if (IsDebugModeEnabled() != enabled) - { - Config::SetBaseOrCurrent(Config::MAIN_ENABLE_DEBUGGING, enabled); - emit DebugModeToggled(enabled); - } -} - -bool Settings::IsDebugModeEnabled() const -{ - return Config::Get(Config::MAIN_ENABLE_DEBUGGING); -} - void Settings::SetRegistersVisible(bool enabled) { if (IsRegistersVisible() != enabled) @@ -847,7 +838,7 @@ bool Settings::IsAssemblerVisible() const void Settings::RefreshWidgetVisibility() { - emit DebugModeToggled(IsDebugModeEnabled()); + emit DebugModeToggled(Config::IsDebuggingEnabled()); emit LogVisibilityChanged(IsLogVisible()); emit LogConfigVisibilityChanged(IsLogConfigVisible()); emit GameCountVisibilityChanged(IsGameCountVisible()); diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index b8ac1bf433..101c726631 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -154,8 +154,6 @@ public: bool GetCheatsEnabled() const; // Debug - void SetDebugModeEnabled(bool enabled); - bool IsDebugModeEnabled() const; void SetRegistersVisible(bool enabled); bool IsRegistersVisible() const; void SetThreadsVisible(bool enabled); @@ -229,6 +227,7 @@ signals: void WiiSpeakMuteChanged(bool muted); void EnableGfxModsChanged(bool enabled); void GameCountVisibilityChanged(bool visible); + void HardcoreModeChanged(bool enabled); private: Settings(); diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index c9b5cfd89d..647aebd13d 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -19,6 +19,7 @@ #include "Common/StringUtil.h" #include "Core/AchievementManager.h" +#include "Core/Config/AchievementSettings.h" #include "Core/Config/MainSettings.h" #include "Core/Config/UISettings.h" #include "Core/Core.h" @@ -88,16 +89,17 @@ static ConfigStringChoice* MakeLanguageComboBox() InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent) { CreateLayout(); - UpdateShowDebuggingCheckbox(); LoadUserStyle(); ConnectLayout(); - connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, - &InterfacePane::UpdateShowDebuggingCheckbox); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &InterfacePane::OnEmulationStateChanged); + connect(&Settings::Instance(), &Settings::HardcoreModeChanged, this, + &InterfacePane::OnHardcoreModeChanged); OnEmulationStateChanged(Core::GetState(Core::System::GetInstance())); + OnHardcoreModeChanged(Config::Get(Config::RA_ENABLED) && + Config::Get(Config::RA_HARDCORE_ENABLED)); } void InterfacePane::CreateLayout() @@ -173,7 +175,8 @@ void InterfacePane::CreateUI() m_checkbox_use_covers = new ConfigBool(tr("Download Game Covers from GameTDB.com for Use in Grid Mode"), Config::MAIN_USE_GAME_COVERS); - m_checkbox_show_debugging_ui = new ToolTipCheckBox(tr("Enable Debugging UI")); + m_checkbox_show_debugging_ui = + new ConfigBool(tr("Enable Debugging UI"), Config::MAIN_ENABLE_DEBUGGING); m_checkbox_focused_hotkeys = new ConfigBool(tr("Hotkeys Require Window Focus"), Config::MAIN_FOCUSED_HOTKEYS); m_checkbox_disable_screensaver = @@ -245,8 +248,9 @@ void InterfacePane::ConnectLayout() &Settings::GameListRefreshRequested); connect(m_checkbox_use_covers, &QCheckBox::toggled, &Settings::Instance(), &Settings::MetadataRefreshRequested); - connect(m_checkbox_show_debugging_ui, &QCheckBox::toggled, &Settings::Instance(), - &Settings::SetDebugModeEnabled); + connect(m_checkbox_show_debugging_ui, &QCheckBox::toggled, &Settings::Instance(), [] { + emit Settings::Instance().DebugModeToggled(Config::Get(Config::MAIN_ENABLE_DEBUGGING)); + }); connect(m_combobox_theme, &QComboBox::currentIndexChanged, &Settings::Instance(), &Settings::ThemeChanged); connect(m_combobox_userstyle, &QComboBox::currentIndexChanged, this, @@ -265,32 +269,6 @@ void InterfacePane::ConnectLayout() &Settings::LockCursorChanged); } -void InterfacePane::UpdateShowDebuggingCheckbox() -{ - SignalBlocking(m_checkbox_show_debugging_ui) - ->setChecked(Settings::Instance().IsDebugModeEnabled()); - - static constexpr char TR_SHOW_DEBUGGING_UI_DESCRIPTION[] = QT_TR_NOOP( - "Shows Dolphin's debugging user interface. This lets you view and modify a game's code and " - "memory contents, set debugging breakpoints, examine network requests, and more." - "

If unsure, leave this unchecked."); - static constexpr char TR_DISABLED_IN_HARDCORE_DESCRIPTION[] = - QT_TR_NOOP("Disabled in Hardcore Mode."); - - bool hardcore = AchievementManager::GetInstance().IsHardcoreModeActive(); - SignalBlocking(m_checkbox_show_debugging_ui)->setEnabled(!hardcore); - if (hardcore) - { - m_checkbox_show_debugging_ui->SetDescription(tr("%1

%2") - .arg(tr(TR_SHOW_DEBUGGING_UI_DESCRIPTION)) - .arg(tr(TR_DISABLED_IN_HARDCORE_DESCRIPTION))); - } - else - { - m_checkbox_show_debugging_ui->SetDescription(tr(TR_SHOW_DEBUGGING_UI_DESCRIPTION)); - } -} - void InterfacePane::LoadUserStyle() { const Settings::StyleType style_type = Settings::Instance().GetStyleType(); @@ -329,6 +307,28 @@ void InterfacePane::OnEmulationStateChanged(Core::State state) m_checkbox_time_tracking->setEnabled(uninitialized); } +void InterfacePane::OnHardcoreModeChanged(bool enabled) +{ + static constexpr char TR_SHOW_DEBUGGING_UI_DESCRIPTION[] = QT_TR_NOOP( + "Shows Dolphin's debugging user interface. This lets you view and modify a game's code and " + "memory contents, set debugging breakpoints, examine network requests, and more." + "

If unsure, leave this unchecked."); + static constexpr char TR_DISABLED_HARDCORE_MODE[] = QT_TR_NOOP( + "

Disabled in RetroAchivements Hardcore Mode."); + + if (enabled) + { + m_checkbox_show_debugging_ui->SetDescription(tr(TR_SHOW_DEBUGGING_UI_DESCRIPTION) + + tr(TR_DISABLED_HARDCORE_MODE)); + } + else + { + m_checkbox_show_debugging_ui->SetDescription(tr(TR_SHOW_DEBUGGING_UI_DESCRIPTION)); + } + + m_checkbox_show_debugging_ui->setEnabled(!enabled); +} + void InterfacePane::AddDescriptions() { static constexpr char TR_TITLE_DATABASE_DESCRIPTION[] = QT_TR_NOOP( diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.h b/Source/Core/DolphinQt/Settings/InterfacePane.h index 1f33e7659d..b4b4359c27 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.h +++ b/Source/Core/DolphinQt/Settings/InterfacePane.h @@ -36,6 +36,7 @@ private: void OnLanguageChanged(); void OnEmulationStateChanged(Core::State state); + void OnHardcoreModeChanged(bool enabled); QVBoxLayout* m_main_layout; ConfigStringChoice* m_combobox_language; diff --git a/Source/Core/DolphinQt/ToolBar.cpp b/Source/Core/DolphinQt/ToolBar.cpp index 57ab64d159..aafc146950 100644 --- a/Source/Core/DolphinQt/ToolBar.cpp +++ b/Source/Core/DolphinQt/ToolBar.cpp @@ -52,7 +52,7 @@ ToolBar::ToolBar(QWidget* parent) : QToolBar(parent) [this] { m_refresh_action->setEnabled(true); }); OnEmulationStateChanged(Core::GetState(Core::System::GetInstance())); - OnDebugModeToggled(Settings::Instance().IsDebugModeEnabled()); + OnDebugModeToggled(Config::IsDebuggingEnabled()); } void ToolBar::OnEmulationStateChanged(Core::State state)