From e28ffc168211886634a5e3951ff1eed338f3e271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 9 Jul 2025 17:31:27 +0200 Subject: [PATCH] Merge pull request #20608 from hrydgard/retroachievements-close-debugger If RetroAchievements' "Hardcore mode" is enabled, prevent debugger use --- Windows/Debugger/Debugger_Disasm.cpp | 4 ++++ Windows/GEDebugger/GEDebugger.cpp | 8 +++++++- Windows/MainWindow.cpp | 2 +- Windows/MainWindowMenu.cpp | 13 +++++++++++++ Windows/MainWindowMenu.h | 1 + Windows/main.cpp | 13 ++++++++----- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 35df8d3ca8..8d6000efd6 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -576,6 +576,10 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { ProcessUpdateDialog(); updateDialogScheduled_ = false; KillTimer(GetDlgHandle(), wParam); + + if (Achievements::HardcoreModeActive()) { + SendMessage(m_hDlg, WM_CLOSE, 0, 0); + } } break; } diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 7184a340a8..2aeaa8f64a 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -33,7 +33,7 @@ #include "Core/Config.h" #include "Core/Screenshot.h" - +#include "Core/RetroAchievements.h" #include "Windows/GEDebugger/GEDebugger.h" #include "Windows/GEDebugger/SimpleGLWindow.h" #include "Windows/GEDebugger/CtrlDisplayListView.h" @@ -950,6 +950,12 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { } else if (!PSP_IsInited() && primaryBuffer_) { SendMessage(m_hDlg, WM_COMMAND, IDC_GEDBG_RESUME, 0); } + if (Achievements::HardcoreModeActive()) { + if (g_activeWindow == WINDOW_GEDEBUGGER) { + g_activeWindow = WINDOW_OTHER; + } + SendMessage(m_hDlg, WM_CLOSE, 0, 0); + } break; case WM_NOTIFY: diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index a5eb3c8e46..c2533ab53d 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -1117,7 +1117,7 @@ namespace MainWindow return DefWindowProc(hWnd, message, wParam, lParam); HDROP hdrop = (HDROP)wParam; - int count = DragQueryFile(hdrop, 0xFFFFFFFF, 0, 0); + const int count = DragQueryFile(hdrop, 0xFFFFFFFF, 0, 0); if (count != 1) { // TODO: Translate? Or just not bother? MessageBox(hwndMain, L"You can only load one file at a time", L"Error", MB_ICONINFORMATION); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index b116d4d2c3..3386646d70 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -981,6 +981,19 @@ namespace MainWindow { } } + void HideDebugWindows() { + if (disasmWindow) + disasmWindow->Show(false); +#if PPSSPP_API(ANY_GL) + if (geDebuggerWindow) + geDebuggerWindow->Show(false); +#endif + if (memoryWindow) + memoryWindow->Show(false); + if (vfpudlg) + vfpudlg->Show(false); + } + void UpdateMenus(bool isMenuSelect) { if (isMenuSelect) { menuShaderInfoLoaded = false; diff --git a/Windows/MainWindowMenu.h b/Windows/MainWindowMenu.h index 5a15f9950d..d7ed1a751f 100644 --- a/Windows/MainWindowMenu.h +++ b/Windows/MainWindowMenu.h @@ -12,4 +12,5 @@ namespace MainWindow { void BrowseAndBoot(RequesterToken token, std::string defaultPath, bool browseDirectory = false); void setTexScalingMultiplier(int level); void SetIngameMenuItemStates(HMENU menu, const GlobalUIState state); + void HideDebugWindows(); } diff --git a/Windows/main.cpp b/Windows/main.cpp index f2304fcdc0..985fddae91 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -48,13 +48,13 @@ #include "Common/Data/Encoding/Utf8.h" #include "Common/Net/Resolve.h" #include "Common/TimeUtil.h" -#include "W32Util/DarkMode.h" -#include "W32Util/ShellUtil.h" #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/SaveState.h" #include "Core/Instance.h" +#include "Core/HLE/Plugins.h" +#include "Core/RetroAchievements.h" #include "Windows/EmuThread.h" #include "Windows/WindowsAudio.h" #include "ext/disarm.h" @@ -77,6 +77,7 @@ #endif #include "Windows/W32Util/ContextMenu.h" #include "Windows/W32Util/DialogManager.h" +#include "Windows/W32Util/DarkMode.h" #include "Windows/W32Util/ShellUtil.h" #include "Windows/Debugger/CtrlDisAsmView.h" @@ -436,8 +437,11 @@ void System_Notify(SystemNotification notification) { g_symbolMap->SortSymbols(); // internal locking is performed here PostMessage(MainWindow::GetHWND(), WM_USER + 1, 0, 0); - if (disasmWindow) + if (Achievements::HardcoreModeActive()) { + MainWindow::HideDebugWindows(); + } else if (disasmWindow) { PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)Core_IsStepping()); + } break; } @@ -445,7 +449,7 @@ void System_Notify(SystemNotification notification) { { PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0); - int peers = GetInstancePeerCount(); + const int peers = GetInstancePeerCount(); if (PPSSPP_ID >= 1 && peers != g_lastNumInstances) { g_lastNumInstances = peers; PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0); @@ -520,7 +524,6 @@ void System_Notify(SystemNotification notification) { case SystemNotification::ROTATE_UPDATED: case SystemNotification::TEST_JAVA_EXCEPTION: break; - case SystemNotification::UI_STATE_CHANGED: case SystemNotification::AUDIO_MODE_CHANGED: case SystemNotification::APP_SWITCH_MODE_CHANGED: break;