Merge pull request #1885 from shygoo/script-ui

[Debugger] Improve script window
This commit is contained in:
zilmar 2020-12-19 07:37:23 +10:30 committed by GitHub
commit 4a4b0b2e33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 367 additions and 215 deletions

View File

@ -13,24 +13,28 @@
#include "DebuggerUI.h"
//char* CEditEval::m_EvalString;
CDebugScripts::CDebugScripts(CDebuggerUI* debugger) :
CDebugDialog<CDebugScripts>(debugger)
CDebugDialog<CDebugScripts>(debugger),
CToolTipDialog<CDebugScripts>(),
m_SelectedScriptName(NULL),
m_hQuitScriptDirWatchEvent(NULL),
m_hScriptDirWatchThread(NULL)
{
m_SelectedScriptName = (char*)malloc(MAX_PATH);
//CScriptSystem::SetScriptsWindow(this);
}
CDebugScripts::~CDebugScripts(void)
{
free(m_SelectedScriptName);
if (m_SelectedScriptName != NULL)
{
free(m_SelectedScriptName);
}
}
LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
DlgResize_Init(false, true);
DlgSavePos_Init(DebuggerUI_ScriptsPos);
DlgToolTip_Init();
HFONT monoFont = CreateFont(-11, 0, 0, 0,
FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
@ -38,11 +42,11 @@ LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l
CLEARTYPE_QUALITY, FF_DONTCARE, L"Consolas"
);
m_InstanceInfoEdit.Attach(GetDlgItem(IDC_CTX_INFO_EDIT));
m_ScriptList.Attach(GetDlgItem(IDC_SCRIPT_LIST));
m_ScriptList.AddColumn(L"Script", 0, 0);
m_ScriptList.SetColumnWidth(0, 100);
m_ScriptList.AddColumn(L"Status", 0);
m_ScriptList.AddColumn(L"Script", 1);
m_ScriptList.SetColumnWidth(0, 16);
m_ScriptList.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
m_ScriptList.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
m_ScriptList.ModifyStyle(LVS_OWNERDRAWFIXED, 0, 0);
@ -55,61 +59,86 @@ LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l
m_ConsoleEdit.SetLimitText(0);
m_ConsoleEdit.SetFont(monoFont);
int statusPaneWidths[] = { -1 };
m_StatusBar.Attach(GetDlgItem(IDC_STATUSBAR));
m_StatusBar.SetParts(1, statusPaneWidths);
RefreshList();
LoadWindowPos();
WindowCreated();
m_hQuitScriptDirWatchEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
m_hScriptDirWatchThread = CreateThread(NULL, 0, ScriptDirWatchProc, (void*)this, 0, NULL);
return 0;
}
LRESULT CDebugScripts::OnDestroy(void)
{
SetEvent(m_hQuitScriptDirWatchEvent);
WaitForSingleObject(m_hScriptDirWatchThread, INFINITE);
CloseHandle(m_hQuitScriptDirWatchEvent);
CloseHandle(m_hScriptDirWatchThread);
return 0;
}
LRESULT CDebugScripts::OnCtlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
HDC hDC = (HDC)wParam;
HWND hCtrl = (HWND)lParam;
WORD ctrlId = (WORD) ::GetWindowLong(hCtrl, GWL_ID);
if (ctrlId == IDC_CONSOLE_EDIT)
{
SetBkColor(hDC, RGB(255, 255, 255));
SetDCBrushColor(hDC, RGB(255, 255, 255));
return (LRESULT)GetStockObject(DC_BRUSH);
}
return FALSE;
}
DWORD WINAPI CDebugScripts::ScriptDirWatchProc(void* ctx)
{
CDebugScripts* _this = (CDebugScripts*)ctx;
HANDLE hEvents[2];
hEvents[0] = FindFirstChangeNotification(L"Scripts", FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
if (hEvents[0] == INVALID_HANDLE_VALUE)
{
return 0;
}
hEvents[1] = _this->m_hQuitScriptDirWatchEvent;
while (true)
{
DWORD status = WaitForMultipleObjects(2, hEvents, FALSE, INFINITE);
switch (status)
{
case WAIT_OBJECT_0:
if (FindNextChangeNotification(hEvents[0]) == FALSE)
{
return 0;
}
_this->PostMessage(WM_REFRESH_LIST, 0, 0);
break;
case WAIT_OBJECT_0 + 1:
return 0;
default:
return 0;
}
}
}
void CDebugScripts::OnExitSizeMove(void)
{
SaveWindowPos(true);
}
void CDebugScripts::ConsolePrint(const char* text)
{
::ShowWindow(*this, SW_SHOWNOACTIVATE);
// Get scrollbar state
SCROLLINFO scroll;
scroll.cbSize = sizeof(SCROLLINFO);
scroll.fMask = SIF_ALL;
m_ConsoleEdit.GetScrollInfo(SB_VERT, &scroll);
m_ConsoleEdit.SetRedraw(FALSE);
m_ConsoleEdit.AppendText(stdstr(text).ToUTF16().c_str());
m_ConsoleEdit.SetRedraw(TRUE);
if ((scroll.nPage + scroll.nPos) - 1 == (uint32_t)scroll.nMax)
{
m_ConsoleEdit.ScrollCaret();
}
}
void CDebugScripts::RefreshConsole()
{
CGuard guard(m_CS);
m_Debugger->OpenScriptsWindow();
CScriptSystem* scriptSystem = m_Debugger->ScriptSystem();
vector<char*>* logData = scriptSystem->LogData();
while (logData->size() != 0)
{
ConsolePrint((*logData)[0]);
free((*logData)[0]);
logData->erase(logData->begin() + 0);
}
}
void CDebugScripts::ConsoleClear()
{
m_ConsoleEdit.SetWindowText(L"");
}
void CDebugScripts::ConsoleCopy()
{
if (!OpenClipboard())
@ -127,41 +156,33 @@ void CDebugScripts::ConsoleCopy()
m_ConsoleEdit.GetWindowText(memBuf, nChars);
GlobalUnlock(hMem);
SetClipboardData(CF_TEXT, hMem);
SetClipboardData(CF_UNICODETEXT, hMem);
GlobalFree(hMem);
CloseClipboard();
}
void CDebugScripts::ConsolePrint(const char* text)
{
if (m_hWnd != NULL)
{
SendMessage(WM_CONSOLE_PRINT, (WPARAM)text);
}
}
void CDebugScripts::ConsoleClear()
{
if (m_hWnd != NULL)
{
SendMessage(WM_CONSOLE_CLEAR);
}
}
void CDebugScripts::RefreshList()
{
CGuard guard(m_CS);
int nIndex = m_ScriptList.GetSelectedIndex();
CPath SearchPath("Scripts", "*");
if (!SearchPath.FindFirst(CPath::FIND_ATTRIBUTE_ALLFILES))
if (m_hWnd != NULL)
{
return;
}
m_ScriptList.SetRedraw(false);
m_ScriptList.DeleteAllItems();
do
{
stdstr scriptFileName = SearchPath.GetNameExtension();
m_ScriptList.AddItem(0, 0, scriptFileName.ToUTF16().c_str());
} while (SearchPath.FindNext());
m_ScriptList.SetRedraw(true);
m_ScriptList.Invalidate();
if (nIndex >= 0)
{
m_ScriptList.SelectItem(nIndex);
RefreshStatus();
PostMessage(WM_REFRESH_LIST);
}
}
@ -173,9 +194,11 @@ LRESULT CDebugScripts::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*
EndDialog(0);
break;
case ID_POPUP_RUN:
case IDC_RUN_BTN:
RunSelected();
break;
case ID_POPUP_STOP:
case IDC_STOP_BTN:
StopSelected();
break;
case ID_POPUP_SCRIPT_EDIT:
@ -187,6 +210,9 @@ LRESULT CDebugScripts::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*
case IDC_COPY_BTN:
ConsoleCopy();
break;
case IDC_SCRIPTDIR_BTN:
ShellExecute(NULL, L"open", L"Scripts", NULL, NULL, SW_SHOW);
break;
}
return FALSE;
}
@ -197,7 +223,10 @@ LRESULT CDebugScripts::OnScriptListDblClicked(NMHDR* pNMHDR)
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
int nItem = pIA->iItem;
m_ScriptList.SelectItem(nItem);
if (nItem == -1)
{
return 0;
}
ToggleSelected();
@ -206,66 +235,55 @@ LRESULT CDebugScripts::OnScriptListDblClicked(NMHDR* pNMHDR)
void CDebugScripts::RefreshStatus()
{
CGuard guard(m_CS);
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
char* szState = "";
switch (state)
{
case STATE_RUNNING: szState = "Running"; break;
case STATE_STARTED: szState = "Started"; break;
case STATE_STOPPED: szState = "Stopped"; break;
case STATE_INVALID: szState = "Not running"; break;
}
stdstr instanceInfo = stdstr_f("%s (%s)", m_SelectedScriptName, szState);
m_InstanceInfoEdit.SetWindowText(instanceInfo.ToUTF16().c_str());
stdstr statusText;
CPath(stdstr_f("Scripts\\%s", m_SelectedScriptName)).GetFullyQualified(statusText);
if (state == STATE_RUNNING)
{
statusText += " (Running)";
m_EvalEdit.EnableWindow(TRUE);
}
else
{
if (state == STATE_STARTED)
{
statusText += " (Started)";
}
m_EvalEdit.EnableWindow(FALSE);
}
}
LRESULT CDebugScripts::OnScriptListClicked(NMHDR* pNMHDR)
{
// Select instance for console input
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
int nItem = pIA->iItem;
wchar_t ScriptName[MAX_PATH];
m_ScriptList.GetItemText(nItem, 0, ScriptName, MAX_PATH);
strcpy(m_SelectedScriptName, stdstr().FromUTF16(ScriptName).c_str());
RefreshStatus();
return 0;
m_StatusBar.SetText(0, statusText.ToUTF16().c_str());
}
LRESULT CDebugScripts::OnScriptListRClicked(NMHDR* pNMHDR)
{
OnScriptListClicked(pNMHDR);
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
int nItem = pIA->iItem;
if (nItem == -1)
{
return 0;
}
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_SCRIPT_POPUP));
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
/*
if (m_Breakpoints->m_RBP.size() == 0 && m_Breakpoints->m_WBP.size() == 0)
if (state == STATE_STARTED || state == STATE_RUNNING)
{
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARALLBPS, MF_DISABLED | MF_GRAYED);
EnableMenuItem(hPopupMenu, ID_POPUP_RUN, MF_DISABLED | MF_GRAYED);
}
*/
else
{
EnableMenuItem(hPopupMenu, ID_POPUP_STOP, MF_DISABLED | MF_GRAYED);
}
POINT mouse;
GetCursorPos(&mouse);
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, NULL);
DestroyMenu(hMenu);
return 0;
@ -291,7 +309,7 @@ LRESULT CDebugScripts::OnScriptListCustomDraw(NMHDR* pNMHDR)
DWORD nItem = pLVCD->nmcd.dwItemSpec;
wchar_t scriptName[MAX_PATH];
m_ScriptList.GetItemText(nItem, 0, scriptName, MAX_PATH);
m_ScriptList.GetItemText(nItem, 1, scriptName, MAX_PATH);
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(stdstr("").FromUTF16(scriptName).c_str());
@ -307,6 +325,116 @@ LRESULT CDebugScripts::OnScriptListCustomDraw(NMHDR* pNMHDR)
return CDRF_DODEFAULT;
}
LRESULT CDebugScripts::OnScriptListItemChanged(NMHDR* pNMHDR)
{
NMLISTVIEW* lpStateChange = reinterpret_cast<NMLISTVIEW*>(pNMHDR);
if ((lpStateChange->uNewState ^ lpStateChange->uOldState) & LVIS_SELECTED)
{
if (lpStateChange->iItem == -1)
{
return FALSE;
}
wchar_t ScriptName[MAX_PATH];
m_ScriptList.GetItemText(lpStateChange->iItem, 1, ScriptName, MAX_PATH);
if (m_SelectedScriptName != NULL)
{
free(m_SelectedScriptName);
}
m_SelectedScriptName = strdup(stdstr().FromUTF16(ScriptName).c_str());
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
::EnableWindow(GetDlgItem(IDC_STOP_BTN), state == STATE_RUNNING || state == STATE_STARTED);
::EnableWindow(GetDlgItem(IDC_RUN_BTN), state == STATE_STOPPED || state == STATE_INVALID);
RefreshStatus();
}
return FALSE;
}
LRESULT CDebugScripts::OnConsoleLog(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
const char *text = (const char*)wParam;
::ShowWindow(*this, SW_SHOWNOACTIVATE);
SCROLLINFO scroll;
scroll.cbSize = sizeof(SCROLLINFO);
scroll.fMask = SIF_ALL;
m_ConsoleEdit.GetScrollInfo(SB_VERT, &scroll);
m_ConsoleEdit.SetRedraw(FALSE);
m_ConsoleEdit.AppendText(stdstr(text).ToUTF16().c_str());
m_ConsoleEdit.SetRedraw(TRUE);
if ((scroll.nPage + scroll.nPos) - 1 == (uint32_t)scroll.nMax)
{
m_ConsoleEdit.ScrollCaret();
}
return FALSE;
}
LRESULT CDebugScripts::OnConsoleClear(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_ConsoleEdit.SetWindowText(L"");
return FALSE;
}
LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
int nIndex = m_ScriptList.GetSelectedIndex();
CPath SearchPath("Scripts", "*");
if (!SearchPath.FindFirst(CPath::FIND_ATTRIBUTE_ALLFILES))
{
return FALSE;
}
m_ScriptList.SetRedraw(false);
m_ScriptList.DeleteAllItems();
size_t nItem = 0;
do
{
stdstr scriptFileName = SearchPath.GetNameExtension();
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(scriptFileName.c_str());
const wchar_t *statusIcon = L"";
switch (state)
{
case STATE_STARTED:
statusIcon = L"*";
break;
case STATE_RUNNING:
statusIcon = L">";
break;
default:
statusIcon = L"-";
break;
}
m_ScriptList.AddItem(nItem, 0, statusIcon);
m_ScriptList.SetItemText(nItem, 1, scriptFileName.ToUTF16().c_str());
nItem++;
} while (SearchPath.FindNext());
m_ScriptList.SetRedraw(true);
m_ScriptList.Invalidate();
if (nIndex >= 0)
{
m_ScriptList.SelectItem(nIndex);
RefreshStatus();
}
return FALSE;
}
void CDebugScripts::EvaluateInSelectedInstance(const char* code)
{
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
@ -314,11 +442,53 @@ void CDebugScripts::EvaluateInSelectedInstance(const char* code)
if (state == STATE_RUNNING || state == STATE_STARTED)
{
CScriptInstance* instance = m_Debugger->ScriptSystem()->GetInstance(m_SelectedScriptName);
//instance->EvalAsync(code);
instance->Eval(code);
}
}
void CDebugScripts::RunSelected()
{
if (m_SelectedScriptName == NULL)
{
return;
}
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
if (state == STATE_INVALID || state == STATE_STOPPED)
{
m_Debugger->ScriptSystem()->RunScript(m_SelectedScriptName);
}
else
{
m_Debugger->Debug_LogScriptsWindow("[Error: Script is already running]\n");
}
}
void CDebugScripts::StopSelected()
{
m_Debugger->ScriptSystem()->StopScript(m_SelectedScriptName);
}
void CDebugScripts::ToggleSelected()
{
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
if (state == STATE_INVALID || state == STATE_STOPPED)
{
RunSelected();
}
else
{
StopSelected();
}
}
void CDebugScripts::EditSelected()
{
ShellExecute(NULL, L"edit", stdstr(m_SelectedScriptName).ToUTF16().c_str(), NULL, L"Scripts", SW_SHOWNORMAL);
}
// Console input
LRESULT CEditEval::OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
@ -390,43 +560,3 @@ LRESULT CEditEval::OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BO
bHandled = FALSE;
return 0;
}
void CDebugScripts::RunSelected()
{
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
if (state == STATE_INVALID || state == STATE_STOPPED)
{
m_Debugger->ScriptSystem()->RunScript(m_SelectedScriptName);
}
else
{
m_Debugger->Debug_LogScriptsWindow("[Error: Script is already running]\n");
}
}
void CDebugScripts::StopSelected()
{
m_Debugger->ScriptSystem()->StopScript(m_SelectedScriptName);
//m_Debugger->Debug_RefreshScriptsWindow();
}
void CDebugScripts::ToggleSelected()
{
INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);
if (state == STATE_INVALID || state == STATE_STOPPED)
{
RunSelected();
}
else
{
StopSelected();
}
}
void CDebugScripts::EditSelected()
{
ShellExecute(NULL, L"edit", stdstr(m_SelectedScriptName).ToUTF16().c_str(), NULL, L"Scripts", SW_SHOWNORMAL);
}

View File

@ -12,6 +12,7 @@
#pragma once
#include "DebuggerUI.h"
#include "ScriptSystem.h"
#include <Project64/UserInterface/WTLControls/TooltipDialog.h>
class CScriptList : public CListViewCtrl
{
@ -49,7 +50,7 @@ public:
BEGIN_MSG_MAP_EX(CEditEval)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
END_MSG_MAP()
};
class CEditConsole : public CWindowImpl<CEditEval, CEdit>
@ -74,22 +75,37 @@ public:
BEGIN_MSG_MAP_EX(CEditEval)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
END_MSG_MAP()
END_MSG_MAP()
};
class CDebugScripts :
public CDebugDialog < CDebugScripts >,
public CDialogResize<CDebugScripts>
public CDebugDialog<CDebugScripts>,
public CDialogResize<CDebugScripts>,
public CToolTipDialog<CDebugScripts>
{
private:
CEdit m_InstanceInfoEdit;
enum {
WM_REFRESH_LIST = WM_USER + 1,
WM_CONSOLE_PRINT = WM_USER + 2,
WM_CONSOLE_CLEAR = WM_USER + 3
};
CEditEval m_EvalEdit;
CEditConsole m_ConsoleEdit;
CScriptList m_ScriptList;
CStatusBarCtrl m_StatusBar;
char* m_SelectedScriptName;
HANDLE m_hQuitScriptDirWatchEvent;
HANDLE m_hScriptDirWatchThread;
static DWORD WINAPI ScriptDirWatchProc(void *ctx);
void RunSelected();
void StopSelected();
void ToggleSelected();
void EditSelected();
void RefreshStatus();
CriticalSection m_CS;
void ConsoleCopy();
public:
enum { IDD = IDD_Debugger_Scripts };
@ -97,51 +113,62 @@ public:
CDebugScripts(CDebuggerUI * debugger);
virtual ~CDebugScripts(void);
void EvaluateInSelectedInstance(const char* code);
void ConsolePrint(const char* text);
void ConsoleClear();
void ConsoleCopy();
void RefreshList();
void RefreshConsole();
void EvaluateInSelectedInstance(const char* code);
void RunSelected();
void StopSelected();
void ToggleSelected();
void EditSelected();
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(void)
{
return 0;
}
LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(void);
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);
LRESULT OnScriptListItemChanged(NMHDR* pNMHDR);
void OnExitSizeMove(void);
LRESULT OnConsoleLog(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);
BEGIN_MSG_MAP_EX(CDebugScripts)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic)
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)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, LVN_ITEMCHANGED, OnScriptListItemChanged)
MSG_WM_DESTROY(OnDestroy)
CHAIN_MSG_MAP(CDialogResize<CDebugScripts>)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
END_MSG_MAP()
MESSAGE_HANDLER(WM_CONSOLE_PRINT, OnConsoleLog)
MESSAGE_HANDLER(WM_CONSOLE_CLEAR, OnConsoleClear)
MESSAGE_HANDLER(WM_REFRESH_LIST, OnRefreshList)
CHAIN_MSG_MAP(CDialogResize<CDebugScripts>)
CHAIN_MSG_MAP_MEMBER(m_ScriptList)
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)
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_STOP_BTN, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPTDIR_BTN, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_STATUSBAR, DLSZ_SIZE_X | DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
};
BEGIN_TOOLTIP_MAP()
TOOLTIP(IDC_CLEAR_BTN, "Clear console output")
TOOLTIP(IDC_COPY_BTN, "Copy console output to the clipboard")
TOOLTIP(IDC_RUN_BTN, "Run selected script")
TOOLTIP(IDC_STOP_BTN, "Stop selected script")
TOOLTIP(IDC_SCRIPTDIR_BTN, "Open scripts directory in file explorer")
END_TOOLTIP_MAP()
};

View File

@ -132,15 +132,6 @@ void CScriptInstance::StartScriptProc()
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &m_hThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
SetState(STATE_STARTED);
bool bWasUnpaused = false;
if (!g_Settings->LoadBool(GameRunning_CPU_Paused) && g_MMU)
{
// Pause CPU during startup phase
bWasUnpaused = true;
g_System->ExternalEvent(SysEvent_PauseCPU_AppLostFocus);
}
duk_context* ctx = m_Ctx;
duk_push_object(ctx);
@ -176,11 +167,6 @@ void CScriptInstance::StartScriptProc()
}
}
if (bWasUnpaused)
{
g_System->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus);
}
if (HaveEvents())
{
StartEventLoop();

View File

@ -821,17 +821,23 @@ BEGIN
LTEXT "CPU Floating Point Registers (COP1)",IDC_STATIC,3,4,119,8
END
IDD_Debugger_Scripts DIALOGEX 0, 0, 337, 170
IDD_Debugger_Scripts DIALOGEX 0, 0, 421, 216
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Scripts"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_CONSOLE_EDIT,101,17,231,133,ES_MULTILINE | ES_AUTOHSCROLL | WS_VSCROLL
EDITTEXT IDC_EVAL_EDIT,5,153,327,12,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN
CONTROL "",IDC_SCRIPT_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,5,4,94,146
EDITTEXT IDC_CTX_INFO_EDIT,101,4,172,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Clear",IDC_CLEAR_BTN,304,4,29,12
PUSHBUTTON "Copy",IDC_COPY_BTN,274,4,29,12
EDITTEXT IDC_CONSOLE_EDIT,136,15,274,147,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
EDITTEXT IDC_EVAL_EDIT,28,186,386,12,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN
CONTROL "",IDC_SCRIPT_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,13,15,106,147
PUSHBUTTON "Clear",IDC_CLEAR_BTN,373,165,37,13
PUSHBUTTON "Copy",IDC_COPY_BTN,333,165,37,13
LTEXT "Eval:",IDC_EVAL_LBL,7,187,18,8
GROUPBOX "Scripts",IDC_SCRIPTS_GRP,7,5,118,177,0,WS_EX_TRANSPARENT
GROUPBOX "Output",IDC_OUTPUT_GRP,129,5,285,177,0,WS_EX_TRANSPARENT
CONTROL "",IDC_STATUSBAR,"msctls_statusbar32",WS_TABSTOP,0,205,420,11
PUSHBUTTON "...",IDC_SCRIPTDIR_BTN,13,165,21,13
PUSHBUTTON "Run",IDC_RUN_BTN,43,165,37,13,WS_DISABLED
PUSHBUTTON "Stop",IDC_STOP_BTN,83,165,37,13,WS_DISABLED
END
IDD_Debugger_RegPI DIALOGEX 0, 0, 190, 210
@ -1648,10 +1654,8 @@ BEGIN
IDD_Debugger_Scripts, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 330
TOPMARGIN, 7
BOTTOMMARGIN, 163
RIGHTMARGIN, 379
BOTTOMMARGIN, 214
END
IDD_Debugger_RegPI, DIALOG

View File

@ -362,7 +362,6 @@
#define IDC_HI_EDIT 1183
#define IDC_LO_EDIT 1184
#define IDC_BP_LIST 1185
#define IDC_CTX_INFO_EDIT 1185
#define IDC_ADDBP_BTN 1186
#define IDC_REMOVESYMBOL_BTN 1186
#define IDC_RMBP_BTN 1187
@ -453,8 +452,11 @@
#define IDC_CLEAR_BTN 1302
#define IDC_DMA_RAM_EDIT 1303
#define IDC_COPY_BTN 1303
#define IDC_SCRIPTDIR_BTN 1304
#define IDC_EXPORT_BTN 1305
#define IDC_RUN_BTN 1305
#define IDC_DMA_ROM_EDIT 1306
#define IDC_STOP_BTN 1306
#define IDC_TRACE_STATIC 1307
#define IDC_RAM_STATIC 1308
#define IDC_ROM_STATIC 1309
@ -701,8 +703,11 @@
#define IDC_F2_LBL 1577
#define IDC_EMAIL 1577
#define IDC_F3_LBL 1578
#define IDC_SCRIPTS_GRP 1578
#define IDC_F4_LBL 1579
#define IDC_OUTPUT_GRP 1579
#define IDC_F5_LBL 1580
#define IDC_EVAL_LBL 1580
#define IDC_F6_LBL 1581
#define IDC_F7_LBL 1582
#define IDC_F8_LBL 1583