29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/debugger_resource.h"
34 #include "../Common/OpenFileDialog.h"
38 #define DEBUGGERWINDOWCLASS "QUAKE4_DEBUGGER_WINDOW"
39 #define ID_DBG_WINDOWMIN 18900
40 #define ID_DBG_WINDOWMAX 19900
42 #define IDC_DBG_SCRIPT 31000
43 #define IDC_DBG_OUTPUT 31001
44 #define IDC_DBG_SPLITTER 31002
45 #define IDC_DBG_TABS 31003
46 #define IDC_DBG_BORDER 31004
47 #define IDC_DBG_CONSOLE 31005
48 #define IDC_DBG_CALLSTACK 31006
49 #define IDC_DBG_WATCH 31007
50 #define IDC_DBG_THREADS 31008
51 #define IDC_DBG_TOOLBAR 31009
53 #define ID_DBG_FILE_MRU1 10000
92 DestroyWindow (
mWnd );
118 wcex.cbSize =
sizeof(WNDCLASSEX);
120 wcex.style = CS_HREDRAW | CS_VREDRAW;
121 wcex.lpfnWndProc = (WNDPROC)
WndProc;
126 wcex.hCursor = LoadCursor(
NULL, IDC_ARROW);
127 wcex.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1);
132 return RegisterClassEx(&wcex) ?
true :
false;
170 Printf (
"Quake 4 Script Debugger v0.1\n\n" );
172 ShowWindow (
mWnd, SW_SHOW );
173 UpdateWindow (
mWnd );
189 static TCHAR delimiters[]=TEXT(
"!@#$%^&*()-+=[]{}|\\;:'\"/,.<>? \t\r\n") ;
197 return _tcschr ( delimiters, *(text + current * 2) ) ?
TRUE :
FALSE;
199 case WB_MOVEWORDLEFT:
205 while ( current > 0 )
209 if ( _tcschr ( delimiters, *(text + current * 2) ) )
220 case WB_MOVEWORDRIGHT:
224 if ( _tcschr ( delimiters, *(text + current * 2) ) )
230 while ( current < max )
233 if ( _tcschr ( delimiters, *(text + current * 2) ) )
249 static int lastStart = -1;
250 static int lastEnd = -1;
257 return SendMessage ( wnd, WM_LBUTTONUP, wparam, lparam );
261 POINT point = { LOWORD(lparam), HIWORD(lparam) };
263 SendMessage ( wnd, WM_LBUTTONDOWN, wparam, lparam );
265 ClientToScreen ( wnd, &point );
266 TrackPopupMenu ( GetSubMenu( menu, 0 ), TPM_RIGHTBUTTON|TPM_LEFTALIGN, point.
x, point.
y, 0, window->
mWnd,
NULL );
267 DestroyMenu ( menu );
274 POINTL pos = {LOWORD(lparam),HIWORD(lparam)};
275 int c = SendMessage ( wnd, EM_CHARFROMPOS, 0, (WPARAM)&pos );
276 int start = SendMessage ( wnd, EM_FINDWORDBREAK, WB_LEFT, c );
277 int end = SendMessage ( wnd, EM_FINDWORDBREAK, WB_RIGHT, c );
281 if ( lastStart == start && lastEnd == end )
294 ti.cbSize =
sizeof(TOOLINFO);
311 char* temp =
new char[end-start+10];
312 range.chrg.cpMin =
start;
313 range.chrg.cpMax =
end;
314 range.lpstrText = temp;
315 SendMessage ( wnd, EM_GETTEXTRANGE, 0, (
LPARAM) &range );
323 ti.cbSize =
sizeof(TOOLINFO);
324 ti.uFlags = TTF_SUBCLASS;
326 ti.hinst = (HINSTANCE)GetModuleHandle(
NULL);
334 SendMessage ( wnd, EM_POSFROMCHAR, (WPARAM)&pos, start );
335 ti.rect.left = pos.x;
337 SendMessage ( wnd, EM_POSFROMCHAR, (WPARAM)&pos, end );
338 ti.rect.right = pos.x;
339 SendMessage ( wnd, EM_POSFROMCHAR, (WPARAM)&pos, SendMessage ( wnd, EM_LINEINDEX, 0, 0 ) );
340 ti.rect.bottom = ti.rect.top - pos.y;
341 SendMessage ( wnd, EM_POSFROMCHAR, (WPARAM)&pos, SendMessage ( wnd, EM_LINEINDEX, 1, 0 ) );
342 ti.rect.bottom = ti.rect.bottom + pos.y;
352 return CallWindowProc ( wndproc, wnd, msg, wparam, lparam );
362 return SendMessage ( window->
mWndScript, WM_RBUTTONDOWN, wparam, lparam );
365 return SendMessage ( window->
mWndScript, WM_RBUTTONUP, wparam, lparam );
367 case WM_LBUTTONDBLCLK:
369 int result = SendMessage ( window->
mWndScript, WM_LBUTTONDBLCLK, wparam, lparam );
376 int result = SendMessage ( window->
mWndScript, WM_LBUTTONDOWN, wparam, lparam );
382 return SendMessage ( window->
mWndScript, WM_LBUTTONUP, wparam, lparam );
392 GetClientRect ( wnd, &rect );
393 dc = BeginPaint ( wnd, &ps );
394 FillRect ( dc, &rect, GetSysColorBrush ( COLOR_3DFACE ) );
409 SendMessage ( window->
mWndScript, EM_POSFROMCHAR, (WPARAM)&pos, c );
410 ImageList_DrawEx ( window->
mImageList, 2, dc, rect.left, pos.y, size, size, CLR_NONE, CLR_NONE, ILD_NORMAL );
423 SendMessage ( window->
mWndScript, EM_POSFROMCHAR, (WPARAM)&pos, c );
424 ImageList_DrawEx ( window->
mImageList, 3, dc, rect.left, pos.y, size, size, CLR_NONE, CLR_NONE, ILD_NORMAL );
436 SendMessage ( window->
mWndScript, EM_POSFROMCHAR, (WPARAM)&pos, c );
437 ImageList_DrawEx ( window->
mImageList, 1, dc, rect.left, pos.y, size, size, CLR_NONE, CLR_NONE, ILD_NORMAL );
443 rect.left = rect.right + 1;
444 HPEN pen = CreatePen ( PS_SOLID, 1, GetSysColor ( COLOR_3DSHADOW ) );
445 HPEN old = (HPEN)SelectObject ( dc, pen );
446 MoveToEx ( dc, rect.right, rect.top,
NULL );
447 LineTo ( dc, rect.right, rect.bottom );
448 SelectObject ( dc, old );
449 DeleteObject ( pen );
450 EndPaint ( wnd, &ps );
455 return DefWindowProc ( wnd, msg, wparam, lparam );
469 title =
"Quake 4 Script Debugger - ";
484 title +=
"[disconnected]";
494 SetWindowText (
mWnd, title );
576 ZeroMemory ( &item,
sizeof(item) );
577 item.mask = LVIF_TEXT|LVIF_IMAGE;
624 int cMenuItems = GetMenuItemCount((HMENU)wParam);
630 hmenu = (HMENU) wParam;
634 for (nPos = 0; nPos < cMenuItems; nPos++)
636 id = GetMenuItemID(hmenu, nPos);
642 HMENU sub = GetSubMenu ( hmenu, nPos );
655 CheckMenuItem ( hmenu, nPos, MF_BYPOSITION|MF_CHECKED );
659 CheckMenuItem ( hmenu, nPos, MF_BYPOSITION|MF_UNCHECKED );
672 info.cbSize =
sizeof(info);
673 info.fMask = MIIM_TYPE|MIIM_STATE;
674 info.fType = MFT_STRING;
679 info.fState = MFS_ENABLED;
687 info.dwTypeData = (LPSTR)run.
c_str();
688 info.cch = run.
Length ( );
690 SendMessage (
mWndToolbar, TB_ENABLEBUTTON,
id, MAKELONG(((info.fState==MFS_ENABLED) ?
TRUE :
FALSE), 0) );
692 SetMenuItemInfo ( hmenu,
id, FALSE, &info );
700 EnableMenuItem ( hmenu, nPos, MF_GRAYED|MF_BYPOSITION);
705 EnableMenuItem ( hmenu, nPos, MF_ENABLED|MF_BYPOSITION);
718 EnableMenuItem ( hmenu, nPos, MF_GRAYED|MF_BYPOSITION );
723 EnableMenuItem ( hmenu, nPos, MF_ENABLED|MF_BYPOSITION );
732 EnableMenuItem ( hmenu, nPos, (
mScripts.
Num()?MF_ENABLED:MF_GRAYED)|MF_BYPOSITION);
761 LoadLibrary (
"Riched20.dll" );
762 mWndScript = CreateWindow (
"RichEdit20A",
"", WS_CHILD|WS_BORDER|ES_NOHIDESEL|ES_READONLY|ES_MULTILINE|ES_WANTRETURN|ES_AUTOVSCROLL|ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL, 0, 0, 100, 100,
mWnd, (HMENU)
IDC_DBG_SCRIPT,
mInstance, 0 );
763 SendMessage (
mWndScript, EM_SETEVENTMASK, 0, ENM_SCROLL|ENM_CHANGE );
772 GetTextMetrics ( dc, &tm );
773 ZeroMemory ( &lf,
sizeof(lf) );
774 lf.lfHeight = tm.tmHeight;
775 strcpy ( lf.lfFaceName,
"Courier New" );
777 SendMessage (
mWndScript, WM_SETFONT, (WPARAM)CreateFontIndirect ( &lf ), 0 );
778 SendMessage (
mWndScript, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(18,10) );
779 SendMessage (
mWndScript, EM_SETBKGNDCOLOR, 0, GetSysColor ( COLOR_3DFACE ) );
781 mWndOutput = CreateWindow (
"RichEdit20A",
"", WS_CHILD|ES_READONLY|ES_MULTILINE|ES_WANTRETURN|ES_AUTOVSCROLL|ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE, 0, 0, 100, 100,
mWnd, (HMENU)
IDC_DBG_OUTPUT,
mInstance, 0 );
782 SendMessage (
mWndOutput, WM_SETFONT, (WPARAM)CreateFontIndirect ( &lf ), 0 );
783 SendMessage (
mWndOutput, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(18,10) );
784 SendMessage (
mWndOutput, EM_SETBKGNDCOLOR, 0, GetSysColor ( COLOR_3DFACE ) );
786 mWndConsole = CreateWindow (
"RichEdit20A",
"", WS_CHILD|ES_READONLY|ES_MULTILINE|ES_WANTRETURN|ES_AUTOVSCROLL|ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL, 0, 0, 100, 100,
mWnd, (HMENU)
IDC_DBG_CONSOLE,
mInstance, 0 );
787 SendMessage (
mWndConsole, WM_SETFONT, (WPARAM)CreateFontIndirect ( &lf ), 0 );
788 SendMessage (
mWndConsole, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(18,10) );
789 SendMessage (
mWndConsole, EM_SETBKGNDCOLOR, 0, GetSysColor ( COLOR_3DFACE ) );
791 mWndMargin = CreateWindow (
"STATIC",
"", WS_VISIBLE|WS_CHILD, 0, 0, 0, 0,
mWndScript, (HMENU)
IDC_DBG_SPLITTER,
mInstance,
NULL );
795 mWndBorder = CreateWindow (
"STATIC",
"", WS_VISIBLE|WS_CHILD|SS_GRAYFRAME, 0, 0, 0, 0,
mWnd, (HMENU)
IDC_DBG_BORDER,
mInstance,
NULL );
801 mWndTabs = CreateWindow ( WC_TABCONTROL,
"", TCS_BOTTOM|WS_CHILD|WS_VISIBLE|TCS_FOCUSNEVER, 0, 0, 0, 0,
mWnd, (HMENU)
IDC_DBG_TABS,
mInstance,
NULL );
802 lf.lfHeight = -MulDiv(8, GetDeviceCaps(dc, LOGPIXELSY), 72);
803 strcpy ( lf.lfFaceName,
"Arial" );
804 SendMessage (
mWndTabs, WM_SETFONT, (WPARAM)CreateFontIndirect ( &lf ), 0 );
808 item.mask = TCIF_TEXT;
809 item.pszText =
"Output";
810 TabCtrl_InsertItem (
mWndTabs, 0, &item );
811 item.pszText =
"Console";
812 TabCtrl_InsertItem (
mWndTabs, 1, &item );
813 item.pszText =
"Call Stack";
814 TabCtrl_InsertItem (
mWndTabs, 2, &item );
815 item.pszText =
"Watch";
816 TabCtrl_InsertItem (
mWndTabs, 3, &item );
817 item.pszText =
"Threads";
818 TabCtrl_InsertItem (
mWndTabs, 4, &item );
820 mWndCallstack = CreateWindow ( WC_LISTVIEW,
"", LVS_REPORT|WS_CHILD|LVS_SHAREIMAGELISTS, 0, 0, 0, 0,
mWnd, (HMENU)
IDC_DBG_CALLSTACK,
mInstance,
NULL );
821 mWndWatch = CreateWindow ( WC_LISTVIEW,
"", LVS_REPORT|WS_CHILD|LVS_EDITLABELS|LVS_OWNERDRAWFIXED, 0, 0, 0, 0,
mWnd, (HMENU)
IDC_DBG_WATCH,
mInstance,
NULL );
822 mWndThreads = CreateWindow ( WC_LISTVIEW,
"", LVS_REPORT|WS_CHILD|LVS_SHAREIMAGELISTS, 0, 0, 0, 0,
mWnd, (HMENU)
IDC_DBG_THREADS,
mInstance,
NULL );
825 col.mask = LVCF_WIDTH|LVCF_TEXT;
830 col.pszText =
"Function";
833 col.pszText =
"Line";
836 col.pszText =
"Filename";
846 col.pszText =
"Name";
849 col.pszText =
"State";
853 col.pszText =
"Name";
854 ListView_InsertColumn (
mWndWatch, 0, &col );
856 col.pszText =
"Value";
857 ListView_InsertColumn (
mWndWatch, 1, &col );
861 mImageList = ImageList_Create ( 16, 16, ILC_COLOR|ILC_MASK, 0, 2 );
871 ListView_SetExtendedListViewStyle (
mWndCallstack, LVS_EX_FULLROWSELECT );
872 ListView_SetExtendedListViewStyle (
mWndThreads, LVS_EX_FULLROWSELECT );
881 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
892 SendMessage (
mWndToolTips, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELONG(400,0) );
893 SendMessage (
mWndToolTips, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(400,0) );
895 SetWindowPos(
mWndToolTips, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
900 lvItem.mask = LVIF_TEXT;
902 ListView_InsertItem (
mWndWatch, &lvItem );
903 ListView_SetExtendedListViewStyle (
mWndWatch, LVS_EX_FULLROWSELECT );
912 for ( i = 0; ; i ++ )
935 int event = HIWORD(wparam);
936 int id = LOWORD(wparam);
953 MessageBox (
mWnd,
va(
"Failed to open script '%s'", filename.
c_str() ),
"Quake 4 Script Debugger", MB_OK );
1016 char exeFile[MAX_PATH];
1017 char curDir[MAX_PATH];
1019 STARTUPINFO startup;
1020 PROCESS_INFORMATION process;
1022 ZeroMemory ( &startup,
sizeof(startup) );
1023 startup.cb =
sizeof(startup);
1025 GetCurrentDirectory ( MAX_PATH, curDir );
1027 GetModuleFileName (
NULL, exeFile, MAX_PATH );
1029 CreateProcess (
NULL, (LPSTR)s,
1032 CloseHandle ( process.hThread );
1033 CloseHandle ( process.hProcess );
1058 SendMessage (
mWnd, WM_SIZE, 0, MAKELPARAM(t.right-t.left,t.bottom-t.top) );
1072 PostMessage (
mWnd, WM_CLOSE, 0, 0 );
1106 dlg.
SetFilter (
"*.script; *.gui; *.state" );
1112 MessageBox (
mWnd,
va(
"Failed to open script '%s'",dlg.
GetFilename ( )),
"Quake 4 Script Debugger", MB_OK );
1160 case WM_INITMENUPOPUP:
1179 SetWindowLong ( wnd, GWL_USERDATA, 0 );
1193 GetCursorPos ( &point );
1194 ScreenToClient ( wnd, &point );
1197 SetCursor ( LoadCursor (
NULL, IDC_SIZENS ) );
1210 SendMessage ( window->
mWndToolbar, TB_AUTOSIZE, 0, 0 );
1212 MoveWindow ( window->
mWndScript, 0, rect.bottom-rect.top, LOWORD(lparam), window->
mSplitterRect.top-(rect.bottom-rect.top),
TRUE );
1215 SetRect ( &rect, 0, window->
mSplitterRect.bottom, LOWORD(lparam), HIWORD(lparam) );
1216 MoveWindow ( window->
mWndTabs, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1219 MoveWindow ( window->
mWndBorder, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1220 InflateRect ( &rect, -1, -1 );
1221 MoveWindow ( window->
mWndOutput, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1222 MoveWindow ( window->
mWndConsole, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1223 MoveWindow ( window->
mWndCallstack, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1224 MoveWindow ( window->
mWndWatch, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1225 MoveWindow ( window->
mWndThreads, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
TRUE );
1232 HDC dc = BeginPaint ( wnd, &ps );
1233 FillRect ( dc, &window->
mSplitterRect, GetSysColorBrush ( COLOR_3DFACE ) );
1238 GetClientRect ( wnd, &rect );
1240 FillRect ( dc, &rect, GetSysColorBrush ( COLOR_APPWORKSPACE ) );
1243 EndPaint ( wnd, &ps );
1247 case WM_LBUTTONDOWN:
1249 POINT pt = { LOWORD(lparam),HIWORD(lparam) };
1255 HDC dc = GetDC ( wnd );
1257 ReleaseDC ( wnd, dc );
1265 HDC dc = GetDC ( wnd );
1267 ReleaseDC ( wnd, dc );
1272 GetClientRect ( wnd, &client );
1273 SendMessage ( wnd, WM_SIZE, 0, MAKELPARAM(client.right-client.left,client.bottom-client.top) );
1275 InvalidateRect ( wnd,
NULL,
TRUE );
1285 HDC dc = GetDC ( wnd );
1287 ReleaseDC ( wnd, dc );
1289 if ( GetCapture ( ) != wnd )
1295 GetClientRect ( wnd, &client );
1310 ReleaseDC ( wnd, dc );
1321 CREATESTRUCT* cs = (CREATESTRUCT*) lparam;
1323 SetWindowLong ( wnd, GWL_USERDATA, (
LONG)cs->lpCreateParams );
1338 hdr = (NMHDR*)lparam;
1341 if ( hdr->code == TTN_GETDISPINFO )
1347 switch ( hdr->idFrom )
1350 switch ( hdr->code )
1354 NMLVKEYDOWN* key = (NMLVKEYDOWN*) hdr;
1355 switch ( key->wVKey )
1359 int sel = ListView_GetNextItem ( hdr->hwndFrom, -1, LVNI_SELECTED );
1360 if ( sel != -1 && sel != ListView_GetItemCount ( hdr->hwndFrom ) - 1 )
1364 item.mask = LVIF_PARAM;
1365 ListView_GetItem ( hdr->hwndFrom, &item );
1366 ListView_DeleteItem ( hdr->hwndFrom, sel );
1371 ListView_SetItemState ( hdr->hwndFrom,
1373 LVIS_SELECTED, LVIS_SELECTED );
1375 if ( ListView_GetNextItem ( hdr->hwndFrom, -1, LVNI_SELECTED ) == -1 )
1377 ListView_SetItemState ( hdr->hwndFrom,
1378 ListView_GetItemCount ( hdr->hwndFrom ) - 1,
1379 LVIS_SELECTED, LVIS_SELECTED );
1387 int sel = ListView_GetNextItem ( hdr->hwndFrom, -1, LVNI_SELECTED );
1390 ListView_EditLabel ( hdr->hwndFrom, sel );
1398 case LVN_BEGINLABELEDIT:
1400 NMLVDISPINFO* di = (NMLVDISPINFO*)hdr;
1402 DWORD style = GetWindowLong ( ListView_GetEditControl ( hdr->hwndFrom ), GWL_STYLE );
1403 SetWindowLong ( ListView_GetEditControl ( hdr->hwndFrom ), GWL_STYLE, style & (~WS_BORDER) );
1408 SetWindowText ( ListView_GetEditControl ( hdr->hwndFrom ), watch->
mVariable );
1414 case LVN_ENDLABELEDIT:
1416 NMLVDISPINFO* di = (NMLVDISPINFO*)hdr;
1418 if ( di->item.iItem == ListView_GetItemCount ( hdr->hwndFrom ) - 1 )
1420 if ( !di->item.pszText || !di->item.pszText[0] )
1425 window->
AddWatch ( ((NMLVDISPINFO*)hdr)->item.pszText );
1432 if ( watch && di->item.pszText && di->item.pszText[0] )
1444 if ( hdr->code == NM_DBLCLK )
1446 int sel = ListView_GetNextItem ( hdr->hwndFrom, -1, LVNI_SELECTED );
1458 if ( hdr->code == TCN_SELCHANGE )
1463 ShowWindow ( window->
mWndWatch, SW_HIDE );
1465 switch ( TabCtrl_GetCurSel ( hdr->hwndFrom ) )
1480 ShowWindow ( window->
mWndWatch, SW_SHOW );
1496 if ( IDNO == MessageBox ( wnd,
"The debugger is currently connected to a running version of the game. Are you sure you want to close now?",
"Quake 4 Script Debugger", MB_YESNO|MB_ICONQUESTION ) )
1501 PostQuitMessage ( 0 );
1505 return DefWindowProc ( wnd, msg, wparam, lparam );
1526 SetForegroundWindow ( find );
1540 unsigned short command;
1542 command = (
unsigned short)MSG_ReadShort ( msg );
1557 MSG_ReadShort ( msg );
1558 MSG_ReadString ( msg, temp, 1024 );
1559 MSG_ReadString ( msg, temp2, 1024 );
1565 info.cbSize =
sizeof(info);
1595 for (
int l = 0;
l < ListView_GetItemCount(
mWndWatch);
l ++ )
1598 item.mask = LVIF_PARAM;
1601 if ( item.lParam == (
LPARAM) watch )
1617 Printf (
"Connected...\n" );
1623 Printf (
"Disconnected...\n" );
1628 SendMessage (
mWndConsole, EM_REPLACESEL, 0, (
LPARAM)(
const char*)(msg->data) + msg->readcount );
1629 SendMessage (
mWndConsole, EM_SCROLLCARET, 0, 0 );
1643 SetForegroundWindow (
mWnd );
1657 ZeroMemory ( &item,
sizeof(item) );
1658 item.mask = LVIF_TEXT|LVIF_IMAGE;
1663 item.iItem = ListView_GetItemCount (
mWndThreads );
1665 item.iImage = entry->
mCurrent ? 1 : 0;
1668 ListView_SetItemText (
mWndThreads, item.iItem, 1, (LPSTR)
va(
"%d", entry->
mID) );
1673 ListView_SetItemText (
mWndThreads, item.iItem, 3,
"Dying" );
1677 ListView_SetItemText (
mWndThreads, item.iItem, 3,
"Waiting" );
1681 ListView_SetItemText (
mWndThreads, item.iItem, 3,
"Stopped" );
1685 ListView_SetItemText (
mWndThreads, item.iItem, 3,
"Running" );
1705 va_start (argptr,fmt);
1709 SendMessage (
mWndOutput, EM_SETSEL, -1, -1 );
1711 SendMessage (
mWndOutput, EM_SCROLLCARET, 0, 0 );
1726 SetCursor ( LoadCursor (
NULL, IDC_WAIT ) );
1749 if ( !script->
Load ( filename ) )
1752 SetCursor ( LoadCursor (
NULL, IDC_ARROW ) );
1769 mBreakpoints.Append ( bp );
1778 if ( lineNumber != -1 )
1788 c = SendMessage (
mWndScript, EM_LINEINDEX, lineNumber - 1, 0 );
1789 SendMessage (
mWndScript, EM_SETSEL, c, c + 1 );
1790 SendMessage (
mWndScript, EM_SCROLLCARET, 0, 0 );
1791 c = SendMessage (
mWndScript, EM_LINEINDEX, lineNumber, 0 );
1803 SetCursor ( LoadCursor (
NULL, IDC_ARROW ) );
1822 SendMessage (
mWndScript, EM_GETSEL, (WPARAM)&sel, 0 );
1823 line = SendMessage (
mWndScript, EM_LINEFROMCHAR, sel, 0 ) + 1;
1833 MessageBeep ( MB_ICONEXCLAMATION );
1860 EndDialog ( wnd, 0 );
1877 mWndToolbar = CreateWindowEx ( 0, TOOLBARCLASSNAME,
"", WS_CHILD|WS_VISIBLE,0,0,0,0,
mWnd, (HMENU)
IDC_DBG_TOOLBAR,
mInstance,
NULL );
1880 SendMessage (
mWndToolbar, TB_BUTTONSTRUCTSIZE, ( WPARAM )
sizeof( TBBUTTON ), 0 );
1881 SendMessage (
mWndToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(16,16) );
1882 SendMessage (
mWndToolbar, TB_SETSTYLE, 0, SendMessage (
mWndToolbar, TB_GETSTYLE, 0, 0 ) | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS );
1885 tbmet.cbSize =
sizeof(TBMETRICS);
1898 TBBUTTON tbb[] = { { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0, -1 },
1900 { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0, -1 },
1903 { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0, -1 },
1907 { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0, -1 } };
1909 SendMessage(
mWndToolbar, TB_ADDBUTTONS, (WPARAM)
sizeof(tbb)/
sizeof(TBBUTTON), (
LPARAM) tbb );
1922 NMTTDISPINFO* ttdi = (NMTTDISPINFO*) lparam;
1923 switch ( ttdi->hdr.idFrom )
1926 strcpy ( ttdi->szText,
"Open Script" );
1930 strcpy ( ttdi->szText,
"Step Into" );
1934 strcpy ( ttdi->szText,
"Step Over" );
1938 strcpy ( ttdi->szText,
"Step Out" );
1942 strcpy ( ttdi->szText,
"Break" );
1948 strcpy ( ttdi->szText,
"Continue" );
1952 strcpy ( ttdi->szText,
"Run" );
1957 strcpy ( ttdi->szText,
"" );
1976 if ( !LOWORD(wparam) )
1984 if (
mScripts[i]->IsFileModified (
true ) )
1986 if ( IDYES == MessageBox (
mWnd,
va(
"%s\n\nThis file has been modified outside of the debugger.\nDo you want to reload it?",
mScripts[i]->GetFilename() ),
"Quake 4 Script Debugger", MB_YESNO|MB_ICONQUESTION ) )
2055 item.mask = LVIF_PARAM;
2056 item.iItem = ListView_GetItemCount (
mWndWatch ) - 1;
2058 item.lParam = (
LPARAM)watch;
2059 ListView_InsertItem (
mWndWatch, &item );
2084 for ( i = 0; i <
count; i ++ )
2125 ZeroMemory ( &info,
sizeof(info) );
2126 info.cbSize =
sizeof(info);
2127 info.fMask = MIIM_FTYPE;
2129 if ( !(info.fType & MFT_SEPARATOR ) )
2167 end = SendMessage (
mWndScript, EM_FINDWORDBREAK, WB_RIGHT, start );
2168 start = SendMessage (
mWndScript, EM_FINDWORDBREAK, WB_LEFT, start );
2171 temp =
new char[end-start+10];
2172 range.chrg.cpMin =
start;
2173 range.chrg.cpMax =
end;
2174 range.lpstrText = temp;
2215 ft.chrg.cpMin = start + 1;
2234 SendMessage (
mWndScript, EM_SCROLLCARET, 0, 0 );
2269 ft.chrg.cpMin =
start;
2276 GETTEXTLENGTHEX gtl;
2277 gtl.flags = GTL_DEFAULT;
2278 gtl.codepage = CP_ACP;
2279 ft.chrg.cpMin = SendMessage (
mWndScript, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0 );
2291 SendMessage (
mWndScript, EM_SCROLLCARET, 0, 0 );
2305 DRAWITEMSTRUCT* dis;
2313 dis = (DRAWITEMSTRUCT*) lparam;
2316 col.mask = LVCF_WIDTH;
2318 rect.left = rect.left - 1;
2319 rect.right = rect.left;
2322 selected = ((dis->itemState & ODS_SELECTED) && GetFocus()==
mWndWatch);
2327 FillRect ( dis->hDC, &dis->rcItem, GetSysColorBrush ( COLOR_HIGHLIGHT ) );
2331 FillRect ( dis->hDC, &dis->rcItem, GetSysColorBrush ( IsWindowEnabled (
mWndWatch ) ? COLOR_WINDOW : COLOR_3DFACE ) );
2336 for ( index = 0; ListView_GetColumn (
mWndWatch, index, &col ); index ++ )
2338 rect.right = rect.left + col.cx;
2339 FrameRect ( dis->hDC, &rect, GetSysColorBrush ( COLOR_3DFACE ) );
2351 SetTextColor ( dis->hDC, GetSysColor ( selected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT ) );
2352 DrawText ( dis->hDC, watch->
mVariable, -1, &textrect, DT_LEFT|DT_VCENTER );
2358 SetTextColor ( dis->hDC, RGB(255,50,50) );
2362 SetTextColor ( dis->hDC, GetSysColor ( selected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT ) );
2364 DrawText ( dis->hDC, watch->
mValue, -1, &textrect, DT_LEFT|DT_VCENTER );
2369 rect.left = rect.right - 1;
void SetString(const char *name, const char *v)
bool FindPrev(const char *text=NULL)
bool GetWindowPlacement(const char *name, HWND hwnd)
bool DoModal(rvDebuggerWindow *window)
#define ID_DBG_DEBUG_STEPINTO
assert(prefInfo.fullscreenBtn)
void SetColumnWidths(const char *name, HWND list)
int Cmp(const char *text) const
idCVarSystem * cvarSystem
const char * GetFilename(void)
int HandleCreate(WPARAM wparam, LPARAM lparam)
#define ID_DBG_DEBUG_SHOWNEXTSTATEMENT
bool DoModal(rvDebuggerWindow *window, int callstackDepth, const char *variable=NULL)
CONST PIXELFORMATDESCRIPTOR UINT
#define ID_DBG_DEBUG_STEPOVER
#define IDC_DBG_CALLSTACK
#define ID_DBG_DEBUG_STEPOUT
#define IDR_DBG_SCRIPT_POPUP
void InspectVariable(const char *name, int callstackDepth)
bool OpenScript(const char *filename, int lineNumber=-1)
#define IDI_DBG_BREAKPOINT
void Printf(const char *format,...)
void UpdateWindowMenu(void)
void EnableWindows(bool state)
static LRESULT CALLBACK MarginWndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
#define DEBUGGERWINDOWCLASS
rvDebuggerBreakpoint * FindBreakpoint(const char *filename, int linenumber)
static LRESULT CALLBACK ScriptWndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
rvDebuggerBreakpoint * GetBreakpoint(int index)
rvRegistryOptions & GetOptions(void)
static bool Activate(void)
#define ID_DBG_DEBUG_BREAK
void AddWatch(const char *name, bool update=true)
int Icmp(const char *text) const
int HandleActivate(WPARAM wparam, LPARAM lparam)
GLuint GLuint GLsizei count
bool Create(HINSTANCE hInstance)
bool InitRecentFiles(void)
#define ID_DBG_DEBUG_QUICKWATCH
#define ID_DBG_EDIT_FINDSELECTED
const char * GetFindText(void)
virtual const char * GetCVarString(const char *name) const =0
idList< rvDebuggerScript * > mScripts
void GetColumnWidths(const char *name, HWND list)
int GetBreakLineNumber(void)
#define IDI_DBG_CURRENTLINE
void SetTitle(const char *title)
#define ID_DBG_FILE_CLOSE
const char * GetBreakFilename(void)
static INT_PTR CALLBACK AboutDlgProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
#define ID_DBG_HELP_ABOUT
void HandleTooltipGetDispInfo(WPARAM wparam, LPARAM lparam)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
int GetSelectedText(idStr &text)
const char * GetFilename(void)
void SetWindowPlacement(const char *name, HWND hwnd)
rvDebuggerClient * mClient
rvDebuggerWatchList mWatches
static const int MAX_MRU_SIZE
rvDebuggerCallstackList & GetCallstack(void)
int HandleCommand(WPARAM wParam, LPARAM lParam)
rvDebuggerClient & GetClient(void)
int Append(const type &obj)
bool Load(const char *filename)
#define ID_DBG_WINDOW_CLOSEALL
int HandleDrawItem(WPARAM wparam, LPARAM lparam)
void AddRecentFile(const char *filename)
#define ID_DBG_DEBUG_TOGGLEBREAKPOINT
#define ID_DBG_DEBUG_RUNTOCURSOR
#define ID_DBG_EDIT_FINDSELECTEDPREV
void Append(const char a)
bool RemoveIndex(int index)
int vsprintf(idStr &string, const char *fmt, va_list argptr)
const char * c_str(void) const
bool RemoveBreakpoint(int bpID)
int HandleInitMenu(WPARAM wParam, LPARAM lParam)
bool FindNext(const char *text=NULL)
#define ID_DBG_EDIT_FINDPREV
int GetRecentFileCount(void)
const char * GetRecentFile(int index)
int GetBreakpointCount(void)
void UpdateCallstack(void)
int AddBreakpoint(const char *filename, int lineNumber, bool onceOnly=false)
#define ID_DBG_EDIT_FINDNEXT
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
char * va(const char *fmt,...)
rvDebuggerThreadList & GetThreads(void)
static int CALLBACK ScriptWordBreakProc(LPTSTR text, int current, int max, int action)
rvDebuggerApp gDebuggerApp
bool DoModal(HWND parent)
void ProcessNetMessage(msg_t *msg)
static LRESULT CALLBACK WndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
void ToggleBreakpoint(void)
const char * GetString(const char *name)
bool Remove(const type &obj)
void SetFilter(const char *filter)
void UpdateRecentFiles(void)