project64/Source/Project64/UserInterface/Debugger/Debugger-Scripts.h

147 lines
4.4 KiB
C
Raw Normal View History

2017-08-18 05:08:22 +00:00
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#include "DebuggerUI.h"
#include "ScriptSystem.h"
class CScriptList : public CListViewCtrl
{
public:
2017-09-13 10:36:03 +00:00
BEGIN_MSG_MAP_EX(CScriptList)
END_MSG_MAP()
2017-08-18 05:08:22 +00:00
};
class CEditEval : public CWindowImpl<CEditEval, CEdit>
{
private:
2017-09-13 10:36:03 +00:00
//static char* m_EvalString;
static const int HISTORY_MAX_ENTRIES = 20;
2020-05-12 12:19:05 +00:00
vector<wchar_t*> m_History;
2017-09-13 10:36:03 +00:00
int m_HistoryIdx;
CDebugScripts* m_ScriptWindow;
2017-08-18 05:08:22 +00:00
public:
2017-09-13 10:36:03 +00:00
CEditEval()
{
m_HistoryIdx = 0;
}
void SetScriptWindow(CDebugScripts* scriptWindow)
{
m_ScriptWindow = scriptWindow;
}
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
BOOL Attach(HWND hWndNew)
{
return SubclassWindow(hWndNew);
}
BEGIN_MSG_MAP_EX(CEditEval)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
2017-08-18 05:08:22 +00:00
};
class CEditConsole : public CWindowImpl<CEditEval, CEdit>
{
private:
LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
2017-09-13 10:36:03 +00:00
{
if (GetKeyState(VK_CONTROL) < 0)
{
if (wParam == 'A')
{
this->SetSelAll();
}
}
return FALSE;
}
2017-08-18 05:08:22 +00:00
public:
2017-09-13 10:36:03 +00:00
BOOL Attach(HWND hWndNew)
{
return SubclassWindow(hWndNew);
}
BEGIN_MSG_MAP_EX(CEditEval)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
2017-08-18 05:08:22 +00:00
};
class CDebugScripts :
2017-09-13 10:36:03 +00:00
public CDebugDialog < CDebugScripts >,
public CDialogResize<CDebugScripts>
2017-08-18 05:08:22 +00:00
{
private:
2017-09-13 10:36:03 +00:00
CEdit m_InstanceInfoEdit;
CEditEval m_EvalEdit;
CEditConsole m_ConsoleEdit;
CScriptList m_ScriptList;
char* m_SelectedScriptName;
2017-08-18 05:08:22 +00:00
2017-09-13 10:36:03 +00:00
void RefreshStatus();
2019-12-25 00:41:20 +00:00
CriticalSection m_CS;
2017-08-18 05:08:22 +00:00
public:
2017-09-13 10:36:03 +00:00
enum { IDD = IDD_Debugger_Scripts };
CDebugScripts(CDebuggerUI * debugger);
virtual ~CDebugScripts(void);
void ConsolePrint(const char* text);
void ConsoleClear();
void ConsoleCopy();
void RefreshList();
void RefreshConsole();
2020-05-12 12:19:05 +00:00
void EvaluateInSelectedInstance(const char* code);
2017-09-13 10:36:03 +00:00
void RunSelected();
void StopSelected();
2020-01-07 03:43:09 +00:00
void ToggleSelected();
void EditSelected();
2017-09-13 10:36:03 +00:00
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(void)
{
return 0;
}
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnScriptListDblClicked(NMHDR* pNMHDR);
LRESULT OnScriptListClicked(NMHDR* pNMHDR);
LRESULT OnScriptListRClicked(NMHDR* pNMHDR);
LRESULT OnScriptListCustomDraw(NMHDR* pNMHDR);
void OnExitSizeMove(void);
2017-09-13 10:36:03 +00:00
BEGIN_MSG_MAP_EX(CDebugScripts)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_DBLCLK, OnScriptListDblClicked)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_CLICK, OnScriptListClicked)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_RCLICK, OnScriptListRClicked)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_CUSTOMDRAW, OnScriptListCustomDraw)
CHAIN_MSG_MAP_MEMBER(m_ScriptList)
MSG_WM_DESTROY(OnDestroy)
CHAIN_MSG_MAP(CDialogResize<CDebugScripts>)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
2017-09-13 10:36:03 +00:00
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugScripts)
DLGRESIZE_CONTROL(IDC_CTX_INFO_EDIT, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_EVAL_EDIT, DLSZ_SIZE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_CONSOLE_EDIT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPT_LIST, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_CLEAR_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_COPY_BTN, DLSZ_MOVE_X)
END_DLGRESIZE_MAP()
2017-08-18 05:08:22 +00:00
};