2017-08-18 05:08:22 +00:00
|
|
|
#pragma once
|
2022-09-26 02:31:54 +00:00
|
|
|
#include "Debugger-ScriptsAutorun.h"
|
2017-08-18 05:08:22 +00:00
|
|
|
#include "DebuggerUI.h"
|
|
|
|
#include "ScriptSystem.h"
|
2021-09-03 05:11:04 +00:00
|
|
|
#include <Project64/UserInterface/WTLControls/EditConInput.h>
|
2020-12-18 20:15:16 +00:00
|
|
|
#include <Project64/UserInterface/WTLControls/TooltipDialog.h>
|
2021-01-19 05:58:59 +00:00
|
|
|
#include <string>
|
2021-04-20 02:56:16 +00:00
|
|
|
#include <vector>
|
2017-08-18 05:08:22 +00:00
|
|
|
|
|
|
|
class CDebugScripts :
|
2020-12-18 20:15:16 +00:00
|
|
|
public CDebugDialog<CDebugScripts>,
|
|
|
|
public CDialogResize<CDebugScripts>,
|
|
|
|
public CToolTipDialog<CDebugScripts>
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
|
|
|
private:
|
2022-09-26 02:31:54 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-12-18 19:57:50 +00:00
|
|
|
WM_REFRESH_LIST = WM_USER + 1,
|
2021-09-03 05:11:04 +00:00
|
|
|
WM_SCRIPT_STATUS = WM_USER + 2,
|
|
|
|
WM_CONSOLE_PRINT = WM_USER + 3,
|
|
|
|
WM_CONSOLE_CLEAR = WM_USER + 4
|
|
|
|
};
|
|
|
|
|
2022-09-26 02:31:54 +00:00
|
|
|
enum
|
|
|
|
{
|
2021-09-03 05:11:04 +00:00
|
|
|
CONFLUSH_TIMER_ID = 0,
|
|
|
|
CONFLUSH_TIMER_INTERVAL = 50
|
2020-12-18 19:57:50 +00:00
|
|
|
};
|
|
|
|
|
2021-09-03 05:11:04 +00:00
|
|
|
CScriptsAutorunDlg m_AutorunDlg;
|
|
|
|
|
|
|
|
CEditConInput m_ConInputEdit;
|
|
|
|
CEditConOutput m_ConOutputEdit;
|
|
|
|
CListViewCtrl m_ScriptList;
|
2020-12-18 19:57:50 +00:00
|
|
|
CStatusBarCtrl m_StatusBar;
|
2021-09-03 05:11:04 +00:00
|
|
|
|
|
|
|
HFONT m_MonoFont, m_MonoBoldFont;
|
|
|
|
|
2021-08-08 10:58:54 +00:00
|
|
|
stdstr m_InstallDir;
|
|
|
|
stdstr m_ScriptsDir;
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-09-03 05:11:04 +00:00
|
|
|
stdstr m_SelectedScriptName;
|
2022-09-26 02:31:54 +00:00
|
|
|
std::vector<wchar_t *> m_InputHistory;
|
2021-09-03 05:11:04 +00:00
|
|
|
size_t m_InputHistoryIndex;
|
|
|
|
|
|
|
|
stdstr m_ConOutputBuffer;
|
|
|
|
|
2020-12-18 19:57:50 +00:00
|
|
|
HANDLE m_hQuitScriptDirWatchEvent;
|
|
|
|
HANDLE m_hScriptDirWatchThread;
|
2022-09-26 02:31:54 +00:00
|
|
|
static DWORD WINAPI ScriptDirWatchProc(void * ctx);
|
2020-12-18 19:57:50 +00:00
|
|
|
|
|
|
|
void RunSelected();
|
|
|
|
void StopSelected();
|
|
|
|
void ToggleSelected();
|
|
|
|
void EditSelected();
|
2017-09-13 10:36:03 +00:00
|
|
|
void RefreshStatus();
|
2020-12-18 19:57:50 +00:00
|
|
|
void ConsoleCopy();
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2022-09-26 02:31:54 +00:00
|
|
|
void SendInput(const char * name, const char * code);
|
2021-09-03 05:11:04 +00:00
|
|
|
|
2017-08-18 05:08:22 +00:00
|
|
|
public:
|
2022-09-26 02:31:54 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IDD = IDD_Debugger_Scripts
|
|
|
|
};
|
2017-09-13 10:36:03 +00:00
|
|
|
|
|
|
|
CDebugScripts(CDebuggerUI * debugger);
|
|
|
|
virtual ~CDebugScripts(void);
|
|
|
|
|
2022-09-26 02:31:54 +00:00
|
|
|
void ConsolePrint(const char * text);
|
2017-09-13 10:36:03 +00:00
|
|
|
void ConsoleClear();
|
|
|
|
void RefreshList();
|
|
|
|
|
2022-09-26 02:31:54 +00:00
|
|
|
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
|
|
|
|
LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
|
|
|
|
LRESULT OnCtlColorEdit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
|
2020-12-18 19:57:50 +00:00
|
|
|
LRESULT OnDestroy(void);
|
2022-09-26 02:31:54 +00:00
|
|
|
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
|
|
|
|
LRESULT OnScriptListDblClicked(NMHDR * pNMHDR);
|
|
|
|
LRESULT OnScriptListRClicked(NMHDR * pNMHDR);
|
|
|
|
LRESULT OnScriptListCustomDraw(NMHDR * pNMHDR);
|
|
|
|
LRESULT OnScriptListItemChanged(NMHDR * pNMHDR);
|
|
|
|
LRESULT OnInputSpecialKey(NMHDR * pNMHDR);
|
2019-01-14 05:52:11 +00:00
|
|
|
void OnExitSizeMove(void);
|
2021-09-03 05:11:04 +00:00
|
|
|
void OnTimer(UINT_PTR nIDEvent);
|
2017-09-13 10:36:03 +00:00
|
|
|
|
2022-09-26 02:31:54 +00:00
|
|
|
LRESULT OnConsolePrint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
|
|
|
|
LRESULT OnConsoleClear(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
|
|
|
|
LRESULT OnRefreshList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
|
2020-12-18 19:57:50 +00:00
|
|
|
|
2017-09-13 10:36:03 +00:00
|
|
|
BEGIN_MSG_MAP_EX(CDebugScripts)
|
2022-09-26 02:31:54 +00:00
|
|
|
{
|
|
|
|
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
|
|
|
|
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
|
|
|
|
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic);
|
|
|
|
MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit);
|
|
|
|
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_DBLCLK, OnScriptListDblClicked);
|
|
|
|
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_RCLICK, OnScriptListRClicked);
|
|
|
|
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_CUSTOMDRAW, OnScriptListCustomDraw);
|
|
|
|
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, LVN_ITEMCHANGED, OnScriptListItemChanged);
|
|
|
|
NOTIFY_HANDLER_EX(IDC_EVAL_EDIT, CIN_SPECIALKEY, OnInputSpecialKey);
|
|
|
|
MSG_WM_TIMER(OnTimer);
|
|
|
|
MSG_WM_DESTROY(OnDestroy);
|
2019-01-14 05:52:11 +00:00
|
|
|
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
|
2022-09-26 02:31:54 +00:00
|
|
|
MESSAGE_HANDLER(WM_CONSOLE_PRINT, OnConsolePrint);
|
|
|
|
MESSAGE_HANDLER(WM_CONSOLE_CLEAR, OnConsoleClear);
|
|
|
|
MESSAGE_HANDLER(WM_REFRESH_LIST, OnRefreshList);
|
|
|
|
CHAIN_MSG_MAP(CDialogResize<CDebugScripts>);
|
|
|
|
}
|
2020-12-18 19:57:50 +00:00
|
|
|
END_MSG_MAP()
|
2017-09-13 10:36:03 +00:00
|
|
|
|
|
|
|
BEGIN_DLGRESIZE_MAP(CDebugScripts)
|
2022-09-26 02:31:54 +00:00
|
|
|
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 | DLSZ_MOVE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_COPY_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_SCRIPTS_GRP, DLSZ_SIZE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_OUTPUT_GRP, DLSZ_SIZE_X | DLSZ_SIZE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_EVAL_LBL, DLSZ_MOVE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_EVAL_EDIT, DLSZ_SIZE_X | DLSZ_MOVE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_RUN_BTN, DLSZ_MOVE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_SCRIPTDIR_BTN, DLSZ_MOVE_Y)
|
|
|
|
DLGRESIZE_CONTROL(IDC_STATUSBAR, DLSZ_SIZE_X | DLSZ_MOVE_Y)
|
2017-09-13 10:36:03 +00:00
|
|
|
END_DLGRESIZE_MAP()
|
2020-12-18 20:15:16 +00:00
|
|
|
|
|
|
|
BEGIN_TOOLTIP_MAP()
|
2022-09-26 02:31:54 +00:00
|
|
|
TOOLTIP(IDC_CLEAR_BTN, "Clear console output")
|
|
|
|
TOOLTIP(IDC_COPY_BTN, "Copy console output to the clipboard")
|
|
|
|
TOOLTIP(IDC_RUN_BTN, "Toggle selected script")
|
|
|
|
TOOLTIP(IDC_SCRIPTDIR_BTN, "Open scripts directory in file explorer")
|
2020-12-18 20:15:16 +00:00
|
|
|
END_TOOLTIP_MAP()
|
2020-12-18 19:57:50 +00:00
|
|
|
};
|