Disable the native debugger when RetroAchievements hardcore mode is enabled

This commit is contained in:
Henrik Rydgård 2024-11-10 19:19:03 +01:00
parent 9056fea501
commit a8744f5992
4 changed files with 50 additions and 13 deletions

View File

@ -19,6 +19,7 @@
#include "Windows/Debugger/DebuggerShared.h" #include "Windows/Debugger/DebuggerShared.h"
#include "Windows/Debugger/BreakpointWindow.h" #include "Windows/Debugger/BreakpointWindow.h"
#include "Windows/Debugger/EditSymbolsWindow.h" #include "Windows/Debugger/EditSymbolsWindow.h"
#include "Core/RetroAchievements.h"
#include "Windows/main.h" #include "Windows/main.h"
#include "Common/CommonWindows.h" #include "Common/CommonWindows.h"
@ -492,7 +493,7 @@ void CtrlDisAsmView::drawArguments(HDC hdc, const DisassemblyLineInfo &line, int
void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
{ {
auto memLock = Memory::Lock(); auto memLock = Memory::Lock();
if (!debugger->isAlive()) return; if (!debugger->isAlive() || Achievements::HardcoreModeActive()) return;
PAINTSTRUCT ps; PAINTSTRUCT ps;
HDC actualHdc = BeginPaint(wnd, &ps); HDC actualHdc = BeginPaint(wnd, &ps);
@ -672,6 +673,9 @@ void CtrlDisAsmView::followBranch()
void CtrlDisAsmView::onChar(WPARAM wParam, LPARAM lParam) void CtrlDisAsmView::onChar(WPARAM wParam, LPARAM lParam)
{ {
if (Achievements::HardcoreModeActive())
return;
if (keyTaken) return; if (keyTaken) return;
char str[2]; char str[2];
@ -713,6 +717,9 @@ void CtrlDisAsmView::editBreakpoint()
void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam) void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam)
{ {
if (Achievements::HardcoreModeActive())
return;
dontRedraw = false; dontRedraw = false;
u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows); u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows);
keyTaken = true; keyTaken = true;
@ -884,6 +891,8 @@ void CtrlDisAsmView::toggleBreakpoint(bool toggleEnabled)
void CtrlDisAsmView::onMouseDown(WPARAM wParam, LPARAM lParam, int button) void CtrlDisAsmView::onMouseDown(WPARAM wParam, LPARAM lParam, int button)
{ {
if (Achievements::HardcoreModeActive())
return;
dontRedraw = false; dontRedraw = false;
int y = HIWORD(lParam); int y = HIWORD(lParam);
@ -947,6 +956,9 @@ void CtrlDisAsmView::NopInstructions(u32 selectRangeStart, u32 selectRangeEnd) {
void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
{ {
if (Achievements::HardcoreModeActive())
return;
if (button == 1) if (button == 1)
{ {
int y = HIWORD(lParam); int y = HIWORD(lParam);
@ -1112,6 +1124,9 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
void CtrlDisAsmView::onMouseMove(WPARAM wParam, LPARAM lParam, int button) void CtrlDisAsmView::onMouseMove(WPARAM wParam, LPARAM lParam, int button)
{ {
if (Achievements::HardcoreModeActive())
return;
if ((button & 1) != 0) if ((button & 1) != 0)
{ {
int y = HIWORD(lParam); int y = HIWORD(lParam);

View File

@ -9,6 +9,7 @@
#include "Core/Config.h" #include "Core/Config.h"
#include "Core/MemMap.h" #include "Core/MemMap.h"
#include "Core/Reporting.h" #include "Core/Reporting.h"
#include "Core/RetroAchievements.h"
#include "Windows/W32Util/ContextMenu.h" #include "Windows/W32Util/ContextMenu.h"
#include "Windows/W32Util/Misc.h" #include "Windows/W32Util/Misc.h"
#include "Windows/InputBox.h" #include "Windows/InputBox.h"
@ -177,6 +178,9 @@ CtrlMemView *CtrlMemView::getFrom(HWND hwnd) {
void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) { void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) {
if (Achievements::HardcoreModeActive())
return;
auto memLock = Memory::Lock(); auto memLock = Memory::Lock();
// draw to a bitmap for double buffering // draw to a bitmap for double buffering
@ -484,6 +488,9 @@ CtrlMemView::GotoMode CtrlMemView::GotoModeFromModifiers(bool isRightClick) {
} }
void CtrlMemView::onMouseDown(WPARAM wParam, LPARAM lParam, int button) { void CtrlMemView::onMouseDown(WPARAM wParam, LPARAM lParam, int button) {
if (Achievements::HardcoreModeActive())
return;
int x = LOWORD(lParam); int x = LOWORD(lParam);
int y = HIWORD(lParam); int y = HIWORD(lParam);
@ -491,6 +498,9 @@ void CtrlMemView::onMouseDown(WPARAM wParam, LPARAM lParam, int button) {
} }
void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) { void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) {
if (Achievements::HardcoreModeActive())
return;
if (button == 2) { if (button == 2) {
int32_t selectedSize = selectRangeEnd_ - selectRangeStart_; int32_t selectedSize = selectRangeEnd_ - selectRangeStart_;
bool enable16 = !asciiSelected_ && (selectedSize == 1 || (selectedSize & 1) == 0); bool enable16 = !asciiSelected_ && (selectedSize == 1 || (selectedSize & 1) == 0);
@ -638,6 +648,9 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) {
} }
void CtrlMemView::onMouseMove(WPARAM wParam, LPARAM lParam, int button) { void CtrlMemView::onMouseMove(WPARAM wParam, LPARAM lParam, int button) {
if (Achievements::HardcoreModeActive())
return;
int x = LOWORD(lParam); int x = LOWORD(lParam);
int y = HIWORD(lParam); int y = HIWORD(lParam);

View File

@ -5,6 +5,7 @@
#include "Core/Debugger/Breakpoints.h" #include "Core/Debugger/Breakpoints.h"
#include "Core/Debugger/SymbolMap.h" #include "Core/Debugger/SymbolMap.h"
#include "Core/RetroAchievements.h"
#include "Windows/Debugger/BreakpointWindow.h" #include "Windows/Debugger/BreakpointWindow.h"
#include "Windows/Debugger/CtrlDisAsmView.h" #include "Windows/Debugger/CtrlDisAsmView.h"
#include "Windows/Debugger/Debugger_MemoryDlg.h" #include "Windows/Debugger/Debugger_MemoryDlg.h"
@ -262,6 +263,9 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
if (Achievements::HardcoreModeActive())
return TRUE;
CtrlDisAsmView *ptr = DisAsmView(); CtrlDisAsmView *ptr = DisAsmView();
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
case ID_TOGGLE_BREAK: case ID_TOGGLE_BREAK:

View File

@ -85,11 +85,13 @@ namespace MainWindow {
} }
} }
UINT menuEnable = menuEnableBool ? MF_ENABLED : MF_GRAYED; const UINT menuEnable = menuEnableBool ? MF_ENABLED : MF_GRAYED;
UINT loadStateEnable = loadStateEnableBool ? MF_ENABLED : MF_GRAYED; const UINT loadStateEnable = loadStateEnableBool ? MF_ENABLED : MF_GRAYED;
UINT saveStateEnable = saveStateEnableBool ? MF_ENABLED : MF_GRAYED; const UINT saveStateEnable = saveStateEnableBool ? MF_ENABLED : MF_GRAYED;
UINT menuInGameEnable = state == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED; const UINT menuInGameEnable = state == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED;
UINT umdSwitchEnable = state == UISTATE_INGAME && getUMDReplacePermit() ? MF_ENABLED : MF_GRAYED; const UINT umdSwitchEnable = state == UISTATE_INGAME && getUMDReplacePermit() ? MF_ENABLED : MF_GRAYED;
const UINT debugEnable = !Achievements::HardcoreModeActive() ? MF_ENABLED : MF_GRAYED;
const UINT debugIngameEnable = (state == UISTATE_INGAME && !Achievements::HardcoreModeActive()) ? MF_ENABLED : MF_GRAYED;
EnableMenuItem(menu, ID_FILE_SAVESTATE_SLOT_MENU, saveStateEnable); EnableMenuItem(menu, ID_FILE_SAVESTATE_SLOT_MENU, saveStateEnable);
EnableMenuItem(menu, ID_FILE_SAVESTATEFILE, saveStateEnable); EnableMenuItem(menu, ID_FILE_SAVESTATEFILE, saveStateEnable);
@ -101,15 +103,18 @@ namespace MainWindow {
EnableMenuItem(menu, ID_EMULATION_RESET, menuEnable); EnableMenuItem(menu, ID_EMULATION_RESET, menuEnable);
EnableMenuItem(menu, ID_EMULATION_SWITCH_UMD, umdSwitchEnable); EnableMenuItem(menu, ID_EMULATION_SWITCH_UMD, umdSwitchEnable);
EnableMenuItem(menu, ID_EMULATION_CHAT, g_Config.bEnableNetworkChat ? menuInGameEnable : MF_GRAYED); EnableMenuItem(menu, ID_EMULATION_CHAT, g_Config.bEnableNetworkChat ? menuInGameEnable : MF_GRAYED);
EnableMenuItem(menu, ID_TOGGLE_BREAK, menuEnable); EnableMenuItem(menu, ID_TOGGLE_BREAK, debugIngameEnable);
EnableMenuItem(menu, ID_DEBUG_LOADMAPFILE, menuEnable); EnableMenuItem(menu, ID_DEBUG_LOADMAPFILE, debugIngameEnable);
EnableMenuItem(menu, ID_DEBUG_SAVEMAPFILE, menuEnable); EnableMenuItem(menu, ID_DEBUG_SAVEMAPFILE, debugIngameEnable);
EnableMenuItem(menu, ID_DEBUG_LOADSYMFILE, menuEnable); EnableMenuItem(menu, ID_DEBUG_LOADSYMFILE, debugIngameEnable);
EnableMenuItem(menu, ID_DEBUG_SAVESYMFILE, menuEnable); EnableMenuItem(menu, ID_DEBUG_SAVESYMFILE, debugIngameEnable);
EnableMenuItem(menu, ID_DEBUG_RESETSYMBOLTABLE, menuEnable); EnableMenuItem(menu, ID_DEBUG_RESETSYMBOLTABLE, debugIngameEnable);
EnableMenuItem(menu, ID_DEBUG_SHOWDEBUGSTATISTICS, menuInGameEnable); EnableMenuItem(menu, ID_DEBUG_SHOWDEBUGSTATISTICS, debugEnable);
EnableMenuItem(menu, ID_DEBUG_EXTRACTFILE, menuEnable); EnableMenuItem(menu, ID_DEBUG_EXTRACTFILE, menuEnable);
EnableMenuItem(menu, ID_DEBUG_MEMORYBASE, menuInGameEnable); EnableMenuItem(menu, ID_DEBUG_MEMORYBASE, menuInGameEnable);
EnableMenuItem(menu, ID_DEBUG_DISASSEMBLY, debugEnable);
EnableMenuItem(menu, ID_DEBUG_MEMORYVIEW, debugEnable);
EnableMenuItem(menu, ID_DEBUG_GEDEBUGGER, debugEnable);
// While playing, this pop up doesn't work - and probably doesn't make sense. // While playing, this pop up doesn't work - and probably doesn't make sense.
EnableMenuItem(menu, ID_OPTIONS_LANGUAGE, state == UISTATE_INGAME ? MF_GRAYED : MF_ENABLED); EnableMenuItem(menu, ID_OPTIONS_LANGUAGE, state == UISTATE_INGAME ? MF_GRAYED : MF_ENABLED);