From 75eeb55617e38375b016262bd3c1eb2b2a9cf487 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 8 Aug 2021 23:40:41 -0700 Subject: [PATCH] UI: Use a UIState for exceptions. This makes it so we can enable Stop/Reset/etc. during them in the menus. --- Core/System.cpp | 1 + Core/System.h | 1 + UI/EmuScreen.cpp | 4 ++-- Windows/Debugger/Debugger_Disasm.cpp | 5 +++-- Windows/MainWindowMenu.cpp | 7 ++++--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index 87392b22eb..04070c614e 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -131,6 +131,7 @@ void UpdateUIState(GlobalUIState newState) { case UISTATE_INGAME: state = "ingame"; break; case UISTATE_MENU: state = "menu"; break; case UISTATE_PAUSEMENU: state = "pausemenu"; break; + case UISTATE_EXCEPTION: state = "exception"; break; } if (state) { System_SendMessage("uistate", state); diff --git a/Core/System.h b/Core/System.h index 13423a0167..380c9e00f3 100644 --- a/Core/System.h +++ b/Core/System.h @@ -33,6 +33,7 @@ enum GlobalUIState { UISTATE_PAUSEMENU, UISTATE_INGAME, UISTATE_EXIT, + UISTATE_EXCEPTION, }; // Use these in conjunction with GetSysDirectory. diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index e82deba8b9..8161fcd4a0 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -952,8 +952,8 @@ void EmuScreen::update() { PSP_CoreParameter().pixelHeight = pixel_yres * bounds.h / dp_yres; #endif - if (!invalid_ && coreState != CORE_RUNTIME_ERROR) { - UpdateUIState(UISTATE_INGAME); + if (!invalid_) { + UpdateUIState(coreState != CORE_RUNTIME_ERROR ? UISTATE_INGAME : UISTATE_EXCEPTION); } if (errorMessage_.size()) { diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 54af241898..3d802ddeef 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -791,9 +791,10 @@ void CDisasm::SavePosition() void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) { HWND hDlg = m_hDlg; + bool ingame = (GetUIState() == UISTATE_INGAME || GetUIState() == UISTATE_EXCEPTION) && PSP_IsInited(); // Update Dialog Windows - if (_bDebug && GetUIState() == UISTATE_INGAME && PSP_IsInited()) + if (_bDebug && ingame) { Core_WaitInactive(TEMP_BREAKPOINT_WAIT_MS); breakpointList->reloadBreakpoints(); @@ -827,7 +828,7 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) { updateThreadLabel(true); - if (GetUIState() == UISTATE_INGAME && PSP_IsInited()) + if (ingame) { SetDlgItemText(m_hDlg, IDC_STOPGO, L"Break"); EnableWindow(GetDlgItem(hDlg, IDC_STOPGO), TRUE); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index c0d790e06f..ac186ad09c 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -68,7 +68,8 @@ namespace MainWindow { LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); void SetIngameMenuItemStates(HMENU menu, const GlobalUIState state) { - UINT menuEnable = state == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED; + UINT menuEnable = state == UISTATE_INGAME || state == UISTATE_EXCEPTION ? MF_ENABLED : MF_GRAYED; + UINT menuInGameEnable = state == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED; UINT umdSwitchEnable = state == UISTATE_INGAME && getUMDReplacePermit() ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, ID_FILE_SAVESTATEFILE, menuEnable); @@ -86,7 +87,7 @@ namespace MainWindow { EnableMenuItem(menu, ID_DEBUG_SAVESYMFILE, menuEnable); EnableMenuItem(menu, ID_DEBUG_RESETSYMBOLTABLE, menuEnable); EnableMenuItem(menu, ID_DEBUG_TAKESCREENSHOT, menuEnable); - EnableMenuItem(menu, ID_DEBUG_SHOWDEBUGSTATISTICS, menuEnable); + EnableMenuItem(menu, ID_DEBUG_SHOWDEBUGSTATISTICS, menuInGameEnable); EnableMenuItem(menu, ID_DEBUG_EXTRACTFILE, menuEnable); // While playing, this pop up doesn't work - and probably doesn't make sense. @@ -394,7 +395,7 @@ namespace MainWindow { Core_EnableStepping(false); } } else { - if (GetUIState() == UISTATE_INGAME || GetUIState() == UISTATE_PAUSEMENU) { + if (GetUIState() == UISTATE_INGAME || GetUIState() == UISTATE_EXCEPTION || GetUIState() == UISTATE_PAUSEMENU) { Core_EnableStepping(false); }