Allow cheat window to be open while game is running

This commit is contained in:
zilmar 2020-05-25 20:08:31 +09:30
parent c764d79e74
commit f4e5ae8efa
5 changed files with 59 additions and 7 deletions

View File

@ -22,13 +22,24 @@ CCheatsUI::~CCheatsUI()
{
}
void CCheatsUI::Display(HWND hParent)
void CCheatsUI::Display(HWND hParent, bool BlockExecution)
{
if (g_BaseSystem)
{
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_Cheats);
}
DoModal(hParent);
if (BlockExecution)
{
DoModal(hParent);
}
else if (m_hWnd != NULL)
{
SetFocus();
}
else
{
Create(hParent);
}
}
LRESULT CCheatsUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
@ -90,13 +101,26 @@ LRESULT CCheatsUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara
return 0;
}
LRESULT CCheatsUI::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_StateBtn.Detach();
return 0;
}
LRESULT CCheatsUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
if (g_BaseSystem)
{
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_Cheats);
}
EndDialog(0);
if (m_bModal)
{
EndDialog(0);
}
else
{
DestroyWindow();
}
return 0;
}
@ -220,6 +244,12 @@ LRESULT CCheatList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar
return true;
}
LRESULT CCheatList::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_hCheatTree.Detach();
return 0;
}
LRESULT CCheatList::OnChangeCodeExtension(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
m_hSelectedItem = (HTREEITEM)lParam;

View File

@ -24,6 +24,7 @@ class CCheatList :
public:
BEGIN_MSG_MAP_EX(CCheatList)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(UM_CHANGECODEEXTENSION, OnChangeCodeExtension)
COMMAND_ID_HANDLER(IDC_UNMARK, OnUnmark)
COMMAND_ID_HANDLER(ID_POPUP_DELETE, OnPopupDelete)
@ -48,6 +49,7 @@ private:
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnChangeCodeExtension(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnUnmark(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
@ -169,6 +171,7 @@ class CCheatsUI :
public:
BEGIN_MSG_MAP_EX(CCheatsUI)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
COMMAND_ID_HANDLER(IDC_STATE, OnStateChange)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
END_MSG_MAP()
@ -178,10 +181,11 @@ public:
CCheatsUI(void);
~CCheatsUI(void);
void Display(HWND hParent);
void Display(HWND hParent, bool BlockExecution);
private:
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnStateChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

View File

@ -274,7 +274,7 @@ void CMainMenu::OnLodState(HWND hWnd)
void CMainMenu::OnCheats(HWND hWnd)
{
CCheatsUI().Display(hWnd);
m_Gui->DisplayCheatsUI(false);
}
void CMainMenu::OnSettings(HWND hWnd)

View File

@ -256,6 +256,10 @@ void CMainGui::GameCpuRunning(CMainGui * Gui)
}
else
{
if (Gui->m_CheatsUI.m_hWnd != NULL)
{
Gui->m_CheatsUI.SendMessage(WM_COMMAND, MAKELONG(IDCANCEL, 0));
}
PostMessage(Gui->m_hMainWindow, WM_GAME_CLOSED, 0, 0);
}
}
@ -466,6 +470,11 @@ bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System)
return bRes;
}
void CMainGui::DisplayCheatsUI(bool BlockExecution)
{
m_CheatsUI.Display(m_hMainWindow, BlockExecution);
}
void CMainGui::BringToTop(void)
{
CGuard Guard(m_CS);
@ -516,6 +525,10 @@ WPARAM CMainGui::ProcessAllMessages(void)
SetEvent(m_ResetInfo->hEvent);
m_ResetInfo = NULL;
}
if (m_CheatsUI.m_hWnd != NULL && IsDialogMessage(m_CheatsUI.m_hWnd, &msg))
{
continue;
}
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; }
TranslateMessage(&msg);
DispatchMessage(&msg);
@ -1062,7 +1075,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
}
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{
CCheatsUI().Display(hWnd);
CCheatsUI().Display(hWnd, true);
}
if (g_Rom)
@ -1091,7 +1104,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
}
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{
CCheatsUI().Display(hWnd);
CCheatsUI().Display(hWnd,true);
}
if (g_Disk)

View File

@ -13,6 +13,7 @@
#include "../Settings/GuiSettings.h"
#include <Project64/UserInterface/Debugger/debugger.h>
#include <Project64-core/Plugins/PluginClass.h>
#include <Project64\UserInterface\CheatClassUI.h>
class CGfxPlugin; //Plugin that controls the rendering
class CAudioPlugin; //Plugin for audio, need the hwnd
@ -86,6 +87,9 @@ public:
//Plugins
bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System);
//Cheats
void DisplayCheatsUI(bool BlockExecution);
//Get Window Handle
void * GetWindowHandle(void) const { return m_hMainWindow; }
void * GetStatusBar(void) const { return m_hStatusWnd; }
@ -126,6 +130,7 @@ private:
HWND m_hMainWindow, m_hStatusWnd;
DWORD m_ThreadId;
CCheatsUI m_CheatsUI;
const bool m_bMainWindow;
bool m_Created;