mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-04 18:09:53 +03:00
1
This commit is contained in:
155
utils/xbox/vxconsole/assert_dialog.cpp
Normal file
155
utils/xbox/vxconsole/assert_dialog.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// ASSERT_DIALOG.CPP
|
||||
//
|
||||
// Handle Remote Assert().
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
AssertAction_t g_AssertAction = ASSERT_ACTION_BREAK;
|
||||
static const char * g_AssertInfo = "Assert Info Not Available.";
|
||||
bool g_AssertDialogActive = false;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// AssertDialogProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CALLBACK AssertDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch( uMsg )
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
SetWindowText( hDlg, "Xbox 360 Assert!" );
|
||||
SetDlgItemText( hDlg, IDC_FILENAME_CONTROL, g_AssertInfo );
|
||||
|
||||
// Center the dialog.
|
||||
RECT rcDlg, rcDesktop;
|
||||
GetWindowRect( hDlg, &rcDlg );
|
||||
GetWindowRect( GetDesktopWindow(), &rcDesktop );
|
||||
SetWindowPos(
|
||||
hDlg,
|
||||
HWND_TOP,
|
||||
((rcDesktop.right-rcDesktop.left) - (rcDlg.right-rcDlg.left)) / 2,
|
||||
((rcDesktop.bottom-rcDesktop.top) - (rcDlg.bottom-rcDlg.top)) / 2,
|
||||
0,
|
||||
0,
|
||||
SWP_NOSIZE );
|
||||
}
|
||||
return true;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch( LOWORD( wParam ) )
|
||||
{
|
||||
// Ignore Asserts in this file from now on.
|
||||
case IDC_IGNORE_FILE:
|
||||
{
|
||||
g_AssertAction = ASSERT_ACTION_IGNORE_FILE;
|
||||
EndDialog( hDlg, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ignore this Assert once.
|
||||
case IDC_IGNORE_THIS:
|
||||
{
|
||||
g_AssertAction = ASSERT_ACTION_IGNORE_THIS;
|
||||
EndDialog( hDlg, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Always ignore this Assert.
|
||||
case IDC_IGNORE_ALWAYS:
|
||||
{
|
||||
g_AssertAction = ASSERT_ACTION_IGNORE_ALWAYS;
|
||||
EndDialog( hDlg, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ignore all Asserts from now on.
|
||||
case IDC_IGNORE_ALL:
|
||||
{
|
||||
g_AssertAction = ASSERT_ACTION_IGNORE_ALL;
|
||||
EndDialog( hDlg, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
case IDC_BREAK:
|
||||
{
|
||||
g_AssertAction = ASSERT_ACTION_BREAK;
|
||||
EndDialog( hDlg, 0 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
// Escape?
|
||||
if ( wParam == 2 )
|
||||
{
|
||||
// Ignore this Assert.
|
||||
g_AssertAction = ASSERT_ACTION_IGNORE_THIS;
|
||||
EndDialog( hDlg, 0 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_Assert
|
||||
//
|
||||
// Sent from application on hitting an Assert
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_Assert( char* commandPtr )
|
||||
{
|
||||
char* cmdToken;
|
||||
int retAddr;
|
||||
int errCode = -1;
|
||||
|
||||
// Flash the taskbar icon (otherwise users may not realise the app has stalled on an Assert, esp. during loading)
|
||||
FLASHWINFO flashWInfo = { sizeof(FLASHWINFO), g_hDlgMain, FLASHW_ALL|FLASHW_TIMERNOFG, 0, 1000 };
|
||||
FlashWindowEx( &flashWInfo );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
if (1 != sscanf( cmdToken, "%x", &retAddr ))
|
||||
goto cleanUp;
|
||||
|
||||
// skip whitespace
|
||||
while ( commandPtr[0] == ' ' )
|
||||
{
|
||||
commandPtr++;
|
||||
}
|
||||
|
||||
// Display file/line/expression info from the message in the Assert dialog
|
||||
// (convert '\t' to '\n'; way simpler than tokenizing a general assert expression)
|
||||
g_AssertInfo = commandPtr;
|
||||
char *tab = commandPtr;
|
||||
while( ( tab = strchr( tab, '\t' ) ) != NULL )
|
||||
{
|
||||
tab[0] = '\n';
|
||||
}
|
||||
|
||||
// Open the Assert dialog, to determine the desired action
|
||||
g_AssertAction = ASSERT_ACTION_BREAK;
|
||||
g_AssertDialogActive = true;
|
||||
DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_ASSERT_DIALOG ), g_hDlgMain, ( DLGPROC )AssertDialogProc );
|
||||
g_AssertDialogActive = false;
|
||||
|
||||
// Write the (endian-converted) result directly back into the application's memory:
|
||||
int xboxRetVal = BigDWord( g_AssertAction );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return errCode;
|
||||
}
|
||||
107
utils/xbox/vxconsole/assert_dialog.rc
Normal file
107
utils/xbox/vxconsole/assert_dialog.rc
Normal file
@@ -0,0 +1,107 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "assert_resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"assert_resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ASSERT_DIALOG DIALOGEX 0, 0, 268, 158
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Assert"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "c:/hl2/src/blah.cpp",IDC_FILENAME_CONTROL,7,7,246,34
|
||||
DEFPUSHBUTTON "&Break in Debugger",IDC_BREAK,7,49,98,14
|
||||
PUSHBUTTON "&Ignore This Assert",IDC_IGNORE_THIS,7,66,98,14
|
||||
EDITTEXT IDC_IGNORE_NUMTIMES,110,66,24,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
|
||||
LTEXT "time(s).",IDC_NOID,138,69,23,8
|
||||
PUSHBUTTON "Always Ignore &This Assert",IDC_IGNORE_ALWAYS,7,83,98,14
|
||||
PUSHBUTTON "Ignore &Nearby Asserts",IDC_IGNORE_NEARBY,7,100,98,14,WS_DISABLED
|
||||
LTEXT "within",IDC_NOID,109,103,19,8
|
||||
EDITTEXT IDC_IGNORE_NUMLINES,131,100,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
|
||||
LTEXT "lines.",IDC_NOID,175,103,17,8
|
||||
PUSHBUTTON "Ignore Asserts in This &File",IDC_IGNORE_FILE,7,117,98,14
|
||||
PUSHBUTTON "Ignore &All Asserts",IDC_IGNORE_ALL,7,134,98,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ASSERT_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 261
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 151
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
29
utils/xbox/vxconsole/assert_resource.h
Normal file
29
utils/xbox/vxconsole/assert_resource.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by assert_dialog.rc
|
||||
//
|
||||
#define IDD_ASSERT_DIALOG 101
|
||||
#define IDC_FILENAME_CONTROL 1000
|
||||
#define IDC_LINE_CONTROL 1001
|
||||
#define IDC_IGNORE_FILE 1002
|
||||
#define IDC_IGNORE_NEARBY 1003
|
||||
#define IDC_IGNORE_NUMLINES 1004
|
||||
#define IDC_IGNORE_THIS 1005
|
||||
#define IDC_BREAK 1006
|
||||
#define IDC_IGNORE_ALL 1008
|
||||
#define IDC_IGNORE_ALWAYS 1009
|
||||
#define IDC_IGNORE_NUMTIMES 1010
|
||||
#define IDC_ASSERT_MSG_CTRL 1011
|
||||
#define IDC_NOID -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1005
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
591
utils/xbox/vxconsole/bindings.cpp
Normal file
591
utils/xbox/vxconsole/bindings.cpp
Normal file
@@ -0,0 +1,591 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// BINDINGS.CPP
|
||||
//
|
||||
// Keyboard Shortcuts
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define ID_BINDINGS_LISTVIEW 100
|
||||
|
||||
// column id
|
||||
#define ID_BIND_KEYCODE 0
|
||||
#define ID_BIND_MENUNAME 1
|
||||
#define ID_BIND_COMMAND 2
|
||||
|
||||
typedef struct
|
||||
{ const CHAR* name;
|
||||
int width;
|
||||
int subItemIndex;
|
||||
} label_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int keyCode;
|
||||
const char *pKeyString;
|
||||
char *pMenuName;
|
||||
char *pCommandString;
|
||||
} bind_t;
|
||||
|
||||
// {VK_F1, "F1", "WireFrame", "incrementvar mat_wireframe 0 2 1"},
|
||||
// {VK_F2, "F2", "FullBright", "incrementvar mat_fullbright 0 2 1"},
|
||||
// {VK_F3, "F3", "Impulse 101", "impulse 101"},
|
||||
// {VK_F4, "F4", "Screenshot", "*screenshot"},
|
||||
|
||||
|
||||
bind_t g_bindings[MAX_BINDINGS] =
|
||||
{
|
||||
{VK_F1, "F1", NULL, NULL},
|
||||
{VK_F2, "F2", NULL, NULL},
|
||||
{VK_F3, "F3", NULL, NULL},
|
||||
{VK_F4, "F4", NULL, NULL},
|
||||
{VK_F5, "F5", NULL, NULL},
|
||||
{VK_F6, "F6", NULL, NULL},
|
||||
{VK_F7, "F7", NULL, NULL},
|
||||
{VK_F8, "F8", NULL, NULL},
|
||||
{VK_F9, "F9", NULL, NULL},
|
||||
{VK_F10, "F10", NULL, NULL},
|
||||
{VK_F11, "F11", NULL, NULL},
|
||||
{VK_F12, "F12", NULL, NULL},
|
||||
};
|
||||
|
||||
label_t g_bindings_labels[] =
|
||||
{
|
||||
{"Key", 80, ID_BIND_KEYCODE},
|
||||
{"Menu Name", 150, ID_BIND_MENUNAME},
|
||||
{"Command", 400, ID_BIND_COMMAND},
|
||||
};
|
||||
|
||||
HWND g_bindings_hWnd;
|
||||
HWND g_bindings_hWndListView;
|
||||
RECT g_bindings_windowRect;
|
||||
char g_bindingsModify_menuName[256];
|
||||
char g_bindingsModify_command[256];
|
||||
char g_bindingsModify_keyCode[256];
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_ModifyEntry
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Bindings_ModifyEntry( int i, const char *pMenuName, const char *pCommandString )
|
||||
{
|
||||
if ( g_bindings[i].pMenuName && g_bindings[i].pMenuName[0] )
|
||||
Sys_Free( g_bindings[i].pMenuName );
|
||||
g_bindings[i].pMenuName = Sys_CopyString( pMenuName );
|
||||
|
||||
if ( g_bindings[i].pCommandString && g_bindings[i].pCommandString[0] )
|
||||
Sys_Free( g_bindings[i].pCommandString );
|
||||
g_bindings[i].pCommandString = Sys_CopyString( pCommandString );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_GetSelectedItem
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int Bindings_GetSelectedItem()
|
||||
{
|
||||
int i;
|
||||
int selection = -1;
|
||||
int state;
|
||||
|
||||
for ( i=0; i<MAX_BINDINGS; i++ )
|
||||
{
|
||||
state = ListView_GetItemState( g_bindings_hWndListView, i, LVIS_SELECTED );
|
||||
if ( state == LVIS_SELECTED )
|
||||
{
|
||||
selection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_TranslateKey
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Bindings_TranslateKey( int vkKeyCode )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; i<MAX_BINDINGS; i++ )
|
||||
{
|
||||
if ( !g_bindings[i].pCommandString || !g_bindings[i].pCommandString[0] )
|
||||
continue;
|
||||
|
||||
if ( vkKeyCode == g_bindings[i].keyCode )
|
||||
{
|
||||
ProcessCommand( g_bindings[i].pCommandString );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_MenuSelection
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Bindings_MenuSelection( int wID )
|
||||
{
|
||||
int index;
|
||||
|
||||
index = wID - IDM_BINDINGS_BIND1;
|
||||
if ( index < 0 || index > MAX_BINDINGS-1 )
|
||||
return false;
|
||||
|
||||
// as if the key were pressed...
|
||||
return ( Bindings_TranslateKey( g_bindings[index].keyCode ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_UpdateMenu
|
||||
//
|
||||
// Builds the dynamic menu
|
||||
//-----------------------------------------------------------------------------
|
||||
void Bindings_UpdateMenu()
|
||||
{
|
||||
HMENU hMenu;
|
||||
HMENU hNewMenu;
|
||||
MENUITEMINFO menuItemInfo;
|
||||
int i;
|
||||
int numAdded;
|
||||
char menuBuff[64];
|
||||
|
||||
hMenu = GetMenu( g_hDlgMain );
|
||||
if ( !hMenu )
|
||||
return;
|
||||
|
||||
memset( &menuItemInfo, 0, sizeof( menuItemInfo ) );
|
||||
menuItemInfo.cbSize = sizeof( MENUITEMINFO );
|
||||
|
||||
numAdded = 0;
|
||||
hNewMenu = CreatePopupMenu();
|
||||
menuItemInfo.fMask = MIIM_ID|MIIM_FTYPE|MIIM_STRING;
|
||||
menuItemInfo.fType = MFT_STRING;
|
||||
for ( i=MAX_BINDINGS-1; i>=0; i-- )
|
||||
{
|
||||
if ( !g_bindings[i].pCommandString || !g_bindings[i].pCommandString[0] )
|
||||
continue;
|
||||
|
||||
menuItemInfo.wID = IDM_BINDINGS_BIND1+i;
|
||||
sprintf( menuBuff, "%s\tF%d", g_bindings[i].pMenuName, g_bindings[i].keyCode-VK_F1+1 );
|
||||
menuItemInfo.dwTypeData = ( LPSTR )menuBuff;
|
||||
InsertMenuItem( hNewMenu, 0, true, &menuItemInfo );
|
||||
|
||||
numAdded++;
|
||||
}
|
||||
|
||||
if ( numAdded )
|
||||
{
|
||||
// add seperator
|
||||
menuItemInfo.fMask = MIIM_FTYPE;
|
||||
menuItemInfo.fType = MFT_SEPARATOR;
|
||||
InsertMenuItem( hNewMenu, 0, true, &menuItemInfo );
|
||||
}
|
||||
|
||||
menuItemInfo.fMask = MIIM_ID|MIIM_FTYPE|MIIM_STRING;
|
||||
menuItemInfo.fType = MFT_STRING;
|
||||
menuItemInfo.wID = IDM_BINDINGS_EDIT;
|
||||
menuItemInfo.dwTypeData = "Edit...";
|
||||
InsertMenuItem( hNewMenu, 0, true, &menuItemInfo );
|
||||
|
||||
// delete the previous menu
|
||||
menuItemInfo.fMask = MIIM_SUBMENU;
|
||||
GetMenuItemInfo( hMenu, IDM_BINDINGS, false, &menuItemInfo );
|
||||
if ( menuItemInfo.hSubMenu )
|
||||
DestroyMenu( menuItemInfo.hSubMenu );
|
||||
else
|
||||
{
|
||||
// add a new menu at the tail of the app menu
|
||||
AppendMenu( hMenu, MF_STRING, ( UINT_PTR )IDM_BINDINGS, "Bindings" );
|
||||
}
|
||||
|
||||
// add the new menu to bar
|
||||
menuItemInfo.fMask = MIIM_SUBMENU;
|
||||
menuItemInfo.hSubMenu = hNewMenu;
|
||||
SetMenuItemInfo( hMenu, IDM_BINDINGS, false, &menuItemInfo );
|
||||
|
||||
DrawMenuBar( g_hDlgMain );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// BindingsModifyDlg_Proc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL CALLBACK BindingsModifyDlg_Proc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
SetDlgItemText( hWnd, IDC_MODIFYBIND_KEYCODE, g_bindingsModify_keyCode );
|
||||
SetDlgItemText( hWnd, IDC_MODIFYBIND_MENUNAME, g_bindingsModify_menuName );
|
||||
SetDlgItemText( hWnd, IDC_MODIFYBIND_COMMAND, g_bindingsModify_command );
|
||||
return ( TRUE );
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( LOWORD( wParam ) )
|
||||
{
|
||||
case IDC_OK:
|
||||
GetDlgItemText( hWnd, IDC_MODIFYBIND_MENUNAME, g_bindingsModify_menuName, sizeof( g_bindingsModify_menuName ) );
|
||||
GetDlgItemText( hWnd, IDC_MODIFYBIND_COMMAND, g_bindingsModify_command, sizeof( g_bindingsModify_command ) );
|
||||
case IDCANCEL:
|
||||
case IDC_CANCEL:
|
||||
EndDialog( hWnd, wParam );
|
||||
return ( TRUE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( FALSE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// BindingsModifyDlg_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void BindingsModifyDlg_Open( int selection )
|
||||
{
|
||||
int result;
|
||||
|
||||
sprintf( g_bindingsModify_keyCode, "F%d", selection+1 );
|
||||
strcpy( g_bindingsModify_menuName, g_bindings[selection].pMenuName );
|
||||
strcpy( g_bindingsModify_command, g_bindings[selection].pCommandString );
|
||||
|
||||
result = DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_MODIFYBIND ), g_hDlgMain, ( DLGPROC )BindingsModifyDlg_Proc );
|
||||
if ( LOWORD( result ) != IDC_OK )
|
||||
return;
|
||||
|
||||
// accept changes and update
|
||||
Bindings_ModifyEntry( selection, g_bindingsModify_menuName, g_bindingsModify_command );
|
||||
ListView_RedrawItems( g_bindings_hWndListView, 0, MAX_BINDINGS-1 );
|
||||
UpdateWindow( g_bindings_hWndListView );
|
||||
Bindings_UpdateMenu();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Bindings_LoadConfig()
|
||||
{
|
||||
char valueBuff[256];
|
||||
char keyBuff[32];
|
||||
char menuName[256];
|
||||
char commandString[256];
|
||||
char *ptr;
|
||||
char *token;
|
||||
int keyCode;
|
||||
int i;
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
for ( i=0; i<MAX_BINDINGS; i++ )
|
||||
{
|
||||
menuName[0] = '\0';
|
||||
commandString[0] = '\0';
|
||||
|
||||
sprintf( keyBuff, "bind%d", i );
|
||||
Sys_GetRegistryString( keyBuff, valueBuff, "", sizeof( valueBuff ) );
|
||||
|
||||
// parse and populate valid values
|
||||
ptr = valueBuff;
|
||||
token = Sys_GetToken( &ptr, false, NULL );
|
||||
if ( token[0] )
|
||||
keyCode = atoi( token );
|
||||
|
||||
token = Sys_GetToken( &ptr, false, NULL );
|
||||
if ( token[0] )
|
||||
strcpy( menuName, token );
|
||||
|
||||
token = Sys_GetToken( &ptr, false, NULL );
|
||||
if ( token[0] )
|
||||
strcpy( commandString, token );
|
||||
|
||||
Bindings_ModifyEntry( i, menuName, commandString );
|
||||
}
|
||||
|
||||
Sys_GetRegistryString( "bindingsWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_bindings_windowRect.left, &g_bindings_windowRect.top, &g_bindings_windowRect.right, &g_bindings_windowRect.bottom );
|
||||
if ( numArgs != 4 )
|
||||
memset( &g_bindings_windowRect, 0, sizeof( g_bindings_windowRect ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Bindings_SaveConfig()
|
||||
{
|
||||
char valueBuff[256];
|
||||
char buff[256];
|
||||
char keyBuff[32];
|
||||
char *pMenuName;
|
||||
char *pCommandString;
|
||||
int len;
|
||||
int i;
|
||||
WINDOWPLACEMENT wp;
|
||||
|
||||
if ( g_bindings_hWnd )
|
||||
{
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_bindings_hWnd, &wp );
|
||||
g_bindings_windowRect = wp.rcNormalPosition;
|
||||
sprintf( buff, "%d %d %d %d", wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom );
|
||||
Sys_SetRegistryString( "bindingsWindowRect", buff );
|
||||
}
|
||||
|
||||
for ( i=0; i<MAX_BINDINGS; i++ )
|
||||
{
|
||||
sprintf( keyBuff, "bind%d", i );
|
||||
|
||||
pMenuName = g_bindings[i].pMenuName;
|
||||
if ( !pMenuName )
|
||||
pMenuName = "";
|
||||
|
||||
pCommandString = g_bindings[i].pCommandString;
|
||||
if ( !pCommandString )
|
||||
pCommandString = "";
|
||||
|
||||
len = _snprintf( valueBuff, sizeof( valueBuff ), "%d \"%s\" \"%s\"", g_bindings[i].keyCode, pMenuName, pCommandString );
|
||||
if ( len == -1 )
|
||||
{
|
||||
// kill it
|
||||
valueBuff[0] = '\0';
|
||||
}
|
||||
|
||||
Sys_SetRegistryString( keyBuff, valueBuff );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_SizeWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Bindings_SizeWindow( HWND hwnd, int cx, int cy )
|
||||
{
|
||||
if ( cx==0 || cy==0 )
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect( hwnd, &rcClient );
|
||||
cx = rcClient.right;
|
||||
cy = rcClient.bottom;
|
||||
}
|
||||
|
||||
// position the ListView
|
||||
SetWindowPos( g_bindings_hWndListView, NULL, 0, 0, cx, cy, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK Bindings_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
bind_t* pBind;
|
||||
int selection;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
Bindings_SaveConfig();
|
||||
Bindings_UpdateMenu();
|
||||
|
||||
g_bindings_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
Bindings_SizeWindow( hwnd, LOWORD( lParam ), HIWORD( lParam ) );
|
||||
return 0L;
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch ( ( ( LPNMHDR )lParam )->code )
|
||||
{
|
||||
case LVN_GETDISPINFO:
|
||||
NMLVDISPINFO* plvdi;
|
||||
plvdi = ( NMLVDISPINFO* )lParam;
|
||||
pBind = ( bind_t* )plvdi->item.lParam;
|
||||
switch ( plvdi->item.iSubItem )
|
||||
{
|
||||
case ID_BIND_KEYCODE:
|
||||
plvdi->item.pszText = ( LPSTR )pBind->pKeyString;
|
||||
return 0L;
|
||||
|
||||
case ID_BIND_MENUNAME:
|
||||
plvdi->item.pszText = pBind->pMenuName;
|
||||
return 0L;
|
||||
|
||||
case ID_BIND_COMMAND:
|
||||
plvdi->item.pszText = pBind->pCommandString;
|
||||
return 0L;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NM_DBLCLK:
|
||||
NMITEMACTIVATE *pnmitem;
|
||||
pnmitem = ( LPNMITEMACTIVATE )lParam;
|
||||
BindingsModifyDlg_Open( pnmitem->iItem );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_BINDOPTIONS_MODIFY:
|
||||
selection = Bindings_GetSelectedItem();
|
||||
if ( selection >= 0 )
|
||||
BindingsModifyDlg_Open( selection );
|
||||
return 0L;
|
||||
|
||||
case IDM_BINDOPTIONS_DELETE:
|
||||
selection = Bindings_GetSelectedItem();
|
||||
if ( selection >= 0 )
|
||||
{
|
||||
Bindings_ModifyEntry( selection, "", "" );
|
||||
ListView_RedrawItems( g_bindings_hWndListView, 0, MAX_BINDINGS-1 );
|
||||
UpdateWindow( g_bindings_hWndListView );
|
||||
Bindings_UpdateMenu();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Bindings_Open()
|
||||
{
|
||||
RECT clientRect;
|
||||
HWND hWnd;
|
||||
int i;
|
||||
LVITEM lvi;
|
||||
|
||||
if ( g_bindings_hWnd )
|
||||
{
|
||||
// only one instance
|
||||
if ( IsIconic( g_bindings_hWnd ) )
|
||||
ShowWindow( g_bindings_hWnd, SW_RESTORE );
|
||||
SetForegroundWindow( g_bindings_hWnd );
|
||||
return;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"BINDINGSCLASS",
|
||||
"Edit Bindings",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
300,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_bindings_hWnd = hWnd;
|
||||
|
||||
GetClientRect( g_bindings_hWnd, &clientRect );
|
||||
hWnd = CreateWindow(
|
||||
WC_LISTVIEW,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_SINGLESEL|LVS_NOSORTHEADER,
|
||||
0,
|
||||
0,
|
||||
clientRect.right-clientRect.left,
|
||||
clientRect.bottom-clientRect.top,
|
||||
g_bindings_hWnd,
|
||||
( HMENU )ID_BINDINGS_LISTVIEW,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_bindings_hWndListView = hWnd;
|
||||
|
||||
// init list view columns
|
||||
for ( i=0; i<sizeof( g_bindings_labels )/sizeof( g_bindings_labels[0] ); i++ )
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
|
||||
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.cx = g_bindings_labels[i].width;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.pszText = ( LPSTR )g_bindings_labels[i].name;
|
||||
|
||||
ListView_InsertColumn( g_bindings_hWndListView, i, &lvc );
|
||||
}
|
||||
|
||||
ListView_SetBkColor( g_bindings_hWndListView, g_backgroundColor );
|
||||
ListView_SetTextBkColor( g_bindings_hWndListView, g_backgroundColor );
|
||||
|
||||
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;
|
||||
ListView_SetExtendedListViewStyleEx( g_bindings_hWndListView, style, style );
|
||||
|
||||
// populate list view
|
||||
for ( i=0; i<MAX_BINDINGS; i++ )
|
||||
{
|
||||
int itemCount = ListView_GetItemCount( g_bindings_hWndListView );
|
||||
|
||||
// setup and insert at end of list
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
||||
lvi.iItem = itemCount;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.state = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
lvi.lParam = ( LPARAM )&g_bindings[i];
|
||||
|
||||
ListView_InsertItem( g_bindings_hWndListView, &lvi );
|
||||
}
|
||||
|
||||
// set the first item selected
|
||||
ListView_SetItemState( g_bindings_hWndListView, 0, LVIS_SELECTED, LVIS_SELECTED );
|
||||
SetFocus( g_bindings_hWndListView );
|
||||
|
||||
if ( g_bindings_windowRect.right && g_bindings_windowRect.bottom )
|
||||
MoveWindow( g_bindings_hWnd, g_bindings_windowRect.left, g_bindings_windowRect.top, g_bindings_windowRect.right-g_bindings_windowRect.left, g_bindings_windowRect.bottom-g_bindings_windowRect.top, FALSE );
|
||||
ShowWindow( g_bindings_hWnd, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bindings_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Bindings_Init()
|
||||
{
|
||||
// set up our window class
|
||||
WNDCLASS wndclass;
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = Bindings_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_BINDOPTIONS );
|
||||
wndclass.lpszClassName = "BINDINGSCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
Bindings_LoadConfig();
|
||||
Bindings_UpdateMenu();
|
||||
|
||||
return true;
|
||||
}
|
||||
1576
utils/xbox/vxconsole/bug.cpp
Normal file
1576
utils/xbox/vxconsole/bug.cpp
Normal file
File diff suppressed because it is too large
Load Diff
73
utils/xbox/vxconsole/common.cpp
Normal file
73
utils/xbox/vxconsole/common.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// COMMON.CPP
|
||||
//
|
||||
// Common/Misc specialized support routines not uniquely owned.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
vprofState_e g_vprof_state = VPROF_OFF;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// NotImplementedYet
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotImplementedYet()
|
||||
{
|
||||
Sys_MessageBox( "Attention!", "Sorry, Not Implemented Yet." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VProf_GetState
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
vprofState_e VProf_GetState()
|
||||
{
|
||||
return g_vprof_state;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VProf_Enable
|
||||
//
|
||||
// Coordinates multiple vprof commands for proper exclusion
|
||||
//-----------------------------------------------------------------------------
|
||||
void VProf_Enable( vprofState_e state )
|
||||
{
|
||||
char commandString[256];
|
||||
|
||||
switch ( state )
|
||||
{
|
||||
case VPROF_CPU:
|
||||
strcpy( commandString, "vprof_off ; vprof_on ; vprof_update cpu" );
|
||||
break;
|
||||
|
||||
case VPROF_TEXTURE:
|
||||
strcpy( commandString, "vprof_off ; vprof_on ; vprof_update texture" );
|
||||
break;
|
||||
|
||||
case VPROF_TEXTUREFRAME:
|
||||
strcpy( commandString, "vprof_off ; vprof_on ; vprof_update texture_frame" );
|
||||
break;
|
||||
|
||||
default:
|
||||
state = VPROF_OFF;
|
||||
strcpy( commandString, "vprof_off" );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// track state
|
||||
if ( g_vprof_state != state )
|
||||
{
|
||||
g_vprof_state = state;
|
||||
|
||||
// do command
|
||||
ProcessCommand( commandString );
|
||||
|
||||
// update all the dependant titles
|
||||
CpuProfile_SetTitle();
|
||||
TexProfile_SetTitle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
217
utils/xbox/vxconsole/config.cpp
Normal file
217
utils/xbox/vxconsole/config.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// CONFIG.CPP
|
||||
//
|
||||
// Configuration Dialog
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
CHAR g_xboxTargetName[MAX_XBOXNAMELEN];
|
||||
char g_localPath[MAX_PATH];
|
||||
char g_targetPath[MAX_PATH];
|
||||
BOOL g_clsOnConnect;
|
||||
BOOL g_loadSymbolsOnConnect;
|
||||
char g_xexTargetPath[MAX_PATH];
|
||||
BOOL g_alwaysAutoConnect;
|
||||
BOOL g_startMinimized;
|
||||
char g_installPath[MAX_PATH];
|
||||
BOOL g_captureDebugSpew_StartupState;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConfigDlg_LoadConfig()
|
||||
{
|
||||
// get our config
|
||||
Sys_GetRegistryString( "xboxName", g_xboxTargetName, "", sizeof( g_xboxTargetName ) );
|
||||
Sys_GetRegistryString( "localPath", g_localPath, "u:\\dev\\game", sizeof( g_localPath ) );
|
||||
Sys_GetRegistryString( "targetPath", g_targetPath, "e:\\valve", sizeof( g_targetPath ) );
|
||||
Sys_GetRegistryString( "installPath", g_installPath, "\\\\fileserver\\user\\xbox\\xbox_orange", sizeof( g_installPath ) );
|
||||
Sys_GetRegistryInteger( "clearOnConnect", true, g_clsOnConnect );
|
||||
Sys_GetRegistryInteger( "loadSymbolsOnConnect", false, g_loadSymbolsOnConnect );
|
||||
Sys_GetRegistryInteger( "alwaysAutoConnect", false, g_alwaysAutoConnect );
|
||||
Sys_GetRegistryInteger( "startMinimized", false, g_startMinimized );
|
||||
Sys_GetRegistryInteger( "captureDebugSpew", true, g_captureDebugSpew_StartupState );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConfigDlg_SaveConfig()
|
||||
{
|
||||
// save config
|
||||
Sys_SetRegistryString( "xboxName", g_xboxTargetName );
|
||||
Sys_SetRegistryString( "localPath", g_localPath );
|
||||
Sys_SetRegistryString( "targetPath", g_targetPath );
|
||||
Sys_SetRegistryString( "installPath", g_installPath );
|
||||
Sys_SetRegistryInteger( "clearOnConnect", g_clsOnConnect );
|
||||
Sys_SetRegistryInteger( "loadSymbolsOnConnect", g_loadSymbolsOnConnect );
|
||||
Sys_SetRegistryInteger( "alwaysAutoConnect", g_alwaysAutoConnect );
|
||||
Sys_SetRegistryInteger( "startMinimized", g_startMinimized );
|
||||
Sys_SetRegistryInteger( "captureDebugSpew", g_captureDebugSpew_StartupState );
|
||||
|
||||
// update
|
||||
SetMainWindowTitle();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_Setup
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConfigDlg_Setup( HWND hWnd )
|
||||
{
|
||||
SetDlgItemText( hWnd,IDC_CONFIG_XBOXNAME, g_xboxTargetName );
|
||||
SetDlgItemText( hWnd,IDC_CONFIG_LOCALPATH, g_localPath );
|
||||
SetDlgItemText( hWnd,IDC_CONFIG_TARGETPATH, g_targetPath );
|
||||
SetDlgItemText( hWnd,IDC_CONFIG_INSTALLPATH, g_installPath );
|
||||
|
||||
EnableWindow( GetDlgItem( hWnd, IDC_CONFIG_PING ), strlen( g_xboxTargetName ) > 0 );
|
||||
|
||||
CheckDlgButton( hWnd, IDC_CONFIG_CLEARONCONNECT, g_clsOnConnect ? BST_CHECKED : BST_UNCHECKED );
|
||||
CheckDlgButton( hWnd, IDC_CONFIG_ALWAYSAUTOCONNECT, g_alwaysAutoConnect ? BST_CHECKED : BST_UNCHECKED );
|
||||
CheckDlgButton( hWnd, IDC_CONFIG_STARTMINIMIZED, g_startMinimized ? BST_CHECKED : BST_UNCHECKED );
|
||||
CheckDlgButton( hWnd, IDC_CONFIG_CAPTUREDEBUGSPEW, g_captureDebugSpew_StartupState ? BST_CHECKED : BST_UNCHECKED );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_Ping
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL ConfigDlg_Ping( HWND hwnd )
|
||||
{
|
||||
char xboxName[MAX_XBOXNAMELEN];
|
||||
BOOL canConnect;
|
||||
char* args[1];
|
||||
|
||||
xboxName[0] = '\0';
|
||||
GetDlgItemText( hwnd, IDC_CONFIG_XBOXNAME, xboxName, MAX_XBOXNAMELEN );
|
||||
|
||||
// ignore ping to current connection
|
||||
if ( !stricmp( g_xboxName, xboxName ) )
|
||||
{
|
||||
if ( g_connectedToXBox )
|
||||
{
|
||||
Sys_MessageBox( "Ping", "Already Connected To: '%s'", xboxName );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// terminate any current connection
|
||||
lc_disconnect( 0, NULL );
|
||||
|
||||
// trial connect
|
||||
args[0] = xboxName;
|
||||
canConnect = lc_connect( 1, args );
|
||||
|
||||
if ( !canConnect )
|
||||
Sys_MessageBox( "Ping FAILURE", "Could Not Connect To: %s", xboxName );
|
||||
else
|
||||
Sys_MessageBox( "Ping SUCCESS", "Connection Valid To: %s", g_xboxName );
|
||||
|
||||
if ( canConnect )
|
||||
lc_disconnect( 0, NULL );
|
||||
|
||||
return canConnect;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_GetChanges
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConfigDlg_GetChanges( HWND hwnd )
|
||||
{
|
||||
char remotePath[MAX_PATH];
|
||||
char localPath[MAX_PATH];
|
||||
char targetPath[MAX_PATH];
|
||||
char installPath[MAX_PATH];
|
||||
char xboxName[MAX_XBOXNAMELEN];
|
||||
char xexLocalPath[MAX_PATH];
|
||||
char xexTargetPath[MAX_PATH];
|
||||
|
||||
xboxName[0] = '\0';
|
||||
remotePath[0] = '\0';
|
||||
localPath[0] = '\0';
|
||||
targetPath[0] = '\0';
|
||||
xexLocalPath[0] = '\0';
|
||||
xexTargetPath[0] = '\0';
|
||||
|
||||
GetDlgItemText( hwnd, IDC_CONFIG_XBOXNAME, xboxName, MAX_XBOXNAMELEN );
|
||||
GetDlgItemText( hwnd, IDC_CONFIG_LOCALPATH, localPath, MAX_PATH );
|
||||
GetDlgItemText( hwnd, IDC_CONFIG_TARGETPATH, targetPath, MAX_PATH );
|
||||
GetDlgItemText( hwnd, IDC_CONFIG_INSTALLPATH, installPath, MAX_PATH );
|
||||
|
||||
strcpy( g_localPath, localPath );
|
||||
Sys_NormalizePath( g_localPath, true );
|
||||
|
||||
strcpy( g_targetPath, targetPath );
|
||||
Sys_NormalizePath( g_targetPath, true );
|
||||
|
||||
strcpy( g_installPath, installPath );
|
||||
Sys_NormalizePath( g_installPath, true );
|
||||
|
||||
strcpy( g_xboxTargetName, xboxName );
|
||||
|
||||
g_clsOnConnect = IsDlgButtonChecked( hwnd, IDC_CONFIG_CLEARONCONNECT );
|
||||
g_loadSymbolsOnConnect = IsDlgButtonChecked( hwnd, IDC_CONFIG_LOADSYMBOLS );
|
||||
g_alwaysAutoConnect = IsDlgButtonChecked( hwnd, IDC_CONFIG_ALWAYSAUTOCONNECT );
|
||||
g_startMinimized = IsDlgButtonChecked( hwnd, IDC_CONFIG_STARTMINIMIZED );
|
||||
g_captureDebugSpew_StartupState = IsDlgButtonChecked( hwnd, IDC_CONFIG_CAPTUREDEBUGSPEW );
|
||||
|
||||
// success
|
||||
return ( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_Proc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL CALLBACK ConfigDlg_Proc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
ConfigDlg_Setup( hwnd );
|
||||
return ( TRUE );
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( LOWORD( wParam ) )
|
||||
{
|
||||
case IDC_CONFIG_PING:
|
||||
ConfigDlg_Ping( hwnd );
|
||||
break;
|
||||
|
||||
case IDC_CONFIG_XBOXNAME:
|
||||
CHAR buff[MAX_XBOXNAMELEN];
|
||||
GetDlgItemText( hwnd, IDC_CONFIG_XBOXNAME, buff, sizeof( buff ) );
|
||||
EnableWindow( GetDlgItem( hwnd, IDC_CONFIG_PING ), strlen( buff ) > 0 );
|
||||
break;
|
||||
|
||||
case IDC_OK:
|
||||
if ( !ConfigDlg_GetChanges( hwnd ) )
|
||||
break;
|
||||
case IDCANCEL:
|
||||
case IDC_CANCEL:
|
||||
EndDialog( hwnd, wParam );
|
||||
return ( TRUE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( FALSE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ConfigDlg_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConfigDlg_Open( void )
|
||||
{
|
||||
int result;
|
||||
|
||||
result = DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_CONFIG ), g_hDlgMain, ( DLGPROC )ConfigDlg_Proc );
|
||||
if ( LOWORD( result ) != IDC_OK )
|
||||
return;
|
||||
|
||||
ConfigDlg_SaveConfig();
|
||||
}
|
||||
983
utils/xbox/vxconsole/cpu_profile.cpp
Normal file
983
utils/xbox/vxconsole/cpu_profile.cpp
Normal file
@@ -0,0 +1,983 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// CPU_PROFILE.CPP
|
||||
//
|
||||
// Cpu Profiling Display
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define PROFILE_MAXCOUNTERS 64
|
||||
#define PROFILE_MAXSAMPLES 512
|
||||
|
||||
#define PROFILE_HISTORY_TIMINGHEIGHT 100
|
||||
#define PROFILE_HISTORY_NUMMINORTICKS 3
|
||||
#define PROFILE_HISTORY_LABELWIDTH 50
|
||||
#define PROFILE_HISTORY_SCALESTEPS 5
|
||||
#define PROFILE_HISTORY_MINSCALE 0.3f
|
||||
#define PROFILE_HISTORY_MAXSCALE 3.0f
|
||||
|
||||
#define PROFILE_SAMPLES_ITEMHEIGHT 15
|
||||
#define PROFILE_SAMPLES_BARHEIGHT 10
|
||||
#define PROFILE_SAMPLES_TIMINGWIDTH 200
|
||||
#define PROFILE_SAMPLES_LABELWIDTH 150
|
||||
#define PROFILE_SAMPLES_LABELGAP 5
|
||||
#define PROFILE_SAMPLES_NUMMINORTICKS 3
|
||||
#define PROFILE_SAMPLES_PEAKHOLDTIME 3000
|
||||
#define PROFILE_SAMPLES_SCALESTEPS 10
|
||||
#define PROFILE_SAMPLES_MINSCALE 0.3f
|
||||
#define PROFILE_SAMPLES_MAXSCALE 3.0f
|
||||
|
||||
#define ID_CPUPROFILE_SAMPLES 1
|
||||
#define ID_CPUPROFILE_HISTORY 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int samples[PROFILE_MAXSAMPLES];
|
||||
unsigned int peakSample;
|
||||
char label[64];
|
||||
COLORREF color;
|
||||
} profileCounter_t;
|
||||
|
||||
HWND g_cpuProfile_hWndSamples;
|
||||
HWND g_cpuProfile_hWndHistory;
|
||||
int g_cpuProfile_numCounters;
|
||||
profileCounter_t g_cpuProfile_counters[PROFILE_MAXCOUNTERS];
|
||||
RECT g_cpuProfile_samplesWindowRect;
|
||||
RECT g_cpuProfile_historyWindowRect;
|
||||
DWORD g_cpuProfile_lastPeakTime;
|
||||
bool g_cpuProfile_history_tickMarks = true;
|
||||
bool g_cpuProfile_history_colors = true;
|
||||
int g_cpuProfile_history_scale;
|
||||
bool g_cpuProfile_samples_tickMarks = true;
|
||||
bool g_cpuProfile_samples_colors = true;
|
||||
int g_cpuProfile_samples_scale;
|
||||
int g_cpuProfile_numSamples;
|
||||
int g_cpuProfile_fpsLabels;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
WINDOWPLACEMENT wp;
|
||||
|
||||
// profile samples
|
||||
if ( g_cpuProfile_hWndSamples )
|
||||
{
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_cpuProfile_hWndSamples, &wp );
|
||||
g_cpuProfile_samplesWindowRect = wp.rcNormalPosition;
|
||||
sprintf( buff, "%d %d %d %d", wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom );
|
||||
Sys_SetRegistryString( "profileSamplesWindowRect", buff );
|
||||
}
|
||||
Sys_SetRegistryInteger( "profileSamplesScale", g_cpuProfile_samples_scale );
|
||||
|
||||
// profile history
|
||||
if ( g_cpuProfile_hWndHistory )
|
||||
{
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_cpuProfile_hWndHistory, &wp );
|
||||
g_cpuProfile_historyWindowRect = wp.rcNormalPosition;
|
||||
sprintf( buff, "%d %d %d %d", wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom );
|
||||
Sys_SetRegistryString( "profileHistoryWindowRect", buff );
|
||||
}
|
||||
Sys_SetRegistryInteger( "profileHistoryScale", g_cpuProfile_history_scale );
|
||||
|
||||
Sys_SetRegistryInteger( "cpuProfileFpsLabels", g_cpuProfile_fpsLabels );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
// profile samples
|
||||
Sys_GetRegistryString( "profileSamplesWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_cpuProfile_samplesWindowRect.left, &g_cpuProfile_samplesWindowRect.top, &g_cpuProfile_samplesWindowRect.right, &g_cpuProfile_samplesWindowRect.bottom );
|
||||
if ( numArgs != 4 )
|
||||
memset( &g_cpuProfile_samplesWindowRect, 0, sizeof( g_cpuProfile_samplesWindowRect ) );
|
||||
Sys_GetRegistryInteger( "profileSamplesScale", 0, g_cpuProfile_samples_scale );
|
||||
if ( g_cpuProfile_samples_scale < -PROFILE_SAMPLES_SCALESTEPS || g_cpuProfile_samples_scale > PROFILE_SAMPLES_SCALESTEPS )
|
||||
g_cpuProfile_samples_scale = 0;
|
||||
|
||||
// profile history
|
||||
Sys_GetRegistryString( "profileHistoryWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_cpuProfile_historyWindowRect.left, &g_cpuProfile_historyWindowRect.top, &g_cpuProfile_historyWindowRect.right, &g_cpuProfile_historyWindowRect.bottom );
|
||||
if ( numArgs != 4 )
|
||||
memset( &g_cpuProfile_historyWindowRect, 0, sizeof( g_cpuProfile_historyWindowRect ) );
|
||||
Sys_GetRegistryInteger( "profileHistoryScale", 0, g_cpuProfile_history_scale );
|
||||
if ( g_cpuProfile_history_scale < -PROFILE_HISTORY_SCALESTEPS || g_cpuProfile_history_scale > PROFILE_HISTORY_SCALESTEPS )
|
||||
g_cpuProfile_history_scale = 0;
|
||||
|
||||
Sys_GetRegistryInteger( "cpuProfileFpsLabels", 0, g_cpuProfile_fpsLabels );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_SetTitle
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_SetTitle()
|
||||
{
|
||||
char titleBuff[128];
|
||||
|
||||
if ( g_cpuProfile_hWndSamples )
|
||||
{
|
||||
strcpy( titleBuff, "CPU Usage Snapshot" );
|
||||
if ( VProf_GetState() == VPROF_CPU )
|
||||
strcat( titleBuff, " [ON]" );
|
||||
|
||||
SetWindowText( g_cpuProfile_hWndSamples, titleBuff );
|
||||
}
|
||||
|
||||
if ( g_cpuProfile_hWndHistory )
|
||||
{
|
||||
strcpy( titleBuff, "CPU Usage History" );
|
||||
if ( VProf_GetState() == VPROF_CPU )
|
||||
strcat( titleBuff, " [ON]" );
|
||||
|
||||
SetWindowText( g_cpuProfile_hWndHistory, titleBuff );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_UpdateWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_UpdateWindow()
|
||||
{
|
||||
if ( g_cpuProfile_hWndSamples && !IsIconic( g_cpuProfile_hWndSamples ) )
|
||||
{
|
||||
// visible - force a client repaint
|
||||
InvalidateRect( g_cpuProfile_hWndSamples, NULL, true );
|
||||
}
|
||||
|
||||
if ( g_cpuProfile_hWndHistory && !IsIconic( g_cpuProfile_hWndHistory ) )
|
||||
{
|
||||
// visible - force a client repaint
|
||||
InvalidateRect( g_cpuProfile_hWndHistory, NULL, true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_SetCpuProfile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_SetCpuProfile( char* commandPtr )
|
||||
{
|
||||
int i;
|
||||
char* cmdToken;
|
||||
int retAddr;
|
||||
int errCode = -1;
|
||||
xrProfile_t* localList;
|
||||
int profileList;
|
||||
int numProfiles;
|
||||
int retVal;
|
||||
|
||||
// get numProfiles
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken,"%x",&numProfiles );
|
||||
|
||||
// get profile attributes
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &profileList );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken,"%x",&retAddr );
|
||||
|
||||
localList = new xrProfile_t[numProfiles];
|
||||
memset( localList, 0, numProfiles*sizeof( xrProfile_t ) );
|
||||
|
||||
// get the caller's profile list
|
||||
DmGetMemory( ( void* )profileList, numProfiles*sizeof( xrProfile_t ), localList, NULL );
|
||||
|
||||
g_cpuProfile_numCounters = numProfiles;
|
||||
if ( g_cpuProfile_numCounters > PROFILE_MAXCOUNTERS-1 )
|
||||
g_cpuProfile_numCounters = PROFILE_MAXCOUNTERS-1;
|
||||
|
||||
for ( i=0; i<g_cpuProfile_numCounters; i++ )
|
||||
{
|
||||
// swap the structure
|
||||
localList[i].color = BigDWord( localList[i].color );
|
||||
|
||||
// clear the old counter
|
||||
memset( &g_cpuProfile_counters[i], 0, sizeof( profileCounter_t ) );
|
||||
|
||||
V_strncpy( g_cpuProfile_counters[i].label, localList[i].labelString, sizeof( g_cpuProfile_counters[i].label ) );
|
||||
g_cpuProfile_counters[i].color = localList[i].color;
|
||||
}
|
||||
|
||||
// build out the reserved last counter as total count
|
||||
memset( &g_cpuProfile_counters[g_cpuProfile_numCounters], 0, sizeof( profileCounter_t ) );
|
||||
strcpy( g_cpuProfile_counters[g_cpuProfile_numCounters].label, "Total" );
|
||||
g_cpuProfile_counters[i].color = RGB( 255,255,255 );
|
||||
g_cpuProfile_numCounters++;
|
||||
|
||||
// set the return code
|
||||
retVal = g_cpuProfile_numCounters-1;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = SetCpuProfile( 0x%8.8x, 0x%8.8x )\n", retVal, numProfiles, profileList );
|
||||
|
||||
delete [] localList;
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_SetCpuProfileData
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_SetCpuProfileData( char* commandPtr )
|
||||
{
|
||||
int i;
|
||||
int total;
|
||||
char* cmdToken;
|
||||
int errCode = -1;
|
||||
int counters;
|
||||
int currentSample;
|
||||
bool newPeaks;
|
||||
unsigned int localCounters[PROFILE_MAXCOUNTERS];
|
||||
DWORD newTime;
|
||||
|
||||
// get profiles
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
{
|
||||
goto cleanUp;
|
||||
}
|
||||
sscanf( cmdToken, "%x", &counters );
|
||||
|
||||
// get the caller's profile list
|
||||
if ( g_cpuProfile_numCounters )
|
||||
{
|
||||
DmGetMemory( ( void* )counters, ( g_cpuProfile_numCounters-1 )*sizeof( int ), localCounters, NULL );
|
||||
}
|
||||
|
||||
// timeout peaks
|
||||
newTime = Sys_GetSystemTime();
|
||||
if ( newTime - g_cpuProfile_lastPeakTime > PROFILE_SAMPLES_PEAKHOLDTIME )
|
||||
{
|
||||
g_cpuProfile_lastPeakTime = newTime;
|
||||
newPeaks = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPeaks = false;
|
||||
}
|
||||
|
||||
// next sample
|
||||
currentSample = g_cpuProfile_numSamples % PROFILE_MAXSAMPLES;
|
||||
g_cpuProfile_numSamples++;
|
||||
|
||||
total = 0;
|
||||
for ( i=0; i<g_cpuProfile_numCounters; i++ )
|
||||
{
|
||||
// swap
|
||||
localCounters[i] = BigDWord( localCounters[i] );
|
||||
|
||||
if ( i != g_cpuProfile_numCounters-1 )
|
||||
{
|
||||
g_cpuProfile_counters[i].samples[currentSample] = localCounters[i];
|
||||
total += localCounters[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// reserved total counter
|
||||
g_cpuProfile_counters[i].samples[currentSample] = total;
|
||||
}
|
||||
|
||||
if ( newPeaks || g_cpuProfile_counters[i].peakSample < g_cpuProfile_counters[i].samples[currentSample] )
|
||||
{
|
||||
g_cpuProfile_counters[i].peakSample = g_cpuProfile_counters[i].samples[currentSample];
|
||||
}
|
||||
}
|
||||
|
||||
DebugCommand( "SetCpuProfileData( 0x%8.8x )\n", counters );
|
||||
|
||||
CpuProfile_UpdateWindow();
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_ZoomIn
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_ZoomIn( int& scale, int numSteps )
|
||||
{
|
||||
scale++;
|
||||
if ( scale > numSteps )
|
||||
{
|
||||
scale = numSteps;
|
||||
return;
|
||||
}
|
||||
CpuProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_ZoomOut
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_ZoomOut( int& scale, int numSteps )
|
||||
{
|
||||
scale--;
|
||||
if ( scale < -numSteps )
|
||||
{
|
||||
scale = -numSteps;
|
||||
return;
|
||||
}
|
||||
CpuProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_CalcScale
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
float CpuProfile_CalcScale( int scale, int numSteps, float min, float max )
|
||||
{
|
||||
float t;
|
||||
|
||||
// from integral scale [-numSteps..numSteps] to float scale [min..max]
|
||||
t = ( float )( scale + numSteps )/( float )( 2*numSteps );
|
||||
t = min + t*( max-min );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ProfileSamples_Draw
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ProfileSamples_Draw( HDC hdc, RECT* clientRect )
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int x;
|
||||
int y;
|
||||
int x0;
|
||||
int y0;
|
||||
int w;
|
||||
float t;
|
||||
float scale;
|
||||
float sampleTime;
|
||||
char labelBuff[128];
|
||||
HPEN hBlackPen;
|
||||
HPEN hPenOld;
|
||||
HPEN hGreyPen;
|
||||
HBRUSH hColoredBrush;
|
||||
HBRUSH hbrushOld;
|
||||
HFONT hFontOld;
|
||||
RECT rect;
|
||||
int currentSample;
|
||||
int numTicks;
|
||||
int timingWidth;
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
|
||||
hBlackPen = CreatePen( PS_SOLID, 1, RGB( 0,0,0 ) );
|
||||
hGreyPen = CreatePen( PS_SOLID, 1, Sys_ColorScale( g_backgroundColor, 0.85f ) );
|
||||
hPenOld = ( HPEN )SelectObject( hdc, hBlackPen );
|
||||
hFontOld = SelectFont( hdc, g_hProportionalFont );
|
||||
|
||||
SetBkColor( hdc, g_backgroundColor );
|
||||
|
||||
// zoom
|
||||
scale = CpuProfile_CalcScale( g_cpuProfile_samples_scale, PROFILE_SAMPLES_SCALESTEPS, PROFILE_SAMPLES_MINSCALE, PROFILE_SAMPLES_MAXSCALE );
|
||||
timingWidth = ( int )( PROFILE_SAMPLES_TIMINGWIDTH*scale );
|
||||
windowWidth = clientRect->right-clientRect->left;
|
||||
windowHeight = clientRect->bottom-clientRect->top;
|
||||
|
||||
numTicks = ( windowWidth-PROFILE_SAMPLES_LABELWIDTH )/timingWidth + 1;
|
||||
if ( numTicks < 0 )
|
||||
numTicks = 1;
|
||||
|
||||
rect.left = 0;
|
||||
rect.right = PROFILE_SAMPLES_LABELWIDTH;
|
||||
rect.top = 0;
|
||||
rect.bottom = PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
DrawText( hdc, "Name", -1, &rect, DT_LEFT );
|
||||
|
||||
// draw timing ticks
|
||||
x = PROFILE_SAMPLES_LABELWIDTH;
|
||||
y = 0;
|
||||
for ( i=0; i<numTicks; i++ )
|
||||
{
|
||||
// tick labels
|
||||
rect.left = x-40;
|
||||
rect.right = x+40;
|
||||
rect.top = y;
|
||||
rect.bottom = y+PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
if ( !g_cpuProfile_fpsLabels )
|
||||
sprintf( labelBuff, "%.2fms", i*( 1000.0f/60.0f ) );
|
||||
else
|
||||
sprintf( labelBuff, "%.2ffps", i == 0 ? 0 : 60.0f/i );
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_CENTER );
|
||||
|
||||
// major ticks
|
||||
x0 = x;
|
||||
y0 = y + PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, x0, y0, NULL );
|
||||
LineTo( hdc, x0, y0+windowHeight );
|
||||
|
||||
if ( g_cpuProfile_samples_tickMarks && g_cpuProfile_samples_scale > -PROFILE_SAMPLES_SCALESTEPS )
|
||||
{
|
||||
// minor ticks
|
||||
x0 = x;
|
||||
y0 = y + PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
SelectObject( hdc, hGreyPen );
|
||||
for ( j=0; j<PROFILE_SAMPLES_NUMMINORTICKS; j++ )
|
||||
{
|
||||
x0 += timingWidth/( PROFILE_SAMPLES_NUMMINORTICKS+1 );
|
||||
|
||||
MoveToEx( hdc, x0, y0, NULL );
|
||||
LineTo( hdc, x0, y0+windowHeight );
|
||||
}
|
||||
}
|
||||
x += timingWidth;
|
||||
}
|
||||
|
||||
// seperator
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, 0, PROFILE_SAMPLES_ITEMHEIGHT, NULL );
|
||||
LineTo( hdc, windowWidth, PROFILE_SAMPLES_ITEMHEIGHT );
|
||||
|
||||
// draw labels
|
||||
x = 0;
|
||||
y = PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
for ( i=0; i<g_cpuProfile_numCounters; i++ )
|
||||
{
|
||||
if ( !g_cpuProfile_counters[i].label )
|
||||
continue;
|
||||
|
||||
rect.left = x;
|
||||
rect.right = x+PROFILE_SAMPLES_LABELWIDTH-PROFILE_SAMPLES_LABELGAP;
|
||||
rect.top = y;
|
||||
rect.bottom = y+PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
DrawText( hdc, g_cpuProfile_counters[i].label, -1, &rect, DT_VCENTER|DT_RIGHT|DT_SINGLELINE|DT_END_ELLIPSIS|DT_MODIFYSTRING );
|
||||
|
||||
// draw the under line
|
||||
MoveToEx( hdc, x, y+PROFILE_SAMPLES_ITEMHEIGHT, NULL );
|
||||
LineTo( hdc, x+PROFILE_SAMPLES_LABELWIDTH, y+PROFILE_SAMPLES_ITEMHEIGHT );
|
||||
|
||||
y += PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
}
|
||||
|
||||
// draw bars
|
||||
SelectObject( hdc, hBlackPen );
|
||||
x = PROFILE_SAMPLES_LABELWIDTH;
|
||||
y = PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
currentSample = g_cpuProfile_numSamples-1;
|
||||
if ( currentSample < 0 )
|
||||
currentSample = 0;
|
||||
else
|
||||
currentSample %= PROFILE_MAXSAMPLES;
|
||||
for ( i=0; i<g_cpuProfile_numCounters; i++ )
|
||||
{
|
||||
if ( !g_cpuProfile_counters[i].label )
|
||||
continue;
|
||||
|
||||
hColoredBrush = CreateSolidBrush( g_cpuProfile_samples_colors ? g_cpuProfile_counters[i].color : g_backgroundColor );
|
||||
hbrushOld = ( HBRUSH )SelectObject( hdc, hColoredBrush );
|
||||
|
||||
// bar - count is in us i.e. 1 major tick = 16667us
|
||||
t = ( float )g_cpuProfile_counters[i].samples[currentSample]/( 1000000.0f/60.0f );
|
||||
w = ( int )( t * ( float )timingWidth );
|
||||
if ( w > windowWidth )
|
||||
w = windowWidth;
|
||||
x0 = x;
|
||||
y0 = y + ( PROFILE_SAMPLES_ITEMHEIGHT-PROFILE_SAMPLES_BARHEIGHT )/2 + 1;
|
||||
Rectangle( hdc, x0, y0, x0 + w, y0 + PROFILE_SAMPLES_BARHEIGHT );
|
||||
|
||||
// peak
|
||||
t = ( float )g_cpuProfile_counters[i].peakSample/( 1000000.0f/60.0f );
|
||||
w = ( int )( t * ( float )timingWidth );
|
||||
if ( w > windowWidth )
|
||||
w = windowWidth;
|
||||
x0 = x + w;
|
||||
y0 = y + PROFILE_SAMPLES_ITEMHEIGHT/2 + 1;
|
||||
|
||||
POINT points[4];
|
||||
points[0].x = x0;
|
||||
points[0].y = y0-4;
|
||||
points[1].x = x0+4;
|
||||
points[1].y = y0;
|
||||
points[2].x = x0;
|
||||
points[2].y = y0+4;
|
||||
points[3].x = x0-4;
|
||||
points[3].y = y0;
|
||||
Polygon( hdc, points, 4 );
|
||||
|
||||
SelectObject( hdc, hbrushOld );
|
||||
DeleteObject( hColoredBrush );
|
||||
|
||||
// draw peak times
|
||||
sampleTime = ( float )g_cpuProfile_counters[i].peakSample/1000.0f;
|
||||
if ( sampleTime >= 0.01F )
|
||||
{
|
||||
sprintf( labelBuff, "%.2f", sampleTime );
|
||||
rect.left = x0 + 8;
|
||||
rect.right = x0 + 8 + 100;
|
||||
rect.top = y;
|
||||
rect.bottom = y + PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_VCENTER|DT_LEFT|DT_SINGLELINE );
|
||||
}
|
||||
|
||||
y += PROFILE_SAMPLES_ITEMHEIGHT;
|
||||
}
|
||||
|
||||
SelectObject( hdc, hFontOld );
|
||||
SelectObject( hdc, hPenOld );
|
||||
DeleteObject( hBlackPen );
|
||||
DeleteObject( hGreyPen );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ProfileHistory_Draw
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ProfileHistory_Draw( HDC hdc, RECT* clientRect )
|
||||
{
|
||||
char labelBuff[128];
|
||||
HPEN hBlackPen;
|
||||
HPEN hPenOld;
|
||||
HPEN hNullPen;
|
||||
HPEN hGreyPen;
|
||||
HBRUSH hColoredBrush;
|
||||
HBRUSH hBrushOld;
|
||||
HFONT hFontOld;
|
||||
int currentSample;
|
||||
int numTicks;
|
||||
int timingHeight;
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
int x;
|
||||
int y;
|
||||
int y0;
|
||||
int i;
|
||||
int j;
|
||||
int h;
|
||||
int numbars;
|
||||
RECT rect;
|
||||
float t;
|
||||
float scale;
|
||||
|
||||
hBlackPen = CreatePen( PS_SOLID, 1, RGB( 0,0,0 ) );
|
||||
hGreyPen = CreatePen( PS_SOLID, 1, Sys_ColorScale( g_backgroundColor, 0.85f ) );
|
||||
hNullPen = CreatePen( PS_NULL, 0, RGB( 0,0,0 ) );
|
||||
hPenOld = ( HPEN )SelectObject( hdc, hBlackPen );
|
||||
hFontOld = SelectFont( hdc, g_hProportionalFont );
|
||||
|
||||
// zoom
|
||||
scale = CpuProfile_CalcScale( g_cpuProfile_history_scale, PROFILE_HISTORY_SCALESTEPS, PROFILE_HISTORY_MINSCALE, PROFILE_HISTORY_MAXSCALE );
|
||||
timingHeight = ( int )( PROFILE_HISTORY_TIMINGHEIGHT*scale );
|
||||
windowWidth = clientRect->right-clientRect->left;
|
||||
windowHeight = clientRect->bottom-clientRect->top;
|
||||
|
||||
numTicks = windowHeight/timingHeight + 2;
|
||||
if ( numTicks < 0 )
|
||||
numTicks = 1;
|
||||
|
||||
SetBkColor( hdc, g_backgroundColor );
|
||||
|
||||
x = 0;
|
||||
y = windowHeight;
|
||||
for ( i=0; i<numTicks; i++ )
|
||||
{
|
||||
// major ticks
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, 0, y, NULL );
|
||||
LineTo( hdc, windowWidth, y );
|
||||
|
||||
if ( g_cpuProfile_history_tickMarks && g_cpuProfile_history_scale > -PROFILE_HISTORY_SCALESTEPS )
|
||||
{
|
||||
// minor ticks
|
||||
y0 = y;
|
||||
SelectObject( hdc, hGreyPen );
|
||||
for ( j=0; j<PROFILE_HISTORY_NUMMINORTICKS; j++ )
|
||||
{
|
||||
y0 += timingHeight/( PROFILE_SAMPLES_NUMMINORTICKS+1 );
|
||||
MoveToEx( hdc, 0, y0, NULL );
|
||||
LineTo( hdc, windowWidth, y0 );
|
||||
}
|
||||
}
|
||||
|
||||
// tick labels
|
||||
if ( i )
|
||||
{
|
||||
rect.left = windowWidth-50;
|
||||
rect.right = windowWidth;
|
||||
rect.top = y-20;
|
||||
rect.bottom = y;
|
||||
if ( !g_cpuProfile_fpsLabels )
|
||||
sprintf( labelBuff, "%.2fms", i*( 1000.0f/60.0f ) );
|
||||
else
|
||||
sprintf( labelBuff, "%.2ffps", 60.0f/i );
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_RIGHT|DT_SINGLELINE|DT_BOTTOM );
|
||||
}
|
||||
|
||||
y -= timingHeight;
|
||||
}
|
||||
|
||||
// vertical bars
|
||||
if ( g_cpuProfile_numSamples )
|
||||
{
|
||||
SelectObject( hdc, hNullPen );
|
||||
|
||||
numbars = windowWidth-PROFILE_HISTORY_LABELWIDTH;
|
||||
currentSample = g_cpuProfile_numSamples-1;
|
||||
for ( x=numbars-1; x>=0; x-=4 )
|
||||
{
|
||||
// all the counters at this sample
|
||||
y = windowHeight;
|
||||
for ( j=0; j<g_cpuProfile_numCounters-1; j++ )
|
||||
{
|
||||
if ( !g_cpuProfile_counters[j].label )
|
||||
continue;
|
||||
|
||||
t = ( float )g_cpuProfile_counters[j].samples[currentSample % PROFILE_MAXSAMPLES]/( 1000000.0f/60.0f );
|
||||
h = ( int )( t * ( float )timingHeight );
|
||||
if ( h )
|
||||
{
|
||||
if ( h > windowHeight )
|
||||
h = windowHeight;
|
||||
|
||||
hColoredBrush = CreateSolidBrush( g_cpuProfile_history_colors ? g_cpuProfile_counters[j].color : RGB( 80,80,80 ) );
|
||||
hBrushOld = ( HBRUSH )SelectObject( hdc, hColoredBrush );
|
||||
|
||||
Rectangle( hdc, x-4, y-h, x, y+1 );
|
||||
y -= h;
|
||||
|
||||
SelectObject( hdc, hBrushOld );
|
||||
DeleteObject( hColoredBrush );
|
||||
}
|
||||
}
|
||||
currentSample--;
|
||||
if ( currentSample < 0 )
|
||||
{
|
||||
// no data
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject( hdc, hFontOld );
|
||||
SelectObject( hdc, hPenOld );
|
||||
DeleteObject( hBlackPen );
|
||||
DeleteObject( hGreyPen );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK CpuProfile_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT rect;
|
||||
int id;
|
||||
bool bIsSamples;
|
||||
bool bIsHistory;
|
||||
CREATESTRUCT *createStructPtr;
|
||||
|
||||
// identify window
|
||||
id = ( int )GetWindowLong( hwnd, GWL_USERDATA+0 );
|
||||
bIsSamples = ( id == ID_CPUPROFILE_SAMPLES );
|
||||
bIsHistory = ( id == ID_CPUPROFILE_HISTORY );
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
// set the window identifier
|
||||
createStructPtr = ( CREATESTRUCT* )lParam;
|
||||
SetWindowLong( hwnd, GWL_USERDATA+0, ( LONG )createStructPtr->lpCreateParams );
|
||||
|
||||
// reset peaks
|
||||
g_cpuProfile_lastPeakTime = 0;
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
CpuProfile_SaveConfig();
|
||||
|
||||
if ( bIsSamples )
|
||||
g_cpuProfile_hWndSamples = NULL;
|
||||
else if ( bIsHistory )
|
||||
g_cpuProfile_hWndHistory = NULL;
|
||||
|
||||
if ( VProf_GetState() == VPROF_CPU )
|
||||
{
|
||||
VProf_Enable( VPROF_OFF );
|
||||
}
|
||||
return 0L;
|
||||
|
||||
case WM_INITMENU:
|
||||
if ( bIsSamples )
|
||||
{
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_CPUPROFILE_TICKMARKS, MF_BYCOMMAND | ( g_cpuProfile_samples_tickMarks ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_CPUPROFILE_COLORS, MF_BYCOMMAND | ( g_cpuProfile_samples_colors ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
}
|
||||
else if ( bIsHistory )
|
||||
{
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_CPUPROFILE_TICKMARKS, MF_BYCOMMAND | ( g_cpuProfile_history_tickMarks ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_CPUPROFILE_COLORS, MF_BYCOMMAND | ( g_cpuProfile_history_colors ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
}
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_CPUPROFILE_FPSLABELS, MF_BYCOMMAND | ( g_cpuProfile_fpsLabels ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_CPUPROFILE_ENABLE, MF_BYCOMMAND | ( VProf_GetState() == VPROF_CPU ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
return 0L;
|
||||
|
||||
case WM_PAINT:
|
||||
GetClientRect( hwnd, &rect );
|
||||
hdc = BeginPaint( hwnd, &ps );
|
||||
if ( bIsSamples )
|
||||
ProfileSamples_Draw( hdc, &rect );
|
||||
else if ( bIsHistory )
|
||||
ProfileHistory_Draw( hdc, &rect );
|
||||
EndPaint( hwnd, &ps );
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
// force a redraw
|
||||
CpuProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_INSERT:
|
||||
if ( bIsSamples )
|
||||
CpuProfile_ZoomIn( g_cpuProfile_samples_scale, PROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
CpuProfile_ZoomIn( g_cpuProfile_history_scale, PROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case VK_DELETE:
|
||||
if ( bIsSamples )
|
||||
CpuProfile_ZoomOut( g_cpuProfile_samples_scale, PROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
CpuProfile_ZoomOut( g_cpuProfile_history_scale, PROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_CPUPROFILE_TICKMARKS:
|
||||
if ( bIsSamples )
|
||||
g_cpuProfile_samples_tickMarks ^= 1;
|
||||
else if ( bIsHistory )
|
||||
g_cpuProfile_history_tickMarks ^= 1;
|
||||
CpuProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_CPUPROFILE_COLORS:
|
||||
if ( bIsSamples )
|
||||
g_cpuProfile_samples_colors ^= 1;
|
||||
else if ( bIsHistory )
|
||||
g_cpuProfile_history_colors ^= 1;
|
||||
CpuProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_CPUPROFILE_FPSLABELS:
|
||||
g_cpuProfile_fpsLabels ^= 1;
|
||||
CpuProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_CPUPROFILE_ZOOMIN:
|
||||
if ( bIsSamples )
|
||||
CpuProfile_ZoomIn( g_cpuProfile_samples_scale, PROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
CpuProfile_ZoomIn( g_cpuProfile_history_scale, PROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case IDM_CPUPROFILE_ZOOMOUT:
|
||||
if ( bIsSamples )
|
||||
CpuProfile_ZoomOut( g_cpuProfile_samples_scale, PROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
CpuProfile_ZoomOut( g_cpuProfile_history_scale, PROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case IDM_CPUPROFILE_ENABLE:
|
||||
bool bEnable = ( VProf_GetState() == VPROF_CPU );
|
||||
bEnable ^= 1;
|
||||
if ( !bEnable )
|
||||
VProf_Enable( VPROF_OFF );
|
||||
else
|
||||
VProf_Enable( VPROF_CPU );
|
||||
CpuProfile_SetTitle();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfileHistory_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfileHistory_Open()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
if ( g_cpuProfile_hWndHistory )
|
||||
{
|
||||
// only one profile instance
|
||||
if ( IsIconic( g_cpuProfile_hWndHistory ) )
|
||||
ShowWindow( g_cpuProfile_hWndHistory, SW_RESTORE );
|
||||
SetForegroundWindow( g_cpuProfile_hWndHistory );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( VProf_GetState() == VPROF_OFF )
|
||||
{
|
||||
VProf_Enable( VPROF_CPU );
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"CPUPROFILEHISTORYCLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
500,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
( void* )ID_CPUPROFILE_HISTORY );
|
||||
g_cpuProfile_hWndHistory = hWnd;
|
||||
|
||||
CpuProfile_SetTitle();
|
||||
|
||||
if ( g_cpuProfile_historyWindowRect.right && g_cpuProfile_historyWindowRect.bottom )
|
||||
MoveWindow( g_cpuProfile_hWndHistory, g_cpuProfile_historyWindowRect.left, g_cpuProfile_historyWindowRect.top, g_cpuProfile_historyWindowRect.right-g_cpuProfile_historyWindowRect.left, g_cpuProfile_historyWindowRect.bottom-g_cpuProfile_historyWindowRect.top, FALSE );
|
||||
ShowWindow( g_cpuProfile_hWndHistory, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfileSamples_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfileSamples_Open()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
if ( g_cpuProfile_hWndSamples )
|
||||
{
|
||||
// only one profile instance
|
||||
if ( IsIconic( g_cpuProfile_hWndSamples ) )
|
||||
ShowWindow( g_cpuProfile_hWndSamples, SW_RESTORE );
|
||||
SetForegroundWindow( g_cpuProfile_hWndSamples );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( VProf_GetState() == VPROF_OFF )
|
||||
{
|
||||
VProf_Enable( VPROF_CPU );
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"CPUPROFILESAMPLESCLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
500,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
( void* )ID_CPUPROFILE_SAMPLES );
|
||||
g_cpuProfile_hWndSamples = hWnd;
|
||||
|
||||
CpuProfile_SetTitle();
|
||||
|
||||
if ( g_cpuProfile_samplesWindowRect.right && g_cpuProfile_samplesWindowRect.bottom )
|
||||
MoveWindow( g_cpuProfile_hWndSamples, g_cpuProfile_samplesWindowRect.left, g_cpuProfile_samplesWindowRect.top, g_cpuProfile_samplesWindowRect.right-g_cpuProfile_samplesWindowRect.left, g_cpuProfile_samplesWindowRect.bottom-g_cpuProfile_samplesWindowRect.top, FALSE );
|
||||
ShowWindow( g_cpuProfile_hWndSamples, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_Clear
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CpuProfile_Clear()
|
||||
{
|
||||
// clear counters and history
|
||||
g_cpuProfile_numCounters = 0;
|
||||
g_cpuProfile_numSamples = 0;
|
||||
|
||||
CpuProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CpuProfile_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CpuProfile_Init()
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
|
||||
// set up our window class
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = CpuProfile_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_CPUPROFILE );
|
||||
wndclass.lpszClassName = "CPUPROFILESAMPLESCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
// set up our window class
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = CpuProfile_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_CPUPROFILE );
|
||||
wndclass.lpszClassName = "CPUPROFILEHISTORYCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
CpuProfile_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
1134
utils/xbox/vxconsole/exclude_paths.cpp
Normal file
1134
utils/xbox/vxconsole/exclude_paths.cpp
Normal file
File diff suppressed because it is too large
Load Diff
416
utils/xbox/vxconsole/fileio.cpp
Normal file
416
utils/xbox/vxconsole/fileio.cpp
Normal file
@@ -0,0 +1,416 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// FILEIO.CPP
|
||||
//
|
||||
// File I/O Service Routines
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SystemTimeToString
|
||||
//
|
||||
// mm/dd/yyyy hh:mm:ss am
|
||||
//-----------------------------------------------------------------------------
|
||||
char *SystemTimeToString( SYSTEMTIME *systemTime, char *buffer, int bufferSize )
|
||||
{
|
||||
char timeString[256];
|
||||
char dateString[256];
|
||||
int length;
|
||||
|
||||
GetDateFormat( LOCALE_SYSTEM_DEFAULT, 0, systemTime, "MM'/'dd'/'yyyy", dateString, sizeof( dateString ) );
|
||||
GetTimeFormat( LOCALE_SYSTEM_DEFAULT, 0, systemTime, "hh':'mm':'ss tt", timeString, sizeof( timeString ) );
|
||||
length = _snprintf( buffer, bufferSize, "%s %s", dateString, timeString );
|
||||
if ( length == -1 )
|
||||
buffer[bufferSize-1] = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CompareFileTimes_NTFStoFATX
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CompareFileTimes_NTFStoFATX( FILETIME* ntfsFileTime, char *ntfsTimeString, int ntfsStringSize, FILETIME* fatxFileTime, char *fatxTimeString, int fatxStringSize )
|
||||
{
|
||||
SYSTEMTIME ntfsSystemTime;
|
||||
SYSTEMTIME fatxSystemTime;
|
||||
int diff;
|
||||
int ntfsSeconds;
|
||||
int fatxSeconds;
|
||||
|
||||
TIME_ZONE_INFORMATION tzInfo;
|
||||
GetTimeZoneInformation( &tzInfo );
|
||||
|
||||
// cannot compare UTC file times directly
|
||||
// disjoint filesystems - xbox has a +/- 2s error
|
||||
// daylight savings time handling on each file system may cause problems
|
||||
FileTimeToSystemTime( ntfsFileTime, &ntfsSystemTime );
|
||||
FileTimeToSystemTime( fatxFileTime, &fatxSystemTime );
|
||||
|
||||
// operate on local times, assumes xbox and pc are both set for same time zone and daylight saving
|
||||
SYSTEMTIME ntfsLocalTime;
|
||||
SYSTEMTIME fatxLocalTime;
|
||||
SystemTimeToTzSpecificLocalTime( &tzInfo, &ntfsSystemTime, &ntfsLocalTime );
|
||||
SystemTimeToTzSpecificLocalTime( &tzInfo, &fatxSystemTime, &fatxLocalTime );
|
||||
|
||||
if ( ntfsTimeString )
|
||||
{
|
||||
SystemTimeToString( &ntfsLocalTime, ntfsTimeString, ntfsStringSize );
|
||||
}
|
||||
|
||||
if ( fatxTimeString )
|
||||
{
|
||||
SystemTimeToString( &fatxLocalTime, fatxTimeString, fatxStringSize );
|
||||
}
|
||||
|
||||
diff = ntfsLocalTime.wYear-fatxLocalTime.wYear;
|
||||
if ( diff )
|
||||
return diff;
|
||||
|
||||
diff = ntfsLocalTime.wMonth-fatxLocalTime.wMonth;
|
||||
if ( diff )
|
||||
return diff;
|
||||
|
||||
diff = ntfsLocalTime.wDay-fatxLocalTime.wDay;
|
||||
if ( diff )
|
||||
return diff;
|
||||
|
||||
diff = ntfsLocalTime.wHour-fatxLocalTime.wHour;
|
||||
if ( diff )
|
||||
return diff;
|
||||
|
||||
// allow for +/- 3s error
|
||||
ntfsSeconds = ntfsLocalTime.wHour*60*60 + ntfsLocalTime.wMinute*60 + ntfsLocalTime.wSecond;
|
||||
fatxSeconds = fatxLocalTime.wHour*60*60 + fatxLocalTime.wMinute*60 + fatxLocalTime.wSecond;
|
||||
|
||||
diff = ntfsSeconds-fatxSeconds;
|
||||
if ( diff > 3 || diff < -3 )
|
||||
return diff;
|
||||
|
||||
// times are considered equal
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FreeTargetFileList
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void FreeTargetFileList( fileNode_t* pFileList )
|
||||
{
|
||||
fileNode_t *nodePtr;
|
||||
fileNode_t *nextPtr;
|
||||
|
||||
if ( !pFileList )
|
||||
return;
|
||||
|
||||
nodePtr = pFileList;
|
||||
while ( nodePtr )
|
||||
{
|
||||
nextPtr = nodePtr->nextPtr;
|
||||
|
||||
Sys_Free( nodePtr->filename );
|
||||
Sys_Free( nodePtr );
|
||||
|
||||
nodePtr = nextPtr;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GetTargetFileList_r
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GetTargetFileList_r( char* targetPath, bool recurse, int attributes, int level, fileNode_t** pFileList )
|
||||
{
|
||||
HRESULT hr;
|
||||
PDM_WALK_DIR pWalkDir = NULL;
|
||||
DM_FILE_ATTRIBUTES fileAttr;
|
||||
bool valid;
|
||||
char filename[MAX_PATH];
|
||||
fileNode_t* nodePtr;
|
||||
bool bGetNormal;
|
||||
int fixedAttributes;
|
||||
|
||||
if ( !level )
|
||||
*pFileList = NULL;
|
||||
|
||||
fixedAttributes = attributes;
|
||||
if ( fixedAttributes & FILE_ATTRIBUTE_NORMAL )
|
||||
{
|
||||
fixedAttributes &= ~FILE_ATTRIBUTE_NORMAL;
|
||||
bGetNormal = true;
|
||||
}
|
||||
else
|
||||
bGetNormal = false;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
hr = DmWalkDir( &pWalkDir, targetPath, &fileAttr );
|
||||
if ( hr != XBDM_NOERR )
|
||||
break;
|
||||
|
||||
strcpy( filename, targetPath );
|
||||
Sys_AddFileSeperator( filename, sizeof( filename ) );
|
||||
strcat( filename, fileAttr.Name );
|
||||
|
||||
// restrict to desired attributes
|
||||
if ( ( bGetNormal && !fileAttr.Attributes ) || ( fileAttr.Attributes & fixedAttributes ) )
|
||||
{
|
||||
Sys_NormalizePath( filename, false );
|
||||
|
||||
// create a new file node
|
||||
nodePtr = ( fileNode_t* )Sys_Alloc( sizeof( fileNode_t ) );
|
||||
|
||||
// link it in
|
||||
nodePtr->filename = Sys_CopyString( filename );
|
||||
nodePtr->changeTime = fileAttr.ChangeTime;
|
||||
nodePtr->creationTime = fileAttr.CreationTime;
|
||||
nodePtr->sizeHigh = fileAttr.SizeHigh;
|
||||
nodePtr->sizeLow = fileAttr.SizeLow;
|
||||
nodePtr->attributes = fileAttr.Attributes;
|
||||
nodePtr->level = level;
|
||||
nodePtr->nextPtr = *pFileList;
|
||||
*pFileList = nodePtr;
|
||||
}
|
||||
|
||||
if ( fileAttr.Attributes & FILE_ATTRIBUTE_DIRECTORY )
|
||||
{
|
||||
if ( recurse )
|
||||
{
|
||||
// descend into directory
|
||||
valid = GetTargetFileList_r( filename, recurse, attributes, level+1, pFileList );
|
||||
if ( !valid )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
DmCloseDir( pWalkDir );
|
||||
|
||||
if ( hr != XBDM_ENDOFLIST )
|
||||
{
|
||||
// failure
|
||||
return false;
|
||||
}
|
||||
|
||||
// ok
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FileSyncEx
|
||||
//
|
||||
// -1: failure, 0: nothing, 1: synced
|
||||
//-----------------------------------------------------------------------------
|
||||
int FileSyncEx( const char* localFilename, const char* targetFilename, int fileSyncMode, bool bVerbose, bool bNoWrite )
|
||||
{
|
||||
bool copy;
|
||||
bool pathExist;
|
||||
WIN32_FILE_ATTRIBUTE_DATA localAttributes;
|
||||
DM_FILE_ATTRIBUTES targetAttributes;
|
||||
HRESULT hr;
|
||||
int errCode;
|
||||
int deltaTime;
|
||||
char localTimeString[256];
|
||||
char targetTimeString[256];
|
||||
|
||||
if ( ( fileSyncMode & FSYNC_TYPEMASK ) == FSYNC_OFF )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !GetFileAttributesEx( localFilename, GetFileExInfoStandard, &localAttributes ) )
|
||||
{
|
||||
// failed to get the local file's attributes
|
||||
if ( bVerbose )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Sync Failure: Local file %s not available\n", localFilename );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( localAttributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
|
||||
{
|
||||
// ignore directory
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( fileSyncMode & FSYNC_ANDEXISTSONTARGET )
|
||||
{
|
||||
hr = DmGetFileAttributes( targetFilename, &targetAttributes );
|
||||
if ( hr != XBDM_NOERR )
|
||||
{
|
||||
// target doesn't exist, no sync operation should commence
|
||||
if ( bVerbose )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "No Update, Target file %s not available\n", targetFilename );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// default success, no operation
|
||||
errCode = 0;
|
||||
|
||||
// default, create path and copy
|
||||
copy = true;
|
||||
pathExist = false;
|
||||
|
||||
if ( ( fileSyncMode & FSYNC_TYPEMASK ) == FSYNC_IFNEWER )
|
||||
{
|
||||
hr = DmGetFileAttributes( targetFilename, &targetAttributes );
|
||||
if ( hr == XBDM_NOERR )
|
||||
{
|
||||
// target path to file exists
|
||||
pathExist = true;
|
||||
|
||||
// compare times
|
||||
deltaTime = CompareFileTimes_NTFStoFATX( &localAttributes.ftLastWriteTime, localTimeString, sizeof( localTimeString), &targetAttributes.ChangeTime, targetTimeString, sizeof( targetTimeString ) );
|
||||
if ( deltaTime < 0 )
|
||||
{
|
||||
// ntfs is older, fatx is newer, no update
|
||||
if ( bVerbose )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "No Update, %s [%s] is newer than %s [%s]\n", targetFilename, targetTimeString, localFilename, localTimeString );
|
||||
}
|
||||
copy = false;
|
||||
}
|
||||
else if ( !deltaTime )
|
||||
{
|
||||
// equal times, compare sizes
|
||||
if ( localAttributes.nFileSizeLow == targetAttributes.SizeLow &&
|
||||
localAttributes.nFileSizeHigh == targetAttributes.SizeHigh )
|
||||
{
|
||||
// file appears synced
|
||||
copy = false;
|
||||
}
|
||||
if ( bVerbose )
|
||||
{
|
||||
if ( copy )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "Update, %s [%s] [%d] has different size than %s [%s] [%d]\n", targetFilename, targetTimeString, targetAttributes.SizeLow, localFilename, localTimeString, localAttributes.nFileSizeLow );
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "No Update, %s [%s] [%d] has same time and file size as %s [%s] [%d]\n", targetFilename, targetTimeString, targetAttributes.SizeLow, localFilename, localTimeString, localAttributes.nFileSizeLow );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ntfs is newer, fatx is older, update
|
||||
if ( bVerbose )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "Update, %s [%s] is older than %s [%s]\n", targetFilename, targetTimeString, localFilename, localTimeString );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( ( fileSyncMode & FSYNC_TYPEMASK ) == FSYNC_ALWAYS )
|
||||
{
|
||||
if ( bVerbose )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "Force Update, %s\n", targetFilename );
|
||||
}
|
||||
}
|
||||
|
||||
if ( copy && !bNoWrite )
|
||||
{
|
||||
if ( !pathExist )
|
||||
{
|
||||
CreateTargetPath( targetFilename );
|
||||
}
|
||||
|
||||
hr = DmSendFile( localFilename, targetFilename );
|
||||
if ( hr == XBDM_NOERR )
|
||||
{
|
||||
// force the target to match the local attributes
|
||||
// to ensure sync
|
||||
memset( &targetAttributes, 0, sizeof( targetAttributes ) );
|
||||
targetAttributes.SizeHigh = localAttributes.nFileSizeHigh;
|
||||
targetAttributes.SizeLow = localAttributes.nFileSizeLow;
|
||||
targetAttributes.CreationTime = localAttributes.ftCreationTime;
|
||||
targetAttributes.ChangeTime = localAttributes.ftLastWriteTime;
|
||||
DmSetFileAttributes( targetFilename, &targetAttributes );
|
||||
|
||||
// success, file copied
|
||||
errCode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
if ( bVerbose )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Sync Failed!\n" );
|
||||
}
|
||||
errCode = -1;
|
||||
}
|
||||
|
||||
DebugCommand( "0x%8.8x = FileSyncEx( %s, %s )\n", hr, localFilename, targetFilename );
|
||||
}
|
||||
|
||||
return errCode;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LoadTargetFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool LoadTargetFile( const char *pTargetPath, int *pFileSize, void **pData )
|
||||
{
|
||||
DM_FILE_ATTRIBUTES fileAttributes;
|
||||
HRESULT hr;
|
||||
DWORD bytesRead;
|
||||
char *pBuffer;
|
||||
|
||||
*pFileSize = 0;
|
||||
*pData = (void *)NULL;
|
||||
|
||||
hr = DmGetFileAttributes( pTargetPath, &fileAttributes );
|
||||
if ( hr != XBDM_NOERR || !fileAttributes.SizeLow )
|
||||
return false;
|
||||
|
||||
// allocate for size and terminating null
|
||||
pBuffer = (char *)Sys_Alloc( fileAttributes.SizeLow+1 );
|
||||
|
||||
hr = DmReadFilePartial( pTargetPath, 0, (LPBYTE)pBuffer, fileAttributes.SizeLow, &bytesRead );
|
||||
if ( hr != XBDM_NOERR || ( bytesRead != fileAttributes.SizeLow ) )
|
||||
{
|
||||
Sys_Free( pBuffer );
|
||||
return false;
|
||||
}
|
||||
|
||||
// add a terminating null
|
||||
pBuffer[fileAttributes.SizeLow] = '\0';
|
||||
|
||||
*pFileSize = fileAttributes.SizeLow;
|
||||
*pData = pBuffer;
|
||||
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CreateTargetPath
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CreateTargetPath( const char *pTargetFilename )
|
||||
{
|
||||
// create path chain
|
||||
char *pPath;
|
||||
char dirPath[MAX_PATH];
|
||||
|
||||
// prime and skip to first seperator
|
||||
strcpy( dirPath, pTargetFilename );
|
||||
pPath = strchr( dirPath, '\\' );
|
||||
while ( pPath )
|
||||
{
|
||||
pPath = strchr( pPath+1, '\\' );
|
||||
if ( pPath )
|
||||
{
|
||||
*pPath = '\0';
|
||||
DmMkdir( dirPath );
|
||||
*pPath = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
BIN
utils/xbox/vxconsole/icon_connect1.ico
Normal file
BIN
utils/xbox/vxconsole/icon_connect1.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
BIN
utils/xbox/vxconsole/icon_connect2.ico
Normal file
BIN
utils/xbox/vxconsole/icon_connect2.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
BIN
utils/xbox/vxconsole/icon_connect2a.ico
Normal file
BIN
utils/xbox/vxconsole/icon_connect2a.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
BIN
utils/xbox/vxconsole/icon_disconnect.ico
Normal file
BIN
utils/xbox/vxconsole/icon_disconnect.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
1307
utils/xbox/vxconsole/local_cmds.cpp
Normal file
1307
utils/xbox/vxconsole/local_cmds.cpp
Normal file
File diff suppressed because it is too large
Load Diff
561
utils/xbox/vxconsole/mem_profile.cpp
Normal file
561
utils/xbox/vxconsole/mem_profile.cpp
Normal file
@@ -0,0 +1,561 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// MEM_PROFILE.CPP
|
||||
//
|
||||
// Memory Profiling Display
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define PROFILE_MAXSAMPLES 512
|
||||
#define PROFILE_MEMORYHEIGHT 100
|
||||
#define PROFILE_NUMMINORTICKS 3
|
||||
#define PROFILE_LABELWIDTH 50
|
||||
#define PROFILE_SCALESTEPS 8
|
||||
#define PROFILE_MINSCALE 0.2f
|
||||
#define PROFILE_MAXSCALE 3.0f
|
||||
#define PROFILE_NUMMINORTICKS 3
|
||||
#define PROFILE_MAJORTICKMB 16
|
||||
#define PROFILE_WARNINGMB 10
|
||||
#define PROFILE_SEVEREMB 5
|
||||
|
||||
#define ID_MEMPROFILE 1
|
||||
|
||||
HWND g_memProfile_hWnd;
|
||||
RECT g_memProfile_WindowRect;
|
||||
int g_memProfile_tickMarks;
|
||||
int g_memProfile_colors;
|
||||
int g_memProfile_scale;
|
||||
UINT_PTR g_memProfile_Timer;
|
||||
int g_memProfile_numSamples;
|
||||
int g_memProfile_samples[PROFILE_MAXSAMPLES];
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
WINDOWPLACEMENT wp;
|
||||
|
||||
// profile history
|
||||
if ( g_memProfile_hWnd )
|
||||
{
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_memProfile_hWnd, &wp );
|
||||
g_memProfile_WindowRect = wp.rcNormalPosition;
|
||||
sprintf( buff, "%d %d %d %d", wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom );
|
||||
Sys_SetRegistryString( "MemProfileWindowRect", buff );
|
||||
}
|
||||
|
||||
Sys_SetRegistryInteger( "MemProfileScale", g_memProfile_scale );
|
||||
Sys_SetRegistryInteger( "MemProfileTickMarks", g_memProfile_tickMarks );
|
||||
Sys_SetRegistryInteger( "MemProfileColors", g_memProfile_colors );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
// profile history
|
||||
Sys_GetRegistryString( "MemProfileWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_memProfile_WindowRect.left, &g_memProfile_WindowRect.top, &g_memProfile_WindowRect.right, &g_memProfile_WindowRect.bottom );
|
||||
if ( numArgs != 4 )
|
||||
{
|
||||
memset( &g_memProfile_WindowRect, 0, sizeof( g_memProfile_WindowRect ) );
|
||||
}
|
||||
|
||||
Sys_GetRegistryInteger( "MemProfileScale", 0, g_memProfile_scale );
|
||||
if ( g_memProfile_scale < -PROFILE_SCALESTEPS || g_memProfile_scale > PROFILE_SCALESTEPS )
|
||||
{
|
||||
g_memProfile_scale = 0;
|
||||
}
|
||||
|
||||
Sys_GetRegistryInteger( "MemProfileTickMarks", 1, g_memProfile_tickMarks );
|
||||
Sys_GetRegistryInteger( "MemProfileColors", 1, g_memProfile_colors );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_SetTitle
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_SetTitle()
|
||||
{
|
||||
char titleBuff[128];
|
||||
|
||||
if ( g_memProfile_hWnd )
|
||||
{
|
||||
strcpy( titleBuff, "Free Memory Available" );
|
||||
if ( g_memProfile_Timer )
|
||||
{
|
||||
strcat( titleBuff, " [ON]" );
|
||||
}
|
||||
|
||||
SetWindowText( g_memProfile_hWnd, titleBuff );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_EnableProfiling
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_EnableProfiling( bool bEnable )
|
||||
{
|
||||
if ( !g_memProfile_hWnd )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UINT_PTR timer = TIMERID_MEMPROFILE;
|
||||
if ( bEnable && !g_memProfile_Timer )
|
||||
{
|
||||
// run at 10Hz
|
||||
g_memProfile_Timer = SetTimer( g_memProfile_hWnd, timer, 100, NULL );
|
||||
}
|
||||
else if ( !bEnable && g_memProfile_Timer )
|
||||
{
|
||||
KillTimer( g_memProfile_hWnd, timer );
|
||||
g_memProfile_Timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_UpdateWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_UpdateWindow()
|
||||
{
|
||||
if ( g_memProfile_hWnd && !IsIconic( g_memProfile_hWnd ) )
|
||||
{
|
||||
// visible - force a client repaint
|
||||
InvalidateRect( g_memProfile_hWnd, NULL, true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_FreeMemory
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_FreeMemory( char* commandPtr )
|
||||
{
|
||||
int errCode = -1;
|
||||
int freeMemory;
|
||||
|
||||
char *cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
{
|
||||
goto cleanUp;
|
||||
}
|
||||
sscanf( cmdToken, "%x", &freeMemory );
|
||||
|
||||
g_memProfile_samples[g_memProfile_numSamples % PROFILE_MAXSAMPLES] = freeMemory;
|
||||
g_memProfile_numSamples++;
|
||||
|
||||
DebugCommand( "FreeMemory( 0x%8.8x )\n", freeMemory );
|
||||
|
||||
MemProfile_UpdateWindow();
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_ZoomIn
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_ZoomIn( int& scale, int numSteps )
|
||||
{
|
||||
scale++;
|
||||
if ( scale > numSteps )
|
||||
{
|
||||
scale = numSteps;
|
||||
return;
|
||||
}
|
||||
MemProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_ZoomOut
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_ZoomOut( int& scale, int numSteps )
|
||||
{
|
||||
scale--;
|
||||
if ( scale < -numSteps )
|
||||
{
|
||||
scale = -numSteps;
|
||||
return;
|
||||
}
|
||||
MemProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_CalcScale
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
float MemProfile_CalcScale( int scale, int numSteps, float min, float max )
|
||||
{
|
||||
float t;
|
||||
|
||||
// from integral scale [-numSteps..numSteps] to float scale [min..max]
|
||||
t = ( float )( scale + numSteps )/( float )( 2*numSteps );
|
||||
t = min + t*( max-min );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_Draw
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_Draw( HDC hdc, RECT* clientRect )
|
||||
{
|
||||
char labelBuff[128];
|
||||
HPEN hBlackPen;
|
||||
HPEN hPenOld;
|
||||
HPEN hNullPen;
|
||||
HPEN hGreyPen;
|
||||
HBRUSH hColoredBrush;
|
||||
HBRUSH hBrushOld;
|
||||
HFONT hFontOld;
|
||||
int currentSample;
|
||||
int numTicks;
|
||||
int memoryHeight;
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
int x;
|
||||
int y;
|
||||
int y0;
|
||||
int i;
|
||||
int j;
|
||||
int h;
|
||||
int numbars;
|
||||
RECT rect;
|
||||
float t;
|
||||
float scale;
|
||||
|
||||
hBlackPen = CreatePen( PS_SOLID, 1, RGB( 0,0,0 ) );
|
||||
hGreyPen = CreatePen( PS_SOLID, 1, Sys_ColorScale( g_backgroundColor, 0.85f ) );
|
||||
hNullPen = CreatePen( PS_NULL, 0, RGB( 0,0,0 ) );
|
||||
hPenOld = ( HPEN )SelectObject( hdc, hBlackPen );
|
||||
hFontOld = SelectFont( hdc, g_hProportionalFont );
|
||||
|
||||
// zoom
|
||||
scale = MemProfile_CalcScale( g_memProfile_scale, PROFILE_SCALESTEPS, PROFILE_MINSCALE, PROFILE_MAXSCALE );
|
||||
memoryHeight = ( int )( PROFILE_MEMORYHEIGHT*scale );
|
||||
windowWidth = clientRect->right-clientRect->left;
|
||||
windowHeight = clientRect->bottom-clientRect->top;
|
||||
|
||||
numTicks = windowHeight/memoryHeight + 2;
|
||||
if ( numTicks < 0 )
|
||||
{
|
||||
numTicks = 1;
|
||||
}
|
||||
else if ( numTicks > 512/PROFILE_MAJORTICKMB + 1 )
|
||||
{
|
||||
numTicks = 512/PROFILE_MAJORTICKMB + 1;
|
||||
}
|
||||
|
||||
SetBkColor( hdc, g_backgroundColor );
|
||||
|
||||
x = 0;
|
||||
y = windowHeight;
|
||||
for ( i=0; i<numTicks; i++ )
|
||||
{
|
||||
// major ticks
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, 0, y, NULL );
|
||||
LineTo( hdc, windowWidth, y );
|
||||
|
||||
if ( g_memProfile_tickMarks )
|
||||
{
|
||||
// could be very zoomed out, gap must be enough for label, otherwise don't draw
|
||||
int gapY = memoryHeight/( PROFILE_NUMMINORTICKS+1 );
|
||||
if ( gapY >= 10 )
|
||||
{
|
||||
// minor ticks
|
||||
y0 = y;
|
||||
SelectObject( hdc, hGreyPen );
|
||||
for ( j=0; j<PROFILE_NUMMINORTICKS; j++ )
|
||||
{
|
||||
y0 += gapY;
|
||||
MoveToEx( hdc, 0, y0, NULL );
|
||||
LineTo( hdc, windowWidth, y0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tick labels
|
||||
if ( i )
|
||||
{
|
||||
rect.left = windowWidth - 50;
|
||||
rect.right = windowWidth;
|
||||
rect.top = y - 20;
|
||||
rect.bottom = y;
|
||||
sprintf( labelBuff, "%d MB", i*PROFILE_MAJORTICKMB );
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_RIGHT|DT_SINGLELINE|DT_BOTTOM );
|
||||
}
|
||||
|
||||
y -= memoryHeight;
|
||||
}
|
||||
|
||||
// vertical bars
|
||||
if ( g_memProfile_numSamples )
|
||||
{
|
||||
SelectObject( hdc, hNullPen );
|
||||
|
||||
numbars = windowWidth-PROFILE_LABELWIDTH;
|
||||
currentSample = g_memProfile_numSamples-1;
|
||||
for ( x=numbars-1; x>=0; x-=4 )
|
||||
{
|
||||
float sample = g_memProfile_samples[currentSample % PROFILE_MAXSAMPLES]/( 1024.0f * 1024.0f );
|
||||
|
||||
y = windowHeight;
|
||||
t = sample/(float)PROFILE_MAJORTICKMB;
|
||||
h = ( int )( t * ( float )memoryHeight );
|
||||
if ( h )
|
||||
{
|
||||
if ( h > windowHeight )
|
||||
h = windowHeight;
|
||||
|
||||
COLORREF barColor;
|
||||
if ( sample >= PROFILE_WARNINGMB )
|
||||
{
|
||||
barColor = RGB( 100, 255, 100 );
|
||||
}
|
||||
else if ( sample >= PROFILE_SEVEREMB )
|
||||
{
|
||||
barColor = RGB( 255, 255, 100 );
|
||||
}
|
||||
else
|
||||
{
|
||||
barColor = RGB( 255, 0, 0 );
|
||||
}
|
||||
|
||||
hColoredBrush = CreateSolidBrush( g_memProfile_colors ? barColor : RGB( 80, 80, 80 ) );
|
||||
hBrushOld = ( HBRUSH )SelectObject( hdc, hColoredBrush );
|
||||
|
||||
Rectangle( hdc, x-4, y-h, x, y+1 );
|
||||
y -= h;
|
||||
|
||||
SelectObject( hdc, hBrushOld );
|
||||
DeleteObject( hColoredBrush );
|
||||
}
|
||||
|
||||
currentSample--;
|
||||
if ( currentSample < 0 )
|
||||
{
|
||||
// no data
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject( hdc, hFontOld );
|
||||
SelectObject( hdc, hPenOld );
|
||||
DeleteObject( hBlackPen );
|
||||
DeleteObject( hGreyPen );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_TimerProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_TimerProc( HWND hwnd, UINT_PTR idEvent )
|
||||
{
|
||||
static bool busy = false;
|
||||
|
||||
if ( busy )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
busy = true;
|
||||
|
||||
if ( g_connectedToApp )
|
||||
{
|
||||
// send as async
|
||||
DmAPI_SendCommand( VXCONSOLE_COMMAND_PREFIX "!" "__memory__ quiet", false );
|
||||
}
|
||||
|
||||
busy = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK MemProfile_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT rect;
|
||||
CREATESTRUCT *createStructPtr;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
// set the window identifier
|
||||
createStructPtr = ( CREATESTRUCT* )lParam;
|
||||
SetWindowLong( hwnd, GWL_USERDATA+0, ( LONG )createStructPtr->lpCreateParams );
|
||||
|
||||
// clear samples
|
||||
g_memProfile_numSamples = 0;
|
||||
memset( g_memProfile_samples, 0, sizeof( g_memProfile_samples ) );
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
MemProfile_SaveConfig();
|
||||
MemProfile_EnableProfiling( false );
|
||||
g_memProfile_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_INITMENU:
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_MEMPROFILE_TICKMARKS, MF_BYCOMMAND | ( g_memProfile_tickMarks ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_MEMPROFILE_COLORS, MF_BYCOMMAND | ( g_memProfile_colors ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_MEMPROFILE_ENABLE, MF_BYCOMMAND | ( g_memProfile_Timer != NULL ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
return 0L;
|
||||
|
||||
case WM_PAINT:
|
||||
GetClientRect( hwnd, &rect );
|
||||
hdc = BeginPaint( hwnd, &ps );
|
||||
MemProfile_Draw( hdc, &rect );
|
||||
EndPaint( hwnd, &ps );
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
// force a redraw
|
||||
MemProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case WM_TIMER:
|
||||
if ( wID == TIMERID_MEMPROFILE )
|
||||
{
|
||||
MemProfile_TimerProc( hwnd, TIMERID_MEMPROFILE );
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_INSERT:
|
||||
MemProfile_ZoomIn( g_memProfile_scale, PROFILE_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case VK_DELETE:
|
||||
MemProfile_ZoomOut( g_memProfile_scale, PROFILE_SCALESTEPS );
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_MEMPROFILE_TICKMARKS:
|
||||
g_memProfile_tickMarks ^= 1;
|
||||
MemProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_MEMPROFILE_COLORS:
|
||||
g_memProfile_colors ^= 1;
|
||||
MemProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_MEMPROFILE_ZOOMIN:
|
||||
MemProfile_ZoomIn( g_memProfile_scale, PROFILE_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case IDM_MEMPROFILE_ZOOMOUT:
|
||||
MemProfile_ZoomOut( g_memProfile_scale, PROFILE_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case IDM_MEMPROFILE_ENABLE:
|
||||
bool bEnable = ( g_memProfile_Timer != NULL );
|
||||
bEnable ^= 1;
|
||||
MemProfile_EnableProfiling( bEnable );
|
||||
MemProfile_SetTitle();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MemProfile_Open()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
if ( g_memProfile_hWnd )
|
||||
{
|
||||
// only one profile instance
|
||||
if ( IsIconic( g_memProfile_hWnd ) )
|
||||
ShowWindow( g_memProfile_hWnd, SW_RESTORE );
|
||||
SetForegroundWindow( g_memProfile_hWnd );
|
||||
return;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"MEMPROFILECLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
500,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
( void* )ID_MEMPROFILE );
|
||||
g_memProfile_hWnd = hWnd;
|
||||
|
||||
MemProfile_EnableProfiling( true );
|
||||
MemProfile_SetTitle();
|
||||
|
||||
if ( g_memProfile_WindowRect.right && g_memProfile_WindowRect.bottom )
|
||||
MoveWindow( g_memProfile_hWnd, g_memProfile_WindowRect.left, g_memProfile_WindowRect.top, g_memProfile_WindowRect.right-g_memProfile_WindowRect.left, g_memProfile_WindowRect.bottom-g_memProfile_WindowRect.top, FALSE );
|
||||
ShowWindow( g_memProfile_hWnd, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MemProfile_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MemProfile_Init()
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
|
||||
// set up our window class
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = MemProfile_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_MEMPROFILE );
|
||||
wndclass.lpszClassName = "MEMPROFILECLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
MemProfile_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
359
utils/xbox/vxconsole/progress.cpp
Normal file
359
utils/xbox/vxconsole/progress.cpp
Normal file
@@ -0,0 +1,359 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// PROGRESS.CPP
|
||||
//
|
||||
// Progress Metering Utility.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define PROGRESS_WIDTH 425
|
||||
#define PROGRESS_HEIGHT 170
|
||||
|
||||
#define ID_PROGRESS_STATUS1 100
|
||||
#define ID_PROGRESS_STATUS2 101
|
||||
#define ID_PROGRESS_STATUS3 102
|
||||
#define ID_PROGRESS_PERCENT 103
|
||||
#define ID_PROGRESS_METER 104
|
||||
#define ID_PROGRESS_CANCEL 105
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK Progress_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
CProgress *pProgress;
|
||||
CREATESTRUCT *createStructPtr;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
createStructPtr = ( CREATESTRUCT* )lParam;
|
||||
SetWindowLong( hwnd, GWL_USERDATA+0, ( LONG )createStructPtr->lpCreateParams );
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
pProgress = ( CProgress* )GetWindowLong( hwnd, GWL_USERDATA+0 );
|
||||
if ( pProgress )
|
||||
pProgress->m_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_CTLCOLORSTATIC:
|
||||
SetBkColor( ( HDC )wParam, g_backgroundColor );
|
||||
return ( BOOL )g_hBackgroundBrush;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( LOWORD( wParam ) )
|
||||
{
|
||||
case ID_PROGRESS_CANCEL:
|
||||
pProgress = ( CProgress* )GetWindowLong( hwnd, GWL_USERDATA+0 );
|
||||
if ( pProgress )
|
||||
pProgress->m_bCancelPressed = true;
|
||||
return ( TRUE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::Update
|
||||
//
|
||||
// Pump the message loop
|
||||
//-----------------------------------------------------------------------------
|
||||
void CProgress::Update()
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
while ( PeekMessage( &msg, NULL, 0, 0, PM_NOYIELD|PM_REMOVE ) )
|
||||
{
|
||||
if ( !TranslateAccelerator( g_hDlgMain, g_hAccel, &msg ) )
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::IsCancel
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CProgress::IsCancel()
|
||||
{
|
||||
return m_bCancelPressed;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::SetMeter
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CProgress::SetMeter( int currentPos, int range )
|
||||
{
|
||||
char buff[16];
|
||||
int percent;
|
||||
|
||||
if ( !m_hWnd || !m_hWndPercent || !m_hWndMeter )
|
||||
return;
|
||||
|
||||
if ( range >= 0 )
|
||||
{
|
||||
SendMessage( m_hWndMeter, PBM_SETRANGE, 0, MAKELPARAM( 0, range ) );
|
||||
m_range = range;
|
||||
}
|
||||
SendMessage( m_hWndMeter, PBM_SETPOS, currentPos, 0 );
|
||||
|
||||
if ( m_range > 0 )
|
||||
{
|
||||
percent = ( int )( 100.0f*currentPos/m_range );
|
||||
if ( percent > 100 )
|
||||
percent = 100;
|
||||
}
|
||||
else
|
||||
percent = 0;
|
||||
sprintf( buff, "%d%%", percent );
|
||||
SetWindowText( m_hWndPercent, buff );
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::SetStatus
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CProgress::SetStatus( const char *line1, const char *line2, const char *line3 )
|
||||
{
|
||||
if ( !m_hWnd )
|
||||
return;
|
||||
|
||||
if ( line1 )
|
||||
SetWindowText( m_hWndStatus1, line1 );
|
||||
if ( line2 )
|
||||
SetWindowText( m_hWndStatus2, line2 );
|
||||
if ( line3 )
|
||||
SetWindowText( m_hWndStatus3, line3 );
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CProgress::Open( const char* title, bool canCancel, bool bHasMeter )
|
||||
{
|
||||
HWND hWnd;
|
||||
RECT clientRect;
|
||||
RECT parentRect;
|
||||
int cx;
|
||||
int cy;
|
||||
int cw;
|
||||
int ch;
|
||||
int y;
|
||||
int dialogHeight;
|
||||
|
||||
dialogHeight = PROGRESS_HEIGHT;
|
||||
if ( !canCancel )
|
||||
dialogHeight -= 25;
|
||||
if ( !bHasMeter )
|
||||
dialogHeight -= GetSystemMetrics( SM_CYVSCROLL );
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"PROGRESSCLASS",
|
||||
title,
|
||||
WS_POPUP|WS_CAPTION,
|
||||
0,
|
||||
0,
|
||||
PROGRESS_WIDTH,
|
||||
dialogHeight,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
( void* )this );
|
||||
m_hWnd = hWnd;
|
||||
if ( !m_hWnd )
|
||||
return;
|
||||
|
||||
// status text line #1
|
||||
GetClientRect( m_hWnd, &clientRect );
|
||||
y = 10;
|
||||
hWnd = CreateWindowEx(
|
||||
0,
|
||||
WC_STATIC,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|SS_WORDELLIPSIS,
|
||||
8,
|
||||
10,
|
||||
clientRect.right-clientRect.left-2*8 - 50,
|
||||
20,
|
||||
m_hWnd,
|
||||
( HMENU )ID_PROGRESS_STATUS1,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
m_hWndStatus1 = hWnd;
|
||||
y += 20;
|
||||
|
||||
// status text line #2
|
||||
hWnd = CreateWindowEx(
|
||||
0,
|
||||
WC_STATIC,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|SS_PATHELLIPSIS,
|
||||
8,
|
||||
y,
|
||||
clientRect.right-clientRect.left-2*8 -50,
|
||||
20,
|
||||
m_hWnd,
|
||||
( HMENU )ID_PROGRESS_STATUS2,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
m_hWndStatus2 = hWnd;
|
||||
y += 20;
|
||||
|
||||
// status text line #3
|
||||
hWnd = CreateWindowEx(
|
||||
0,
|
||||
WC_STATIC,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|SS_PATHELLIPSIS,
|
||||
8,
|
||||
y,
|
||||
clientRect.right-clientRect.left-2*8 -50,
|
||||
20,
|
||||
m_hWnd,
|
||||
( HMENU )ID_PROGRESS_STATUS3,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
m_hWndStatus3 = hWnd;
|
||||
y += 20;
|
||||
|
||||
// set font
|
||||
SendMessage( m_hWndStatus1, WM_SETFONT, ( WPARAM )g_hProportionalFont, TRUE );
|
||||
SendMessage( m_hWndStatus2, WM_SETFONT, ( WPARAM )g_hProportionalFont, TRUE );
|
||||
SendMessage( m_hWndStatus3, WM_SETFONT, ( WPARAM )g_hProportionalFont, TRUE );
|
||||
|
||||
if ( bHasMeter )
|
||||
{
|
||||
// percent
|
||||
hWnd = CreateWindowEx(
|
||||
0,
|
||||
WC_STATIC,
|
||||
"0%",
|
||||
WS_VISIBLE|WS_CHILD|SS_RIGHT,
|
||||
( clientRect.right-clientRect.left ) - 2*8 - 50,
|
||||
y - 20,
|
||||
50,
|
||||
20,
|
||||
m_hWnd,
|
||||
( HMENU )ID_PROGRESS_PERCENT,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
m_hWndPercent = hWnd;
|
||||
SendMessage( m_hWndPercent, WM_SETFONT, ( WPARAM )g_hProportionalFont, TRUE );
|
||||
|
||||
// progress meter
|
||||
ch = GetSystemMetrics( SM_CYVSCROLL );
|
||||
cw = ( clientRect.right-clientRect.left ) - 2*8;
|
||||
cx = ( clientRect.left + clientRect.right )/2 - cw/2;
|
||||
cy = y;
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
PROGRESS_CLASS,
|
||||
NULL,
|
||||
WS_VISIBLE|WS_CHILD,
|
||||
cx,
|
||||
cy,
|
||||
cw,
|
||||
ch,
|
||||
m_hWnd,
|
||||
( HMENU )ID_PROGRESS_METER,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
m_hWndMeter = hWnd;
|
||||
y = cy+ch;
|
||||
|
||||
// ensure bar is reset
|
||||
SendMessage( m_hWndMeter, PBM_SETRANGE, 0, 0 );
|
||||
SendMessage( m_hWndMeter, PBM_SETPOS, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hWndPercent = NULL;
|
||||
m_hWndMeter = NULL;
|
||||
}
|
||||
|
||||
m_bCancelPressed = false;
|
||||
if ( canCancel )
|
||||
{
|
||||
ch = 25;
|
||||
cw = 80;
|
||||
cx = ( clientRect.left + clientRect.right )/2 - cw/2;
|
||||
cy = clientRect.bottom - 8 - ch;
|
||||
|
||||
// cancel button
|
||||
hWnd = CreateWindowEx(
|
||||
0,
|
||||
WC_BUTTON,
|
||||
"Cancel",
|
||||
WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
|
||||
cx,
|
||||
cy,
|
||||
cw,
|
||||
ch,
|
||||
m_hWnd,
|
||||
( HMENU )ID_PROGRESS_CANCEL,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
m_hWndCancel = hWnd;
|
||||
|
||||
SendMessage( m_hWndCancel, WM_SETFONT, ( WPARAM )g_hProportionalFont, TRUE );
|
||||
}
|
||||
|
||||
// get parent rectangle
|
||||
GetWindowRect( g_hDlgMain, &parentRect );
|
||||
cx = ( parentRect.left + parentRect.right )/2 - PROGRESS_WIDTH/2;
|
||||
cy = ( parentRect.top + parentRect.bottom )/2 - dialogHeight/2;
|
||||
|
||||
MoveWindow( m_hWnd, cx, cy, PROGRESS_WIDTH, dialogHeight, FALSE );
|
||||
ShowWindow( m_hWnd, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::~CProgress
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CProgress::~CProgress()
|
||||
{
|
||||
if ( !m_hWnd )
|
||||
return;
|
||||
|
||||
DestroyWindow( m_hWnd );
|
||||
m_hWnd = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CProgress::CProgress
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CProgress::CProgress()
|
||||
{
|
||||
// set up our window class
|
||||
WNDCLASS wndclass;
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = Progress_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = sizeof( CProgress* );
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = NULL;
|
||||
wndclass.lpszClassName = "PROGRESSCLASS";
|
||||
RegisterClass( &wndclass );
|
||||
|
||||
m_hWnd = 0;
|
||||
m_bCancelPressed = false;
|
||||
}
|
||||
484
utils/xbox/vxconsole/remote_cmds.cpp
Normal file
484
utils/xbox/vxconsole/remote_cmds.cpp
Normal file
@@ -0,0 +1,484 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// REMOTE_CMDS.CPP
|
||||
//
|
||||
// Remote commands received by an external application and dispatched.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
remoteCommand_t *g_remoteCommands[MAX_RCMDS];
|
||||
int g_numRemoteCommands;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MatchRemoteCommands
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int MatchRemoteCommands( char *pCmdStr, const char *cmdList[], int maxCmds )
|
||||
{
|
||||
int numCommands = 0;
|
||||
|
||||
// look in local
|
||||
int matchLen = strlen( pCmdStr );
|
||||
for ( int i=0; i<g_numRemoteCommands; i++ )
|
||||
{
|
||||
if ( !strnicmp( pCmdStr, g_remoteCommands[i]->strCommand, matchLen ) )
|
||||
{
|
||||
cmdList[numCommands++] = g_remoteCommands[i]->strCommand;
|
||||
if ( numCommands >= maxCmds )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ( numCommands );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GetToken
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
char *GetToken( char **ppTokenStream )
|
||||
{
|
||||
static char token[MAX_TOKENCHARS];
|
||||
int len;
|
||||
char c;
|
||||
char *pData;
|
||||
|
||||
len = 0;
|
||||
token[0] = 0;
|
||||
|
||||
if ( !ppTokenStream )
|
||||
return NULL;
|
||||
|
||||
pData = *ppTokenStream;
|
||||
|
||||
// skip whitespace
|
||||
skipwhite:
|
||||
while ( ( c = *pData ) <= ' ' )
|
||||
{
|
||||
if ( !c )
|
||||
goto cleanup;
|
||||
pData++;
|
||||
}
|
||||
|
||||
// skip // comments
|
||||
if ( c=='/' && pData[1] == '/' )
|
||||
{
|
||||
while ( *pData && *pData != '\n' )
|
||||
pData++;
|
||||
goto skipwhite;
|
||||
}
|
||||
|
||||
// handle quoted strings specially
|
||||
if ( c == '\"' )
|
||||
{
|
||||
pData++;
|
||||
while ( 1 )
|
||||
{
|
||||
c = *pData++;
|
||||
if ( c=='\"' || !c )
|
||||
goto cleanup;
|
||||
|
||||
token[len] = c;
|
||||
len++;
|
||||
if ( len > MAX_TOKENCHARS-1 )
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
// parse a regular word
|
||||
do
|
||||
{
|
||||
token[len] = c;
|
||||
pData++;
|
||||
len++;
|
||||
if ( len > MAX_TOKENCHARS-1 )
|
||||
break;
|
||||
c = *pData;
|
||||
}
|
||||
while ( c > ' ' && c <= '~' );
|
||||
|
||||
cleanup:
|
||||
token[len] = 0;
|
||||
*ppTokenStream = pData;
|
||||
return ( token );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CommandCompleted
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CommandCompleted( int errCode )
|
||||
{
|
||||
char cmdString[MAX_PATH];
|
||||
|
||||
// send command complete
|
||||
sprintf( cmdString, "%s!__complete__%d", VXCONSOLE_COMMAND_PREFIX, errCode );
|
||||
DmAPI_SendCommand( cmdString, true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DebugCommand
|
||||
//-----------------------------------------------------------------------------
|
||||
void DebugCommand( const char *pStrFormat, ... )
|
||||
{
|
||||
char buffer[MAX_QUEUEDSTRINGLEN];
|
||||
va_list arglist;
|
||||
|
||||
if ( !g_debugCommands )
|
||||
return;
|
||||
|
||||
va_start( arglist, pStrFormat );
|
||||
_vsnprintf( buffer, MAX_QUEUEDSTRINGLEN, pStrFormat, arglist );
|
||||
va_end( arglist );
|
||||
|
||||
PrintToQueue( RGB( 0,128,0 ), "[CMD]: %s", buffer );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remote_NotifyPrintFunc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD __stdcall Remote_NotifyPrintFunc( const CHAR *pStrNotification )
|
||||
{
|
||||
int color;
|
||||
|
||||
if ( !strnicmp( pStrNotification, VXCONSOLE_PRINT_PREFIX, strlen( VXCONSOLE_PRINT_PREFIX ) ) )
|
||||
{
|
||||
// skip past prefix!
|
||||
pStrNotification += strlen( VXCONSOLE_PRINT_PREFIX )+1;
|
||||
}
|
||||
|
||||
color = XBX_CLR_DEFAULT;
|
||||
|
||||
if ( !strnicmp( pStrNotification, VXCONSOLE_COLOR_PREFIX, strlen( VXCONSOLE_COLOR_PREFIX ) ) )
|
||||
{
|
||||
// skip past prefix[12345678]
|
||||
char buff[16];
|
||||
pStrNotification += strlen( VXCONSOLE_COLOR_PREFIX );
|
||||
memcpy( buff, pStrNotification, 10 );
|
||||
if ( buff[0] == '[' && buff[9] == ']' )
|
||||
{
|
||||
buff[0] = ' ';
|
||||
buff[9] = ' ';
|
||||
buff[10] = '\0';
|
||||
|
||||
sscanf( buff, "%x", &color );
|
||||
pStrNotification += 10;
|
||||
}
|
||||
}
|
||||
|
||||
PrintToQueue( color, "%s\n", pStrNotification );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remote_NotifyDebugString
|
||||
//
|
||||
// Print as [DBG]:xxxx
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD __stdcall Remote_NotifyDebugString( ULONG dwNotification, DWORD dwParam )
|
||||
{
|
||||
if ( g_captureDebugSpew )
|
||||
{
|
||||
PDMN_DEBUGSTR p = ( PDMN_DEBUGSTR )dwParam;
|
||||
int len;
|
||||
|
||||
// strip all terminating cr
|
||||
len = p->Length-1;
|
||||
while ( len > 0 )
|
||||
{
|
||||
if ( p->String[len] != '\n' )
|
||||
{
|
||||
len++;
|
||||
break;
|
||||
}
|
||||
len--;
|
||||
}
|
||||
|
||||
// for safety, terminate
|
||||
CHAR* strTemp = new CHAR[len+1];
|
||||
memcpy( strTemp, p->String, len*sizeof( CHAR ) );
|
||||
strTemp[len] = '\0';
|
||||
|
||||
PrintToQueue( RGB( 0,0,255 ), "[DBG]: %s\n", strTemp );
|
||||
|
||||
delete[] strTemp;
|
||||
}
|
||||
|
||||
// Don't let the compiler complain about unused parameters
|
||||
( VOID )dwNotification;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remote_CompareCommands
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int Remote_CompareCommands( const void *pElem1, const void *pElem2 )
|
||||
{
|
||||
remoteCommand_t *pCmd1;
|
||||
remoteCommand_t *pCmd2;
|
||||
|
||||
pCmd1 = *( remoteCommand_t** )( pElem1 );
|
||||
pCmd2 = *( remoteCommand_t** )( pElem2 );
|
||||
|
||||
return ( strcmp( pCmd1->strCommand, pCmd2->strCommand ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remote_DeleteCommands
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Remote_DeleteCommands()
|
||||
{
|
||||
if ( !g_numRemoteCommands )
|
||||
return;
|
||||
|
||||
for ( int i=0; i<g_numRemoteCommands; i++ )
|
||||
{
|
||||
delete [] g_remoteCommands[i]->strCommand;
|
||||
delete [] g_remoteCommands[i]->strHelp;
|
||||
delete g_remoteCommands[i];
|
||||
|
||||
g_remoteCommands[i] = NULL;
|
||||
}
|
||||
|
||||
g_numRemoteCommands = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remote_AddCommand
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Remote_AddCommand( char *command, char *helptext )
|
||||
{
|
||||
if ( g_numRemoteCommands == MAX_RCMDS )
|
||||
{
|
||||
// full
|
||||
return false;
|
||||
}
|
||||
|
||||
// look for duplicate
|
||||
int i;
|
||||
for ( i = 0; i < g_numRemoteCommands; i++ )
|
||||
{
|
||||
if ( !stricmp( command, g_remoteCommands[i]->strCommand ) )
|
||||
break;
|
||||
}
|
||||
if ( i < g_numRemoteCommands )
|
||||
{
|
||||
// already in list, skip - not an error
|
||||
return true;
|
||||
}
|
||||
|
||||
// add new command to list
|
||||
g_remoteCommands[g_numRemoteCommands] = new remoteCommand_t;
|
||||
g_remoteCommands[g_numRemoteCommands]->strCommand = new char[strlen( command )+1];
|
||||
strcpy( g_remoteCommands[g_numRemoteCommands]->strCommand, command );
|
||||
|
||||
g_remoteCommands[g_numRemoteCommands]->strHelp = new char[strlen( helptext )+1];
|
||||
strcpy( g_remoteCommands[g_numRemoteCommands]->strHelp, helptext );
|
||||
|
||||
g_numRemoteCommands++;
|
||||
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_AddCommands
|
||||
//
|
||||
// Exposes an app's list of remote commands
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_AddCommands( char *commandPtr )
|
||||
{
|
||||
char* cmdToken;
|
||||
int numCommands;
|
||||
int cmdList;
|
||||
int retAddr;
|
||||
int retVal;
|
||||
int errCode;
|
||||
xrCommand_t* locallist;
|
||||
|
||||
errCode = -1;
|
||||
|
||||
// pacifier for lengthy operation
|
||||
ConsoleWindowPrintf( RGB( 0, 0, 0 ), "Receiving Console Commands From Game..." );
|
||||
|
||||
// get number of commands
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &numCommands );
|
||||
|
||||
// get command list
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &cmdList );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &retAddr );
|
||||
|
||||
locallist = new xrCommand_t[numCommands];
|
||||
memset( locallist, 0, numCommands*sizeof( xrCommand_t ) );
|
||||
|
||||
// get the caller's command list
|
||||
DmGetMemory( ( void* )cmdList, numCommands*sizeof( xrCommand_t ), locallist, NULL );
|
||||
|
||||
int numAdded = 0;
|
||||
for ( int i=0; i<numCommands; i++ )
|
||||
{
|
||||
if ( Remote_AddCommand( locallist[i].nameString, locallist[i].helpString ) )
|
||||
numAdded++;
|
||||
}
|
||||
|
||||
// sort the list
|
||||
qsort( g_remoteCommands, g_numRemoteCommands, sizeof( remoteCommand_t* ), Remote_CompareCommands );
|
||||
|
||||
ConsoleWindowPrintf( RGB( 0, 0, 0 ), "Completed.\n" );
|
||||
|
||||
// return the result
|
||||
retVal = numAdded;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = AddCommands( 0x%8.8x, 0x%8.8x )\n", retVal, numCommands, cmdList );
|
||||
|
||||
delete [] locallist;
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
if ( g_bPlayTestMode )
|
||||
{
|
||||
if ( g_connectedToApp )
|
||||
{
|
||||
// send the developer command
|
||||
ProcessCommand( "developer 1" );
|
||||
}
|
||||
}
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Remote_NotifyCommandFunc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD __stdcall Remote_NotifyCommandFunc( const CHAR *strNotification )
|
||||
{
|
||||
CHAR* commandPtr;
|
||||
CHAR* cmdToken;
|
||||
int errCode;
|
||||
bool async;
|
||||
|
||||
// skip over the command prefix and the exclamation mark
|
||||
strNotification += strlen( VXCONSOLE_COMMAND_PREFIX ) + 1;
|
||||
commandPtr = ( CHAR* )strNotification;
|
||||
|
||||
// failure until otherwise
|
||||
errCode = -1;
|
||||
|
||||
// default synchronous
|
||||
async = false;
|
||||
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
|
||||
if ( cmdToken && !stricmp( cmdToken, "AddCommands()" ) )
|
||||
{
|
||||
errCode = rc_AddCommands( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "SetProfile()" ) )
|
||||
{
|
||||
// first arg dictates routing
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( cmdToken && !stricmp( cmdToken, "cpu" ) )
|
||||
errCode = rc_SetCpuProfile( commandPtr );
|
||||
else if ( cmdToken && !stricmp( cmdToken, "texture" ) )
|
||||
errCode = rc_SetTexProfile( commandPtr );
|
||||
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "SetProfileData()" ) )
|
||||
{
|
||||
// first arg dictates routing
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( cmdToken && !stricmp( cmdToken, "cpu" ) )
|
||||
errCode = rc_SetCpuProfileData( commandPtr );
|
||||
else if ( cmdToken && !stricmp( cmdToken, "texture" ) )
|
||||
errCode = rc_SetTexProfileData( commandPtr );
|
||||
|
||||
async = true;
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "TextureList()" ) )
|
||||
{
|
||||
errCode = rc_TextureList( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "MaterialList()" ) )
|
||||
{
|
||||
errCode = rc_MaterialList( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "SoundList()" ) )
|
||||
{
|
||||
errCode = rc_SoundList( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "TimeStampLog()" ) )
|
||||
{
|
||||
errCode = rc_TimeStampLog( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "MemDump()" ) )
|
||||
{
|
||||
errCode = rc_MemDump( commandPtr );
|
||||
async = true;
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "MapInfo()" ) )
|
||||
{
|
||||
errCode = rc_MapInfo( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "Assert()" ) )
|
||||
{
|
||||
errCode = rc_Assert( commandPtr );
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "FreeMemory()" ) )
|
||||
{
|
||||
errCode = rc_FreeMemory( commandPtr );
|
||||
async = true;
|
||||
goto cleanUp;
|
||||
}
|
||||
else if ( cmdToken && !stricmp( cmdToken, "Disconnect()" ) )
|
||||
{
|
||||
// disconnect requires specialized processing
|
||||
// send command status first while connection valid, then do actual disconnect
|
||||
// disconnect is always assumed to be valid, can't be denied
|
||||
CommandCompleted( 0 );
|
||||
DoDisconnect( TRUE );
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// unknown command
|
||||
PrintToQueue( RGB( 255,0,0 ), "Unknown Command: %s\n", strNotification );
|
||||
goto cleanUp;
|
||||
}
|
||||
|
||||
cleanUp:
|
||||
if ( !async )
|
||||
CommandCompleted( errCode );
|
||||
|
||||
return ( S_OK );
|
||||
}
|
||||
241
utils/xbox/vxconsole/resource.h
Normal file
241
utils/xbox/vxconsole/resource.h
Normal file
@@ -0,0 +1,241 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by vxconsole.rc
|
||||
//
|
||||
#define MENU_PROFILE 4
|
||||
#define MENU_CPUPROFILE 4
|
||||
#define MENU_VXCONSOLE 100
|
||||
#define IDD_VXCONSOLE 104
|
||||
#define IDD_CONFIG 111
|
||||
#define IDC_LABEL 113
|
||||
#define IDD_SYNCFILES 116
|
||||
#define MENU_SHOWTEXTURES 118
|
||||
#define MENU_TEXPROFILE 120
|
||||
#define MENU_BINDOPTIONS 122
|
||||
#define IDD_MODIFYBIND 123
|
||||
#define MENU_SHOWMATERIALS 124
|
||||
#define MENU_SHOWSOUNDS 125
|
||||
#define MENU_SHOWMEMORYDUMP 127
|
||||
#define IDD_BUG 128
|
||||
#define MENU_TIMESTAMPLOG 129
|
||||
#define IDD_EXCLUDEPATHS 131
|
||||
#define IDD_INSTALL 132
|
||||
#define MENU_MEMPROFILE 133
|
||||
#define IDI_VXCONSOLE 200
|
||||
#define IDI_DISCONNECTED 201
|
||||
#define IDI_CONNECT1_ON 202
|
||||
#define IDI_CONNECT2_ON 203
|
||||
#define IDI_CONNECT2_OFF 204
|
||||
#define IDC_COMMAND 1000
|
||||
#define IDC_OUTPUT 1010
|
||||
#define IDC_CONFIG_XBOXNAME 1015
|
||||
#define IDC_CONFIG_REMOTEPATH 1016
|
||||
#define IDC_CONFIG_LOCALPATH 1017
|
||||
#define IDC_CONFIG_PING 1018
|
||||
#define IDC_OK 1019
|
||||
#define IDC_CANCEL 1020
|
||||
#define IDC_CONFIG_CLEARONCONNECT 1021
|
||||
#define IDC_CONFIG_TARGETPATH 1022
|
||||
#define IDC_CONFIG_XBELOCALPATH 1023
|
||||
#define IDC_CONFIG_XEXLOCALPATH 1023
|
||||
#define IDC_CONFIG_XBETARGETPATH 1024
|
||||
#define IDC_CONFIG_XEXTARGETPATH 1024
|
||||
#define IDC_CONFIG_INSTALLPATH 1025
|
||||
#define IDC_CONFIG_LOADSYMBOLS 1028
|
||||
#define IDC_SYNCFILES_LOCALPATH 1029
|
||||
#define IDC_SYNCFILES_TARGETPATH 1030
|
||||
#define IDC_SYNCFILES_FORCESYNC 1035
|
||||
#define IDC_SYNCFILES_NOWRITE 1036
|
||||
#define IDC_SYNCFILES_DELETEORPHANS 1037
|
||||
#define IDC_CONFIG_SAMPLEFILE 1038
|
||||
#define IDC_SYNCFILES_VERBOSE 1038
|
||||
#define IDC_CONFIG_SAMPLELOCAL 1039
|
||||
#define IDC_SYNCFILES_ANDEXISTSONXBOX 1039
|
||||
#define IDC_CONFIG_SAMPLETARGET 1040
|
||||
#define IDC_CONFIG_XBEFORCESYNC 1045
|
||||
#define IDC_CONFIG_XEXFORCESYNC 1045
|
||||
#define IDC_CONFIG_XBESYNCONCONNECT 1046
|
||||
#define IDC_CONFIG_XEXSYNCONCONNECT 1046
|
||||
#define IDC_MODIFYBIND_MENUNAME 1050
|
||||
#define IDC_MODIFYBIND_COMMAND 1051
|
||||
#define IDC_MODIFYBIND_KEYCODE 1052
|
||||
#define IDC_CONFIG_ALWAYSAUTOCONNECT 1053
|
||||
#define IDC_CONFIG_STARTMINIMIZED 1054
|
||||
#define IDC_CONFIG_CAPTUREDEBUGSPEW 1055
|
||||
#define IDC_BUG_CLEARFORM 1056
|
||||
#define IDC_BUG_TITLE 1057
|
||||
#define IDC_BUG_DESCRIPTION 1058
|
||||
#define IDC_BUG_CLEARFORM2 1059
|
||||
#define IDC_BUG_UPDATE 1059
|
||||
#define IDC_BUG_INCLUDEBSP 1060
|
||||
#define IDC_BUG_SAVEGAME 1061
|
||||
#define IDC_BUG_INCLUDEVMF 1062
|
||||
#define IDC_BUG_TAKESHOT 1063
|
||||
#define IDC_BUG_SEVERITY 1065
|
||||
#define IDC_BUG_REPORTTYPE 1066
|
||||
#define IDC_BUG_PRIORITY 1067
|
||||
#define IDC_BUG_AREA 1068
|
||||
#define IDC_BUG_TAKESHOT_LABEL 1069
|
||||
#define IDC_BUG_SAVEGAME_LABEL 1070
|
||||
#define IDC_BUG_INCLUDEBSP_LABEL 1071
|
||||
#define IDC_BUG_INCLUDEVMF_LABEL 1072
|
||||
#define IDC_BUG_POSITION_LABEL 1073
|
||||
#define IDC_BUG_ORIENTATION_LABEL 1074
|
||||
#define IDC_BUG_MAP_LABEL 1075
|
||||
#define IDC_BUG_BUILD_LABEL 1076
|
||||
#define IDC_BUG_SUBMITTER_LABEL 1077
|
||||
#define IDC_BUG_MAPNUMBER 1078
|
||||
#define IDC_BUG_SUBMIT 1079
|
||||
#define IDC_BUG_SEVERITY2 1080
|
||||
#define IDC_BUG_OWNER 1080
|
||||
#define IDC_BUG_GAME 1082
|
||||
#define IDC_CHECK1 1083
|
||||
#define IDC_BUG_COMPRESS_SCREENSHOT 1083
|
||||
#define IDC_PATHS_LINKGAMEDIRS 1083
|
||||
#define IDC_INSTALL_FORCESYNC 1083
|
||||
#define IDC_PATHS_TREE 1085
|
||||
#define IDC_PATHS_RESCAN 1086
|
||||
#define IDC_PATHS_EXPAND 1087
|
||||
#define IDC_PATHS_COLLAPSE 1088
|
||||
#define IDC_INSTALL_LIST 1088
|
||||
#define IDC_INSTALL_REFRESH 1089
|
||||
#define IDC_CHECK2 1091
|
||||
#define IDC_INSTALL_CLEANTARGET 1091
|
||||
#define IDR_MAIN_ACCEL 3000
|
||||
#define IDM_CONNECT 40002
|
||||
#define IDM_DEBUGMONITOR 40004
|
||||
#define IDM_DEBUGCOMMANDS 40008
|
||||
#define IDM_AUTOCONNECT 40009
|
||||
#define IDM_DISCONNECT 40013
|
||||
#define IDM_EXIT 40017
|
||||
#define IDM_CONFIG 40018
|
||||
#define IDM_DEBUGMEMORY 40019
|
||||
#define IDM_FILELOG 40021
|
||||
#define IDM_CLEARLOG 40026
|
||||
#define IDM_ENABLELOG 40027
|
||||
#define IDM_REFRESHLOG 40031
|
||||
#define ID_LOG_SUMMARY 40032
|
||||
#define IDM_SUMMARYLOG 40035
|
||||
#define ID_Menu 40048
|
||||
#define IDM_PROFILESAMPLES 40064
|
||||
#define IDM_PROFILEHISTORY 40066
|
||||
#define IDM_SYNCTARGET 40073
|
||||
#define IDM_SYNCIFNEWER 40074
|
||||
#define IDM_ENABLEFILESERVING 40075
|
||||
#define ID_CONNECTION_FILESERVING 40076
|
||||
#define IDM_FILESERVING_LOCALONLY 40080
|
||||
#define IDM_FILESERVING_REMOTEONLY 40081
|
||||
#define IDM_FILESERVING_LOCALFIRST 40083
|
||||
#define IDM_FILESYNC_OFF 40088
|
||||
#define IDM_FILESYNC_ALWAYS 40089
|
||||
#define IDM_FILESYNC_IFNEWER 40090
|
||||
#define IDM_EXPORTLOG 40092
|
||||
#define ID_Menu40094 40094
|
||||
#define IDM_SYMBOLS_ADDRESS 40106
|
||||
#define IDM_SYMBOLS_FUNCTIONNAME 40110
|
||||
#define IDM_SYMBOLS_MODULEANDLINE 40112
|
||||
#define IDM_SYMBOLS_FILEPATHANDLINE 40114
|
||||
#define IDM_SYMBOLS_LOAD 40116
|
||||
#define IDM_SYNCFILES 40117
|
||||
#define IDM_SYMBOLS_DETAILS 40119
|
||||
#define IDM_OPTIONS_TREEVIEW 40121
|
||||
#define ID_Menu40123 40123
|
||||
#define IDM_SHOWMATERIALS 40124
|
||||
#define IDM_REFRESH 40127
|
||||
#define IDM_SHOWRESOURCES_TEXTURES 40130
|
||||
#define IDM_OPTIONS_CURRENTFRAME 40132
|
||||
#define IDM_OPTIONS_SUMMARY 40135
|
||||
#define IDM_OPTIONS_REFRESH 40136
|
||||
#define IDM_OPTIONS_EXPORT 40137
|
||||
#define IDM_OPTIONS_FULLPATH 40139
|
||||
#define ID_CONNECTION_PROFILING 40140
|
||||
#define ID_PROFILING_CPU 40141
|
||||
#define ID_PROFILING_TEXTURE 40142
|
||||
#define ID_CONNECTION_TEXTUREPROFILING 40147
|
||||
#define IDM_CPU_SAMPLES 40148
|
||||
#define IDM_CPU_HISTORY 40149
|
||||
#define IDM_SHOWRESOURCES_MATERIALS 40154
|
||||
#define IDM_SHOWRESOURCES_MODELS 40155
|
||||
#define ID_CONNECTION_EE 40157
|
||||
#define IDM_CPUPROFILE_TICKMARKS 40160
|
||||
#define IDM_CPUPROFILE_COLORS 40161
|
||||
#define IDM_CPUPROFILE_ZOOMIN 40162
|
||||
#define IDM_CPUPROFILE_ZOOMOUT 40163
|
||||
#define IDM_CPUPROFILE_ENABLE 40164
|
||||
#define IDM_TEXPROFILE_TICKMARKS 40166
|
||||
#define IDM_TEXPROFILE_COLORS 40168
|
||||
#define IDM_TEXPROFILE_ZOOMIN 40172
|
||||
#define IDM_TEXPROFILE_ZOOMOUT 40173
|
||||
#define IDM_TEXPROFILE_ENABLE 40174
|
||||
#define IDM_TEXPROFILE_CURRENTFRAME 40176
|
||||
#define ID_Menu40177 40177
|
||||
#define ID_VPROFILING_SHOWTEXTURE 40178
|
||||
#define ID_Menu40189 40189
|
||||
#define IDM_BINDOPTIONS_MODIFY 40192
|
||||
#define IDM_BINDOPTIONS_DELETE 40193
|
||||
#define IDM_TIMESTAMPLOG 50502
|
||||
#define IDM_CPUPROFILE_FPSLABELS 50505
|
||||
#define IDM_SHOWRESOURCES_SOUNDS 50509
|
||||
#define IDM_OPTIONS_PLAYSOUND 50513
|
||||
#define IDM_D3D_SAMPLES 50516
|
||||
#define IDM_D3D_HISTORY 50517
|
||||
#define IDM_MEMORYDUMP 50520
|
||||
#define IDM_OPTIONS_BYTES 50527
|
||||
#define IDM_OPTIONS_KILOBYTES 50530
|
||||
#define IDM_OPTIONS_MEGABYTES 50531
|
||||
#define IDM_OPTIONS_COLLAPSEOUTPUT 50533
|
||||
#define IDM_SYNCINSTALL 50535
|
||||
#define ID_Menu50536 50536
|
||||
#define IDM_FILESYNC_ANDEXISTSONTARGET 50539
|
||||
#define ID_CONNECTION_SEARCHPATHS 50540
|
||||
#define ID_SEARCHPATHS_NOZIPS 50541
|
||||
#define ID_SEARCHPATHS_PAKFILESFIRST 50542
|
||||
#define ID_SEARCHPATHS_PAKFILES 50543
|
||||
#define ID_Menu50546 50546
|
||||
#define IDM_SYNCINSTALL_TODVD 50547
|
||||
#define IDM_SYNCINSTALL_TOHDD 50548
|
||||
#define IDM_SHOWRESOURCES_BUG 50550
|
||||
#define IDM_BUG 50552
|
||||
#define IDM_SYNCXEX 50553
|
||||
#define IDM_DEBUGSPEW 50557
|
||||
#define IDM_CAPTUREGAMESPEW 50560
|
||||
#define IDM_CAPTUREDEBUGSPEW 50561
|
||||
#define ID_CONNECTION_DVDEXCLUDEPATHS 50562
|
||||
#define IDM_DVDEXCLUDEPATHS 50563
|
||||
#define IDM_EXCLUDEPATHS 50564
|
||||
#define ID_OPTIONS_SHOWTEXTURE 50565
|
||||
#define IDM_OPTIONS_SHOWTEXTURE 50566
|
||||
#define IDM_OPTIONS_DRAWTEXTURE 50567
|
||||
#define ID_OPTIONS_HIDETEXTURE 50568
|
||||
#define IDM_OPTIONS_HIDETEXTURE 50569
|
||||
#define ID_PROFILING_SHOWMEMORYUSAGE 50570
|
||||
#define IDM_SHOWMEMORYUSAGE 50571
|
||||
#define IDM_SHOWFREEMEMORY 50572
|
||||
#define ID_OPTIONS_TICKMARKS 50573
|
||||
#define ID_OPTIONS_ZOOMIN 50574
|
||||
#define ID_OPTIONS_ZOOMOUT 50575
|
||||
#define ID_OPTIONS_ENABLE 50576
|
||||
#define IDM_MEMPROFILE_TICKMARKS 50577
|
||||
#define IDM_MEMPROFILE_ZOOMIN 50578
|
||||
#define IDM_MEMPROFILE_ZOOMOUT 50579
|
||||
#define IDM_MEMPROFILE_ENABLE 50580
|
||||
#define ID_OPTIONS_COLORS 50581
|
||||
#define IDM_MEMPROFILE_COLORS 50582
|
||||
#define ID_OPTIONS_CLEAR 50583
|
||||
#define IDM_OPTIONS_CLEAR 50584
|
||||
#define ID_PROFILING_TESTINGMODE 50585
|
||||
#define IDM_PLAYTESTMODE 50586
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 134
|
||||
#define _APS_NEXT_COMMAND_VALUE 50587
|
||||
#define _APS_NEXT_CONTROL_VALUE 1092
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
575
utils/xbox/vxconsole/show_materials.cpp
Normal file
575
utils/xbox/vxconsole/show_materials.cpp
Normal file
@@ -0,0 +1,575 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SHOW_MATERIALS.CPP
|
||||
//
|
||||
// Show Materials Display.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define ID_SHOWMATERIALS_LISTVIEW 100
|
||||
|
||||
// column id
|
||||
#define ID_SM_NAME 0
|
||||
#define ID_SM_SHADER 1
|
||||
#define ID_SM_REFCOUNT 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int listIndex;
|
||||
char *pName;
|
||||
char *pShaderName;
|
||||
int refCount;
|
||||
char refCountBuff[16];
|
||||
} material_t;
|
||||
|
||||
typedef struct
|
||||
{ const CHAR* name;
|
||||
int width;
|
||||
int subItemIndex;
|
||||
CHAR nameBuff[32];
|
||||
} label_t;
|
||||
|
||||
HWND g_showMaterials_hWnd;
|
||||
HWND g_showMaterials_hWndListView;
|
||||
RECT g_showMaterials_windowRect;
|
||||
int g_showMaterials_sortColumn;
|
||||
int g_showMaterials_sortDescending;
|
||||
material_t *g_showMaterials_pMaterials;
|
||||
int g_showMaterials_numMaterials;
|
||||
int g_showMaterials_currentFrame;
|
||||
|
||||
label_t g_showMaterials_Labels[] =
|
||||
{
|
||||
{"Name", 300, ID_SM_NAME},
|
||||
{"Shader", 150, ID_SM_SHADER},
|
||||
{"RefCount", 80, ID_SM_REFCOUNT},
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
|
||||
Sys_SetRegistryInteger( "showMaterialsCurrentFrame", g_showMaterials_currentFrame );
|
||||
Sys_SetRegistryInteger( "showMaterialsSortColumn", g_showMaterials_sortColumn );
|
||||
Sys_SetRegistryInteger( "showMaterialsSortDescending", g_showMaterials_sortDescending );
|
||||
|
||||
WINDOWPLACEMENT wp;
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_showMaterials_hWnd, &wp );
|
||||
g_showMaterials_windowRect = wp.rcNormalPosition;
|
||||
|
||||
sprintf( buff, "%d %d %d %d", g_showMaterials_windowRect.left, g_showMaterials_windowRect.top, g_showMaterials_windowRect.right, g_showMaterials_windowRect.bottom );
|
||||
Sys_SetRegistryString( "showMaterialsWindowRect", buff );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
Sys_GetRegistryInteger( "showMaterialsCurrentFrame", false, g_showMaterials_currentFrame );
|
||||
Sys_GetRegistryInteger( "showMaterialsSortColumn", ID_SM_NAME, g_showMaterials_sortColumn );
|
||||
Sys_GetRegistryInteger( "showMaterialsSortDescending", false, g_showMaterials_sortDescending );
|
||||
|
||||
Sys_GetRegistryString( "showMaterialsWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_showMaterials_windowRect.left, &g_showMaterials_windowRect.top, &g_showMaterials_windowRect.right, &g_showMaterials_windowRect.bottom );
|
||||
if ( numArgs != 4 || g_showMaterials_windowRect.left < 0 || g_showMaterials_windowRect.top < 0 || g_showMaterials_windowRect.right < 0 || g_showMaterials_windowRect.bottom < 0 )
|
||||
memset( &g_showMaterials_windowRect, 0, sizeof( g_showMaterials_windowRect ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_Clear
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_Clear()
|
||||
{
|
||||
// delete all the list view entries
|
||||
if ( g_showMaterials_hWnd )
|
||||
ListView_DeleteAllItems( g_showMaterials_hWndListView );
|
||||
|
||||
if ( !g_showMaterials_pMaterials )
|
||||
return;
|
||||
|
||||
for ( int i=0; i<g_showMaterials_numMaterials; i++ )
|
||||
{
|
||||
free( g_showMaterials_pMaterials[i].pName );
|
||||
free( g_showMaterials_pMaterials[i].pShaderName );
|
||||
}
|
||||
|
||||
g_showMaterials_pMaterials = NULL;
|
||||
g_showMaterials_numMaterials = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_Export
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_Export()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_SetTitle
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_SetTitle()
|
||||
{
|
||||
char titleBuff[128];
|
||||
|
||||
if ( g_showMaterials_hWnd )
|
||||
{
|
||||
strcpy( titleBuff, "Materials " );
|
||||
if ( g_showMaterials_currentFrame )
|
||||
strcat( titleBuff, " [FRAME]" );
|
||||
|
||||
SetWindowText( g_showMaterials_hWnd, titleBuff );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_CompareFunc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CALLBACK ShowMaterials_CompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
|
||||
{
|
||||
material_t* pMaterialA = ( material_t* )lParam1;
|
||||
material_t* pMaterialB = ( material_t* )lParam2;
|
||||
|
||||
int sort = 0;
|
||||
switch ( g_showMaterials_sortColumn )
|
||||
{
|
||||
case ID_SM_NAME:
|
||||
sort = stricmp( pMaterialA->pName, pMaterialB->pName );
|
||||
break;
|
||||
|
||||
case ID_SM_SHADER:
|
||||
sort = stricmp( pMaterialA->pShaderName, pMaterialB->pShaderName );
|
||||
break;
|
||||
|
||||
case ID_SM_REFCOUNT:
|
||||
sort = pMaterialA->refCount - pMaterialB->refCount;
|
||||
break;
|
||||
}
|
||||
|
||||
// flip the sort order
|
||||
if ( g_showMaterials_sortDescending )
|
||||
sort *= -1;
|
||||
|
||||
return ( sort );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_SortItems
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_SortItems()
|
||||
{
|
||||
LVITEM lvitem;
|
||||
material_t *pMaterial;
|
||||
int i;
|
||||
|
||||
if ( !g_showMaterials_hWnd )
|
||||
{
|
||||
// only sort if window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
ListView_SortItems( g_showMaterials_hWndListView, ShowMaterials_CompareFunc, 0 );
|
||||
|
||||
memset( &lvitem, 0, sizeof( lvitem ) );
|
||||
lvitem.mask = LVIF_PARAM;
|
||||
|
||||
// get each item and reset its list index
|
||||
int itemCount = ListView_GetItemCount( g_showMaterials_hWndListView );
|
||||
for ( i=0; i<itemCount; i++ )
|
||||
{
|
||||
lvitem.iItem = i;
|
||||
ListView_GetItem( g_showMaterials_hWndListView, &lvitem );
|
||||
|
||||
pMaterial = ( material_t* )lvitem.lParam;
|
||||
pMaterial->listIndex = i;
|
||||
}
|
||||
|
||||
// update list view columns with sort key
|
||||
for ( i=0; i<sizeof( g_showMaterials_Labels )/sizeof( g_showMaterials_Labels[0] ); i++ )
|
||||
{
|
||||
char symbol;
|
||||
LVCOLUMN lvc;
|
||||
|
||||
if ( i == g_showMaterials_sortColumn )
|
||||
symbol = g_showMaterials_sortDescending ? '<' : '>';
|
||||
else
|
||||
symbol = ' ';
|
||||
sprintf( g_showMaterials_Labels[i].nameBuff, "%s %c", g_showMaterials_Labels[i].name, symbol );
|
||||
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = ( LPSTR )g_showMaterials_Labels[i].nameBuff;
|
||||
|
||||
ListView_SetColumn( g_showMaterials_hWndListView, i, &lvc );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_AddViewItem
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_AddViewItem( material_t* pMaterial )
|
||||
{
|
||||
LVITEM lvi;
|
||||
|
||||
if ( !g_showMaterials_hWnd )
|
||||
{
|
||||
// only valid if log window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
// update the text callback buffers
|
||||
sprintf( pMaterial->refCountBuff, "%d", pMaterial->refCount );
|
||||
|
||||
int itemCount = ListView_GetItemCount( g_showMaterials_hWndListView );
|
||||
|
||||
// setup and insert at end of list
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
||||
lvi.iItem = itemCount;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.state = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
lvi.lParam = ( LPARAM )pMaterial;
|
||||
|
||||
// insert and set the real index
|
||||
pMaterial->listIndex = ListView_InsertItem( g_showMaterials_hWndListView, &lvi );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_Refresh
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_Refresh()
|
||||
{
|
||||
char command[256];
|
||||
|
||||
strcpy( command, "mat_material_list" );
|
||||
|
||||
// if ( !g_showMaterials_currentFrame )
|
||||
// strcat( command, " all" );
|
||||
|
||||
// send the command to application which replies with list data
|
||||
if ( g_connectedToApp )
|
||||
ProcessCommand( command );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_SizeWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_SizeWindow( HWND hwnd, int cx, int cy )
|
||||
{
|
||||
if ( cx==0 || cy==0 )
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect( hwnd, &rcClient );
|
||||
cx = rcClient.right;
|
||||
cy = rcClient.bottom;
|
||||
}
|
||||
|
||||
// position the ListView
|
||||
SetWindowPos( g_showMaterials_hWndListView, NULL, 0, 0, cx, cy, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK ShowMaterials_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
material_t* pMaterial;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
ShowMaterials_SaveConfig();
|
||||
g_showMaterials_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_INITMENU:
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_OPTIONS_CURRENTFRAME, MF_BYCOMMAND | ( g_showMaterials_currentFrame ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
ShowMaterials_SizeWindow( hwnd, LOWORD( lParam ), HIWORD( lParam ) );
|
||||
return 0L;
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch ( ( ( LPNMHDR )lParam )->code )
|
||||
{
|
||||
case LVN_COLUMNCLICK:
|
||||
NMLISTVIEW* pnmlv;
|
||||
pnmlv = ( NMLISTVIEW* )lParam;
|
||||
if ( g_showMaterials_sortColumn == pnmlv->iSubItem )
|
||||
{
|
||||
// user has clicked on same column - flip the sort
|
||||
g_showMaterials_sortDescending ^= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sort by new column
|
||||
g_showMaterials_sortColumn = pnmlv->iSubItem;
|
||||
}
|
||||
ShowMaterials_SortItems();
|
||||
return 0L;
|
||||
|
||||
case LVN_GETDISPINFO:
|
||||
NMLVDISPINFO* plvdi;
|
||||
plvdi = ( NMLVDISPINFO* )lParam;
|
||||
pMaterial = ( material_t* )plvdi->item.lParam;
|
||||
switch ( plvdi->item.iSubItem )
|
||||
{
|
||||
case ID_SM_NAME:
|
||||
plvdi->item.pszText = pMaterial->pName;
|
||||
return 0L;
|
||||
|
||||
case ID_SM_SHADER:
|
||||
plvdi->item.pszText = pMaterial->pShaderName;
|
||||
return 0L;
|
||||
|
||||
case ID_SM_REFCOUNT:
|
||||
plvdi->item.pszText = pMaterial->refCountBuff;
|
||||
return 0L;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_OPTIONS_REFRESH:
|
||||
ShowMaterials_Refresh();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_EXPORT:
|
||||
ShowMaterials_Export();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_CURRENTFRAME:
|
||||
g_showMaterials_currentFrame ^= 1;
|
||||
ShowMaterials_SetTitle();
|
||||
ShowMaterials_Refresh();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ShowMaterials_Init()
|
||||
{
|
||||
// set up our window class
|
||||
WNDCLASS wndclass;
|
||||
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = ShowMaterials_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_SHOWMATERIALS );
|
||||
wndclass.lpszClassName = "SHOWMATERIALSCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
ShowMaterials_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowMaterials_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowMaterials_Open()
|
||||
{
|
||||
RECT clientRect;
|
||||
HWND hWnd;
|
||||
int i;
|
||||
|
||||
if ( g_showMaterials_hWnd )
|
||||
{
|
||||
// only one instance
|
||||
if ( IsIconic( g_showMaterials_hWnd ) )
|
||||
ShowWindow( g_showMaterials_hWnd, SW_RESTORE );
|
||||
SetForegroundWindow( g_showMaterials_hWnd );
|
||||
return;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"SHOWMATERIALSCLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
700,
|
||||
400,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_showMaterials_hWnd = hWnd;
|
||||
|
||||
GetClientRect( g_showMaterials_hWnd, &clientRect );
|
||||
hWnd = CreateWindow(
|
||||
WC_LISTVIEW,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|LVS_REPORT,
|
||||
0,
|
||||
0,
|
||||
clientRect.right-clientRect.left,
|
||||
clientRect.bottom-clientRect.top,
|
||||
g_showMaterials_hWnd,
|
||||
( HMENU )ID_SHOWMATERIALS_LISTVIEW,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_showMaterials_hWndListView = hWnd;
|
||||
|
||||
// init list view columns
|
||||
for ( i=0; i<sizeof( g_showMaterials_Labels )/sizeof( g_showMaterials_Labels[0] ); i++ )
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
|
||||
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.cx = g_showMaterials_Labels[i].width;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.pszText = ( LPSTR )g_showMaterials_Labels[i].name;
|
||||
|
||||
ListView_InsertColumn( g_showMaterials_hWndListView, i, &lvc );
|
||||
}
|
||||
|
||||
ListView_SetBkColor( g_showMaterials_hWndListView, g_backgroundColor );
|
||||
ListView_SetTextBkColor( g_showMaterials_hWndListView, g_backgroundColor );
|
||||
|
||||
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;
|
||||
ListView_SetExtendedListViewStyleEx( g_showMaterials_hWndListView, style, style );
|
||||
|
||||
// populate list view
|
||||
for ( i=0; i<g_showMaterials_numMaterials; i++ )
|
||||
ShowMaterials_AddViewItem( &g_showMaterials_pMaterials[i] );
|
||||
ShowMaterials_SortItems();
|
||||
|
||||
ShowMaterials_SetTitle();
|
||||
|
||||
if ( g_showMaterials_windowRect.right && g_showMaterials_windowRect.bottom )
|
||||
MoveWindow( g_showMaterials_hWnd, g_showMaterials_windowRect.left, g_showMaterials_windowRect.top, g_showMaterials_windowRect.right-g_showMaterials_windowRect.left, g_showMaterials_windowRect.bottom-g_showMaterials_windowRect.top, FALSE );
|
||||
ShowWindow( g_showMaterials_hWnd, SHOW_OPENWINDOW );
|
||||
|
||||
// get data from application
|
||||
ShowMaterials_Refresh();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_MaterialList
|
||||
//
|
||||
// Sent from application with material list
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_MaterialList( char* commandPtr )
|
||||
{
|
||||
char* cmdToken;
|
||||
int numMaterials;
|
||||
int materialList;
|
||||
int retAddr;
|
||||
int retVal;
|
||||
int errCode = -1;
|
||||
xrMaterial_t* pLocalList;
|
||||
|
||||
// remove old entries
|
||||
ShowMaterials_Clear();
|
||||
|
||||
// get number of materials
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &numMaterials );
|
||||
|
||||
// get material list
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &materialList );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &retAddr );
|
||||
|
||||
pLocalList = new xrMaterial_t[numMaterials];
|
||||
memset( pLocalList, 0, numMaterials*sizeof( xrMaterial_t ) );
|
||||
|
||||
g_showMaterials_numMaterials = numMaterials;
|
||||
g_showMaterials_pMaterials = new material_t[numMaterials];
|
||||
memset( g_showMaterials_pMaterials, 0, numMaterials*sizeof( material_t ) );
|
||||
|
||||
// get the caller's command list
|
||||
DmGetMemory( ( void* )materialList, numMaterials*sizeof( xrMaterial_t ), pLocalList, NULL );
|
||||
|
||||
// build out the resident list
|
||||
for ( int i=0; i<numMaterials; i++ )
|
||||
{
|
||||
// swap the structure
|
||||
pLocalList[i].refCount = BigDWord( pLocalList[i].refCount );
|
||||
|
||||
g_showMaterials_pMaterials[i].pName = strdup( pLocalList[i].nameString );
|
||||
g_showMaterials_pMaterials[i].pShaderName = strdup( pLocalList[i].shaderString );
|
||||
g_showMaterials_pMaterials[i].refCount = pLocalList[i].refCount;
|
||||
|
||||
// add to list view
|
||||
ShowMaterials_AddViewItem( &g_showMaterials_pMaterials[i] );
|
||||
}
|
||||
|
||||
// return the result
|
||||
retVal = numMaterials;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = MaterialList( 0x%8.8x, 0x%8.8x )\n", retVal, numMaterials, materialList );
|
||||
|
||||
delete [] pLocalList;
|
||||
|
||||
// update
|
||||
ShowMaterials_SortItems();
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
1440
utils/xbox/vxconsole/show_memdump.cpp
Normal file
1440
utils/xbox/vxconsole/show_memdump.cpp
Normal file
File diff suppressed because it is too large
Load Diff
778
utils/xbox/vxconsole/show_sounds.cpp
Normal file
778
utils/xbox/vxconsole/show_sounds.cpp
Normal file
@@ -0,0 +1,778 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SHOW_SOUNDS.CPP
|
||||
//
|
||||
// Show Sounds Display.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define ID_SHOWSOUNDS_LISTVIEW 100
|
||||
|
||||
// column id
|
||||
#define ID_SS_NAME 0
|
||||
#define ID_SS_PREFIX 1
|
||||
#define ID_SS_FORMAT 2
|
||||
#define ID_SS_RATE 3
|
||||
#define ID_SS_BITS 4
|
||||
#define ID_SS_CHANNELS 5
|
||||
#define ID_SS_SIZE 6
|
||||
#define ID_SS_STREAMED 7
|
||||
#define ID_SS_LOOPED 8
|
||||
#define ID_SS_LENGTH 9
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int listIndex;
|
||||
char *pName;
|
||||
char *pPrefix;
|
||||
char *pFormat;
|
||||
int rate;
|
||||
char rateBuff[16];
|
||||
int bits;
|
||||
char bitsBuff[16];
|
||||
int channels;
|
||||
char channelsBuff[16];
|
||||
int numSamples;
|
||||
int dataSize;
|
||||
char dataSizeBuff[16];
|
||||
int streamed;
|
||||
char streamedBuff[16];
|
||||
int looped;
|
||||
char loopedBuff[16];
|
||||
float length;
|
||||
char lengthBuff[16];
|
||||
} sound_t;
|
||||
|
||||
typedef struct
|
||||
{ const CHAR* name;
|
||||
int width;
|
||||
int subItemIndex;
|
||||
CHAR nameBuff[32];
|
||||
} label_t;
|
||||
|
||||
HWND g_showSounds_hWnd;
|
||||
HWND g_showSounds_hWndListView;
|
||||
RECT g_showSounds_windowRect;
|
||||
int g_showSounds_sortColumn;
|
||||
int g_showSounds_sortDescending;
|
||||
sound_t *g_showSounds_pSounds;
|
||||
int g_showSounds_numSounds;
|
||||
int g_showSounds_currentFrame;
|
||||
|
||||
label_t g_showSounds_Labels[] =
|
||||
{
|
||||
{"Name", 300, ID_SS_NAME},
|
||||
{"Prefix", 80, ID_SS_PREFIX},
|
||||
{"Format", 80, ID_SS_FORMAT},
|
||||
{"Rate", 80, ID_SS_RATE},
|
||||
{"Bits", 80, ID_SS_BITS},
|
||||
{"Channels", 80, ID_SS_CHANNELS},
|
||||
{"Size", 80, ID_SS_SIZE},
|
||||
{"Streamed", 80, ID_SS_STREAMED},
|
||||
{"Looped", 80, ID_SS_LOOPED},
|
||||
{"Length", 80, ID_SS_LENGTH},
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
|
||||
Sys_SetRegistryInteger( "showSoundsSortColumn", g_showSounds_sortColumn );
|
||||
Sys_SetRegistryInteger( "showSoundsSortDescending", g_showSounds_sortDescending );
|
||||
|
||||
WINDOWPLACEMENT wp;
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_showSounds_hWnd, &wp );
|
||||
g_showSounds_windowRect = wp.rcNormalPosition;
|
||||
|
||||
sprintf( buff, "%d %d %d %d", g_showSounds_windowRect.left, g_showSounds_windowRect.top, g_showSounds_windowRect.right, g_showSounds_windowRect.bottom );
|
||||
Sys_SetRegistryString( "showSoundsWindowRect", buff );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
Sys_GetRegistryInteger( "showSoundsSortColumn", ID_SS_NAME, g_showSounds_sortColumn );
|
||||
Sys_GetRegistryInteger( "showSoundsSortDescending", false, g_showSounds_sortDescending );
|
||||
|
||||
Sys_GetRegistryString( "showSoundsWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_showSounds_windowRect.left, &g_showSounds_windowRect.top, &g_showSounds_windowRect.right, &g_showSounds_windowRect.bottom );
|
||||
if ( numArgs != 4 || g_showSounds_windowRect.left < 0 || g_showSounds_windowRect.top < 0 || g_showSounds_windowRect.right < 0 || g_showSounds_windowRect.bottom < 0 )
|
||||
memset( &g_showSounds_windowRect, 0, sizeof( g_showSounds_windowRect ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Clear
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_Clear()
|
||||
{
|
||||
// delete all the list view entries
|
||||
if ( g_showSounds_hWnd )
|
||||
ListView_DeleteAllItems( g_showSounds_hWndListView );
|
||||
|
||||
if ( !g_showSounds_pSounds )
|
||||
return;
|
||||
|
||||
for ( int i=0; i<g_showSounds_numSounds; i++ )
|
||||
{
|
||||
free( g_showSounds_pSounds[i].pName );
|
||||
free( g_showSounds_pSounds[i].pPrefix );
|
||||
free( g_showSounds_pSounds[i].pFormat );
|
||||
}
|
||||
|
||||
g_showSounds_pSounds = NULL;
|
||||
g_showSounds_numSounds = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Export
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_Export()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Summary
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_Summary()
|
||||
{
|
||||
char buff[1024];
|
||||
|
||||
// tally the totals
|
||||
int totalStreamed = 0;
|
||||
int totalStatic = 0;
|
||||
for ( int i=0; i<g_showSounds_numSounds; i++ )
|
||||
{
|
||||
if ( g_showSounds_pSounds[i].streamed )
|
||||
{
|
||||
totalStreamed += g_showSounds_pSounds[i].dataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalStatic += g_showSounds_pSounds[i].dataSize;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(
|
||||
buff,
|
||||
"Entries:\t\t\t%d\n"
|
||||
"Static Memory:\t\t%.2f MB\n"
|
||||
"Streamed Memory:\t\t%.2f MB\n",
|
||||
g_showSounds_numSounds,
|
||||
( float )totalStatic/( 1024.0F*1024.0F ),
|
||||
( float )totalStreamed/( 1024.0F*1024.0F ) );
|
||||
|
||||
MessageBox( g_showSounds_hWnd, buff, "Sound Summary", MB_OK|MB_APPLMODAL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Play
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_Play()
|
||||
{
|
||||
char command[256];
|
||||
sound_t* pSound;
|
||||
int selection;
|
||||
LVITEM lvitem;
|
||||
|
||||
if ( !g_connectedToApp )
|
||||
return;
|
||||
|
||||
selection = ListView_GetSelectionMark( g_showSounds_hWndListView );
|
||||
if ( selection == -1 )
|
||||
return;
|
||||
|
||||
memset( &lvitem, 0, sizeof( lvitem ) );
|
||||
lvitem.mask = LVIF_PARAM;
|
||||
lvitem.iItem = selection;
|
||||
ListView_GetItem( g_showSounds_hWndListView, &lvitem );
|
||||
|
||||
pSound = ( sound_t* )lvitem.lParam;
|
||||
|
||||
sprintf( command, "play %s%s", pSound->pPrefix, pSound->pName );
|
||||
|
||||
// send the command to application
|
||||
ProcessCommand( command );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_CompareFunc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CALLBACK ShowSounds_CompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
|
||||
{
|
||||
sound_t* pSoundA = ( sound_t* )lParam1;
|
||||
sound_t* pSoundB = ( sound_t* )lParam2;
|
||||
|
||||
int sort = 0;
|
||||
switch ( g_showSounds_sortColumn )
|
||||
{
|
||||
case ID_SS_NAME:
|
||||
sort = stricmp( pSoundA->pName, pSoundB->pName );
|
||||
break;
|
||||
|
||||
case ID_SS_PREFIX:
|
||||
sort = stricmp( pSoundA->pPrefix, pSoundB->pPrefix );
|
||||
break;
|
||||
|
||||
case ID_SS_FORMAT:
|
||||
sort = stricmp( pSoundA->pFormat, pSoundB->pFormat );
|
||||
break;
|
||||
|
||||
case ID_SS_RATE:
|
||||
sort = pSoundA->rate - pSoundB->rate;
|
||||
break;
|
||||
|
||||
case ID_SS_BITS:
|
||||
sort = pSoundA->bits - pSoundB->bits;
|
||||
break;
|
||||
|
||||
case ID_SS_CHANNELS:
|
||||
sort = stricmp( pSoundA->channelsBuff, pSoundB->channelsBuff );
|
||||
break;
|
||||
|
||||
case ID_SS_SIZE:
|
||||
sort = pSoundA->dataSize - pSoundB->dataSize;
|
||||
break;
|
||||
|
||||
case ID_SS_STREAMED:
|
||||
sort = stricmp( pSoundA->streamedBuff, pSoundB->streamedBuff );
|
||||
break;
|
||||
|
||||
case ID_SS_LOOPED:
|
||||
sort = stricmp( pSoundA->loopedBuff, pSoundB->loopedBuff );
|
||||
break;
|
||||
|
||||
case ID_SS_LENGTH:
|
||||
if ( pSoundA->length < pSoundB->length )
|
||||
sort = -1;
|
||||
else if ( pSoundA->length == pSoundB->length )
|
||||
sort = 0;
|
||||
else
|
||||
sort = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// flip the sort order
|
||||
if ( g_showSounds_sortDescending )
|
||||
sort *= -1;
|
||||
|
||||
return ( sort );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_SortItems
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_SortItems()
|
||||
{
|
||||
LVITEM lvitem;
|
||||
sound_t *pSound;
|
||||
int i;
|
||||
|
||||
if ( !g_showSounds_hWnd )
|
||||
{
|
||||
// only sort if window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
ListView_SortItems( g_showSounds_hWndListView, ShowSounds_CompareFunc, 0 );
|
||||
|
||||
memset( &lvitem, 0, sizeof( lvitem ) );
|
||||
lvitem.mask = LVIF_PARAM;
|
||||
|
||||
// get each item and reset its list index
|
||||
int itemCount = ListView_GetItemCount( g_showSounds_hWndListView );
|
||||
for ( i=0; i<itemCount; i++ )
|
||||
{
|
||||
lvitem.iItem = i;
|
||||
ListView_GetItem( g_showSounds_hWndListView, &lvitem );
|
||||
|
||||
pSound = ( sound_t* )lvitem.lParam;
|
||||
pSound->listIndex = i;
|
||||
}
|
||||
|
||||
// update list view columns with sort key
|
||||
for ( i=0; i<sizeof( g_showSounds_Labels )/sizeof( g_showSounds_Labels[0] ); i++ )
|
||||
{
|
||||
char symbol;
|
||||
LVCOLUMN lvc;
|
||||
|
||||
if ( i == g_showSounds_sortColumn )
|
||||
symbol = g_showSounds_sortDescending ? '<' : '>';
|
||||
else
|
||||
symbol = ' ';
|
||||
sprintf( g_showSounds_Labels[i].nameBuff, "%s %c", g_showSounds_Labels[i].name, symbol );
|
||||
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = ( LPSTR )g_showSounds_Labels[i].nameBuff;
|
||||
|
||||
ListView_SetColumn( g_showSounds_hWndListView, i, &lvc );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_AddViewItem
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_AddViewItem( sound_t* pSound )
|
||||
{
|
||||
LVITEM lvi;
|
||||
|
||||
if ( !g_showSounds_hWnd )
|
||||
{
|
||||
// only valid if log window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
// update the text callback buffers
|
||||
if ( pSound->rate >= 0 )
|
||||
sprintf( pSound->rateBuff, "%5.2f KHz", ( float )pSound->rate/1000.0f );
|
||||
else
|
||||
strcpy( pSound->rateBuff, "???" );
|
||||
|
||||
if ( pSound->bits >= 0 )
|
||||
sprintf( pSound->bitsBuff, "%d", pSound->bits );
|
||||
else
|
||||
strcpy( pSound->bitsBuff, "???" );
|
||||
|
||||
if ( pSound->channels >= 1 )
|
||||
strcpy( pSound->channelsBuff, pSound->channels == 2 ? "Stereo" : "Mono" );
|
||||
else
|
||||
strcpy( pSound->channelsBuff, "???" );
|
||||
|
||||
if ( pSound->dataSize >= 0 )
|
||||
sprintf( pSound->dataSizeBuff, "%d", pSound->dataSize );
|
||||
else
|
||||
strcpy( pSound->dataSizeBuff, "???" );
|
||||
|
||||
if ( pSound->streamed >= 0 )
|
||||
strcpy( pSound->streamedBuff, pSound->streamed ? "Stream" : "Static" );
|
||||
else
|
||||
strcpy( pSound->streamedBuff, "???" );
|
||||
|
||||
if ( pSound->looped >= 0 )
|
||||
strcpy( pSound->loopedBuff, pSound->looped ? "Looped" : "One-Shot" );
|
||||
else
|
||||
strcpy( pSound->loopedBuff, "???" );
|
||||
|
||||
sprintf( pSound->lengthBuff, "%2.2d:%2.2d:%3.3d", ( int )pSound->length/60, ( int )pSound->length%60, ( int )( 1000*( pSound->length-( int )pSound->length ) )%1000 );
|
||||
|
||||
int itemCount = ListView_GetItemCount( g_showSounds_hWndListView );
|
||||
|
||||
// setup and insert at end of list
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
||||
lvi.iItem = itemCount;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.state = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
lvi.lParam = ( LPARAM )pSound;
|
||||
|
||||
// insert and set the real index
|
||||
pSound->listIndex = ListView_InsertItem( g_showSounds_hWndListView, &lvi );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Refresh
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_Refresh()
|
||||
{
|
||||
char command[256];
|
||||
|
||||
strcpy( command, "vx_soundlist" );
|
||||
|
||||
// send the command to application which replies with list data
|
||||
if ( g_connectedToApp )
|
||||
ProcessCommand( command );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_SizeWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_SizeWindow( HWND hwnd, int cx, int cy )
|
||||
{
|
||||
if ( cx==0 || cy==0 )
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect( hwnd, &rcClient );
|
||||
cx = rcClient.right;
|
||||
cy = rcClient.bottom;
|
||||
}
|
||||
|
||||
// position the ListView
|
||||
SetWindowPos( g_showSounds_hWndListView, NULL, 0, 0, cx, cy, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK ShowSounds_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
sound_t* pSound;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
ShowSounds_SaveConfig();
|
||||
g_showSounds_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_INITMENU:
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
ShowSounds_SizeWindow( hwnd, LOWORD( lParam ), HIWORD( lParam ) );
|
||||
return 0L;
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch ( ( ( LPNMHDR )lParam )->code )
|
||||
{
|
||||
case LVN_COLUMNCLICK:
|
||||
NMLISTVIEW* pnmlv;
|
||||
pnmlv = ( NMLISTVIEW* )lParam;
|
||||
if ( g_showSounds_sortColumn == pnmlv->iSubItem )
|
||||
{
|
||||
// user has clicked on same column - flip the sort
|
||||
g_showSounds_sortDescending ^= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sort by new column
|
||||
g_showSounds_sortColumn = pnmlv->iSubItem;
|
||||
}
|
||||
ShowSounds_SortItems();
|
||||
return 0L;
|
||||
|
||||
case LVN_GETDISPINFO:
|
||||
NMLVDISPINFO* plvdi;
|
||||
plvdi = ( NMLVDISPINFO* )lParam;
|
||||
pSound = ( sound_t* )plvdi->item.lParam;
|
||||
switch ( plvdi->item.iSubItem )
|
||||
{
|
||||
case ID_SS_NAME:
|
||||
plvdi->item.pszText = pSound->pName;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_PREFIX:
|
||||
plvdi->item.pszText = pSound->pPrefix;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_FORMAT:
|
||||
plvdi->item.pszText = pSound->pFormat;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_RATE:
|
||||
plvdi->item.pszText = pSound->rateBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_BITS:
|
||||
plvdi->item.pszText = pSound->bitsBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_CHANNELS:
|
||||
plvdi->item.pszText = pSound->channelsBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_SIZE:
|
||||
plvdi->item.pszText = pSound->dataSizeBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_STREAMED:
|
||||
plvdi->item.pszText = pSound->streamedBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_LOOPED:
|
||||
plvdi->item.pszText = pSound->loopedBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_SS_LENGTH:
|
||||
plvdi->item.pszText = pSound->lengthBuff;
|
||||
return 0L;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_OPTIONS_SUMMARY:
|
||||
ShowSounds_Summary();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_REFRESH:
|
||||
ShowSounds_Refresh();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_EXPORT:
|
||||
ShowSounds_Export();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_PLAYSOUND:
|
||||
ShowSounds_Play();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ShowSounds_Init()
|
||||
{
|
||||
// set up our window class
|
||||
WNDCLASS wndclass;
|
||||
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = ShowSounds_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_SHOWSOUNDS );
|
||||
wndclass.lpszClassName = "SHOWSOUNDSCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
ShowSounds_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowSounds_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowSounds_Open()
|
||||
{
|
||||
RECT clientRect;
|
||||
HWND hWnd;
|
||||
int i;
|
||||
|
||||
if ( g_showSounds_hWnd )
|
||||
{
|
||||
// only one instance
|
||||
if ( IsIconic( g_showSounds_hWnd ) )
|
||||
ShowWindow( g_showSounds_hWnd, SW_RESTORE );
|
||||
SetForegroundWindow( g_showSounds_hWnd );
|
||||
return;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"SHOWSOUNDSCLASS",
|
||||
"Sounds",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
700,
|
||||
400,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_showSounds_hWnd = hWnd;
|
||||
|
||||
GetClientRect( g_showSounds_hWnd, &clientRect );
|
||||
hWnd = CreateWindow(
|
||||
WC_LISTVIEW,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_SINGLESEL,
|
||||
0,
|
||||
0,
|
||||
clientRect.right-clientRect.left,
|
||||
clientRect.bottom-clientRect.top,
|
||||
g_showSounds_hWnd,
|
||||
( HMENU )ID_SHOWSOUNDS_LISTVIEW,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_showSounds_hWndListView = hWnd;
|
||||
|
||||
// init list view columns
|
||||
for ( i=0; i<sizeof( g_showSounds_Labels )/sizeof( g_showSounds_Labels[0] ); i++ )
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
|
||||
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.cx = g_showSounds_Labels[i].width;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.pszText = ( LPSTR )g_showSounds_Labels[i].name;
|
||||
|
||||
ListView_InsertColumn( g_showSounds_hWndListView, i, &lvc );
|
||||
}
|
||||
|
||||
ListView_SetBkColor( g_showSounds_hWndListView, g_backgroundColor );
|
||||
ListView_SetTextBkColor( g_showSounds_hWndListView, g_backgroundColor );
|
||||
|
||||
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;
|
||||
ListView_SetExtendedListViewStyleEx( g_showSounds_hWndListView, style, style );
|
||||
|
||||
// populate list view
|
||||
for ( i=0; i<g_showSounds_numSounds; i++ )
|
||||
ShowSounds_AddViewItem( &g_showSounds_pSounds[i] );
|
||||
ShowSounds_SortItems();
|
||||
|
||||
if ( g_showSounds_windowRect.right && g_showSounds_windowRect.bottom )
|
||||
MoveWindow( g_showSounds_hWnd, g_showSounds_windowRect.left, g_showSounds_windowRect.top, g_showSounds_windowRect.right-g_showSounds_windowRect.left, g_showSounds_windowRect.bottom-g_showSounds_windowRect.top, FALSE );
|
||||
ShowWindow( g_showSounds_hWnd, SHOW_OPENWINDOW );
|
||||
|
||||
// get data from application
|
||||
ShowSounds_Refresh();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_SoundList
|
||||
//
|
||||
// Sent from application with sound list
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_SoundList( char* commandPtr )
|
||||
{
|
||||
char* cmdToken;
|
||||
int numSounds;
|
||||
int soundList;
|
||||
int retAddr;
|
||||
int retVal;
|
||||
int errCode = -1;
|
||||
xrSound_t* pLocalList;
|
||||
int prefixLen;
|
||||
char *pStr;
|
||||
|
||||
// remove old entries
|
||||
ShowSounds_Clear();
|
||||
|
||||
// get number of sounds
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &numSounds );
|
||||
|
||||
// get sound list
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &soundList );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &retAddr );
|
||||
|
||||
pLocalList = new xrSound_t[numSounds];
|
||||
memset( pLocalList, 0, numSounds*sizeof( xrSound_t ) );
|
||||
|
||||
g_showSounds_numSounds = numSounds;
|
||||
g_showSounds_pSounds = new sound_t[numSounds];
|
||||
memset( g_showSounds_pSounds, 0, numSounds*sizeof( sound_t ) );
|
||||
|
||||
// get the caller's command list
|
||||
DmGetMemory( ( void* )soundList, numSounds*sizeof( xrSound_t ), pLocalList, NULL );
|
||||
|
||||
// build out the resident list
|
||||
for ( int i=0; i<numSounds; i++ )
|
||||
{
|
||||
// swap the structure
|
||||
pLocalList[i].rate = BigDWord( pLocalList[i].rate );
|
||||
pLocalList[i].bits = BigDWord( pLocalList[i].bits );
|
||||
pLocalList[i].channels = BigDWord( pLocalList[i].channels );
|
||||
pLocalList[i].looped = BigDWord( pLocalList[i].looped );
|
||||
pLocalList[i].dataSize = BigDWord( pLocalList[i].dataSize );
|
||||
pLocalList[i].numSamples = BigDWord( pLocalList[i].numSamples );
|
||||
pLocalList[i].streamed = BigDWord( pLocalList[i].streamed );
|
||||
|
||||
// strip the prefix
|
||||
pStr = pLocalList[i].nameString;
|
||||
while ( *pStr )
|
||||
{
|
||||
if ( __iscsym( *pStr ) )
|
||||
{
|
||||
// first non-preifx character
|
||||
break;
|
||||
}
|
||||
pStr++;
|
||||
}
|
||||
g_showSounds_pSounds[i].pName = strdup( pStr );
|
||||
|
||||
char prefixString[256];
|
||||
prefixLen = pStr - pLocalList[i].nameString;
|
||||
memcpy( prefixString, pLocalList[i].nameString, prefixLen );
|
||||
prefixString[prefixLen] = '\0';
|
||||
g_showSounds_pSounds[i].pPrefix = strdup( prefixString );
|
||||
|
||||
// get the format name
|
||||
g_showSounds_pSounds[i].pFormat = strdup( pLocalList[i].formatString );
|
||||
|
||||
g_showSounds_pSounds[i].rate = pLocalList[i].rate;
|
||||
g_showSounds_pSounds[i].bits = pLocalList[i].bits;
|
||||
g_showSounds_pSounds[i].channels = pLocalList[i].channels;
|
||||
g_showSounds_pSounds[i].dataSize = pLocalList[i].dataSize;
|
||||
g_showSounds_pSounds[i].numSamples = pLocalList[i].numSamples;
|
||||
g_showSounds_pSounds[i].streamed = pLocalList[i].streamed;
|
||||
g_showSounds_pSounds[i].looped = pLocalList[i].looped;
|
||||
|
||||
// determine duration
|
||||
// must use sample count due to compression
|
||||
if ( g_showSounds_pSounds[i].rate > 0 )
|
||||
g_showSounds_pSounds[i].length = ( float )g_showSounds_pSounds[i].numSamples/( float )g_showSounds_pSounds[i].rate;
|
||||
else
|
||||
g_showSounds_pSounds[i].length = 0;
|
||||
|
||||
// add to list view
|
||||
ShowSounds_AddViewItem( &g_showSounds_pSounds[i] );
|
||||
}
|
||||
|
||||
// return the result
|
||||
retVal = numSounds;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = SoundList( 0x%8.8x, 0x%8.8x )\n", retVal, numSounds, soundList );
|
||||
|
||||
delete [] pLocalList;
|
||||
|
||||
// update
|
||||
ShowSounds_SortItems();
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
971
utils/xbox/vxconsole/show_textures.cpp
Normal file
971
utils/xbox/vxconsole/show_textures.cpp
Normal file
@@ -0,0 +1,971 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SHOW_TEXTURES.CPP
|
||||
//
|
||||
// Show Textures Display.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define ID_SHOWTEXTURES_LISTVIEW 100
|
||||
|
||||
// column id
|
||||
#define ID_ST_NAME 0
|
||||
#define ID_ST_SIZE 1
|
||||
#define ID_ST_GROUP 2
|
||||
#define ID_ST_FORMAT 3
|
||||
#define ID_ST_WIDTH 4
|
||||
#define ID_ST_HEIGHT 5
|
||||
#define ID_ST_DEPTH 6
|
||||
#define ID_ST_NUMLEVELS 7
|
||||
#define ID_ST_BINDS 8
|
||||
#define ID_ST_REFCOUNT 9
|
||||
#define ID_ST_LOAD 10
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LS_STATIC, // surface
|
||||
LS_PROCEDURAL, // lacks disk based bits
|
||||
LS_SYNCHRONOUS, // loaded synchronously
|
||||
LS_FALLBACK, // fallback version, queued hires
|
||||
LS_HIRES, // finalized at hires
|
||||
LS_FAILED, // failed to load
|
||||
LS_MAX
|
||||
} loadState_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int listIndex;
|
||||
char *pLongName;
|
||||
char *pShortName;
|
||||
char *pGroupName;
|
||||
char *pFormatName;
|
||||
int size;
|
||||
char sizeBuff[16];
|
||||
int width;
|
||||
char widthBuff[16];
|
||||
int height;
|
||||
char heightBuff[16];
|
||||
int depth;
|
||||
char depthBuff[16];
|
||||
int numLevels;
|
||||
char numLevelsBuff[16];
|
||||
int binds;
|
||||
char bindsBuff[16];
|
||||
int refCount;
|
||||
char refCountBuff[16];
|
||||
int loadState;
|
||||
int edram;
|
||||
} texture_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const CHAR* name;
|
||||
int width;
|
||||
int subItemIndex;
|
||||
CHAR nameBuff[32];
|
||||
} label_t;
|
||||
|
||||
HWND g_showTextures_hWnd;
|
||||
HWND g_showTextures_hWndListView;
|
||||
RECT g_showTextures_windowRect;
|
||||
int g_showTextures_sortColumn;
|
||||
int g_showTextures_sortDescending;
|
||||
texture_t *g_showTextures_pTextures;
|
||||
int g_showTextures_numTextures;
|
||||
int g_showTextures_currentFrame;
|
||||
int g_showTextures_fullPath;
|
||||
char g_showTextures_drawTextureName[MAX_PATH];
|
||||
|
||||
char *g_showTextures_loadStrings[LS_MAX] =
|
||||
{
|
||||
"Static",
|
||||
"Procedural",
|
||||
"Synchronous",
|
||||
"Fallback",
|
||||
"",
|
||||
"Failed",
|
||||
};
|
||||
|
||||
label_t g_showTextures_Labels[] =
|
||||
{
|
||||
{"Name", 150, ID_ST_NAME},
|
||||
{"D3D Size", 80, ID_ST_SIZE},
|
||||
{"Group", 150, ID_ST_GROUP},
|
||||
{"Format", 120, ID_ST_FORMAT},
|
||||
{"Width", 80, ID_ST_WIDTH},
|
||||
{"Height", 80, ID_ST_HEIGHT},
|
||||
{"Depth", 80, ID_ST_DEPTH},
|
||||
{"NumLevels", 80, ID_ST_NUMLEVELS},
|
||||
{"Binds", 80, ID_ST_BINDS},
|
||||
{"RefCount", 80, ID_ST_REFCOUNT},
|
||||
{"Load State", 120, ID_ST_LOAD},
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
|
||||
Sys_SetRegistryInteger( "showTexturesFullPath", g_showTextures_fullPath );
|
||||
Sys_SetRegistryInteger( "showTexturesCurrentFrame", g_showTextures_currentFrame );
|
||||
Sys_SetRegistryInteger( "showTexturesSortColumn", g_showTextures_sortColumn );
|
||||
Sys_SetRegistryInteger( "showTexturesSortDescending", g_showTextures_sortDescending );
|
||||
|
||||
WINDOWPLACEMENT wp;
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_showTextures_hWnd, &wp );
|
||||
g_showTextures_windowRect = wp.rcNormalPosition;
|
||||
|
||||
sprintf( buff, "%d %d %d %d", g_showTextures_windowRect.left, g_showTextures_windowRect.top, g_showTextures_windowRect.right, g_showTextures_windowRect.bottom );
|
||||
Sys_SetRegistryString( "showTexturesWindowRect", buff );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
Sys_GetRegistryInteger( "showTexturesFullPath", true, g_showTextures_fullPath );
|
||||
Sys_GetRegistryInteger( "showTexturesCurrentFrame", false, g_showTextures_currentFrame );
|
||||
Sys_GetRegistryInteger( "showTexturesSortColumn", ID_ST_NAME, g_showTextures_sortColumn );
|
||||
Sys_GetRegistryInteger( "showTexturesSortDescending", false, g_showTextures_sortDescending );
|
||||
|
||||
Sys_GetRegistryString( "showTexturesWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_showTextures_windowRect.left, &g_showTextures_windowRect.top, &g_showTextures_windowRect.right, &g_showTextures_windowRect.bottom );
|
||||
if ( numArgs != 4 || g_showTextures_windowRect.left < 0 || g_showTextures_windowRect.top < 0 || g_showTextures_windowRect.right < 0 || g_showTextures_windowRect.bottom < 0 )
|
||||
{
|
||||
memset( &g_showTextures_windowRect, 0, sizeof( g_showTextures_windowRect ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_Clear
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_Clear()
|
||||
{
|
||||
// delete all the list view entries
|
||||
if ( g_showTextures_hWnd )
|
||||
{
|
||||
ListView_DeleteAllItems( g_showTextures_hWndListView );
|
||||
}
|
||||
|
||||
if ( !g_showTextures_pTextures )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i=0; i<g_showTextures_numTextures; i++ )
|
||||
{
|
||||
free( g_showTextures_pTextures[i].pLongName );
|
||||
free( g_showTextures_pTextures[i].pShortName );
|
||||
free( g_showTextures_pTextures[i].pGroupName );
|
||||
free( g_showTextures_pTextures[i].pFormatName );
|
||||
}
|
||||
|
||||
g_showTextures_pTextures = NULL;
|
||||
g_showTextures_numTextures = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_Export
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_Export()
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
char logFilename[MAX_PATH];
|
||||
int retval;
|
||||
FILE* fp;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
memset( &ofn, 0, sizeof( ofn ) );
|
||||
ofn.lStructSize = sizeof( ofn );
|
||||
ofn.hwndOwner = g_showTextures_hWnd;
|
||||
ofn.lpstrFile = logFilename;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof( logFilename );
|
||||
ofn.lpstrFilter = "Excel CSV\0*.CSV\0All Files\0*.*\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = "c:\\";
|
||||
ofn.Flags = OFN_PATHMUSTEXIST;
|
||||
|
||||
// display the Open dialog box.
|
||||
retval = GetOpenFileName( &ofn );
|
||||
if ( !retval )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Sys_AddExtension( ".csv", logFilename, sizeof( logFilename ) );
|
||||
|
||||
fp = fopen( logFilename, "wt+" );
|
||||
if ( !fp )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// labels
|
||||
count = sizeof( g_showTextures_Labels )/sizeof( g_showTextures_Labels[0] );
|
||||
for ( i=0; i<count; i++ )
|
||||
{
|
||||
fprintf( fp, "\"%s\"", g_showTextures_Labels[i].name );
|
||||
if ( i != count-1 )
|
||||
{
|
||||
fprintf( fp, "," );
|
||||
}
|
||||
}
|
||||
fprintf( fp, "\n" );
|
||||
|
||||
// dump to the log
|
||||
for ( i=0; i<g_showTextures_numTextures; i++ )
|
||||
{
|
||||
if ( g_showTextures_fullPath )
|
||||
{
|
||||
fprintf( fp, "\"%s\"", g_showTextures_pTextures[i].pLongName );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( fp, "\"%s\"", g_showTextures_pTextures[i].pShortName );
|
||||
}
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].sizeBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].pGroupName );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].pFormatName );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].widthBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].heightBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].depthBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].numLevelsBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].bindsBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_pTextures[i].refCountBuff );
|
||||
fprintf( fp, ",\"%s\"", g_showTextures_loadStrings[g_showTextures_pTextures[i].loadState] );
|
||||
fprintf( fp, "\n" );
|
||||
}
|
||||
|
||||
fclose( fp );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_Summary
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_Summary()
|
||||
{
|
||||
char buff[1024];
|
||||
|
||||
// tally the totals
|
||||
int total = 0;
|
||||
for ( int i=0; i<g_showTextures_numTextures; i++ )
|
||||
{
|
||||
if ( g_showTextures_pTextures[i].edram )
|
||||
{
|
||||
// edram is does not affect system memory total
|
||||
continue;
|
||||
}
|
||||
total += g_showTextures_pTextures[i].size;
|
||||
}
|
||||
|
||||
sprintf(
|
||||
buff,
|
||||
"Entries:\t\t\t%d\n"
|
||||
"System D3D Memory:\t%.2f MB\n",
|
||||
g_showTextures_numTextures,
|
||||
( float )total/( 1024.0F*1024.0F ) );
|
||||
|
||||
MessageBox( g_showTextures_hWnd, buff, "Texture Summary", MB_OK|MB_APPLMODAL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_DrawTexture
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_DrawTexture()
|
||||
{
|
||||
char command[256];
|
||||
texture_t* pTexture;
|
||||
int selection;
|
||||
LVITEM lvitem;
|
||||
|
||||
if ( !g_connectedToApp )
|
||||
return;
|
||||
|
||||
selection = ListView_GetSelectionMark( g_showTextures_hWndListView );
|
||||
if ( selection == -1 )
|
||||
return;
|
||||
|
||||
memset( &lvitem, 0, sizeof( lvitem ) );
|
||||
lvitem.mask = LVIF_PARAM;
|
||||
lvitem.iItem = selection;
|
||||
ListView_GetItem( g_showTextures_hWndListView, &lvitem );
|
||||
|
||||
pTexture = ( texture_t* )lvitem.lParam;
|
||||
|
||||
if ( !V_stricmp( g_showTextures_drawTextureName, pTexture->pLongName ) )
|
||||
{
|
||||
// hide
|
||||
sprintf( command, "mat_drawTexture \"\"" );
|
||||
g_showTextures_drawTextureName[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
// show
|
||||
sprintf( command, "mat_drawTexture %s", pTexture->pLongName );
|
||||
V_strncpy( g_showTextures_drawTextureName, pTexture->pLongName, sizeof( g_showTextures_drawTextureName ) );
|
||||
}
|
||||
|
||||
// send the command to application
|
||||
ProcessCommand( command );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_SetTitle
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_SetTitle()
|
||||
{
|
||||
char titleBuff[128];
|
||||
|
||||
if ( g_showTextures_hWnd )
|
||||
{
|
||||
strcpy( titleBuff, "Textures " );
|
||||
if ( g_showTextures_currentFrame )
|
||||
{
|
||||
strcat( titleBuff, " [FRAME]" );
|
||||
}
|
||||
if ( g_showTextures_fullPath )
|
||||
{
|
||||
strcat( titleBuff, " [FULL PATH]" );
|
||||
}
|
||||
|
||||
SetWindowText( g_showTextures_hWnd, titleBuff );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_CompareFunc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CALLBACK ShowTextures_CompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
|
||||
{
|
||||
texture_t* pTextureA = ( texture_t* )lParam1;
|
||||
texture_t* pTextureB = ( texture_t* )lParam2;
|
||||
|
||||
int sort = 0;
|
||||
switch ( g_showTextures_sortColumn )
|
||||
{
|
||||
case ID_ST_NAME:
|
||||
if ( g_showTextures_fullPath )
|
||||
{
|
||||
sort = stricmp( pTextureA->pLongName, pTextureB->pLongName );
|
||||
}
|
||||
else
|
||||
{
|
||||
sort = stricmp( pTextureA->pShortName, pTextureB->pShortName );
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_ST_GROUP:
|
||||
sort = stricmp( pTextureA->pGroupName, pTextureB->pGroupName );
|
||||
break;
|
||||
|
||||
case ID_ST_FORMAT:
|
||||
sort = stricmp( pTextureA->pFormatName, pTextureB->pFormatName );
|
||||
break;
|
||||
|
||||
case ID_ST_SIZE:
|
||||
sort = pTextureA->size - pTextureB->size;
|
||||
break;
|
||||
|
||||
case ID_ST_WIDTH:
|
||||
sort = pTextureA->width - pTextureB->width;
|
||||
break;
|
||||
|
||||
case ID_ST_HEIGHT:
|
||||
sort = pTextureA->height - pTextureB->height;
|
||||
break;
|
||||
|
||||
case ID_ST_DEPTH:
|
||||
sort = pTextureA->depth - pTextureB->depth;
|
||||
break;
|
||||
|
||||
case ID_ST_NUMLEVELS:
|
||||
sort = pTextureA->numLevels - pTextureB->numLevels;
|
||||
break;
|
||||
|
||||
case ID_ST_BINDS:
|
||||
sort = pTextureA->binds - pTextureB->binds;
|
||||
break;
|
||||
|
||||
case ID_ST_REFCOUNT:
|
||||
sort = pTextureA->refCount - pTextureB->refCount;
|
||||
break;
|
||||
|
||||
case ID_ST_LOAD:
|
||||
sort = stricmp( g_showTextures_loadStrings[pTextureA->loadState], g_showTextures_loadStrings[pTextureB->loadState] );
|
||||
break;
|
||||
}
|
||||
|
||||
// flip the sort order
|
||||
if ( g_showTextures_sortDescending )
|
||||
{
|
||||
sort *= -1;
|
||||
}
|
||||
|
||||
return ( sort );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_SortItems
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_SortItems()
|
||||
{
|
||||
LVITEM lvitem;
|
||||
texture_t *pTexture;
|
||||
int i;
|
||||
|
||||
if ( !g_showTextures_hWnd )
|
||||
{
|
||||
// only sort if window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
ListView_SortItems( g_showTextures_hWndListView, ShowTextures_CompareFunc, 0 );
|
||||
|
||||
memset( &lvitem, 0, sizeof( lvitem ) );
|
||||
lvitem.mask = LVIF_PARAM;
|
||||
|
||||
// get each item and reset its list index
|
||||
int itemCount = ListView_GetItemCount( g_showTextures_hWndListView );
|
||||
for ( i=0; i<itemCount; i++ )
|
||||
{
|
||||
lvitem.iItem = i;
|
||||
ListView_GetItem( g_showTextures_hWndListView, &lvitem );
|
||||
|
||||
pTexture = ( texture_t* )lvitem.lParam;
|
||||
pTexture->listIndex = i;
|
||||
}
|
||||
|
||||
// update list view columns with sort key
|
||||
for ( i=0; i<sizeof( g_showTextures_Labels )/sizeof( g_showTextures_Labels[0] ); i++ )
|
||||
{
|
||||
char symbol;
|
||||
LVCOLUMN lvc;
|
||||
|
||||
if ( i == g_showTextures_sortColumn )
|
||||
{
|
||||
symbol = g_showTextures_sortDescending ? '<' : '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
symbol = ' ';
|
||||
}
|
||||
sprintf( g_showTextures_Labels[i].nameBuff, "%s %c", g_showTextures_Labels[i].name, symbol );
|
||||
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = ( LPSTR )g_showTextures_Labels[i].nameBuff;
|
||||
|
||||
ListView_SetColumn( g_showTextures_hWndListView, i, &lvc );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_AddViewItem
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_AddViewItem( texture_t* pTexture )
|
||||
{
|
||||
LVITEM lvi;
|
||||
|
||||
if ( !g_showTextures_hWnd )
|
||||
{
|
||||
// only valid if log window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
// update the text callback buffers
|
||||
sprintf( pTexture->sizeBuff, "%d", pTexture->size );
|
||||
sprintf( pTexture->widthBuff, "%d", pTexture->width );
|
||||
sprintf( pTexture->heightBuff, "%d", pTexture->height );
|
||||
sprintf( pTexture->depthBuff, "%d", pTexture->depth );
|
||||
sprintf( pTexture->numLevelsBuff, "%d", pTexture->numLevels );
|
||||
sprintf( pTexture->bindsBuff, "%d", pTexture->binds );
|
||||
sprintf( pTexture->refCountBuff, "%d", pTexture->refCount );
|
||||
|
||||
int itemCount = ListView_GetItemCount( g_showTextures_hWndListView );
|
||||
|
||||
// setup and insert at end of list
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
||||
lvi.iItem = itemCount;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.state = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
lvi.lParam = ( LPARAM )pTexture;
|
||||
|
||||
// insert and set the real index
|
||||
pTexture->listIndex = ListView_InsertItem( g_showTextures_hWndListView, &lvi );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_Refresh
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_Refresh()
|
||||
{
|
||||
char command[256];
|
||||
|
||||
strcpy( command, "mat_get_textures" );
|
||||
|
||||
if ( !g_showTextures_currentFrame )
|
||||
{
|
||||
strcat( command, " all" );
|
||||
}
|
||||
|
||||
// send the command to application which replies with list data
|
||||
if ( g_connectedToApp )
|
||||
{
|
||||
ProcessCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_SizeWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_SizeWindow( HWND hwnd, int cx, int cy )
|
||||
{
|
||||
if ( cx==0 || cy==0 )
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect( hwnd, &rcClient );
|
||||
cx = rcClient.right;
|
||||
cy = rcClient.bottom;
|
||||
}
|
||||
|
||||
// position the ListView
|
||||
SetWindowPos( g_showTextures_hWndListView, NULL, 0, 0, cx, cy, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK ShowTextures_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
texture_t* pTexture;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
ShowTextures_SaveConfig();
|
||||
g_showTextures_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_INITMENU:
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_OPTIONS_CURRENTFRAME, MF_BYCOMMAND | ( g_showTextures_currentFrame ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_OPTIONS_FULLPATH, MF_BYCOMMAND | ( g_showTextures_fullPath ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
ShowTextures_SizeWindow( hwnd, LOWORD( lParam ), HIWORD( lParam ) );
|
||||
return 0L;
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch ( ( ( LPNMHDR )lParam )->code )
|
||||
{
|
||||
case LVN_COLUMNCLICK:
|
||||
NMLISTVIEW* pnmlv;
|
||||
pnmlv = ( NMLISTVIEW* )lParam;
|
||||
if ( g_showTextures_sortColumn == pnmlv->iSubItem )
|
||||
{
|
||||
// user has clicked on same column - flip the sort
|
||||
g_showTextures_sortDescending ^= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sort by new column
|
||||
g_showTextures_sortColumn = pnmlv->iSubItem;
|
||||
}
|
||||
ShowTextures_SortItems();
|
||||
return 0L;
|
||||
|
||||
case LVN_GETDISPINFO:
|
||||
NMLVDISPINFO* plvdi;
|
||||
plvdi = ( NMLVDISPINFO* )lParam;
|
||||
pTexture = ( texture_t* )plvdi->item.lParam;
|
||||
switch ( plvdi->item.iSubItem )
|
||||
{
|
||||
case ID_ST_NAME:
|
||||
if ( g_showTextures_fullPath )
|
||||
plvdi->item.pszText = pTexture->pLongName;
|
||||
else
|
||||
plvdi->item.pszText = pTexture->pShortName;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_GROUP:
|
||||
plvdi->item.pszText = pTexture->pGroupName;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_FORMAT:
|
||||
plvdi->item.pszText = pTexture->pFormatName;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_SIZE:
|
||||
plvdi->item.pszText = pTexture->sizeBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_WIDTH:
|
||||
plvdi->item.pszText = pTexture->widthBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_HEIGHT:
|
||||
plvdi->item.pszText = pTexture->heightBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_DEPTH:
|
||||
plvdi->item.pszText = pTexture->depthBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_NUMLEVELS:
|
||||
plvdi->item.pszText = pTexture->numLevelsBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_BINDS:
|
||||
plvdi->item.pszText = pTexture->bindsBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_ST_LOAD:
|
||||
plvdi->item.pszText = g_showTextures_loadStrings[pTexture->loadState];
|
||||
return 0L;
|
||||
|
||||
case ID_ST_REFCOUNT:
|
||||
plvdi->item.pszText = pTexture->refCountBuff;
|
||||
return 0L;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_OPTIONS_SUMMARY:
|
||||
ShowTextures_Summary();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_REFRESH:
|
||||
ShowTextures_Refresh();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_EXPORT:
|
||||
ShowTextures_Export();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_CURRENTFRAME:
|
||||
g_showTextures_currentFrame ^= 1;
|
||||
ShowTextures_SetTitle();
|
||||
ShowTextures_Refresh();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_FULLPATH:
|
||||
g_showTextures_fullPath ^= 1;
|
||||
ShowTextures_SetTitle();
|
||||
ShowTextures_SortItems();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_DRAWTEXTURE:
|
||||
ShowTextures_DrawTexture();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ShowTextures_Init()
|
||||
{
|
||||
// set up our window class
|
||||
WNDCLASS wndclass;
|
||||
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = ShowTextures_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_SHOWTEXTURES );
|
||||
wndclass.lpszClassName = "SHOWTEXTURESCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
ShowTextures_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShowTextures_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShowTextures_Open()
|
||||
{
|
||||
RECT clientRect;
|
||||
HWND hWnd;
|
||||
int i;
|
||||
|
||||
if ( g_showTextures_hWnd )
|
||||
{
|
||||
// only one instance
|
||||
if ( IsIconic( g_showTextures_hWnd ) )
|
||||
{
|
||||
ShowWindow( g_showTextures_hWnd, SW_RESTORE );
|
||||
}
|
||||
SetForegroundWindow( g_showTextures_hWnd );
|
||||
return;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"SHOWTEXTURESCLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
700,
|
||||
400,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_showTextures_hWnd = hWnd;
|
||||
|
||||
GetClientRect( g_showTextures_hWnd, &clientRect );
|
||||
hWnd = CreateWindow(
|
||||
WC_LISTVIEW,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|LVS_REPORT,
|
||||
0,
|
||||
0,
|
||||
clientRect.right-clientRect.left,
|
||||
clientRect.bottom-clientRect.top,
|
||||
g_showTextures_hWnd,
|
||||
( HMENU )ID_SHOWTEXTURES_LISTVIEW,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_showTextures_hWndListView = hWnd;
|
||||
|
||||
// init list view columns
|
||||
for ( i=0; i<sizeof( g_showTextures_Labels )/sizeof( g_showTextures_Labels[0] ); i++ )
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
|
||||
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.cx = g_showTextures_Labels[i].width;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.pszText = ( LPSTR )g_showTextures_Labels[i].name;
|
||||
ListView_InsertColumn( g_showTextures_hWndListView, i, &lvc );
|
||||
}
|
||||
|
||||
ListView_SetBkColor( g_showTextures_hWndListView, g_backgroundColor );
|
||||
ListView_SetTextBkColor( g_showTextures_hWndListView, g_backgroundColor );
|
||||
|
||||
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;
|
||||
ListView_SetExtendedListViewStyleEx( g_showTextures_hWndListView, style, style );
|
||||
|
||||
// populate list view
|
||||
for ( i=0; i<g_showTextures_numTextures; i++ )
|
||||
{
|
||||
ShowTextures_AddViewItem( &g_showTextures_pTextures[i] );
|
||||
}
|
||||
ShowTextures_SortItems();
|
||||
|
||||
ShowTextures_SetTitle();
|
||||
|
||||
if ( g_showTextures_windowRect.right && g_showTextures_windowRect.bottom )
|
||||
{
|
||||
MoveWindow( g_showTextures_hWnd, g_showTextures_windowRect.left, g_showTextures_windowRect.top, g_showTextures_windowRect.right-g_showTextures_windowRect.left, g_showTextures_windowRect.bottom-g_showTextures_windowRect.top, FALSE );
|
||||
}
|
||||
ShowWindow( g_showTextures_hWnd, SHOW_OPENWINDOW );
|
||||
|
||||
// get data from application
|
||||
ShowTextures_Refresh();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_TextureList
|
||||
//
|
||||
// Sent from application with texture list
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_TextureList( char* commandPtr )
|
||||
{
|
||||
int errCode = -1;
|
||||
char* cmdToken;
|
||||
int numTextures;
|
||||
int textureList;
|
||||
int retAddr;
|
||||
int retVal;
|
||||
xrTexture_t* pLocalList;
|
||||
|
||||
// remove old entries
|
||||
ShowTextures_Clear();
|
||||
|
||||
// get number of textures
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &numTextures );
|
||||
|
||||
// get texture list
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &textureList );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &retAddr );
|
||||
|
||||
pLocalList = new xrTexture_t[numTextures];
|
||||
memset( pLocalList, 0, numTextures*sizeof( xrTexture_t ) );
|
||||
|
||||
g_showTextures_numTextures = numTextures;
|
||||
g_showTextures_pTextures = new texture_t[numTextures];
|
||||
memset( g_showTextures_pTextures, 0, numTextures*sizeof( texture_t ) );
|
||||
|
||||
// get the caller's command list
|
||||
DmGetMemory( ( void* )textureList, numTextures*sizeof( xrTexture_t ), pLocalList, NULL );
|
||||
|
||||
// build out the resident list
|
||||
for ( int i=0; i<numTextures; i++ )
|
||||
{
|
||||
// swap the structure
|
||||
pLocalList[i].size = BigDWord( pLocalList[i].size );
|
||||
pLocalList[i].width = BigDWord( pLocalList[i].width );
|
||||
pLocalList[i].height = BigDWord( pLocalList[i].height );
|
||||
pLocalList[i].depth = BigDWord( pLocalList[i].depth );
|
||||
pLocalList[i].numLevels = BigDWord( pLocalList[i].numLevels );
|
||||
pLocalList[i].binds = BigDWord( pLocalList[i].binds );
|
||||
pLocalList[i].refCount = BigDWord( pLocalList[i].refCount );
|
||||
pLocalList[i].sRGB = BigDWord( pLocalList[i].sRGB );
|
||||
pLocalList[i].edram = BigDWord( pLocalList[i].edram );
|
||||
pLocalList[i].procedural = BigDWord( pLocalList[i].procedural );
|
||||
pLocalList[i].fallback = BigDWord( pLocalList[i].fallback );
|
||||
pLocalList[i].final = BigDWord( pLocalList[i].final );
|
||||
pLocalList[i].failed = BigDWord( pLocalList[i].failed );
|
||||
|
||||
// get the name
|
||||
g_showTextures_pTextures[i].pLongName = strdup( pLocalList[i].nameString );
|
||||
|
||||
CHAR shortName[MAX_PATH];
|
||||
Sys_StripPath( g_showTextures_pTextures[i].pLongName, shortName, sizeof( shortName ) );
|
||||
g_showTextures_pTextures[i].pShortName = strdup( shortName );
|
||||
|
||||
// get the group name
|
||||
g_showTextures_pTextures[i].pGroupName = strdup( pLocalList[i].groupString );
|
||||
|
||||
// get the format name
|
||||
const char *pFormatName = pLocalList[i].formatString;
|
||||
if ( !strnicmp( pFormatName, "D3DFMT_", 7 ) )
|
||||
{
|
||||
// strip D3DFMT_
|
||||
pFormatName += 7;
|
||||
}
|
||||
char tempName[MAX_PATH];
|
||||
if ( pLocalList[i].sRGB )
|
||||
{
|
||||
strcpy( tempName, pFormatName );
|
||||
strcat( tempName, " (SRGB)" );
|
||||
pFormatName = tempName;
|
||||
}
|
||||
g_showTextures_pTextures[i].pFormatName = strdup( pFormatName );
|
||||
|
||||
g_showTextures_pTextures[i].size = pLocalList[i].size;
|
||||
g_showTextures_pTextures[i].width = pLocalList[i].width;
|
||||
g_showTextures_pTextures[i].height = pLocalList[i].height;
|
||||
g_showTextures_pTextures[i].depth = pLocalList[i].depth;
|
||||
g_showTextures_pTextures[i].numLevels = pLocalList[i].numLevels;
|
||||
g_showTextures_pTextures[i].binds = pLocalList[i].binds;
|
||||
g_showTextures_pTextures[i].refCount = pLocalList[i].refCount;
|
||||
g_showTextures_pTextures[i].edram = pLocalList[i].edram;
|
||||
|
||||
loadState_e loadState;
|
||||
if ( pLocalList[i].edram || V_stristr( g_showTextures_pTextures[i].pGroupName, "RenderTarget" ) )
|
||||
{
|
||||
loadState = LS_STATIC;
|
||||
}
|
||||
else if ( pLocalList[i].procedural )
|
||||
{
|
||||
loadState = LS_PROCEDURAL;
|
||||
}
|
||||
else if ( pLocalList[i].final )
|
||||
{
|
||||
loadState = LS_HIRES;
|
||||
}
|
||||
else if ( pLocalList[i].failed )
|
||||
{
|
||||
loadState = LS_FAILED;
|
||||
}
|
||||
else if ( pLocalList[i].fallback )
|
||||
{
|
||||
loadState = LS_FALLBACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadState = LS_SYNCHRONOUS;
|
||||
}
|
||||
g_showTextures_pTextures[i].loadState = loadState;
|
||||
|
||||
// add to list view
|
||||
ShowTextures_AddViewItem( &g_showTextures_pTextures[i] );
|
||||
}
|
||||
|
||||
// return the result
|
||||
retVal = numTextures;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = TextureList( 0x%8.8x, 0x%8.8x )\n", retVal, numTextures, textureList );
|
||||
|
||||
delete [] pLocalList;
|
||||
|
||||
// update
|
||||
ShowTextures_SortItems();
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return errCode;
|
||||
}
|
||||
942
utils/xbox/vxconsole/sync_files.cpp
Normal file
942
utils/xbox/vxconsole/sync_files.cpp
Normal file
@@ -0,0 +1,942 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SYNC_FILES.CPP
|
||||
//
|
||||
// Sync Files Routines.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
char g_syncfiles_localPath[MAX_PATH];
|
||||
char g_syncfiles_targetPath[MAX_PATH];
|
||||
fileNode_t *g_syncfiles_targetFiles;
|
||||
int g_syncfiles_numTargetFiles;
|
||||
CProgress *g_syncFiles_progress;
|
||||
BOOL g_syncFiles_noWrite;
|
||||
BOOL g_syncFiles_force;
|
||||
BOOL g_syncFiles_verbose;
|
||||
|
||||
struct dvdimage_t
|
||||
{
|
||||
char szString[MAX_PATH];
|
||||
CUtlString installPath;
|
||||
CUtlString versionDetailString;
|
||||
};
|
||||
CUtlVector< dvdimage_t> g_install_dvdImages;
|
||||
int g_install_Selection;
|
||||
bool g_install_bForceSync;
|
||||
bool g_install_bCleanTarget;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_Validate
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SyncFilesDlg_Validate()
|
||||
{
|
||||
if ( !g_connectedToXBox )
|
||||
{
|
||||
Sys_MessageBox( "Sync Error", "Cannot sync until connected to XBox." );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_Setup
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void SyncFilesDlg_Setup( HWND hWnd )
|
||||
{
|
||||
SetDlgItemText( hWnd, IDC_SYNCFILES_LOCALPATH, g_syncfiles_localPath );
|
||||
SetDlgItemText( hWnd, IDC_SYNCFILES_TARGETPATH, g_syncfiles_targetPath );
|
||||
|
||||
CheckDlgButton( hWnd, IDC_SYNCFILES_FORCESYNC, g_syncFiles_force ? BST_CHECKED : BST_UNCHECKED );
|
||||
CheckDlgButton( hWnd, IDC_SYNCFILES_NOWRITE, g_syncFiles_noWrite ? BST_CHECKED : BST_UNCHECKED );
|
||||
CheckDlgButton( hWnd, IDC_SYNCFILES_VERBOSE, g_syncFiles_verbose ? BST_CHECKED : BST_UNCHECKED );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_GetChanges
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SyncFilesDlg_GetChanges( HWND hwnd )
|
||||
{
|
||||
char localPath[MAX_PATH];
|
||||
char targetPath[MAX_PATH];
|
||||
|
||||
localPath[0] = '\0';
|
||||
targetPath[0] = '\0';
|
||||
|
||||
GetDlgItemText( hwnd, IDC_SYNCFILES_LOCALPATH, localPath, MAX_PATH );
|
||||
GetDlgItemText( hwnd, IDC_SYNCFILES_TARGETPATH, targetPath, MAX_PATH );
|
||||
|
||||
strcpy( g_syncfiles_localPath, localPath );
|
||||
Sys_NormalizePath( g_syncfiles_localPath, true );
|
||||
|
||||
strcpy( g_syncfiles_targetPath, targetPath );
|
||||
Sys_NormalizePath( g_syncfiles_targetPath, true );
|
||||
|
||||
g_syncFiles_force = IsDlgButtonChecked( hwnd, IDC_SYNCFILES_FORCESYNC ) != 0;
|
||||
g_syncFiles_noWrite = IsDlgButtonChecked( hwnd, IDC_SYNCFILES_NOWRITE ) != 0;
|
||||
g_syncFiles_verbose = IsDlgButtonChecked( hwnd, IDC_SYNCFILES_VERBOSE ) != 0;
|
||||
|
||||
// success
|
||||
return ( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_Proc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL CALLBACK SyncFilesDlg_Proc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
SyncFilesDlg_Setup( hwnd );
|
||||
return ( TRUE );
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( LOWORD( wParam ) )
|
||||
{
|
||||
case IDC_OK:
|
||||
if ( !SyncFilesDlg_GetChanges( hwnd ) )
|
||||
break;
|
||||
EndDialog( hwnd, wParam );
|
||||
return ( TRUE );
|
||||
|
||||
case IDCANCEL:
|
||||
case IDC_CANCEL:
|
||||
EndDialog( hwnd, wParam );
|
||||
return ( TRUE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( FALSE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFiles_FreeTargetList
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void SyncFiles_FreeTargetList()
|
||||
{
|
||||
g_syncfiles_numTargetFiles = 0;
|
||||
|
||||
FreeTargetFileList( g_syncfiles_targetFiles );
|
||||
g_syncfiles_targetFiles = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFiles_DoUpdates
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SyncFiles_DoUpdates()
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA localAttributes;
|
||||
fileNode_t *nodePtr;
|
||||
char sourceFilename[MAX_PATH];
|
||||
char statusBuff1[MAX_PATH];
|
||||
char statusBuff2[MAX_PATH];
|
||||
int targetPathLen;
|
||||
char *ptr;
|
||||
int progress;
|
||||
int fileSyncMode;
|
||||
int numSynced;
|
||||
int retVal;
|
||||
|
||||
g_syncFiles_progress->SetStatus( "Syncing Target Files...", "", "" );
|
||||
g_syncFiles_progress->SetMeter( 0, g_syncfiles_numTargetFiles );
|
||||
|
||||
fileSyncMode = FSYNC_ANDEXISTSONTARGET;
|
||||
if ( g_syncFiles_force )
|
||||
fileSyncMode |= FSYNC_ALWAYS;
|
||||
else
|
||||
fileSyncMode |= FSYNC_IFNEWER;
|
||||
|
||||
targetPathLen = strlen( g_syncfiles_targetPath );
|
||||
|
||||
numSynced = 0;
|
||||
progress = 0;
|
||||
nodePtr = g_syncfiles_targetFiles;
|
||||
while ( nodePtr )
|
||||
{
|
||||
ptr = nodePtr->filename+targetPathLen;
|
||||
if ( *ptr == '\\' )
|
||||
ptr++;
|
||||
|
||||
// replace with source path head
|
||||
strcpy( sourceFilename, g_syncfiles_localPath );
|
||||
Sys_AddFileSeperator( sourceFilename, sizeof( sourceFilename ) );
|
||||
strcat( sourceFilename, ptr );
|
||||
|
||||
float sourceFileSize = 0;
|
||||
if ( GetFileAttributesEx( sourceFilename, GetFileExInfoStandard, &localAttributes ) )
|
||||
{
|
||||
sourceFileSize = (float)localAttributes.nFileSizeLow / (1024.0f * 1024.0f);
|
||||
}
|
||||
|
||||
_snprintf( statusBuff1, sizeof( statusBuff1 ), "Local File: %s (%.2f MB)", sourceFilename, sourceFileSize );
|
||||
statusBuff1[sizeof( statusBuff1 ) - 1] = '\0';
|
||||
_snprintf( statusBuff2, sizeof( statusBuff2 ), "Target File: %s", nodePtr->filename );
|
||||
statusBuff1[sizeof( statusBuff2 ) - 1] = '\0';
|
||||
g_syncFiles_progress->SetStatus( NULL, statusBuff1, statusBuff2 );
|
||||
|
||||
retVal = FileSyncEx( sourceFilename, nodePtr->filename, fileSyncMode, g_syncFiles_verbose != FALSE, g_syncFiles_noWrite != FALSE);
|
||||
if ( retVal == 1 )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "Sync: %s -> %s\n", sourceFilename, nodePtr->filename );
|
||||
numSynced++;
|
||||
}
|
||||
|
||||
progress++;
|
||||
g_syncFiles_progress->SetMeter( progress, -1 );
|
||||
if ( g_syncFiles_progress->IsCancel() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
nodePtr = nodePtr->nextPtr;
|
||||
}
|
||||
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "Synced %d/%d Files.\n", numSynced, g_syncfiles_numTargetFiles );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFiles_GetTargetList
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SyncFiles_GetTargetList( char* pTargetPath )
|
||||
{
|
||||
g_syncFiles_progress->SetStatus( "Getting Target Files...", "", "" );
|
||||
g_syncFiles_progress->SetMeter( 0, 100 );
|
||||
|
||||
if ( !GetTargetFileList_r( pTargetPath, true, FA_NORMAL|FA_READONLY, 0, &g_syncfiles_targetFiles ) )
|
||||
{
|
||||
ConsoleWindowPrintf( RGB( 255,0,0 ), "Bad Target Path '%s'\n", pTargetPath );
|
||||
return false;
|
||||
}
|
||||
|
||||
fileNode_t* pFileNode;
|
||||
for ( pFileNode = g_syncfiles_targetFiles; pFileNode; pFileNode = pFileNode->nextPtr )
|
||||
{
|
||||
g_syncfiles_numTargetFiles++;
|
||||
}
|
||||
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void SyncFilesDlg_SaveConfig()
|
||||
{
|
||||
Sys_SetRegistryString( "syncfiles_localPath", g_syncfiles_localPath );
|
||||
Sys_SetRegistryString( "syncfiles_targetPath", g_syncfiles_targetPath );
|
||||
Sys_SetRegistryInteger( "syncfiles_force", g_syncFiles_force );
|
||||
Sys_SetRegistryInteger( "syncfiles_noWrite", g_syncFiles_noWrite );
|
||||
Sys_SetRegistryInteger( "syncfiles_verbose", g_syncFiles_verbose );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void SyncFilesDlg_Open( void )
|
||||
{
|
||||
int result;
|
||||
bool bError;
|
||||
bool bValid;
|
||||
|
||||
result = DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_SYNCFILES ), g_hDlgMain, ( DLGPROC )SyncFilesDlg_Proc );
|
||||
if ( LOWORD( result ) != IDC_OK )
|
||||
return;
|
||||
|
||||
SyncFilesDlg_SaveConfig();
|
||||
|
||||
if ( !SyncFilesDlg_Validate() )
|
||||
return;
|
||||
|
||||
g_syncFiles_progress = new CProgress;
|
||||
g_syncFiles_progress->Open( "Sync Files...", true, true );
|
||||
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "\nSyncing Files From '%s' to '%s'\n", g_syncfiles_localPath, g_syncfiles_targetPath );
|
||||
|
||||
bError = true;
|
||||
|
||||
// get a file listing from target
|
||||
bValid = SyncFiles_GetTargetList( g_syncfiles_targetPath );
|
||||
if ( !bValid )
|
||||
goto cleanUp;
|
||||
|
||||
// mark all files needing update
|
||||
bValid = SyncFiles_DoUpdates();
|
||||
if ( !bValid )
|
||||
goto cleanUp;
|
||||
|
||||
bError = false;
|
||||
|
||||
cleanUp:
|
||||
delete g_syncFiles_progress;
|
||||
g_syncFiles_progress = NULL;
|
||||
|
||||
if ( bError )
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Aborted.\n" );
|
||||
else
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "Finished.\n" );
|
||||
|
||||
SyncFiles_FreeTargetList();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void SyncFilesDlg_LoadConfig()
|
||||
{
|
||||
// get our config
|
||||
Sys_GetRegistryString( "syncfiles_localPath", g_syncfiles_localPath, g_localPath, sizeof( g_syncfiles_localPath ) );
|
||||
Sys_GetRegistryString( "syncfiles_targetPath", g_syncfiles_targetPath, g_targetPath, sizeof( g_syncfiles_targetPath ) );
|
||||
Sys_GetRegistryInteger( "syncfiles_force", false, g_syncFiles_force );
|
||||
Sys_GetRegistryInteger( "syncfiles_noWrite", false, g_syncFiles_noWrite );
|
||||
Sys_GetRegistryInteger( "syncfiles_verbose", false, g_syncFiles_verbose );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SyncFilesDlg_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SyncFilesDlg_Init()
|
||||
{
|
||||
SyncFilesDlg_LoadConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InstallDlg_InstallImage
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void InstallDlg_InstallImage( const char *pInstallPath, bool bForce, bool bCleanTarget )
|
||||
{
|
||||
int errCode;
|
||||
char *pToken;
|
||||
char arg1[MAXTOKEN];
|
||||
char arg2[MAXTOKEN];
|
||||
char sourceFilename[MAX_PATH];
|
||||
char sourcePath[MAX_PATH];
|
||||
char targetFilename[MAX_PATH];
|
||||
char filename[MAX_PATH];
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE h;
|
||||
|
||||
if ( !pInstallPath[0] )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "\nSyncing From Install Depot: %s\n", pInstallPath );
|
||||
|
||||
// get the install script
|
||||
char szScriptPath[MAX_PATH];
|
||||
V_ComposeFileName( pInstallPath, "../dvd_install.txt", szScriptPath, sizeof( szScriptPath ) );
|
||||
if ( !Sys_Exists( szScriptPath ) )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Failed to open: %s\n", szScriptPath );
|
||||
return;
|
||||
}
|
||||
|
||||
// sanity check
|
||||
// DVD image auto-build failure prevents the presence of the default.xex
|
||||
char szTempFilename[MAX_PATH];
|
||||
V_ComposeFileName( pInstallPath, "default.xex", szTempFilename, sizeof( szTempFilename ) );
|
||||
if ( !Sys_Exists( szTempFilename ) )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Cancelled Installation! DVD Image Auto-Build Process Failed - Missing default.xex!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// get the version detail
|
||||
char szVersionPath[MAX_PATH];
|
||||
char *pVersionDetailString = NULL;
|
||||
V_ComposeFileName( pInstallPath, "version.txt", szVersionPath, sizeof( szVersionPath ) );
|
||||
if ( Sys_LoadFile( szVersionPath, (void**)&pVersionDetailString ) <= 0 )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Cancelled Installation! DVD Image Auto-Build Process Failed! - Missing version.txt\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Sys_LoadScriptFile( szScriptPath );
|
||||
|
||||
CProgress* pProgress = new CProgress;
|
||||
pProgress->Open( "Installing DVD Image...", true, false );
|
||||
|
||||
int numFailed = 0;
|
||||
int numSkipped = 0;
|
||||
int numUpdated = 0;
|
||||
int version = 0;
|
||||
|
||||
bool bFailed = true;
|
||||
bool bSyntaxError = false;
|
||||
bool bCancelled = false;
|
||||
while ( 1 )
|
||||
{
|
||||
pToken = Sys_GetToken( true );
|
||||
if ( !pToken || !pToken[0] )
|
||||
break;
|
||||
|
||||
if ( pProgress->IsCancel() )
|
||||
{
|
||||
bCancelled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !stricmp( pToken, "$version" ) )
|
||||
{
|
||||
// version <num> <targetroot>
|
||||
pToken = Sys_GetToken( false );
|
||||
if ( !pToken || !pToken[0] )
|
||||
{
|
||||
bSyntaxError = true;
|
||||
break;
|
||||
}
|
||||
version = atoi( pToken );
|
||||
if ( version < 0 )
|
||||
{
|
||||
version = 0;
|
||||
}
|
||||
|
||||
pToken = Sys_GetToken( false );
|
||||
if ( !pToken || !pToken[0] )
|
||||
{
|
||||
bSyntaxError = true;
|
||||
break;
|
||||
}
|
||||
Sys_StripQuotesFromToken( pToken );
|
||||
V_FixSlashes( pToken );
|
||||
if ( pToken[0] == CORRECT_PATH_SEPARATOR )
|
||||
{
|
||||
// remove initial slash
|
||||
memcpy( pToken, pToken+1, strlen( pToken ) );
|
||||
}
|
||||
|
||||
char szRootPath[MAX_PATH];
|
||||
V_ComposeFileName( g_targetPath, pToken, szRootPath, sizeof( szRootPath ) );
|
||||
|
||||
if ( bCleanTarget )
|
||||
{
|
||||
// delete any exisiting files at target
|
||||
DM_FILE_ATTRIBUTES fileAttributes;
|
||||
HRESULT hr = DmGetFileAttributes( szRootPath, &fileAttributes );
|
||||
if ( hr == XBDM_NOERR )
|
||||
{
|
||||
// delete all files at valid target
|
||||
V_ComposeFileName( szRootPath, "*.*", szTempFilename, sizeof( szTempFilename ) );
|
||||
char *pArgs[3];
|
||||
pArgs[0] = "*del";
|
||||
pArgs[1] = szTempFilename;
|
||||
pArgs[2] = "/s";
|
||||
if ( !lc_del( 3, pArgs ) )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Failed To Delete Files At '%s'.\n", szRootPath );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char szTargetVersionPath[MAX_PATH];
|
||||
V_ComposeFileName( szRootPath, "version.txt", szTargetVersionPath, sizeof( szTargetVersionPath ) );
|
||||
|
||||
if ( !bForce )
|
||||
{
|
||||
int fileSize;
|
||||
char *pTargetVersionDetailString;
|
||||
if ( !LoadTargetFile( szTargetVersionPath, &fileSize, (void**)&pTargetVersionDetailString ) )
|
||||
{
|
||||
// expected version does not exist
|
||||
// force full install
|
||||
bForce = true;
|
||||
}
|
||||
else if ( strcmp( pVersionDetailString, pTargetVersionDetailString ) != 0 )
|
||||
{
|
||||
// different versions
|
||||
bForce = true;
|
||||
}
|
||||
Sys_Free( pTargetVersionDetailString );
|
||||
}
|
||||
|
||||
if ( bForce && !FileSyncEx( szVersionPath, szTargetVersionPath, FSYNC_ALWAYS, true, false ) )
|
||||
{
|
||||
numFailed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( pToken, "$print" ) )
|
||||
{
|
||||
// print <string>
|
||||
pToken = Sys_GetToken( false );
|
||||
if ( !pToken || !pToken[0] )
|
||||
{
|
||||
bSyntaxError = true;
|
||||
break;
|
||||
}
|
||||
Sys_StripQuotesFromToken( pToken );
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "%s\n", pToken );
|
||||
}
|
||||
else if ( !stricmp( pToken, "$copy" ) )
|
||||
{
|
||||
// copy <source> <target>
|
||||
pToken = Sys_GetToken( false );
|
||||
if ( !pToken || !pToken[0] )
|
||||
{
|
||||
bSyntaxError = true;
|
||||
break;
|
||||
}
|
||||
Sys_StripQuotesFromToken( pToken );
|
||||
V_FixSlashes( pToken );
|
||||
if ( !V_strnicmp( pToken, "DVD\\", 4 ) )
|
||||
{
|
||||
// skip past DVD, used as a placeholder
|
||||
pToken += 4;
|
||||
}
|
||||
V_ComposeFileName( pInstallPath, pToken, arg1, sizeof( arg1 ) );
|
||||
|
||||
pToken = Sys_GetToken( false );
|
||||
if ( !pToken || !pToken[0] )
|
||||
{
|
||||
bSyntaxError = true;
|
||||
break;
|
||||
}
|
||||
Sys_StripQuotesFromToken( pToken );
|
||||
V_FixSlashes( pToken );
|
||||
if ( pToken[0] == CORRECT_PATH_SEPARATOR )
|
||||
{
|
||||
// remove initial slash
|
||||
memcpy( pToken, pToken+1, strlen( pToken ) );
|
||||
}
|
||||
V_ComposeFileName( g_targetPath, pToken, arg2, sizeof( arg2 ) );
|
||||
|
||||
Sys_StripFilename( arg1, sourcePath, sizeof( sourcePath ) );
|
||||
|
||||
h = FindFirstFile( arg1, &findData );
|
||||
if ( h != INVALID_HANDLE_VALUE )
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( pProgress->IsCancel() )
|
||||
{
|
||||
bCancelled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !stricmp( findData.cFileName, "." ) || !stricmp( findData.cFileName, ".." ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
strcpy( sourceFilename, sourcePath );
|
||||
Sys_AddFileSeperator( sourceFilename, sizeof( sourceFilename ) );
|
||||
strcat( sourceFilename, findData.cFileName );
|
||||
Sys_NormalizePath( sourceFilename, false );
|
||||
|
||||
Sys_StripPath( arg2, filename, sizeof( filename ) );
|
||||
if ( filename[0] )
|
||||
{
|
||||
// target filename is specified
|
||||
strcpy( targetFilename, arg2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// target filename is path
|
||||
strcpy( targetFilename, arg2 );
|
||||
Sys_AddFileSeperator( targetFilename, sizeof( targetFilename ) );
|
||||
strcat( targetFilename, findData.cFileName );
|
||||
Sys_NormalizePath( targetFilename, false );
|
||||
}
|
||||
|
||||
ConsoleWindowPrintf( XBX_CLR_DEFAULT, "\nCopying: %s -> %s\n", sourceFilename, targetFilename );
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA localAttributes;
|
||||
float sourceFileSize = 0;
|
||||
if ( GetFileAttributesEx( sourceFilename, GetFileExInfoStandard, &localAttributes ) )
|
||||
{
|
||||
sourceFileSize = (float)localAttributes.nFileSizeLow / (1024.0f * 1024.0f);
|
||||
}
|
||||
|
||||
char statusBuff1[MAX_PATH];
|
||||
V_snprintf( statusBuff1, sizeof( statusBuff1 ), "Copying (%.2f MB) ... Please Wait", sourceFileSize );
|
||||
pProgress->SetStatus( statusBuff1, sourceFilename, targetFilename );
|
||||
|
||||
int fileSyncMode = bForce ? FSYNC_ALWAYS : FSYNC_IFNEWER;
|
||||
errCode = FileSyncEx( sourceFilename, targetFilename, fileSyncMode, true, false );
|
||||
if ( errCode < 0 )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Sync Failure!\n" );
|
||||
numFailed++;
|
||||
}
|
||||
else if ( errCode == 0 )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_BLUE, "Sync Skipped!\n" );
|
||||
numSkipped++;
|
||||
}
|
||||
else if ( errCode == 1 )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_GREEN, "Sync Completed!\n" );
|
||||
numUpdated++;
|
||||
}
|
||||
}
|
||||
while ( FindNextFile( h, &findData ) );
|
||||
|
||||
FindClose( h );
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( pToken, "$end" ) )
|
||||
{
|
||||
bFailed = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Unknown token: '%s' in '%s'\n", pToken, szScriptPath );
|
||||
bSyntaxError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bSyntaxError )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Syntax Error in '%s'.\n", szScriptPath );
|
||||
}
|
||||
|
||||
if ( bCancelled )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Cancelled Installation!\n" );
|
||||
}
|
||||
else if ( bFailed )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "Failed Installation!\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pCRLF = V_stristr( pVersionDetailString, "\r\n" );
|
||||
if ( pCRLF )
|
||||
{
|
||||
*pCRLF = '\0';
|
||||
}
|
||||
|
||||
// spew stats
|
||||
ConsoleWindowPrintf( XBX_CLR_BLACK, "\n" );
|
||||
ConsoleWindowPrintf( XBX_CLR_BLACK, "Installation Completed.\n" );
|
||||
ConsoleWindowPrintf( XBX_CLR_BLACK, "-----------------------\n" );
|
||||
ConsoleWindowPrintf( XBX_CLR_BLACK, "Version: %s\n", pVersionDetailString ? pVersionDetailString : "???" );
|
||||
|
||||
if ( numFailed )
|
||||
{
|
||||
ConsoleWindowPrintf( XBX_CLR_RED, "%d Failures.\n", numFailed );
|
||||
}
|
||||
ConsoleWindowPrintf( XBX_CLR_BLACK, "%d Files In Sync.\n", numSkipped );
|
||||
ConsoleWindowPrintf( XBX_CLR_BLACK, "%d Files Updated.\n", numUpdated );
|
||||
}
|
||||
|
||||
delete pProgress;
|
||||
Sys_Free( pVersionDetailString );
|
||||
Sys_FreeScriptFile();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InstallDlg_GetChanges
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool InstallDlg_GetChanges( HWND hWnd )
|
||||
{
|
||||
g_install_bForceSync = IsDlgButtonChecked( hWnd, IDC_INSTALL_FORCESYNC ) != 0;
|
||||
g_install_bCleanTarget = IsDlgButtonChecked( hWnd, IDC_INSTALL_CLEANTARGET ) != 0;
|
||||
|
||||
g_install_Selection = -1;
|
||||
for ( int i = 0; i < g_install_dvdImages.Count(); i++ )
|
||||
{
|
||||
int state = ListView_GetItemState( GetDlgItem( hWnd, IDC_INSTALL_LIST ), i, LVIS_FOCUSED|LVIS_SELECTED );
|
||||
if ( state == ( LVIS_FOCUSED|LVIS_SELECTED ) )
|
||||
{
|
||||
g_install_Selection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SortDVDImages
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int SortDVDImages( const dvdimage_t *pA, const dvdimage_t *pB )
|
||||
{
|
||||
char szStringA[256];
|
||||
char szStringB[256];
|
||||
|
||||
V_strncpy( szStringA, pA->szString, sizeof( szStringA ) );
|
||||
V_strncpy( szStringB, pB->szString, sizeof( szStringB ) );
|
||||
|
||||
// sort staging first
|
||||
char *pCommentA = V_stristr( szStringA, " (" );
|
||||
char *pCommentB = V_stristr( szStringB, " (" );
|
||||
if ( pCommentA )
|
||||
{
|
||||
*pCommentA = '\0';
|
||||
}
|
||||
if ( pCommentB )
|
||||
{
|
||||
*pCommentB = '\0';
|
||||
}
|
||||
|
||||
return stricmp( szStringB, szStringA );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InstallDlg_Populate
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void InstallDlg_Populate( HWND hWnd )
|
||||
{
|
||||
HWND hWndListView = GetDlgItem( hWnd, IDC_INSTALL_LIST );
|
||||
|
||||
ListView_DeleteAllItems( hWndListView );
|
||||
g_install_dvdImages.Purge();
|
||||
|
||||
// get list of DVD images
|
||||
char szPath[MAX_PATH];
|
||||
V_ComposeFileName( g_installPath, "DVD_*", szPath, sizeof( szPath ) );
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE h = FindFirstFile( szPath, &findData );
|
||||
if ( h != INVALID_HANDLE_VALUE )
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( !stricmp( findData.cFileName, "." ) || !stricmp( findData.cFileName, ".." ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( !( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
|
||||
{
|
||||
// skip files
|
||||
continue;
|
||||
}
|
||||
|
||||
char szInstallPath[MAX_PATH];
|
||||
V_strncpy( szInstallPath, g_installPath, sizeof( szInstallPath ) );
|
||||
V_AppendSlash( szInstallPath, sizeof( szInstallPath ) );
|
||||
V_strncat( szInstallPath, findData.cFileName, sizeof( szInstallPath ) );
|
||||
|
||||
// qualify dvd dirs that are images
|
||||
char szBooterPath[MAX_PATH];
|
||||
V_ComposeFileName( szInstallPath, "default.xex", szBooterPath, sizeof( szBooterPath ) );
|
||||
if ( !Sys_Exists( szBooterPath ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
char szVersionPath[MAX_PATH];
|
||||
V_ComposeFileName( szInstallPath, "version.txt", szVersionPath, sizeof( szVersionPath ) );
|
||||
char *pVersionDetailString = NULL;
|
||||
if ( Sys_LoadFile( szVersionPath, (void**)&pVersionDetailString ) == -1 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
char *pCRLF = V_stristr( pVersionDetailString, "\r\n" );
|
||||
if ( pCRLF )
|
||||
{
|
||||
*pCRLF = '\0';
|
||||
}
|
||||
|
||||
dvdimage_t image;
|
||||
|
||||
int year = 0;
|
||||
int month = 0;
|
||||
int day = 0;
|
||||
int hour = 0;
|
||||
int minute = 0;
|
||||
char timeOfDay[256];
|
||||
sscanf( findData.cFileName, "DVD_%d_%d_%d_%d_%d_%s", &year, &month, &day, &hour, &minute, timeOfDay );
|
||||
|
||||
const char *pInfoString = timeOfDay;
|
||||
if ( !V_strnicmp( timeOfDay, "PM", 2 ) )
|
||||
{
|
||||
if ( hour != 12 )
|
||||
{
|
||||
// 24 hour time for correct sorting
|
||||
hour += 12;
|
||||
}
|
||||
pInfoString += 2;
|
||||
}
|
||||
else if ( !V_strnicmp( timeOfDay, "AM", 2 ) )
|
||||
{
|
||||
if ( hour == 12 )
|
||||
{
|
||||
// 24 hour time for correct sorting
|
||||
hour = 0;
|
||||
}
|
||||
pInfoString += 2;
|
||||
}
|
||||
|
||||
char szCommentBuff[128];
|
||||
if ( pInfoString[0] == '_' )
|
||||
{
|
||||
// optional info after AM/PM
|
||||
pInfoString++;
|
||||
V_snprintf( szCommentBuff, sizeof( szCommentBuff ), " (%s)", pInfoString );
|
||||
}
|
||||
else
|
||||
{
|
||||
szCommentBuff[0] = '\0';
|
||||
}
|
||||
|
||||
V_snprintf( image.szString, sizeof( image.szString ), "%2.2d/%2.2d/%4.4d %2.2d:%2.2d%s", month, day, year, hour, minute, szCommentBuff );
|
||||
|
||||
image.installPath = szInstallPath;
|
||||
image.versionDetailString = pVersionDetailString;
|
||||
g_install_dvdImages.AddToTail( image );
|
||||
Sys_Free( pVersionDetailString );
|
||||
}
|
||||
while ( FindNextFile( h, &findData ) );
|
||||
FindClose( h );
|
||||
}
|
||||
|
||||
// current image will be at head
|
||||
g_install_dvdImages.Sort( SortDVDImages );
|
||||
|
||||
for ( int i = 0; i < g_install_dvdImages.Count(); i++ )
|
||||
{
|
||||
// setup and insert at end of list
|
||||
LVITEM lvi;
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
||||
lvi.iItem = i;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.state = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
lvi.lParam = (LPARAM)i;
|
||||
|
||||
ListView_InsertItem( hWndListView, &lvi );
|
||||
}
|
||||
|
||||
if ( g_install_dvdImages.Count() )
|
||||
{
|
||||
ListView_SetItemState( hWndListView, 0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InstallDlg_Setup
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void InstallDlg_Setup( HWND hWnd )
|
||||
{
|
||||
g_install_Selection = -1;
|
||||
g_install_bForceSync = false;
|
||||
g_install_bCleanTarget = false;
|
||||
|
||||
HWND hWndListView = GetDlgItem( hWnd, IDC_INSTALL_LIST );
|
||||
|
||||
// initialize columns
|
||||
LVCOLUMN lvc;
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.cx = 200;
|
||||
lvc.pszText = ( LPSTR )"Date Built:";
|
||||
ListView_InsertColumn( hWndListView, 0, &lvc );
|
||||
lvc.iSubItem = 0;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.cx = 500;
|
||||
lvc.pszText = ( LPSTR )"Perforce Changelist:";
|
||||
ListView_InsertColumn( hWndListView, 1, &lvc );
|
||||
|
||||
ListView_SetBkColor( hWndListView, g_backgroundColor );
|
||||
ListView_SetTextBkColor( hWndListView, g_backgroundColor );
|
||||
|
||||
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES;
|
||||
ListView_SetExtendedListViewStyleEx( hWndListView, style, style );
|
||||
|
||||
InstallDlg_Populate( hWnd );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InstallDlg_Proc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL CALLBACK InstallDlg_Proc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
InstallDlg_Setup( hWnd );
|
||||
return ( TRUE );
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch ( ( ( LPNMHDR )lParam )->code )
|
||||
{
|
||||
case LVN_GETDISPINFO:
|
||||
NMLVDISPINFO* plvdi;
|
||||
plvdi = (NMLVDISPINFO*)lParam;
|
||||
int item = (int)plvdi->item.lParam;
|
||||
switch ( plvdi->item.iSubItem )
|
||||
{
|
||||
case 0:
|
||||
plvdi->item.pszText = g_install_dvdImages[item].szString;
|
||||
return TRUE;
|
||||
case 1:
|
||||
plvdi->item.pszText = (LPSTR)g_install_dvdImages[item].versionDetailString.String();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( LOWORD( wParam ) )
|
||||
{
|
||||
case IDC_OK:
|
||||
InstallDlg_GetChanges( hWnd );
|
||||
EndDialog( hWnd, wParam );
|
||||
return ( TRUE );
|
||||
|
||||
case IDC_INSTALL_REFRESH:
|
||||
InstallDlg_Populate( hWnd );
|
||||
return TRUE;
|
||||
|
||||
case IDCANCEL:
|
||||
case IDC_CANCEL:
|
||||
EndDialog( hWnd, wParam );
|
||||
return ( TRUE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( FALSE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InstallDlg_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void InstallDlg_Open( void )
|
||||
{
|
||||
int result = DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_INSTALL ), g_hDlgMain, ( DLGPROC )InstallDlg_Proc );
|
||||
if ( LOWORD( result ) == IDC_OK && g_install_Selection != -1 )
|
||||
{
|
||||
InstallDlg_InstallImage(
|
||||
g_install_dvdImages[g_install_Selection].installPath.String(),
|
||||
g_install_bForceSync,
|
||||
g_install_bCleanTarget );
|
||||
}
|
||||
|
||||
g_install_dvdImages.Purge();
|
||||
}
|
||||
292
utils/xbox/vxconsole/sys_scriptlib.cpp
Normal file
292
utils/xbox/vxconsole/sys_scriptlib.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SYS_SCRIPTLIB.CPP
|
||||
//
|
||||
//
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
char g_sys_token[MAXTOKEN];
|
||||
char* g_sys_scriptbuff;
|
||||
char* g_sys_scriptptr;
|
||||
char* g_sys_scriptendptr;
|
||||
int g_sys_scriptsize;
|
||||
int g_sys_scriptline;
|
||||
bool g_sys_endofscript;
|
||||
bool g_sys_tokenready;
|
||||
int g_sys_oldscriptline;
|
||||
char* g_sys_oldscriptptr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_FreeScriptFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_FreeScriptFile(void)
|
||||
{
|
||||
if (g_sys_scriptbuff)
|
||||
{
|
||||
Sys_Free(g_sys_scriptbuff);
|
||||
g_sys_scriptbuff = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_LoadScriptFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_LoadScriptFile(const char* filename)
|
||||
{
|
||||
g_sys_scriptsize = Sys_LoadFile(filename,(void **)&g_sys_scriptbuff);
|
||||
|
||||
Sys_ResetParser();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_SetScriptData
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_SetScriptData(const char* data, int length)
|
||||
{
|
||||
g_sys_scriptbuff = (char *)data;
|
||||
g_sys_scriptsize = length;
|
||||
|
||||
Sys_ResetParser();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_UnGetToken
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_UnGetToken(void)
|
||||
{
|
||||
g_sys_tokenready = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_GetToken
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
char* Sys_GetToken(bool crossline)
|
||||
{
|
||||
char* tokenptr;
|
||||
|
||||
if (g_sys_tokenready)
|
||||
{
|
||||
g_sys_tokenready = false;
|
||||
return (g_sys_token);
|
||||
}
|
||||
|
||||
g_sys_token[0] = '\0';
|
||||
|
||||
if (g_sys_scriptptr >= g_sys_scriptendptr)
|
||||
{
|
||||
g_sys_endofscript = true;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
skipspace:
|
||||
while (*g_sys_scriptptr <= ' ')
|
||||
{
|
||||
if (g_sys_scriptptr >= g_sys_scriptendptr)
|
||||
{
|
||||
g_sys_endofscript = true;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (*g_sys_scriptptr++ == '\n')
|
||||
{
|
||||
if (!crossline)
|
||||
{
|
||||
// unexpected newline at g_sys_scriptline
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
g_sys_scriptline++;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_sys_scriptptr >= g_sys_scriptendptr)
|
||||
{
|
||||
g_sys_endofscript = true;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
// skip commented line
|
||||
if ((g_sys_scriptptr[0] == ';') || (g_sys_scriptptr[0] == '/' && g_sys_scriptptr[1] == '/'))
|
||||
{
|
||||
if (!crossline)
|
||||
{
|
||||
// unexpected newline at g_sys_scriptline
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
while (*g_sys_scriptptr++ != '\n')
|
||||
{
|
||||
if (g_sys_scriptptr >= g_sys_scriptendptr)
|
||||
{
|
||||
g_sys_endofscript = true;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
g_sys_scriptline++;
|
||||
goto skipspace;
|
||||
}
|
||||
|
||||
tokenptr = g_sys_token;
|
||||
if (g_sys_scriptptr[0] == '\"' && g_sys_scriptptr[1])
|
||||
{
|
||||
// copy quoted token
|
||||
do
|
||||
{
|
||||
*tokenptr++ = *g_sys_scriptptr++;
|
||||
if (g_sys_scriptptr == g_sys_scriptendptr)
|
||||
break;
|
||||
|
||||
if (tokenptr == &g_sys_token[MAXTOKEN])
|
||||
{
|
||||
// token too large
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
while (*g_sys_scriptptr >= ' ' && *g_sys_scriptptr != '\"');
|
||||
|
||||
if (g_sys_scriptptr[0] == '\"')
|
||||
*tokenptr++ = *g_sys_scriptptr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy token
|
||||
while (*g_sys_scriptptr > ' ' && *g_sys_scriptptr != ';' && *g_sys_scriptptr != '\"')
|
||||
{
|
||||
*tokenptr++ = *g_sys_scriptptr++;
|
||||
if (g_sys_scriptptr == g_sys_scriptendptr)
|
||||
break;
|
||||
|
||||
if (tokenptr == &g_sys_token[MAXTOKEN])
|
||||
{
|
||||
// token too large
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*tokenptr = '\0';
|
||||
|
||||
return (g_sys_token);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_SkipRestOfLine
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_SkipRestOfLine(void)
|
||||
{
|
||||
while (*g_sys_scriptptr++ != '\n')
|
||||
{
|
||||
if (g_sys_scriptptr >= g_sys_scriptendptr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_sys_scriptline++;
|
||||
|
||||
// flush any queued token
|
||||
g_sys_tokenready = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_TokenAvailable
|
||||
//
|
||||
// Returns (TRUE) if token available on line.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Sys_TokenAvailable (void)
|
||||
{
|
||||
char* ptr;
|
||||
|
||||
ptr = g_sys_scriptptr;
|
||||
while (*ptr <= ' ')
|
||||
{
|
||||
if (ptr >= g_sys_scriptendptr)
|
||||
{
|
||||
g_sys_endofscript = true;
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (*ptr++ == '\n')
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_EndOfScript
|
||||
//
|
||||
// Returns (TRUE) at end of script
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Sys_EndOfScript(void)
|
||||
{
|
||||
if (g_sys_scriptptr >= g_sys_scriptendptr)
|
||||
{
|
||||
g_sys_endofscript = true;
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_ResetParser
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_ResetParser(void)
|
||||
{
|
||||
g_sys_scriptptr = g_sys_scriptbuff;
|
||||
g_sys_scriptendptr = g_sys_scriptptr + g_sys_scriptsize;
|
||||
g_sys_scriptline = 1;
|
||||
g_sys_endofscript = false;
|
||||
g_sys_tokenready = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_SaveParser
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_SaveParser(void)
|
||||
{
|
||||
g_sys_oldscriptline = g_sys_scriptline;
|
||||
g_sys_oldscriptptr = g_sys_scriptptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_RestoreParser
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_RestoreParser(void)
|
||||
{
|
||||
g_sys_scriptline = g_sys_oldscriptline;
|
||||
g_sys_scriptptr = g_sys_oldscriptptr;
|
||||
g_sys_tokenready = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sys_StripQuotesFromToken
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void Sys_StripQuotesFromToken( char *pToken )
|
||||
{
|
||||
int len;
|
||||
|
||||
len = strlen( pToken );
|
||||
if ( len >= 2 && pToken[0] == '\"' )
|
||||
{
|
||||
memcpy( pToken, pToken+1, len-1 );
|
||||
pToken[len-2] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
34
utils/xbox/vxconsole/sys_scriptlib.h
Normal file
34
utils/xbox/vxconsole/sys_scriptlib.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SYS_SCRIPTLIB.H
|
||||
//
|
||||
// System Utilities.
|
||||
//=====================================================================================//
|
||||
#pragma once
|
||||
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define MAXTOKEN 128
|
||||
|
||||
extern void Sys_LoadScriptFile(const char* filename);
|
||||
extern void Sys_SetScriptData(const char* data, int length);
|
||||
extern void Sys_FreeScriptFile(void);
|
||||
extern char* Sys_GetToken(bool crossline);
|
||||
extern char* Sys_GetQuotedToken(bool crossline);
|
||||
extern void Sys_UnGetToken(void);
|
||||
extern bool Sys_TokenAvailable(void);
|
||||
extern void Sys_SaveParser(void);
|
||||
extern void Sys_RestoreParser(void);
|
||||
extern void Sys_ResetParser(void);
|
||||
extern void Sys_SkipRestOfLine(void);
|
||||
extern bool Sys_EndOfScript(void);
|
||||
extern char* Sys_GetRawToken(void);
|
||||
extern void Sys_StripQuotesFromToken( char *pToken );
|
||||
|
||||
extern char g_sys_token[MAXTOKEN];
|
||||
extern char* g_sys_scriptbuffer;
|
||||
extern char* g_sys_scriptptr;
|
||||
extern char* g_sys_scriptendptr;
|
||||
extern int g_sys_scriptsize;
|
||||
extern int g_sys_scriptline;
|
||||
extern bool g_sys_endofscript;
|
||||
1090
utils/xbox/vxconsole/sys_utils.cpp
Normal file
1090
utils/xbox/vxconsole/sys_utils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
65
utils/xbox/vxconsole/sys_utils.h
Normal file
65
utils/xbox/vxconsole/sys_utils.h
Normal file
@@ -0,0 +1,65 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// SYS_UTILS.H
|
||||
//
|
||||
// System Utilities.
|
||||
//=====================================================================================//
|
||||
#pragma once
|
||||
|
||||
#include "vxconsole.h"
|
||||
|
||||
#pragma warning(disable : 4100) // warning C4100: unreferenced formal parameter
|
||||
|
||||
#define MAX_SYSPRINTMSG 1024
|
||||
#define MAX_SYSTOKENCHARS 1024
|
||||
|
||||
#define MAKEINT64( hiword, loword ) ( ( __int64 )( ( ( ( __int64 )( hiword ) ) << 32 ) | ( __int64 )( loword ) ) )
|
||||
|
||||
extern void Sys_MessageBox( const CHAR *title, const CHAR *format, ... );
|
||||
extern void Sys_Error( const CHAR *format, ... );
|
||||
|
||||
extern void *Sys_Alloc( int size );
|
||||
extern void Sys_Free( void *ptr );
|
||||
extern CHAR *Sys_CopyString( const CHAR *str );
|
||||
|
||||
extern int Sys_LoadFile( const CHAR *filename, void **bufferptr, bool bText = false );
|
||||
extern bool Sys_SaveFile( const CHAR *filename, void *buffer, long count, bool bText = false );
|
||||
extern long Sys_FileLength( const CHAR *filename, bool bText = false );
|
||||
extern long Sys_FileLength( int handle );
|
||||
extern BOOL Sys_FileTime( CHAR *filename, FILETIME *time );
|
||||
extern void Sys_CreatePath( const char* pInPath );
|
||||
|
||||
extern void Sys_AddFileSeperator( CHAR *path, int outPathLen );
|
||||
extern void Sys_NormalizePath( CHAR *path, bool forceToLower );
|
||||
extern void Sys_StripFilename( const CHAR *path, CHAR *outpath, int outPathLen );
|
||||
extern void Sys_StripExtension( const CHAR *path, CHAR *outpath, int outPathLen );
|
||||
extern void Sys_StripPath( const CHAR *path, CHAR *outpath, int outPathLen );
|
||||
extern void Sys_GetExtension( const CHAR *path, CHAR *outpath, int outPathLen );
|
||||
extern void Sys_AddExtension( const CHAR *extension, CHAR *outpath, int outPathLen );
|
||||
extern void Sys_TempFilename( CHAR *outpath, int outPathLen );
|
||||
extern BOOL Sys_Exists( const CHAR *filename );
|
||||
|
||||
extern CHAR *Sys_GetToken( CHAR **dataptr, BOOL crossline, int *numlines );
|
||||
extern CHAR *Sys_SkipWhitespace( CHAR *data, BOOL *hasNewLines, int *numlines );
|
||||
extern void Sys_SkipBracedSection( CHAR **dataptr, int *numlines );
|
||||
extern void Sys_SkipRestOfLine( CHAR **dataptr, int *numlines );
|
||||
|
||||
extern void Sys_SetRegistryPrefix( const CHAR *pPrefix );
|
||||
extern BOOL Sys_SetRegistryString( const CHAR *key, const CHAR *value );
|
||||
extern BOOL Sys_GetRegistryString( const CHAR *key, CHAR *value, const CHAR *defValue, int valueLen );
|
||||
extern BOOL Sys_SetRegistryInteger( const CHAR *key, int value );
|
||||
extern BOOL Sys_GetRegistryInteger( const CHAR *key, int defValue, int &value );
|
||||
|
||||
extern DWORD Sys_GetSystemTime( void );
|
||||
extern COLORREF Sys_ColorScale( COLORREF color, float scale );
|
||||
extern bool Sys_IsWildcardMatch( const CHAR *wildcardString, const CHAR *stringToCheck, bool caseSensitive );
|
||||
extern char *Sys_NumberToCommaString( __int64 number, char *buffer, int bufferSize );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
993
utils/xbox/vxconsole/tex_profile.cpp
Normal file
993
utils/xbox/vxconsole/tex_profile.cpp
Normal file
@@ -0,0 +1,993 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// TEX_PROFILE.CPP
|
||||
//
|
||||
// Texture Profiling Display.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define TEXPROFILE_MAXCOUNTERS 64
|
||||
#define TEXPROFILE_MAXSAMPLES 512
|
||||
|
||||
#define TEXPROFILE_MAJORTICKSIZE 4
|
||||
#define TEXPROFILE_MAJORTICKBYTES ( TEXPROFILE_MAJORTICKSIZE*1024.0f*1024.0f )
|
||||
|
||||
#define TEXPROFILE_HISTORY_MAJORTICKHEIGHT 100
|
||||
#define TEXPROFILE_HISTORY_NUMMINORTICKS 3
|
||||
#define TEXPROFILE_HISTORY_LABELWIDTH 50
|
||||
#define TEXPROFILE_HISTORY_SCALESTEPS 5
|
||||
#define TEXPROFILE_HISTORY_MINSCALE 0.3f
|
||||
#define TEXPROFILE_HISTORY_MAXSCALE 3.0f
|
||||
|
||||
#define TEXPROFILE_SAMPLES_ITEMHEIGHT 15
|
||||
#define TEXPROFILE_SAMPLES_BARHEIGHT 10
|
||||
#define TEXPROFILE_SAMPLES_MAJORTICKWIDTH 200
|
||||
#define TEXPROFILE_SAMPLES_LABELWIDTH 150
|
||||
#define TEXPROFILE_SAMPLES_LABELGAP 5
|
||||
#define TEXPROFILE_SAMPLES_NUMMINORTICKS 3
|
||||
#define TEXPROFILE_SAMPLES_PEAKHOLDTIME 3000
|
||||
#define TEXPROFILE_SAMPLES_SCALESTEPS 10
|
||||
#define TEXPROFILE_SAMPLES_MINSCALE 0.3f
|
||||
#define TEXPROFILE_SAMPLES_MAXSCALE 3.0f
|
||||
|
||||
#define ID_TEXPROFILE_SAMPLES 1
|
||||
#define ID_TEXPROFILE_HISTORY 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int samples[TEXPROFILE_MAXSAMPLES];
|
||||
unsigned int peakSample;
|
||||
char label[64];
|
||||
COLORREF color;
|
||||
} profileCounter_t;
|
||||
|
||||
HWND g_texProfile_hWndSamples;
|
||||
HWND g_texProfile_hWndHistory;
|
||||
int g_texProfile_numCounters;
|
||||
profileCounter_t g_texProfile_counters[TEXPROFILE_MAXCOUNTERS];
|
||||
RECT g_texProfile_samplesWindowRect;
|
||||
RECT g_texProfile_historyWindowRect;
|
||||
DWORD g_texProfile_lastPeakTime;
|
||||
bool g_texProfile_history_tickMarks = true;
|
||||
bool g_texProfile_history_colors = true;
|
||||
int g_texProfile_history_scale;
|
||||
bool g_texProfile_samples_tickMarks = true;
|
||||
bool g_texProfile_samples_colors = true;
|
||||
int g_texProfile_samples_scale;
|
||||
int g_texProfile_numSamples;
|
||||
int g_texProfile_currentFrame;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
// profile samples
|
||||
Sys_GetRegistryString( "texProfileSamplesWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_texProfile_samplesWindowRect.left, &g_texProfile_samplesWindowRect.top, &g_texProfile_samplesWindowRect.right, &g_texProfile_samplesWindowRect.bottom );
|
||||
if ( numArgs != 4 || g_texProfile_samplesWindowRect.left < 0 || g_texProfile_samplesWindowRect.top < 0 || g_texProfile_samplesWindowRect.right < 0 || g_texProfile_samplesWindowRect.bottom < 0 )
|
||||
memset( &g_texProfile_samplesWindowRect, 0, sizeof( g_texProfile_samplesWindowRect ) );
|
||||
Sys_GetRegistryInteger( "texProfileSamplesScale", 0, g_texProfile_samples_scale );
|
||||
if ( g_texProfile_samples_scale < -TEXPROFILE_SAMPLES_SCALESTEPS || g_texProfile_samples_scale > TEXPROFILE_SAMPLES_SCALESTEPS )
|
||||
g_texProfile_samples_scale = 0;
|
||||
|
||||
// profile history
|
||||
Sys_GetRegistryString( "texProfileHistoryWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_texProfile_historyWindowRect.left, &g_texProfile_historyWindowRect.top, &g_texProfile_historyWindowRect.right, &g_texProfile_historyWindowRect.bottom );
|
||||
if ( numArgs != 4 || g_texProfile_historyWindowRect.left < 0 || g_texProfile_historyWindowRect.top < 0 || g_texProfile_historyWindowRect.right < 0 || g_texProfile_historyWindowRect.bottom < 0 )
|
||||
memset( &g_texProfile_historyWindowRect, 0, sizeof( g_texProfile_historyWindowRect ) );
|
||||
Sys_GetRegistryInteger( "texProfileHistoryScale", 0, g_texProfile_history_scale );
|
||||
if ( g_texProfile_history_scale < -TEXPROFILE_HISTORY_SCALESTEPS || g_texProfile_history_scale > TEXPROFILE_HISTORY_SCALESTEPS )
|
||||
g_texProfile_history_scale = 0;
|
||||
|
||||
Sys_GetRegistryInteger( "texProfileCurrentFrame", 0, g_texProfile_currentFrame );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
WINDOWPLACEMENT wp;
|
||||
|
||||
// profile samples
|
||||
if ( g_texProfile_hWndSamples )
|
||||
{
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_texProfile_hWndSamples, &wp );
|
||||
g_texProfile_samplesWindowRect = wp.rcNormalPosition;
|
||||
sprintf( buff, "%d %d %d %d", wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom );
|
||||
Sys_SetRegistryString( "texProfileSamplesWindowRect", buff );
|
||||
}
|
||||
Sys_SetRegistryInteger( "texProfileSamplesScale", g_texProfile_samples_scale );
|
||||
|
||||
// profile history
|
||||
if ( g_texProfile_hWndHistory )
|
||||
{
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_texProfile_hWndHistory, &wp );
|
||||
g_texProfile_historyWindowRect = wp.rcNormalPosition;
|
||||
sprintf( buff, "%d %d %d %d", wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom );
|
||||
Sys_SetRegistryString( "texProfileHistoryWindowRect", buff );
|
||||
}
|
||||
Sys_SetRegistryInteger( "texProfileHistoryScale", g_texProfile_history_scale );
|
||||
|
||||
Sys_SetRegistryInteger( "texProfileCurrentFrame", g_texProfile_currentFrame );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_SetTitle
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_SetTitle()
|
||||
{
|
||||
char titleBuff[128];
|
||||
|
||||
if ( g_texProfile_hWndSamples )
|
||||
{
|
||||
strcpy( titleBuff, "D3D Usage Snapshot" );
|
||||
if ( VProf_GetState() == VPROF_TEXTURE || VProf_GetState() == VPROF_TEXTUREFRAME )
|
||||
strcat( titleBuff, " [ON]" );
|
||||
if ( g_texProfile_currentFrame )
|
||||
strcat( titleBuff, " [FRAME]" );
|
||||
|
||||
SetWindowText( g_texProfile_hWndSamples, titleBuff );
|
||||
}
|
||||
|
||||
if ( g_texProfile_hWndHistory )
|
||||
{
|
||||
strcpy( titleBuff, "D3D Usage History" );
|
||||
if ( VProf_GetState() == VPROF_TEXTURE || VProf_GetState() == VPROF_TEXTUREFRAME )
|
||||
strcat( titleBuff, " [ON]" );
|
||||
if ( g_texProfile_currentFrame )
|
||||
strcat( titleBuff, " [FRAME]" );
|
||||
|
||||
SetWindowText( g_texProfile_hWndHistory, titleBuff );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_UpdateWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_UpdateWindow()
|
||||
{
|
||||
if ( g_texProfile_hWndSamples && !IsIconic( g_texProfile_hWndSamples ) )
|
||||
{
|
||||
// visible - force a client repaint
|
||||
InvalidateRect( g_texProfile_hWndSamples, NULL, true );
|
||||
}
|
||||
|
||||
if ( g_texProfile_hWndHistory && !IsIconic( g_texProfile_hWndHistory ) )
|
||||
{
|
||||
// visible - force a client repaint
|
||||
InvalidateRect( g_texProfile_hWndHistory, NULL, true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_SetTexProfile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_SetTexProfile( char* commandPtr )
|
||||
{
|
||||
int i;
|
||||
char* cmdToken;
|
||||
int retAddr;
|
||||
int retVal;
|
||||
int errCode = -1;
|
||||
xrProfile_t* localList;
|
||||
int profileList;
|
||||
int numProfiles;
|
||||
|
||||
// get numProfiles
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken,"%x",&numProfiles );
|
||||
|
||||
// get profile attributes
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &profileList );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken,"%x",&retAddr );
|
||||
|
||||
localList = new xrProfile_t[numProfiles];
|
||||
memset( localList, 0, numProfiles*sizeof( xrProfile_t ) );
|
||||
|
||||
// get the caller's profile list
|
||||
DmGetMemory( ( void* )profileList, numProfiles*sizeof( xrProfile_t ), localList, NULL );
|
||||
|
||||
g_texProfile_numCounters = numProfiles;
|
||||
if ( g_texProfile_numCounters > TEXPROFILE_MAXCOUNTERS-1 )
|
||||
g_texProfile_numCounters = TEXPROFILE_MAXCOUNTERS-1;
|
||||
|
||||
for ( i=0; i<g_texProfile_numCounters; i++ )
|
||||
{
|
||||
// swap the structure
|
||||
localList[i].color = BigDWord( localList[i].color );
|
||||
|
||||
// clear the old counter
|
||||
memset( &g_texProfile_counters[i], 0, sizeof( profileCounter_t ) );
|
||||
|
||||
V_strncpy( g_texProfile_counters[i].label, localList[i].labelString, sizeof( g_texProfile_counters[i].label ) );
|
||||
g_texProfile_counters[i].color = localList[i].color;
|
||||
}
|
||||
|
||||
// build out the reserved last counter as total count
|
||||
memset( &g_texProfile_counters[g_texProfile_numCounters], 0, sizeof( profileCounter_t ) );
|
||||
strcpy( g_texProfile_counters[g_texProfile_numCounters].label, "Total" );
|
||||
g_texProfile_counters[i].color = RGB( 255,255,255 );
|
||||
g_texProfile_numCounters++;
|
||||
|
||||
// set the return code
|
||||
retVal = g_texProfile_numCounters-1;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = SetTexProfile( 0x%8.8x, 0x%8.8x )\n", retVal, numProfiles, profileList );
|
||||
|
||||
delete [] localList;
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_SetTexProfileData
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_SetTexProfileData( char* commandPtr )
|
||||
{
|
||||
int i;
|
||||
char* cmdToken;
|
||||
int errCode = -1;
|
||||
int counters;
|
||||
int currentSample;
|
||||
int total;
|
||||
bool newPeaks;
|
||||
unsigned int localCounters[TEXPROFILE_MAXCOUNTERS];
|
||||
DWORD newTime;
|
||||
|
||||
// get profiles
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &counters );
|
||||
|
||||
// get the caller's profile list
|
||||
if ( g_texProfile_numCounters )
|
||||
DmGetMemory( ( void* )counters, ( g_texProfile_numCounters-1 )*sizeof( int ), localCounters, NULL );
|
||||
|
||||
// timeout peaks
|
||||
newTime = Sys_GetSystemTime();
|
||||
if ( newTime - g_texProfile_lastPeakTime > TEXPROFILE_SAMPLES_PEAKHOLDTIME )
|
||||
{
|
||||
g_texProfile_lastPeakTime = newTime;
|
||||
newPeaks = true;
|
||||
}
|
||||
else
|
||||
newPeaks = false;
|
||||
|
||||
// next sample
|
||||
currentSample = g_texProfile_numSamples % TEXPROFILE_MAXSAMPLES;
|
||||
g_texProfile_numSamples++;
|
||||
|
||||
total = 0;
|
||||
for ( i=0; i<g_texProfile_numCounters; i++ )
|
||||
{
|
||||
if ( i != g_texProfile_numCounters-1 )
|
||||
{
|
||||
g_texProfile_counters[i].samples[currentSample] = localCounters[i];
|
||||
total += localCounters[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// reserved total counter
|
||||
g_texProfile_counters[i].samples[currentSample] = total;
|
||||
}
|
||||
|
||||
if ( newPeaks || g_texProfile_counters[i].peakSample < g_texProfile_counters[i].samples[currentSample] )
|
||||
g_texProfile_counters[i].peakSample = g_texProfile_counters[i].samples[currentSample];
|
||||
}
|
||||
|
||||
DebugCommand( "SetTexProfileData( 0x%8.8x )\n", counters );
|
||||
|
||||
TexProfile_UpdateWindow();
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_ZoomIn
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_ZoomIn( int& scale, int numSteps )
|
||||
{
|
||||
scale++;
|
||||
if ( scale > numSteps )
|
||||
{
|
||||
scale = numSteps;
|
||||
return;
|
||||
}
|
||||
TexProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_ZoomOut
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_ZoomOut( int& scale, int numSteps )
|
||||
{
|
||||
scale--;
|
||||
if ( scale < -numSteps )
|
||||
{
|
||||
scale = -numSteps;
|
||||
return;
|
||||
}
|
||||
TexProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_CalcScale
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
float TexProfile_CalcScale( int scale, int numSteps, float min, float max )
|
||||
{
|
||||
float t;
|
||||
|
||||
// from integral scale [-numSteps..numSteps] to float scale [min..max]
|
||||
t = ( float )( scale + numSteps )/( float )( 2*numSteps );
|
||||
t = min + t*( max-min );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfileSamples_Draw
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfileSamples_Draw( HDC hdc, RECT* clientRect )
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int x;
|
||||
int y;
|
||||
int x0;
|
||||
int y0;
|
||||
int w;
|
||||
float t;
|
||||
float scale;
|
||||
float sample;
|
||||
char labelBuff[128];
|
||||
HPEN hBlackPen;
|
||||
HPEN hPenOld;
|
||||
HPEN hGreyPen;
|
||||
HBRUSH hColoredBrush;
|
||||
HBRUSH hbrushOld;
|
||||
HFONT hFontOld;
|
||||
RECT rect;
|
||||
int currentSample;
|
||||
int numTicks;
|
||||
int tickWidth;
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
|
||||
hBlackPen = CreatePen( PS_SOLID, 1, RGB( 0,0,0 ) );
|
||||
hGreyPen = CreatePen( PS_SOLID, 1, Sys_ColorScale( g_backgroundColor, 0.85f ) );
|
||||
hPenOld = ( HPEN )SelectObject( hdc, hBlackPen );
|
||||
hFontOld = SelectFont( hdc, g_hProportionalFont );
|
||||
|
||||
SetBkColor( hdc, g_backgroundColor );
|
||||
|
||||
// zoom
|
||||
scale = TexProfile_CalcScale( g_texProfile_samples_scale, TEXPROFILE_SAMPLES_SCALESTEPS, TEXPROFILE_SAMPLES_MINSCALE, TEXPROFILE_SAMPLES_MAXSCALE );
|
||||
tickWidth = ( int )( TEXPROFILE_SAMPLES_MAJORTICKWIDTH*scale );
|
||||
windowWidth = clientRect->right-clientRect->left;
|
||||
windowHeight = clientRect->bottom-clientRect->top;
|
||||
|
||||
numTicks = ( windowWidth-TEXPROFILE_SAMPLES_LABELWIDTH )/tickWidth + 1;
|
||||
if ( numTicks < 0 )
|
||||
numTicks = 1;
|
||||
|
||||
rect.left = 0;
|
||||
rect.right = TEXPROFILE_SAMPLES_LABELWIDTH;
|
||||
rect.top = 0;
|
||||
rect.bottom = TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
DrawText( hdc, "Name", -1, &rect, DT_LEFT );
|
||||
|
||||
// draw size ticks
|
||||
x = TEXPROFILE_SAMPLES_LABELWIDTH;
|
||||
y = 0;
|
||||
for ( i=0; i<numTicks; i++ )
|
||||
{
|
||||
// tick labels
|
||||
rect.left = x-40;
|
||||
rect.right = x+40;
|
||||
rect.top = y;
|
||||
rect.bottom = y+TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
sprintf( labelBuff, "%dMB", i*TEXPROFILE_MAJORTICKSIZE );
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_CENTER );
|
||||
|
||||
// major ticks
|
||||
x0 = x;
|
||||
y0 = y + TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, x0, y0, NULL );
|
||||
LineTo( hdc, x0, y0+windowHeight );
|
||||
|
||||
if ( g_texProfile_samples_tickMarks && g_texProfile_samples_scale > -TEXPROFILE_SAMPLES_SCALESTEPS )
|
||||
{
|
||||
// minor ticks
|
||||
x0 = x;
|
||||
y0 = y + TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
SelectObject( hdc, hGreyPen );
|
||||
for ( j=0; j<TEXPROFILE_SAMPLES_NUMMINORTICKS; j++ )
|
||||
{
|
||||
x0 += tickWidth/( TEXPROFILE_SAMPLES_NUMMINORTICKS+1 );
|
||||
|
||||
MoveToEx( hdc, x0, y0, NULL );
|
||||
LineTo( hdc, x0, y0+windowHeight );
|
||||
}
|
||||
}
|
||||
x += tickWidth;
|
||||
}
|
||||
|
||||
// seperator
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, 0, TEXPROFILE_SAMPLES_ITEMHEIGHT, NULL );
|
||||
LineTo( hdc, windowWidth, TEXPROFILE_SAMPLES_ITEMHEIGHT );
|
||||
|
||||
// draw labels
|
||||
x = 0;
|
||||
y = TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
for ( i=0; i<g_texProfile_numCounters; i++ )
|
||||
{
|
||||
if ( !g_texProfile_counters[i].label )
|
||||
continue;
|
||||
|
||||
rect.left = x;
|
||||
rect.right = x+TEXPROFILE_SAMPLES_LABELWIDTH-TEXPROFILE_SAMPLES_LABELGAP;
|
||||
rect.top = y;
|
||||
rect.bottom = y+TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
DrawText( hdc, g_texProfile_counters[i].label, -1, &rect, DT_VCENTER|DT_RIGHT|DT_SINGLELINE|DT_END_ELLIPSIS|DT_MODIFYSTRING );
|
||||
|
||||
// draw the under line
|
||||
MoveToEx( hdc, x, y+TEXPROFILE_SAMPLES_ITEMHEIGHT, NULL );
|
||||
LineTo( hdc, x+TEXPROFILE_SAMPLES_LABELWIDTH, y+TEXPROFILE_SAMPLES_ITEMHEIGHT );
|
||||
|
||||
y += TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
}
|
||||
|
||||
// draw bars
|
||||
SelectObject( hdc, hBlackPen );
|
||||
x = TEXPROFILE_SAMPLES_LABELWIDTH;
|
||||
y = TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
currentSample = g_texProfile_numSamples-1;
|
||||
if ( currentSample < 0 )
|
||||
currentSample = 0;
|
||||
else
|
||||
currentSample %= TEXPROFILE_MAXSAMPLES;
|
||||
for ( i=0; i<g_texProfile_numCounters; i++ )
|
||||
{
|
||||
if ( !g_texProfile_counters[i].label )
|
||||
continue;
|
||||
|
||||
hColoredBrush = CreateSolidBrush( g_texProfile_samples_colors ? g_texProfile_counters[i].color : g_backgroundColor );
|
||||
hbrushOld = ( HBRUSH )SelectObject( hdc, hColoredBrush );
|
||||
|
||||
// bar - count is in bytes, scale to major tick
|
||||
t = ( float )g_texProfile_counters[i].samples[currentSample]/TEXPROFILE_MAJORTICKBYTES;
|
||||
w = ( int )( t * ( float )tickWidth );
|
||||
if ( w > windowWidth )
|
||||
w = windowWidth;
|
||||
x0 = x;
|
||||
y0 = y + ( TEXPROFILE_SAMPLES_ITEMHEIGHT-TEXPROFILE_SAMPLES_BARHEIGHT )/2 + 1;
|
||||
Rectangle( hdc, x0, y0, x0 + w, y0 + TEXPROFILE_SAMPLES_BARHEIGHT );
|
||||
|
||||
// peak
|
||||
t = ( float )g_texProfile_counters[i].peakSample/TEXPROFILE_MAJORTICKBYTES;
|
||||
w = ( int )( t * ( float )tickWidth );
|
||||
if ( w > windowWidth )
|
||||
w = windowWidth;
|
||||
x0 = x + w;
|
||||
y0 = y + TEXPROFILE_SAMPLES_ITEMHEIGHT/2 + 1;
|
||||
|
||||
POINT points[4];
|
||||
points[0].x = x0;
|
||||
points[0].y = y0-4;
|
||||
points[1].x = x0+4;
|
||||
points[1].y = y0;
|
||||
points[2].x = x0;
|
||||
points[2].y = y0+4;
|
||||
points[3].x = x0-4;
|
||||
points[3].y = y0;
|
||||
Polygon( hdc, points, 4 );
|
||||
|
||||
SelectObject( hdc, hbrushOld );
|
||||
DeleteObject( hColoredBrush );
|
||||
|
||||
// draw peak sizes
|
||||
sample = ( float )g_texProfile_counters[i].peakSample/1024.0f;
|
||||
if ( sample >= 0.01F )
|
||||
{
|
||||
sprintf( labelBuff, "%.2f MB", sample/1024.0f );
|
||||
rect.left = x0 + 8;
|
||||
rect.right = x0 + 8 + 100;
|
||||
rect.top = y;
|
||||
rect.bottom = y + TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_VCENTER|DT_LEFT|DT_SINGLELINE );
|
||||
}
|
||||
|
||||
y += TEXPROFILE_SAMPLES_ITEMHEIGHT;
|
||||
}
|
||||
|
||||
SelectObject( hdc, hFontOld );
|
||||
SelectObject( hdc, hPenOld );
|
||||
DeleteObject( hBlackPen );
|
||||
DeleteObject( hGreyPen );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfileHistory_Draw
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfileHistory_Draw( HDC hdc, RECT* clientRect )
|
||||
{
|
||||
char labelBuff[128];
|
||||
HPEN hBlackPen;
|
||||
HPEN hPenOld;
|
||||
HPEN hNullPen;
|
||||
HPEN hGreyPen;
|
||||
HBRUSH hColoredBrush;
|
||||
HBRUSH hBrushOld;
|
||||
HFONT hFontOld;
|
||||
int currentSample;
|
||||
int numTicks;
|
||||
int tickHeight;
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
int x;
|
||||
int y;
|
||||
int y0;
|
||||
int i;
|
||||
int j;
|
||||
int h;
|
||||
int numbars;
|
||||
RECT rect;
|
||||
float t;
|
||||
float scale;
|
||||
|
||||
hBlackPen = CreatePen( PS_SOLID, 1, RGB( 0,0,0 ) );
|
||||
hGreyPen = CreatePen( PS_SOLID, 1, Sys_ColorScale( g_backgroundColor, 0.85f ) );
|
||||
hNullPen = CreatePen( PS_NULL, 0, RGB( 0,0,0 ) );
|
||||
hPenOld = ( HPEN )SelectObject( hdc, hBlackPen );
|
||||
hFontOld = SelectFont( hdc, g_hProportionalFont );
|
||||
|
||||
// zoom
|
||||
scale = TexProfile_CalcScale( g_texProfile_history_scale, TEXPROFILE_HISTORY_SCALESTEPS, TEXPROFILE_HISTORY_MINSCALE, TEXPROFILE_HISTORY_MAXSCALE );
|
||||
tickHeight = ( int )( TEXPROFILE_HISTORY_MAJORTICKHEIGHT*scale );
|
||||
windowWidth = clientRect->right-clientRect->left;
|
||||
windowHeight = clientRect->bottom-clientRect->top;
|
||||
|
||||
numTicks = windowHeight/tickHeight + 2;
|
||||
if ( numTicks < 0 )
|
||||
numTicks = 1;
|
||||
|
||||
SetBkColor( hdc, g_backgroundColor );
|
||||
|
||||
x = 0;
|
||||
y = windowHeight;
|
||||
for ( i=0; i<numTicks; i++ )
|
||||
{
|
||||
// major ticks
|
||||
SelectObject( hdc, hBlackPen );
|
||||
MoveToEx( hdc, 0, y, NULL );
|
||||
LineTo( hdc, windowWidth, y );
|
||||
|
||||
if ( g_texProfile_history_tickMarks && g_texProfile_history_scale > -TEXPROFILE_HISTORY_SCALESTEPS )
|
||||
{
|
||||
// minor ticks
|
||||
y0 = y;
|
||||
SelectObject( hdc, hGreyPen );
|
||||
for ( j=0; j<TEXPROFILE_HISTORY_NUMMINORTICKS; j++ )
|
||||
{
|
||||
y0 += tickHeight/( TEXPROFILE_SAMPLES_NUMMINORTICKS+1 );
|
||||
MoveToEx( hdc, 0, y0, NULL );
|
||||
LineTo( hdc, windowWidth, y0 );
|
||||
}
|
||||
}
|
||||
|
||||
// tick labels
|
||||
if ( i )
|
||||
{
|
||||
rect.left = windowWidth-50;
|
||||
rect.right = windowWidth;
|
||||
rect.top = y-20;
|
||||
rect.bottom = y;
|
||||
sprintf( labelBuff, "%dMB", i*TEXPROFILE_MAJORTICKSIZE );
|
||||
DrawText( hdc, labelBuff, -1, &rect, DT_RIGHT|DT_SINGLELINE|DT_BOTTOM );
|
||||
}
|
||||
|
||||
y -= tickHeight;
|
||||
}
|
||||
|
||||
// vertical bars
|
||||
if ( g_texProfile_numSamples )
|
||||
{
|
||||
SelectObject( hdc, hNullPen );
|
||||
|
||||
numbars = windowWidth-TEXPROFILE_HISTORY_LABELWIDTH;
|
||||
currentSample = g_texProfile_numSamples-1;
|
||||
for ( x=numbars-1; x>=0; x-=4 )
|
||||
{
|
||||
// all the counters at this sample
|
||||
y = windowHeight;
|
||||
for ( j=0; j<g_texProfile_numCounters-1; j++ )
|
||||
{
|
||||
if ( !g_texProfile_counters[j].label )
|
||||
continue;
|
||||
|
||||
t = ( float )g_texProfile_counters[j].samples[currentSample % TEXPROFILE_MAXSAMPLES]/TEXPROFILE_MAJORTICKBYTES;
|
||||
h = ( int )( t * ( float )tickHeight );
|
||||
if ( h )
|
||||
{
|
||||
if ( h > windowHeight )
|
||||
h = windowHeight;
|
||||
|
||||
hColoredBrush = CreateSolidBrush( g_texProfile_history_colors ? g_texProfile_counters[j].color : RGB( 80,80,80 ) );
|
||||
hBrushOld = ( HBRUSH )SelectObject( hdc, hColoredBrush );
|
||||
|
||||
Rectangle( hdc, x-4, y-h, x, y+1 );
|
||||
y -= h;
|
||||
|
||||
SelectObject( hdc, hBrushOld );
|
||||
DeleteObject( hColoredBrush );
|
||||
}
|
||||
}
|
||||
currentSample--;
|
||||
if ( currentSample < 0 )
|
||||
{
|
||||
// no data
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject( hdc, hFontOld );
|
||||
SelectObject( hdc, hPenOld );
|
||||
DeleteObject( hBlackPen );
|
||||
DeleteObject( hGreyPen );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK TexProfile_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT rect;
|
||||
int id;
|
||||
bool bIsSamples;
|
||||
bool bIsHistory;
|
||||
CREATESTRUCT *createStructPtr;
|
||||
bool bIsEnabled;
|
||||
|
||||
// identify window
|
||||
id = ( int )GetWindowLong( hwnd, GWL_USERDATA+0 );
|
||||
bIsSamples = ( id == ID_TEXPROFILE_SAMPLES );
|
||||
bIsHistory = ( id == ID_TEXPROFILE_HISTORY );
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
// set the window identifier
|
||||
createStructPtr = ( CREATESTRUCT* )lParam;
|
||||
SetWindowLong( hwnd, GWL_USERDATA+0, ( LONG )createStructPtr->lpCreateParams );
|
||||
|
||||
// reset peaks
|
||||
g_texProfile_lastPeakTime = 0;
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
TexProfile_SaveConfig();
|
||||
|
||||
if ( bIsSamples )
|
||||
g_texProfile_hWndSamples = NULL;
|
||||
else if ( bIsHistory )
|
||||
g_texProfile_hWndHistory = NULL;
|
||||
|
||||
if ( VProf_GetState() == VPROF_TEXTURE || VProf_GetState() == VPROF_TEXTUREFRAME )
|
||||
{
|
||||
VProf_Enable( VPROF_OFF );
|
||||
}
|
||||
return 0L;
|
||||
|
||||
case WM_INITMENU:
|
||||
if ( bIsSamples )
|
||||
{
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_TEXPROFILE_TICKMARKS, MF_BYCOMMAND | ( g_texProfile_samples_tickMarks ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_TEXPROFILE_COLORS, MF_BYCOMMAND | ( g_texProfile_samples_colors ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
}
|
||||
else if ( bIsHistory )
|
||||
{
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_TEXPROFILE_TICKMARKS, MF_BYCOMMAND | ( g_texProfile_history_tickMarks ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_TEXPROFILE_COLORS, MF_BYCOMMAND | ( g_texProfile_history_colors ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
}
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_TEXPROFILE_ENABLE, MF_BYCOMMAND | ( ( VProf_GetState() == VPROF_TEXTURE || VProf_GetState() == VPROF_TEXTUREFRAME ) ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
CheckMenuItem( ( HMENU )wParam, IDM_TEXPROFILE_CURRENTFRAME, MF_BYCOMMAND | ( g_texProfile_currentFrame ? MF_CHECKED : MF_UNCHECKED ) );
|
||||
return 0L;
|
||||
|
||||
case WM_PAINT:
|
||||
GetClientRect( hwnd, &rect );
|
||||
hdc = BeginPaint( hwnd, &ps );
|
||||
if ( bIsSamples )
|
||||
TexProfileSamples_Draw( hdc, &rect );
|
||||
else if ( bIsHistory )
|
||||
TexProfileHistory_Draw( hdc, &rect );
|
||||
EndPaint( hwnd, &ps );
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
// force a redraw
|
||||
TexProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_INSERT:
|
||||
if ( bIsSamples )
|
||||
TexProfile_ZoomIn( g_texProfile_samples_scale, TEXPROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
TexProfile_ZoomIn( g_texProfile_history_scale, TEXPROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case VK_DELETE:
|
||||
if ( bIsSamples )
|
||||
TexProfile_ZoomOut( g_texProfile_samples_scale, TEXPROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
TexProfile_ZoomOut( g_texProfile_history_scale, TEXPROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_TEXPROFILE_TICKMARKS:
|
||||
if ( bIsSamples )
|
||||
g_texProfile_samples_tickMarks ^= 1;
|
||||
else if ( bIsHistory )
|
||||
g_texProfile_history_tickMarks ^= 1;
|
||||
TexProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_TEXPROFILE_COLORS:
|
||||
if ( bIsSamples )
|
||||
g_texProfile_samples_colors ^= 1;
|
||||
else if ( bIsHistory )
|
||||
g_texProfile_history_colors ^= 1;
|
||||
TexProfile_UpdateWindow();
|
||||
return 0L;
|
||||
|
||||
case IDM_TEXPROFILE_ZOOMIN:
|
||||
if ( bIsSamples )
|
||||
TexProfile_ZoomIn( g_texProfile_samples_scale, TEXPROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
TexProfile_ZoomIn( g_texProfile_history_scale, TEXPROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case IDM_TEXPROFILE_ZOOMOUT:
|
||||
if ( bIsSamples )
|
||||
TexProfile_ZoomOut( g_texProfile_samples_scale, TEXPROFILE_SAMPLES_SCALESTEPS );
|
||||
else if ( bIsHistory )
|
||||
TexProfile_ZoomOut( g_texProfile_history_scale, TEXPROFILE_HISTORY_SCALESTEPS );
|
||||
return 0L;
|
||||
|
||||
case IDM_TEXPROFILE_ENABLE:
|
||||
bIsEnabled = ( VProf_GetState() == VPROF_TEXTURE || VProf_GetState() == VPROF_TEXTUREFRAME );
|
||||
bIsEnabled ^= 1;
|
||||
if ( !bIsEnabled )
|
||||
VProf_Enable( VPROF_OFF );
|
||||
else
|
||||
{
|
||||
if ( !g_texProfile_currentFrame )
|
||||
VProf_Enable( VPROF_TEXTURE );
|
||||
else
|
||||
VProf_Enable( VPROF_TEXTUREFRAME );
|
||||
}
|
||||
TexProfile_SetTitle();
|
||||
return 0L;
|
||||
|
||||
case IDM_TEXPROFILE_CURRENTFRAME:
|
||||
bIsEnabled = ( VProf_GetState() == VPROF_TEXTURE || VProf_GetState() == VPROF_TEXTUREFRAME );
|
||||
g_texProfile_currentFrame ^= 1;
|
||||
if ( bIsEnabled )
|
||||
{
|
||||
if ( !g_texProfile_currentFrame )
|
||||
VProf_Enable( VPROF_TEXTURE );
|
||||
else
|
||||
VProf_Enable( VPROF_TEXTUREFRAME );
|
||||
}
|
||||
TexProfile_SetTitle();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfileHistory_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfileHistory_Open()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
if ( g_texProfile_hWndHistory )
|
||||
{
|
||||
// only one profile instance
|
||||
if ( IsIconic( g_texProfile_hWndHistory ) )
|
||||
ShowWindow( g_texProfile_hWndHistory, SW_RESTORE );
|
||||
SetForegroundWindow( g_texProfile_hWndHistory );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( VProf_GetState() == VPROF_OFF )
|
||||
{
|
||||
if ( !g_texProfile_currentFrame )
|
||||
VProf_Enable( VPROF_TEXTURE );
|
||||
else
|
||||
VProf_Enable( VPROF_TEXTUREFRAME );
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"TEXPROFILEHISTORYCLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
500,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
( void* )ID_TEXPROFILE_HISTORY );
|
||||
g_texProfile_hWndHistory = hWnd;
|
||||
|
||||
TexProfile_SetTitle();
|
||||
|
||||
if ( g_texProfile_historyWindowRect.right && g_texProfile_historyWindowRect.bottom )
|
||||
MoveWindow( g_texProfile_hWndHistory, g_texProfile_historyWindowRect.left, g_texProfile_historyWindowRect.top, g_texProfile_historyWindowRect.right-g_texProfile_historyWindowRect.left, g_texProfile_historyWindowRect.bottom-g_texProfile_historyWindowRect.top, FALSE );
|
||||
ShowWindow( g_texProfile_hWndHistory, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfileSamples_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfileSamples_Open()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
if ( g_texProfile_hWndSamples )
|
||||
{
|
||||
// only one profile instance
|
||||
if ( IsIconic( g_texProfile_hWndSamples ) )
|
||||
ShowWindow( g_texProfile_hWndSamples, SW_RESTORE );
|
||||
SetForegroundWindow( g_texProfile_hWndSamples );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( VProf_GetState() == VPROF_OFF )
|
||||
{
|
||||
if ( !g_texProfile_currentFrame )
|
||||
VProf_Enable( VPROF_TEXTURE );
|
||||
else
|
||||
VProf_Enable( VPROF_TEXTUREFRAME );
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"TEXPROFILESAMPLESCLASS",
|
||||
"",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
500,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
( void* )ID_TEXPROFILE_SAMPLES );
|
||||
g_texProfile_hWndSamples = hWnd;
|
||||
|
||||
TexProfile_SetTitle();
|
||||
|
||||
if ( g_texProfile_samplesWindowRect.right && g_texProfile_samplesWindowRect.bottom )
|
||||
MoveWindow( g_texProfile_hWndSamples, g_texProfile_samplesWindowRect.left, g_texProfile_samplesWindowRect.top, g_texProfile_samplesWindowRect.right-g_texProfile_samplesWindowRect.left, g_texProfile_samplesWindowRect.bottom-g_texProfile_samplesWindowRect.top, FALSE );
|
||||
ShowWindow( g_texProfile_hWndSamples, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_Clear
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TexProfile_Clear()
|
||||
{
|
||||
// clear counters and history
|
||||
g_texProfile_numCounters = 0;
|
||||
g_texProfile_numSamples = 0;
|
||||
|
||||
TexProfile_UpdateWindow();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TexProfile_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool TexProfile_Init()
|
||||
{
|
||||
WNDCLASS wndclass;
|
||||
|
||||
// set up our window class
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = TexProfile_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_TEXPROFILE );
|
||||
wndclass.lpszClassName = "TEXPROFILESAMPLESCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
// set up our window class
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = TexProfile_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_TEXPROFILE );
|
||||
wndclass.lpszClassName = "TEXPROFILEHISTORYCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
TexProfile_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
623
utils/xbox/vxconsole/timestamp_log.cpp
Normal file
623
utils/xbox/vxconsole/timestamp_log.cpp
Normal file
@@ -0,0 +1,623 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// TIMESTAMP_LOG.CPP
|
||||
//
|
||||
// TimeStamp Log Display.
|
||||
//=====================================================================================//
|
||||
#include "vxconsole.h"
|
||||
|
||||
#define ID_TIMESTAMPLOG_LISTVIEW 100
|
||||
|
||||
// column id
|
||||
#define ID_TSL_TIME 0
|
||||
#define ID_TSL_DELTATIME 1
|
||||
#define ID_TSL_MEMORY 2
|
||||
#define ID_TSL_DELTAMEMORY 3
|
||||
#define ID_TSL_MESSAGE 4
|
||||
|
||||
typedef struct
|
||||
{ const CHAR* name;
|
||||
int width;
|
||||
int subItemIndex;
|
||||
CHAR nameBuff[32];
|
||||
} label_t;
|
||||
|
||||
struct timeStampLogNode_t
|
||||
{
|
||||
int index;
|
||||
float time;
|
||||
float deltaTime;
|
||||
int memory;
|
||||
int deltaMemory;
|
||||
char timeBuff[32];
|
||||
char deltaTimeBuff[32];
|
||||
char memoryBuff[32];
|
||||
char deltaMemoryBuff[32];
|
||||
char *pMessage;
|
||||
timeStampLogNode_t *pNext;
|
||||
};
|
||||
|
||||
HWND g_timeStampLog_hWnd;
|
||||
HWND g_timeStampLog_hWndListView;
|
||||
RECT g_timeStampLog_windowRect;
|
||||
timeStampLogNode_t *g_timeStampLog_pNodes;
|
||||
int g_timeStampLog_sortColumn;
|
||||
int g_timeStampLog_sortDescending;
|
||||
|
||||
label_t g_timeStampLog_Labels[] =
|
||||
{
|
||||
{"Time", 100, ID_TSL_TIME},
|
||||
{"Delta Time", 100, ID_TSL_DELTATIME},
|
||||
{"Memory", 100, ID_TSL_MEMORY},
|
||||
{"Delta Memory", 100, ID_TSL_DELTAMEMORY},
|
||||
{"Message", 400, ID_TSL_MESSAGE},
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_CompareFunc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
int CALLBACK TimeStampLog_CompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
|
||||
{
|
||||
timeStampLogNode_t* pNodeA = ( timeStampLogNode_t* )lParam1;
|
||||
timeStampLogNode_t* pNodeB = ( timeStampLogNode_t* )lParam2;
|
||||
|
||||
int sort = 0;
|
||||
switch ( g_timeStampLog_sortColumn )
|
||||
{
|
||||
case ID_TSL_TIME:
|
||||
sort = ( int )( 1000.0f*pNodeA->time - 1000.0f*pNodeB->time );
|
||||
break;
|
||||
|
||||
case ID_TSL_DELTATIME:
|
||||
sort = ( int )( 1000.0f*pNodeA->deltaTime - 1000.0f*pNodeB->deltaTime );
|
||||
break;
|
||||
|
||||
case ID_TSL_MEMORY:
|
||||
sort = pNodeA->memory - pNodeB->memory;
|
||||
break;
|
||||
|
||||
case ID_TSL_DELTAMEMORY:
|
||||
sort = pNodeA->deltaMemory - pNodeB->deltaMemory;
|
||||
break;
|
||||
|
||||
case ID_TSL_MESSAGE:
|
||||
sort = stricmp( pNodeA->pMessage, pNodeB->pMessage );
|
||||
break;
|
||||
}
|
||||
|
||||
// flip the sort order
|
||||
if ( g_timeStampLog_sortDescending )
|
||||
sort *= -1;
|
||||
|
||||
return ( sort );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_SortItems
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_SortItems()
|
||||
{
|
||||
LVITEM lvitem;
|
||||
timeStampLogNode_t *pNode;
|
||||
int i;
|
||||
|
||||
if ( !g_timeStampLog_hWnd )
|
||||
{
|
||||
// only sort if window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
ListView_SortItems( g_timeStampLog_hWndListView, TimeStampLog_CompareFunc, 0 );
|
||||
|
||||
memset( &lvitem, 0, sizeof( lvitem ) );
|
||||
lvitem.mask = LVIF_PARAM;
|
||||
|
||||
// get each item and reset its list index
|
||||
int itemCount = ListView_GetItemCount( g_timeStampLog_hWndListView );
|
||||
for ( i=0; i<itemCount; i++ )
|
||||
{
|
||||
lvitem.iItem = i;
|
||||
ListView_GetItem( g_timeStampLog_hWndListView, &lvitem );
|
||||
|
||||
pNode = ( timeStampLogNode_t* )lvitem.lParam;
|
||||
pNode->index = i;
|
||||
}
|
||||
|
||||
// update list view columns with sort key
|
||||
for ( i=0; i<sizeof( g_timeStampLog_Labels )/sizeof( g_timeStampLog_Labels[0] ); i++ )
|
||||
{
|
||||
char symbol;
|
||||
LVCOLUMN lvc;
|
||||
|
||||
if ( i == g_timeStampLog_sortColumn )
|
||||
symbol = g_timeStampLog_sortDescending ? '<' : '>';
|
||||
else
|
||||
symbol = ' ';
|
||||
sprintf( g_timeStampLog_Labels[i].nameBuff, "%s %c", g_timeStampLog_Labels[i].name, symbol );
|
||||
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = ( LPSTR )g_timeStampLog_Labels[i].nameBuff;
|
||||
|
||||
ListView_SetColumn( g_timeStampLog_hWndListView, i, &lvc );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_AddViewItem
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_AddViewItem( timeStampLogNode_t* pNode )
|
||||
{
|
||||
LVITEM lvi;
|
||||
|
||||
if ( !g_timeStampLog_hWnd )
|
||||
{
|
||||
// only valid if log window is visible
|
||||
return;
|
||||
}
|
||||
|
||||
// update the text callback buffers
|
||||
sprintf( pNode->timeBuff, "%2.2d:%2.2d:%2.2d:%3.3d", ( int )pNode->time/3600, ( ( int )pNode->time/60 )%60, ( int )pNode->time%60, ( int )( 1000*( pNode->time-( int )pNode->time ) )%1000 );
|
||||
sprintf( pNode->deltaTimeBuff, "%.3f", pNode->deltaTime );
|
||||
sprintf( pNode->memoryBuff, "%.2f MB", pNode->memory/( 1024.0f*1024.0f ) );
|
||||
sprintf( pNode->deltaMemoryBuff, "%d", pNode->deltaMemory );
|
||||
|
||||
int itemCount = ListView_GetItemCount( g_timeStampLog_hWndListView );
|
||||
|
||||
// setup and insert at end of list
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
|
||||
lvi.iItem = itemCount;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.state = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
lvi.lParam = ( LPARAM )pNode;
|
||||
|
||||
// insert
|
||||
pNode->index = ListView_InsertItem( g_timeStampLog_hWndListView, &lvi );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_AddItem
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_AddItem( float time, float deltaTime, int memory, int deltaMemory, const char* pMessage )
|
||||
{
|
||||
timeStampLogNode_t* pNode;
|
||||
|
||||
// create and init
|
||||
pNode = new timeStampLogNode_t;
|
||||
memset( pNode, 0, sizeof( timeStampLogNode_t ) );
|
||||
|
||||
pNode->time = time;
|
||||
pNode->deltaTime = deltaTime;
|
||||
pNode->memory = memory;
|
||||
pNode->deltaMemory = deltaMemory;
|
||||
pNode->pMessage = Sys_CopyString( pMessage ? pMessage : "" );
|
||||
|
||||
// link in
|
||||
pNode->pNext = g_timeStampLog_pNodes;
|
||||
g_timeStampLog_pNodes = pNode;
|
||||
|
||||
TimeStampLog_AddViewItem( pNode );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_Clear
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_Clear()
|
||||
{
|
||||
timeStampLogNode_t* pNode;
|
||||
timeStampLogNode_t* pNextNode;
|
||||
|
||||
// delete all the list view entries
|
||||
if ( g_timeStampLog_hWnd )
|
||||
ListView_DeleteAllItems( g_timeStampLog_hWndListView );
|
||||
|
||||
// delete nodes in chain
|
||||
pNode = g_timeStampLog_pNodes;
|
||||
while ( pNode )
|
||||
{
|
||||
pNextNode = pNode->pNext;
|
||||
|
||||
Sys_Free( pNode->pMessage );
|
||||
delete pNode;
|
||||
|
||||
pNode = pNextNode;
|
||||
}
|
||||
g_timeStampLog_pNodes = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_SaveConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_SaveConfig()
|
||||
{
|
||||
char buff[256];
|
||||
|
||||
Sys_SetRegistryInteger( "timeStampLogSortColumn", g_timeStampLog_sortColumn );
|
||||
Sys_SetRegistryInteger( "timeStampLogSortDescending", g_timeStampLog_sortDescending );
|
||||
|
||||
WINDOWPLACEMENT wp;
|
||||
memset( &wp, 0, sizeof( wp ) );
|
||||
wp.length = sizeof( WINDOWPLACEMENT );
|
||||
GetWindowPlacement( g_timeStampLog_hWnd, &wp );
|
||||
g_timeStampLog_windowRect = wp.rcNormalPosition;
|
||||
|
||||
sprintf( buff, "%d %d %d %d", g_timeStampLog_windowRect.left, g_timeStampLog_windowRect.top, g_timeStampLog_windowRect.right, g_timeStampLog_windowRect.bottom );
|
||||
Sys_SetRegistryString( "timeStampLogWindowRect", buff );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_LoadConfig
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_LoadConfig()
|
||||
{
|
||||
int numArgs;
|
||||
char buff[256];
|
||||
|
||||
Sys_GetRegistryInteger( "timeStampLogSortColumn", ID_TSL_TIME, g_timeStampLog_sortColumn );
|
||||
Sys_GetRegistryInteger( "timeStampLogSortDescending", false, g_timeStampLog_sortDescending );
|
||||
|
||||
Sys_GetRegistryString( "timeStampLogWindowRect", buff, "", sizeof( buff ) );
|
||||
numArgs = sscanf( buff, "%d %d %d %d", &g_timeStampLog_windowRect.left, &g_timeStampLog_windowRect.top, &g_timeStampLog_windowRect.right, &g_timeStampLog_windowRect.bottom );
|
||||
if ( numArgs != 4 || g_timeStampLog_windowRect.left < 0 || g_timeStampLog_windowRect.top < 0 || g_timeStampLog_windowRect.right < 0 || g_timeStampLog_windowRect.bottom < 0 )
|
||||
memset( &g_timeStampLog_windowRect, 0, sizeof( g_timeStampLog_windowRect ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_SizeWindow
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_SizeWindow( HWND hwnd, int width, int height )
|
||||
{
|
||||
if ( width==0 || height==0 )
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect( hwnd, &rcClient );
|
||||
width = rcClient.right;
|
||||
height = rcClient.bottom;
|
||||
}
|
||||
|
||||
// position the ListView
|
||||
SetWindowPos( g_timeStampLog_hWndListView, NULL, 0, 0, width, height, SWP_NOZORDER );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_Export
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_Export()
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
char logFilename[MAX_PATH];
|
||||
int retval;
|
||||
FILE* fp;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
memset( &ofn, 0, sizeof( ofn ) );
|
||||
ofn.lStructSize = sizeof( ofn );
|
||||
ofn.hwndOwner = g_timeStampLog_hWnd;
|
||||
ofn.lpstrFile = logFilename;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof( logFilename );
|
||||
ofn.lpstrFilter = "Excel CSV\0*.CSV\0All Files\0*.*\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = "c:\\";
|
||||
ofn.Flags = OFN_PATHMUSTEXIST;
|
||||
|
||||
// display the open dialog box
|
||||
retval = GetOpenFileName( &ofn );
|
||||
if ( !retval )
|
||||
return;
|
||||
|
||||
Sys_AddExtension( ".csv", logFilename, sizeof( logFilename ) );
|
||||
|
||||
fp = fopen( logFilename, "wt+" );
|
||||
if ( !fp )
|
||||
return;
|
||||
|
||||
// labels
|
||||
count = ARRAYSIZE( g_timeStampLog_Labels );
|
||||
for ( i=0; i<count; i++ )
|
||||
{
|
||||
fprintf( fp, "\"%s\"", g_timeStampLog_Labels[i].name );
|
||||
if ( i != count-1 )
|
||||
fprintf( fp, "," );
|
||||
}
|
||||
fprintf( fp, "\n" );
|
||||
|
||||
// build a list for easy reverse traversal
|
||||
CUtlVector< timeStampLogNode_t* > nodeList;
|
||||
timeStampLogNode_t *pNode;
|
||||
pNode = g_timeStampLog_pNodes;
|
||||
while ( pNode )
|
||||
{
|
||||
nodeList.AddToTail( pNode );
|
||||
pNode = pNode->pNext;
|
||||
}
|
||||
|
||||
// dump to the log
|
||||
for ( int i=nodeList.Count()-1; i>=0; i-- )
|
||||
{
|
||||
pNode = nodeList[i];
|
||||
|
||||
fprintf( fp, "\"%s\"", pNode->timeBuff );
|
||||
fprintf( fp, ",\"%s\"", pNode->deltaTimeBuff );
|
||||
fprintf( fp, ",\"%s\"", pNode->memoryBuff );
|
||||
fprintf( fp, ",\"%s\"", pNode->deltaMemoryBuff );
|
||||
fprintf( fp, ",\"%s\"", pNode->pMessage );
|
||||
fprintf( fp, "\n" );
|
||||
}
|
||||
|
||||
fclose( fp );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_WndProc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK TimeStampLog_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
WORD wID = LOWORD( wParam );
|
||||
timeStampLogNode_t *pNode;
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
TimeStampLog_SaveConfig();
|
||||
g_timeStampLog_hWnd = NULL;
|
||||
return 0L;
|
||||
|
||||
case WM_SIZE:
|
||||
TimeStampLog_SizeWindow( hwnd, LOWORD( lParam ), HIWORD( lParam ) );
|
||||
return 0L;
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch ( ( ( LPNMHDR )lParam )->code )
|
||||
{
|
||||
case LVN_COLUMNCLICK:
|
||||
NMLISTVIEW* pnmlv;
|
||||
pnmlv = ( NMLISTVIEW* )lParam;
|
||||
if ( g_timeStampLog_sortColumn == pnmlv->iSubItem )
|
||||
{
|
||||
// user has clicked on same column - flip the sort
|
||||
g_timeStampLog_sortDescending ^= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sort by new column
|
||||
g_timeStampLog_sortColumn = pnmlv->iSubItem;
|
||||
}
|
||||
TimeStampLog_SortItems();
|
||||
return 0L;
|
||||
|
||||
case LVN_GETDISPINFO:
|
||||
NMLVDISPINFO* plvdi;
|
||||
plvdi = ( NMLVDISPINFO* )lParam;
|
||||
pNode = ( timeStampLogNode_t * )plvdi->item.lParam;
|
||||
switch ( plvdi->item.iSubItem )
|
||||
{
|
||||
case ID_TSL_TIME:
|
||||
plvdi->item.pszText = pNode->timeBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_TSL_DELTATIME:
|
||||
plvdi->item.pszText = pNode->deltaTimeBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_TSL_MEMORY:
|
||||
plvdi->item.pszText = pNode->memoryBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_TSL_DELTAMEMORY:
|
||||
plvdi->item.pszText = pNode->deltaMemoryBuff;
|
||||
return 0L;
|
||||
|
||||
case ID_TSL_MESSAGE:
|
||||
plvdi->item.pszText = pNode->pMessage;
|
||||
return 0L;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch ( wID )
|
||||
{
|
||||
case IDM_OPTIONS_CLEAR:
|
||||
TimeStampLog_Clear();
|
||||
return 0L;
|
||||
|
||||
case IDM_OPTIONS_EXPORT:
|
||||
TimeStampLog_Export();
|
||||
return 0L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_Init
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool TimeStampLog_Init()
|
||||
{
|
||||
// set up our window class
|
||||
WNDCLASS wndclass;
|
||||
|
||||
memset( &wndclass, 0, sizeof( wndclass ) );
|
||||
wndclass.style = 0;
|
||||
wndclass.lpfnWndProc = TimeStampLog_WndProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = g_hInstance;
|
||||
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
|
||||
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndclass.hbrBackground = g_hBackgroundBrush;
|
||||
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_TIMESTAMPLOG );
|
||||
wndclass.lpszClassName = "TIMESTAMPLOGCLASS";
|
||||
if ( !RegisterClass( &wndclass ) )
|
||||
return false;
|
||||
|
||||
TimeStampLog_LoadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TimeStampLog_Open
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TimeStampLog_Open()
|
||||
{
|
||||
RECT clientRect;
|
||||
HWND hWnd;
|
||||
int i;
|
||||
timeStampLogNode_t *pNode;
|
||||
|
||||
if ( g_timeStampLog_hWnd )
|
||||
{
|
||||
// only one file log instance
|
||||
if ( IsIconic( g_timeStampLog_hWnd ) )
|
||||
ShowWindow( g_timeStampLog_hWnd, SW_RESTORE );
|
||||
SetForegroundWindow( g_timeStampLog_hWnd );
|
||||
return;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
"TIMESTAMPLOGCLASS",
|
||||
"TimeStamp Log",
|
||||
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
300,
|
||||
g_hDlgMain,
|
||||
NULL,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_timeStampLog_hWnd = hWnd;
|
||||
|
||||
GetClientRect( g_timeStampLog_hWnd, &clientRect );
|
||||
hWnd = CreateWindow(
|
||||
WC_LISTVIEW,
|
||||
"",
|
||||
WS_VISIBLE|WS_CHILD|LVS_REPORT,
|
||||
0,
|
||||
0,
|
||||
clientRect.right-clientRect.left,
|
||||
clientRect.bottom-clientRect.top,
|
||||
g_timeStampLog_hWnd,
|
||||
( HMENU )ID_TIMESTAMPLOG_LISTVIEW,
|
||||
g_hInstance,
|
||||
NULL );
|
||||
g_timeStampLog_hWndListView = hWnd;
|
||||
|
||||
// init list view columns
|
||||
for ( i=0; i<sizeof( g_timeStampLog_Labels )/sizeof( g_timeStampLog_Labels[0] ); i++ )
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
memset( &lvc, 0, sizeof( lvc ) );
|
||||
|
||||
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.cx = g_timeStampLog_Labels[i].width;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.pszText = ( LPSTR )g_timeStampLog_Labels[i].name;
|
||||
|
||||
ListView_InsertColumn( g_timeStampLog_hWndListView, i, &lvc );
|
||||
}
|
||||
|
||||
ListView_SetBkColor( g_timeStampLog_hWndListView, g_backgroundColor );
|
||||
ListView_SetTextBkColor( g_timeStampLog_hWndListView, g_backgroundColor );
|
||||
|
||||
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;
|
||||
ListView_SetExtendedListViewStyleEx( g_timeStampLog_hWndListView, style, style );
|
||||
|
||||
// populate list view
|
||||
pNode = g_timeStampLog_pNodes;
|
||||
while ( pNode )
|
||||
{
|
||||
TimeStampLog_AddViewItem( pNode );
|
||||
pNode = pNode->pNext;
|
||||
}
|
||||
TimeStampLog_SortItems();
|
||||
|
||||
if ( g_timeStampLog_windowRect.right && g_timeStampLog_windowRect.bottom )
|
||||
MoveWindow( g_timeStampLog_hWnd, g_timeStampLog_windowRect.left, g_timeStampLog_windowRect.top, g_timeStampLog_windowRect.right-g_timeStampLog_windowRect.left, g_timeStampLog_windowRect.bottom-g_timeStampLog_windowRect.top, FALSE );
|
||||
ShowWindow( g_timeStampLog_hWnd, SHOW_OPENWINDOW );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// rc_TimeStampLog
|
||||
//
|
||||
// Sent from application with time stamp log
|
||||
//-----------------------------------------------------------------------------
|
||||
int rc_TimeStampLog( char* commandPtr )
|
||||
{
|
||||
char *cmdToken;
|
||||
int timeStampAddr;
|
||||
int retAddr;
|
||||
int retVal;
|
||||
int errCode = -1;
|
||||
xrTimeStamp_t timeStamp;
|
||||
|
||||
// get data
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &timeStampAddr );
|
||||
|
||||
// get retAddr
|
||||
cmdToken = GetToken( &commandPtr );
|
||||
if ( !cmdToken[0] )
|
||||
goto cleanUp;
|
||||
sscanf( cmdToken, "%x", &retAddr );
|
||||
|
||||
// get the caller's data
|
||||
DmGetMemory( ( void* )timeStampAddr, sizeof( xrTimeStamp_t ), &timeStamp, NULL );
|
||||
|
||||
// swap the structure
|
||||
BigFloat( &timeStamp.time, &timeStamp.time );
|
||||
BigFloat( &timeStamp.deltaTime, &timeStamp.deltaTime );
|
||||
timeStamp.memory = BigDWord( timeStamp.memory );
|
||||
timeStamp.deltaMemory = BigDWord( timeStamp.deltaMemory );
|
||||
|
||||
// add to log
|
||||
TimeStampLog_AddItem( timeStamp.time, timeStamp.deltaTime, timeStamp.memory, timeStamp.deltaMemory, timeStamp.messageString );
|
||||
TimeStampLog_SortItems();
|
||||
|
||||
// return the result
|
||||
retVal = 0;
|
||||
int xboxRetVal = BigDWord( retVal );
|
||||
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
|
||||
|
||||
DebugCommand( "0x%8.8x = TimeStampLog( 0x%8.8x )\n", retVal, timeStampAddr );
|
||||
|
||||
// success
|
||||
errCode = 0;
|
||||
|
||||
cleanUp:
|
||||
return ( errCode );
|
||||
}
|
||||
1528
utils/xbox/vxconsole/vxconsole.cpp
Normal file
1528
utils/xbox/vxconsole/vxconsole.cpp
Normal file
File diff suppressed because it is too large
Load Diff
479
utils/xbox/vxconsole/vxconsole.h
Normal file
479
utils/xbox/vxconsole/vxconsole.h
Normal file
@@ -0,0 +1,479 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// VXCONSOLE.H
|
||||
//
|
||||
// Master Header.
|
||||
//=====================================================================================//
|
||||
#pragma once
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <share.h>
|
||||
#include <richedit.h>
|
||||
#include <assert.h>
|
||||
#include <xbdm.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "resource.h"
|
||||
#include "assert_resource.h"
|
||||
#include "sys_utils.h"
|
||||
#include "sys_scriptlib.h"
|
||||
#include "bugreporter/bugreporter.h"
|
||||
#include "jpeglib/jpeglib.h"
|
||||
#include "UtlBuffer.h"
|
||||
#include "strtools.h"
|
||||
#include "xbox/xbox_vxconsole.h"
|
||||
#include "UtlRBTree.h"
|
||||
#include "UtlSymbol.h"
|
||||
#include "UtlVector.h"
|
||||
#include "UtlString.h"
|
||||
|
||||
#define VXCONSOLE_VERSION "1.2"
|
||||
#define VXCONSOLE_CLASSNAME "VXConsole"
|
||||
#define VXCONSOLE_TITLE "VXConsole"
|
||||
#define VXCONSOLE_FONT "Courier"
|
||||
#define VXCONSOLE_FONTSIZE 10
|
||||
#define VXCONSOLE_MAGIC "3\\"
|
||||
#define VXCONSOLE_REGISTRY "HKEY_CURRENT_USER\\Software\\VXConsole\\" VXCONSOLE_MAGIC
|
||||
#ifdef _DEBUG
|
||||
#define VXCONSOLE_BUILDTYPE "Debug"
|
||||
#else
|
||||
#define VXCONSOLE_BUILDTYPE "Release"
|
||||
#endif
|
||||
|
||||
#define VXCONSOLE_WINDOWBYTES ( DLGWINDOWEXTRA + 4 )
|
||||
#define VXCONSOLE_CONFIGID ( VXCONSOLE_WINDOWBYTES - 4 )
|
||||
|
||||
#define MAX_QUEUEDSTRINGS 4096
|
||||
#define MAX_QUEUEDSTRINGLEN 512
|
||||
#define MAX_RCMDNAMELEN 32
|
||||
#define MAX_RCMDS 4096
|
||||
#define MAX_TOKENCHARS 256
|
||||
#define MAX_XBOXNAMELEN 64
|
||||
#define MAX_ARGVELEMS 20
|
||||
#define MAX_COMMANDHISTORY 25
|
||||
|
||||
#define TIMERID_AUTOCONNECT 0x1000
|
||||
#define TIMERID_MEMPROFILE 0x1001
|
||||
|
||||
#define IDC_COMMANDHINT 666
|
||||
|
||||
#define XBX_CLR_RED ( RGB( 255,0,0 ) )
|
||||
#define XBX_CLR_GREEN ( RGB( 0,255,0 ) )
|
||||
#define XBX_CLR_WHITE ( RGB( 255,255,255 ) )
|
||||
#define XBX_CLR_BLACK ( RGB( 0,0,0 ) )
|
||||
#define XBX_CLR_BLUE ( RGB( 0,0,255 ) )
|
||||
#define XBX_CLR_YELLOW ( RGB( 255,255,0 ) )
|
||||
#define XBX_CLR_LTGREY ( RGB( 180,180,180 ) )
|
||||
#define XBX_CLR_DEFAULT XBX_CLR_BLACK
|
||||
|
||||
// The command prefix that is prepended to all communication between the Xbox
|
||||
// app and the debug console app
|
||||
#define VXCONSOLE_PRINT_PREFIX "XPRT"
|
||||
#define VXCONSOLE_COMMAND_PREFIX "XCMD"
|
||||
#define VXCONSOLE_COMMAND_ACK "XACK"
|
||||
#define VXCONSOLE_COLOR_PREFIX "XCLR"
|
||||
|
||||
#define ICON_APPLICATION 0
|
||||
#define ICON_DISCONNECTED 1
|
||||
#define ICON_CONNECTED_XBOX 2
|
||||
#define ICON_CONNECTED_APP0 3
|
||||
#define ICON_CONNECTED_APP1 4
|
||||
#define MAX_ICONS 5
|
||||
|
||||
typedef BOOL ( *cmdHandler_t )( int argc, char* argv[] );
|
||||
|
||||
#define IDM_BINDINGS 50000
|
||||
#define IDM_BINDINGS_EDIT ( IDM_BINDINGS+1 )
|
||||
#define IDM_BINDINGS_BIND1 ( IDM_BINDINGS+2 )
|
||||
#define IDM_BINDINGS_BIND2 ( IDM_BINDINGS+3 )
|
||||
#define IDM_BINDINGS_BIND3 ( IDM_BINDINGS+4 )
|
||||
#define IDM_BINDINGS_BIND4 ( IDM_BINDINGS+5 )
|
||||
#define IDM_BINDINGS_BIND5 ( IDM_BINDINGS+6 )
|
||||
#define IDM_BINDINGS_BIND6 ( IDM_BINDINGS+7 )
|
||||
#define IDM_BINDINGS_BIND7 ( IDM_BINDINGS+8 )
|
||||
#define IDM_BINDINGS_BIND8 ( IDM_BINDINGS+9 )
|
||||
#define IDM_BINDINGS_BIND9 ( IDM_BINDINGS+10 )
|
||||
#define IDM_BINDINGS_BIND10 ( IDM_BINDINGS+11 )
|
||||
#define IDM_BINDINGS_BIND11 ( IDM_BINDINGS+12 )
|
||||
#define IDM_BINDINGS_BIND12 ( IDM_BINDINGS+13 )
|
||||
#define MAX_BINDINGS ( VK_F12-VK_F1+1 )
|
||||
|
||||
// file serving
|
||||
#define FSERVE_LOCALONLY 0
|
||||
#define FSERVE_REMOTEONLY 1
|
||||
#define FSERVE_LOCALFIRST 2
|
||||
|
||||
// file sync
|
||||
#define FSYNC_OFF 0x00000000
|
||||
#define FSYNC_ALWAYS 0x00000001
|
||||
#define FSYNC_IFNEWER 0x00000002
|
||||
#define FSYNC_TYPEMASK 0x0000000F
|
||||
#define FSYNC_ANDEXISTSONTARGET 0x80000000
|
||||
|
||||
// track function invocations
|
||||
typedef enum
|
||||
{
|
||||
FL_INVALID,
|
||||
FL_STAT,
|
||||
FL_FOPEN,
|
||||
FL_FSEEK,
|
||||
FL_FTELL,
|
||||
FL_FREAD,
|
||||
FL_FWRITE,
|
||||
FL_FCLOSE,
|
||||
FL_FEOF,
|
||||
FL_FERROR,
|
||||
FL_FFLUSH,
|
||||
FL_FGETS,
|
||||
FL_MAXFUNCTIONCOUNTS,
|
||||
} fileLogFunctions_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VPROF_OFF = 0,
|
||||
VPROF_CPU,
|
||||
VPROF_TEXTURE,
|
||||
VPROF_TEXTUREFRAME,
|
||||
} vprofState_e;
|
||||
|
||||
// funtion command types
|
||||
#define FN_CONSOLE 0x00 // command runs at console
|
||||
#define FN_XBOX 0x01 // command requires xbox
|
||||
#define FN_APP 0x02 // command requires application
|
||||
|
||||
// shorthand
|
||||
#define FA_NORMAL FILE_ATTRIBUTE_NORMAL
|
||||
#define FA_DIRECTORY FILE_ATTRIBUTE_DIRECTORY
|
||||
#define FA_READONLY FILE_ATTRIBUTE_READONLY
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const CHAR* strCommand;
|
||||
int flags;
|
||||
cmdHandler_t pfnHandler;
|
||||
const CHAR* strHelp;
|
||||
} localCommand_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* strCommand;
|
||||
char* strHelp;
|
||||
} remoteCommand_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CRITICAL_SECTION CriticalSection;
|
||||
int numMessages;
|
||||
bool bInit;
|
||||
COLORREF aColors[MAX_QUEUEDSTRINGS];
|
||||
CHAR *pMessages[MAX_QUEUEDSTRINGS];
|
||||
} printQueue_t;
|
||||
|
||||
class CProgress
|
||||
{
|
||||
public:
|
||||
CProgress();
|
||||
~CProgress();
|
||||
void Open( const char* title, bool canCancel, bool bHasMeter );
|
||||
void SetStatus( const char *line1, const char *line2, const char *line3 );
|
||||
void SetMeter( int currentPos, int range );
|
||||
bool IsCancel();
|
||||
HWND m_hWnd;
|
||||
HWND m_hWndStatus1;
|
||||
HWND m_hWndStatus2;
|
||||
HWND m_hWndStatus3;
|
||||
HWND m_hWndPercent;
|
||||
HWND m_hWndMeter;
|
||||
HWND m_hWndCancel;
|
||||
bool m_bCancelPressed;
|
||||
int m_range;
|
||||
|
||||
private:
|
||||
void Update();
|
||||
};
|
||||
|
||||
typedef struct fileNode_s
|
||||
{
|
||||
char *filename;
|
||||
FILETIME creationTime;
|
||||
FILETIME changeTime;
|
||||
DWORD sizeHigh;
|
||||
DWORD sizeLow;
|
||||
DWORD attributes;
|
||||
int level;
|
||||
struct fileNode_s *nextPtr;
|
||||
bool needsUpdate;
|
||||
}
|
||||
fileNode_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FILEIO.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void RemoteToLocalFilename( const char* inFilename, char* outFilename, int outSize );
|
||||
extern void RemoteToTargetFilename( const char* inFilename, char* outFilename, int outSize );
|
||||
extern void FreeTargetFileList( fileNode_t* pFileList );
|
||||
extern bool GetTargetFileList_r( char* targetPath, bool recurse, int attributes, int level, fileNode_t** pFileList );
|
||||
extern char *SystemTimeToString( SYSTEMTIME *systemTime, char *buffer, int bufferSize );
|
||||
extern bool CreateTargetPath( const char *pTargetFilename );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// BINDINGS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern bool Bindings_TranslateKey( int vkKeyCode );
|
||||
extern bool Bindings_MenuSelection( int wID );
|
||||
extern void Bindings_LoadConfig();
|
||||
extern void Bindings_SaveConfig();
|
||||
extern void Bindings_Open();
|
||||
extern bool Bindings_Init();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// COMMON.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VXCONSOLE.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void SetConnectionIcon( int icon );
|
||||
extern void PrintToQueue( COLORREF color, const CHAR* strFormat, ... );
|
||||
extern void ProcessPrintQueue();
|
||||
extern void DmAPI_DisplayError( const char* strApiName, HRESULT hr );
|
||||
extern int ConsoleWindowPrintf( COLORREF rgb, LPCTSTR lpFmt, ... );
|
||||
extern int CmdToArgv( char* str, char* argv[], int maxargs );
|
||||
extern char* GetToken( char** tokenStreamPtr );
|
||||
extern void DebugCommand( const char* strFormat, ... );
|
||||
extern bool ProcessCommand( const char* strCmd );
|
||||
extern HRESULT DmAPI_SendCommand( const char* strCommand, bool wait );
|
||||
extern void NotImplementedYet();
|
||||
extern void SetMainWindowTitle();
|
||||
extern HWND g_hDlgMain;
|
||||
extern HWND g_hwndOutputWindow;
|
||||
extern UINT_PTR g_autoConnectTimer;
|
||||
extern BOOL g_autoConnect;
|
||||
extern CHAR g_xboxName[];
|
||||
extern DWORD g_xboxAddress;
|
||||
extern CHAR g_remotePath[];
|
||||
extern CHAR g_localPath[];
|
||||
extern CHAR g_targetPath[];
|
||||
extern CHAR g_installPath[];
|
||||
extern CHAR g_xboxTargetName[];
|
||||
extern BOOL g_connectedToApp;
|
||||
extern BOOL g_connectedToXBox;
|
||||
extern PDMN_SESSION g_pdmnSession;
|
||||
extern PDM_CONNECTION g_pdmConnection;
|
||||
extern BOOL g_debugCommands;
|
||||
extern BOOL g_captureDebugSpew;
|
||||
extern HINSTANCE g_hInstance;
|
||||
extern HICON g_hIcons[];
|
||||
extern BOOL g_reboot;
|
||||
extern int g_rebootArgc;
|
||||
extern char* g_rebootArgv[];
|
||||
extern int g_connectCount;
|
||||
extern int g_currentIcon;
|
||||
extern BOOL g_clsOnConnect;
|
||||
extern DWORD g_connectedTime;
|
||||
extern HBRUSH g_hBackgroundBrush;
|
||||
extern COLORREF g_backgroundColor;
|
||||
extern HFONT g_hFixedFont;
|
||||
extern HFONT g_hProportionalFont;
|
||||
extern HANDLE g_hCommandReadyEvent;
|
||||
extern BOOL g_loadSymbolsOnConnect;
|
||||
extern HACCEL g_hAccel;
|
||||
extern BOOL g_alwaysAutoConnect;
|
||||
extern BOOL g_startMinimized;
|
||||
extern int g_connectFailure;
|
||||
extern BOOL g_captureDebugSpew_StartupState;
|
||||
extern bool g_bSuppressBlink;
|
||||
extern BOOL g_bPlayTestMode;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LOCAL_CMDS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern BOOL lc_bug( int argc, char* argv[] );
|
||||
extern BOOL lc_dir( int argc, char* argv[] );
|
||||
extern BOOL lc_del( int argc, char* argv[] );
|
||||
extern BOOL lc_memory( int argc, char* argv[] );
|
||||
extern BOOL lc_screenshot( int argc, char* argv[] );
|
||||
extern BOOL lc_help( int argc, char* argv[] );
|
||||
extern BOOL lc_cls( int argc, char* argv[] );
|
||||
extern BOOL lc_connect( int argc, char* argv[] );
|
||||
extern BOOL lc_autoConnect( int argc, char* argv[] );
|
||||
extern BOOL lc_disconnect( int argc, char* argv[] );
|
||||
extern BOOL lc_quit( int argc, char* argv[] );
|
||||
extern BOOL lc_crashdump( int argc, char* argv[] );
|
||||
extern BOOL lc_listen( int argc, char* argv[] );
|
||||
extern BOOL lc_run( int argc, char* argv[] );
|
||||
extern BOOL lc_reset( int argc, char* argv[] );
|
||||
extern BOOL lc_modules( int argc, char* argv[] );
|
||||
extern BOOL lc_sections( int argc, char* argv[] );
|
||||
extern BOOL lc_threads( int argc, char* argv[] );
|
||||
extern BOOL lc_ClearConfigs( int argc, char* argv[] );
|
||||
extern void AutoConnectTimerProc( HWND hwnd, UINT_PTR idEvent );
|
||||
extern int MatchLocalCommands( char* cmdStr, const char* cmdList[], int maxCmds );
|
||||
extern void DoDisconnect( BOOL bKeepConnection, int waitTime = 15 );
|
||||
extern localCommand_t g_localCommands[];
|
||||
extern const int g_numLocalCommands;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// REMOTE_CMDS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern int rc_AddCommands( char* commandPtr );
|
||||
extern void Remote_DeleteCommands();
|
||||
extern DWORD __stdcall Remote_NotifyDebugString( ULONG dwNotification, DWORD dwParam );
|
||||
extern DWORD __stdcall Remote_NotifyPrintFunc( const CHAR* strNotification );
|
||||
extern DWORD __stdcall Remote_NotifyCommandFunc( const CHAR* strNotification );
|
||||
extern int MatchRemoteCommands( char* cmdStr, const char* cmdList[], int maxCmds );
|
||||
extern remoteCommand_t* g_remoteCommands[];
|
||||
extern int g_numRemoteCommands;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// BUG.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern bool BugDlg_Init( void );
|
||||
extern void BugDlg_Open( void );
|
||||
extern void BugReporter_FreeInterfaces();
|
||||
extern int rc_MapInfo( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CONFIG.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void ConfigDlg_Open( void );
|
||||
extern void ConfigDlg_LoadConfig();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FILELOG.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void FileLog_Open();
|
||||
extern bool FileLog_Init();
|
||||
extern void FileLog_Clear();
|
||||
extern unsigned int FileLog_AddItem( const char* filename, unsigned int fp );
|
||||
extern void FileLog_UpdateItem( unsigned int log, unsigned int fp, fileLogFunctions_e functionId, int value );
|
||||
extern void FileLog_SaveConfig();
|
||||
extern void FileLog_LoadConfig();
|
||||
extern bool g_fileLogEnable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CPU_PROFILE.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void CpuProfileSamples_Open();
|
||||
extern void CpuProfileHistory_Open();
|
||||
extern void CpuProfile_SetTitle();
|
||||
extern bool CpuProfile_Init();
|
||||
extern void CpuProfile_Clear();
|
||||
extern int rc_SetCpuProfile( char* commandPtr );
|
||||
extern int rc_SetCpuProfileData( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TEX_PROFILE.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void TexProfile_SetTitle();
|
||||
extern void TexProfileSamples_Open();
|
||||
extern void TexProfileHistory_Open();
|
||||
extern bool TexProfile_Init();
|
||||
extern int rc_SetTexProfile( char* commandPtr );
|
||||
extern int rc_SetTexProfileData( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MEM_PROFILE.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void MemProfile_Open();
|
||||
extern void MemProfile_SetTitle();
|
||||
extern bool MemProfile_Init();
|
||||
extern void MemProfile_Clear();
|
||||
extern int rc_FreeMemory( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MEMLOG.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void MemoryLog_Open();
|
||||
extern bool MemoryLog_Init();
|
||||
extern void MemoryLog_Clear();
|
||||
extern void MemoryLog_SaveConfig();
|
||||
extern void MemoryLog_LoadConfig();
|
||||
extern void MemoryLog_TreeView( bool enable );
|
||||
extern void MemoryLog_RefreshItems();
|
||||
extern int rc_MemoryLog( char* commandPtr );
|
||||
extern bool g_memoryLog_enable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SYNC_FILES.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern int FileSyncEx( const char* localFilename, const char* remoteFilename, int fileSyncMode, bool bVerbose, bool bNoWrite );
|
||||
extern bool SyncFilesDlg_Init( void );
|
||||
extern void SyncFilesDlg_Open( void );
|
||||
extern void InstallDlg_Open( void );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FILEIO.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern int CompareFileTimes_NTFStoFATX( FILETIME* ntfsFileTime, char *ntfsTimeString, int ntfsStringSize, FILETIME* fatxFileTime, char *fatxTimeString, int fatxStringSize );
|
||||
extern bool LoadTargetFile( const char *pTargetPath, int *pFileSize, void **pData );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PROGRESS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern bool Progress_Init();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SHOW_TEXTURES.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void ShowTextures_Open();
|
||||
extern bool ShowTextures_Init();
|
||||
extern int rc_TextureList( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TIMESTAMP_LOG.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void TimeStampLog_Open();
|
||||
extern bool TimeStampLog_Init();
|
||||
extern void TimeStampLog_Clear();
|
||||
extern int rc_TimeStampLog( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// COMMON.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern vprofState_e VProf_GetState();
|
||||
extern void VProf_Enable( vprofState_e state );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SHOW_MATERIALS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void ShowMaterials_Open();
|
||||
extern bool ShowMaterials_Init();
|
||||
extern int rc_MaterialList( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SHOW_SOUNDS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void ShowSounds_Open();
|
||||
extern bool ShowSounds_Init();
|
||||
extern int rc_SoundList( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SHOW_MEMDUMP.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern void ShowMemDump_Open();
|
||||
extern bool ShowMemDump_Init();
|
||||
extern int rc_MemDump( char* commandPtr );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// EXCLUDE_PATHS.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern bool ExcludePathsDlg_Init( void );
|
||||
extern void ExcludePathsDlg_Open( void );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASSERT_DIALOG.CPP
|
||||
//-----------------------------------------------------------------------------
|
||||
extern bool g_AssertDialogActive;
|
||||
int rc_Assert( char *commandPtr );
|
||||
BIN
utils/xbox/vxconsole/vxconsole.ico
Normal file
BIN
utils/xbox/vxconsole/vxconsole.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
557
utils/xbox/vxconsole/vxconsole.rc
Normal file
557
utils/xbox/vxconsole/vxconsole.rc
Normal file
@@ -0,0 +1,557 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_VXCONSOLE ICON "VXConsole.ico"
|
||||
IDI_CONNECT1_ON ICON "icon_connect1.ico"
|
||||
IDI_DISCONNECTED ICON "icon_disconnect.ico"
|
||||
IDI_CONNECT2_OFF ICON "icon_connect2.ico"
|
||||
IDI_CONNECT2_ON ICON "icon_connect2a.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_VXCONSOLE DIALOGEX 7, 18, 416, 203
|
||||
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
EXSTYLE WS_EX_CLIENTEDGE
|
||||
MENU MENU_VXCONSOLE
|
||||
CLASS "VXConsole"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||
BEGIN
|
||||
COMBOBOX IDC_COMMAND,26,182,386,130,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Cmd:",IDC_LABEL,5,184,17,8,SS_CENTERIMAGE
|
||||
CONTROL "",IDC_OUTPUT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_NOHIDESEL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL,5,7,404,170
|
||||
END
|
||||
|
||||
IDD_CONFIG DIALOGEX 0, 0, 412, 151
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDC_OK,355,130,50,14
|
||||
PUSHBUTTON "Cancel",IDC_CANCEL,296,130,50,14
|
||||
LTEXT "Target XBox Name:",IDC_STATIC,7,7,126,9
|
||||
EDITTEXT IDC_CONFIG_XBOXNAME,7,18,148,13,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Ping",IDC_CONFIG_PING,163,18,43,13
|
||||
CONTROL "Clear Log On Connect",IDC_CONFIG_CLEARONCONNECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,17,149,12
|
||||
CONTROL "Always Auto-Connect At Startup",IDC_CONFIG_ALWAYSAUTOCONNECT,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,33,149,12
|
||||
CONTROL "Start Minimized",IDC_CONFIG_STARTMINIMIZED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,49,149,12
|
||||
EDITTEXT IDC_CONFIG_INSTALLPATH,7,117,199,13,ES_AUTOHSCROLL
|
||||
LTEXT "PC Local Game Path: (Example: u:\\dev\\game)",IDC_STATIC,7,37,199,9
|
||||
EDITTEXT IDC_CONFIG_LOCALPATH,7,49,199,13,ES_AUTOHSCROLL
|
||||
LTEXT "XBox Target HDD Path: (Example: e:\\valve)",IDC_STATIC,7,70,199,9
|
||||
EDITTEXT IDC_CONFIG_TARGETPATH,7,81,199,13,ES_AUTOHSCROLL
|
||||
LTEXT "Installation Depot:",IDC_STATIC,7,105,116,9
|
||||
CONTROL "Enable Capture Debug Spew At Startup",IDC_CONFIG_CAPTUREDEBUGSPEW,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,65,149,12
|
||||
END
|
||||
|
||||
IDD_SYNCFILES DIALOGEX 0, 0, 227, 154
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Sync Files"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Sync",IDC_OK,170,132,50,14
|
||||
PUSHBUTTON "Cancel",IDC_CANCEL,111,132,50,14
|
||||
LTEXT "XBox Target Path (To):",IDC_STATIC,7,39,116,9
|
||||
EDITTEXT IDC_SYNCFILES_TARGETPATH,7,51,213,13,ES_AUTOHSCROLL
|
||||
LTEXT "PC Source Path (From):",IDC_STATIC,7,7,142,9
|
||||
EDITTEXT IDC_SYNCFILES_LOCALPATH,7,19,213,13,ES_AUTOHSCROLL
|
||||
CONTROL "Force Sync",IDC_SYNCFILES_FORCESYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,89,116,10
|
||||
CONTROL "Skip Writing Files (Test Mode)",IDC_SYNCFILES_NOWRITE,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,105,116,10
|
||||
CONTROL "Verbose",IDC_SYNCFILES_VERBOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,73,116,10
|
||||
END
|
||||
|
||||
IDD_MODIFYBIND DIALOGEX 0, 0, 260, 106
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDC_OK,202,86,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,144,86,50,14
|
||||
LTEXT "Key:",IDC_STATIC,7,7,16,8
|
||||
LTEXT "Static",IDC_MODIFYBIND_KEYCODE,28,7,51,8
|
||||
LTEXT "Menu Name:",IDC_STATIC,7,21,41,8
|
||||
EDITTEXT IDC_MODIFYBIND_MENUNAME,7,31,245,14,ES_AUTOHSCROLL
|
||||
LTEXT "Command:",IDC_STATIC,7,50,35,8
|
||||
EDITTEXT IDC_MODIFYBIND_COMMAND,7,60,243,14,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_BUG DIALOGEX 0, 0, 441, 375
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Bug Reporter"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
EDITTEXT IDC_BUG_TITLE,70,7,361,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_BUG_DESCRIPTION,70,26,361,90,ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL
|
||||
PUSHBUTTON "Take Shot",IDC_BUG_TAKESHOT,7,122,56,14
|
||||
PUSHBUTTON "Save Game",IDC_BUG_SAVEGAME,7,141,56,14
|
||||
PUSHBUTTON "Include .bsp",IDC_BUG_INCLUDEBSP,7,159,56,14
|
||||
PUSHBUTTON "Include .vmf",IDC_BUG_INCLUDEVMF,7,178,56,14
|
||||
CONTROL "Compress Screenshot",IDC_BUG_COMPRESS_SCREENSHOT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,298,104,10
|
||||
COMBOBOX IDC_BUG_OWNER,282,202,152,195,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BUG_SEVERITY,282,221,152,77,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BUG_REPORTTYPE,282,240,152,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BUG_PRIORITY,282,259,152,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BUG_GAME,282,278,152,195,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BUG_AREA,282,297,152,125,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_BUG_MAPNUMBER,282,316,152,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Clear Form",IDC_BUG_CLEARFORM,7,354,50,14
|
||||
PUSHBUTTON "Update",IDC_BUG_UPDATE,67,354,50,14
|
||||
PUSHBUTTON "Cancel",IDC_CANCEL,321,354,50,14
|
||||
DEFPUSHBUTTON "Submit",IDC_BUG_SUBMIT,384,354,50,14
|
||||
LTEXT "Title:",IDC_STATIC,7,7,45,8
|
||||
LTEXT "Description:",IDC_STATIC,7,26,45,8
|
||||
LTEXT "Position:",IDC_STATIC,7,204,44,8
|
||||
LTEXT "Orientation:",IDC_STATIC,7,223,44,8
|
||||
LTEXT "Map:",IDC_STATIC,7,242,44,8
|
||||
LTEXT "Build:",IDC_STATIC,7,261,44,8
|
||||
LTEXT "Submitter:",IDC_STATIC,7,280,40,8
|
||||
LTEXT "",IDC_BUG_POSITION_LABEL,70,201,152,14,SS_SUNKEN
|
||||
LTEXT "",IDC_BUG_ORIENTATION_LABEL,70,220,152,14,SS_SUNKEN
|
||||
LTEXT "",IDC_BUG_MAP_LABEL,70,239,152,14,SS_SUNKEN
|
||||
LTEXT "",IDC_BUG_BUILD_LABEL,70,258,152,14,SS_SUNKEN
|
||||
LTEXT "",IDC_BUG_SUBMITTER_LABEL,70,277,152,14,SS_SUNKEN
|
||||
LTEXT "Owner:",IDC_STATIC,232,204,40,8
|
||||
LTEXT "Severity:",IDC_STATIC,232,223,40,8
|
||||
LTEXT "Report Type:",IDC_STATIC,232,242,44,8
|
||||
LTEXT "Priority:",IDC_STATIC,232,261,26,8
|
||||
LTEXT "Game:",IDC_STATIC,231,280,40,8
|
||||
LTEXT "Area:",IDC_STATIC,232,299,19,8
|
||||
LTEXT "Map Number:",IDC_STATIC,232,318,44,8
|
||||
LTEXT "",IDC_BUG_TAKESHOT_LABEL,70,122,364,14,SS_SUNKEN | SS_PATHELLIPSIS
|
||||
LTEXT "",IDC_BUG_SAVEGAME_LABEL,70,141,364,14,SS_SUNKEN | SS_PATHELLIPSIS
|
||||
LTEXT "",IDC_BUG_INCLUDEBSP_LABEL,70,159,364,14,SS_SUNKEN | SS_PATHELLIPSIS
|
||||
LTEXT "",IDC_BUG_INCLUDEVMF_LABEL,70,178,364,14,SS_SUNKEN | SS_PATHELLIPSIS
|
||||
END
|
||||
|
||||
IDD_EXCLUDEPATHS DIALOGEX 0, 0, 412, 313
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Exclude Xbox HDD Paths"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_PATHS_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_CHECKBOXES | WS_BORDER | WS_TABSTOP,7,7,398,276,WS_EX_CLIENTEDGE
|
||||
PUSHBUTTON "Re-Scan",IDC_PATHS_RESCAN,7,292,50,14
|
||||
PUSHBUTTON "Expand All",IDC_PATHS_EXPAND,64,292,50,14
|
||||
PUSHBUTTON "Collapse All",IDC_PATHS_COLLAPSE,122,292,50,14
|
||||
PUSHBUTTON "Cancel",IDC_CANCEL,294,292,50,14
|
||||
DEFPUSHBUTTON "OK",IDC_OK,355,292,50,14
|
||||
CONTROL "Link Game Directories",IDC_PATHS_LINKGAMEDIRS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,188,294,91,10
|
||||
END
|
||||
|
||||
IDD_INSTALL DIALOGEX 0, 0, 492, 261
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Sync to DVD Image"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_INSTALL_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,477,215
|
||||
PUSHBUTTON "Refresh",IDC_INSTALL_REFRESH,7,234,50,14
|
||||
CONTROL "Force Sync",IDC_INSTALL_FORCESYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,236,51,10
|
||||
CONTROL "Exact Image (Deletes Unrelated Files)",IDC_INSTALL_CLEANTARGET,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,185,236,137,10
|
||||
PUSHBUTTON "Cancel",IDC_CANCEL,373,234,50,14
|
||||
DEFPUSHBUTTON "OK",IDC_OK,434,234,50,14
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS
|
||||
BEGIN
|
||||
"X", IDM_AUTOCONNECT, VIRTKEY, CONTROL, NOINVERT
|
||||
"H", IDM_PROFILEHISTORY, VIRTKEY, CONTROL, NOINVERT
|
||||
"S", IDM_PROFILESAMPLES, VIRTKEY, CONTROL, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
MENU_VXCONSOLE MENU
|
||||
BEGIN
|
||||
POPUP "Main"
|
||||
BEGIN
|
||||
MENUITEM "Configuration..", IDM_CONFIG
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Exit", IDM_EXIT
|
||||
END
|
||||
POPUP "Connection"
|
||||
BEGIN
|
||||
MENUITEM "Capture Game Spew", IDM_CAPTUREGAMESPEW
|
||||
MENUITEM "Capture Debug Spew", IDM_CAPTUREDEBUGSPEW
|
||||
MENUITEM "Show Remote Command Traffic", IDM_DEBUGCOMMANDS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Bug Reporter...", IDM_BUG
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Sync Xbox HDD Files...", IDM_SYNCFILES
|
||||
MENUITEM "Sync Xbox HDD To DVD Image...", IDM_SYNCINSTALL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Exclude Xbox HDD Paths...", IDM_EXCLUDEPATHS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Auto Connect\tCtrl+X", IDM_AUTOCONNECT
|
||||
END
|
||||
POPUP "Profiling"
|
||||
BEGIN
|
||||
MENUITEM "TimeStamp Log", IDM_TIMESTAMPLOG
|
||||
MENUITEM "Memory Dump", IDM_MEMORYDUMP
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "Show CPU Usage"
|
||||
BEGIN
|
||||
MENUITEM "Snapshot", IDM_CPU_SAMPLES
|
||||
MENUITEM " History", IDM_CPU_HISTORY
|
||||
END
|
||||
POPUP "Show D3D Usage"
|
||||
BEGIN
|
||||
MENUITEM "Snapshot", IDM_D3D_SAMPLES
|
||||
MENUITEM "History", IDM_D3D_HISTORY
|
||||
END
|
||||
MENUITEM "Show Memory Usage", IDM_SHOWMEMORYUSAGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Playtest Mode", IDM_PLAYTESTMODE
|
||||
END
|
||||
POPUP "Resources"
|
||||
BEGIN
|
||||
MENUITEM "List Materials", IDM_SHOWRESOURCES_MATERIALS
|
||||
MENUITEM "List Models", IDM_SHOWRESOURCES_MODELS
|
||||
MENUITEM "List Textures", IDM_SHOWRESOURCES_TEXTURES
|
||||
MENUITEM "List Sounds", IDM_SHOWRESOURCES_SOUNDS
|
||||
END
|
||||
END
|
||||
|
||||
MENU_CPUPROFILE MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Tick Marks", IDM_CPUPROFILE_TICKMARKS
|
||||
MENUITEM "Colors", IDM_CPUPROFILE_COLORS
|
||||
MENUITEM "FPS", IDM_CPUPROFILE_FPSLABELS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Zoom In\tINS", IDM_CPUPROFILE_ZOOMIN
|
||||
MENUITEM "Zoom Out\tDEL", IDM_CPUPROFILE_ZOOMOUT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Enable", IDM_CPUPROFILE_ENABLE
|
||||
END
|
||||
END
|
||||
|
||||
MENU_SHOWTEXTURES MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Summary...", IDM_OPTIONS_SUMMARY
|
||||
MENUITEM "Refresh", IDM_OPTIONS_REFRESH
|
||||
MENUITEM "Export...", IDM_OPTIONS_EXPORT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Current Frame", IDM_OPTIONS_CURRENTFRAME
|
||||
MENUITEM "Full Path", IDM_OPTIONS_FULLPATH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Draw Texture", IDM_OPTIONS_DRAWTEXTURE
|
||||
END
|
||||
END
|
||||
|
||||
MENU_TEXPROFILE MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Tick Marks", IDM_TEXPROFILE_TICKMARKS
|
||||
MENUITEM "Colors", IDM_TEXPROFILE_COLORS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Zoom In\tINS", IDM_TEXPROFILE_ZOOMIN
|
||||
MENUITEM "Zoom Out\tDEL", IDM_TEXPROFILE_ZOOMOUT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Current Frame", IDM_TEXPROFILE_CURRENTFRAME
|
||||
MENUITEM "Enable", IDM_TEXPROFILE_ENABLE
|
||||
END
|
||||
END
|
||||
|
||||
MENU_BINDOPTIONS MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Modify...", IDM_BINDOPTIONS_MODIFY
|
||||
MENUITEM "Delete", IDM_BINDOPTIONS_DELETE
|
||||
END
|
||||
END
|
||||
|
||||
MENU_SHOWMATERIALS MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Refresh", IDM_OPTIONS_REFRESH
|
||||
MENUITEM "Export", IDM_OPTIONS_EXPORT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Current Frame", IDM_OPTIONS_CURRENTFRAME
|
||||
END
|
||||
END
|
||||
|
||||
MENU_SHOWSOUNDS MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Summary...", IDM_OPTIONS_SUMMARY
|
||||
MENUITEM "Refresh", IDM_OPTIONS_REFRESH
|
||||
MENUITEM "Export...", IDM_OPTIONS_EXPORT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Play", IDM_OPTIONS_PLAYSOUND
|
||||
END
|
||||
END
|
||||
|
||||
MENU_SHOWMEMORYDUMP MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Refresh", IDM_OPTIONS_REFRESH
|
||||
MENUITEM "Export...", IDM_OPTIONS_EXPORT
|
||||
MENUITEM "Summary...", IDM_OPTIONS_SUMMARY
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Size as Bytes", IDM_OPTIONS_BYTES
|
||||
MENUITEM "Size as KB", IDM_OPTIONS_KILOBYTES
|
||||
MENUITEM "Size as MB", IDM_OPTIONS_MEGABYTES
|
||||
MENUITEM "Collapse Output", IDM_OPTIONS_COLLAPSEOUTPUT
|
||||
END
|
||||
END
|
||||
|
||||
MENU_TIMESTAMPLOG MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Clear", IDM_OPTIONS_CLEAR
|
||||
MENUITEM "Export", IDM_OPTIONS_EXPORT
|
||||
END
|
||||
END
|
||||
|
||||
MENU_MEMPROFILE MENU
|
||||
BEGIN
|
||||
POPUP "Options"
|
||||
BEGIN
|
||||
MENUITEM "Tick Marks", IDM_MEMPROFILE_TICKMARKS
|
||||
MENUITEM "Colors", IDM_MEMPROFILE_COLORS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Zoom In\tINS", IDM_MEMPROFILE_ZOOMIN
|
||||
MENUITEM "Zoom Out\t INS", IDM_MEMPROFILE_ZOOMOUT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Enable", IDM_MEMPROFILE_ENABLE
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_CONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 405
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 144
|
||||
END
|
||||
|
||||
IDD_SYNCFILES, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 220
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 146
|
||||
END
|
||||
|
||||
IDD_MODIFYBIND, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 252
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 99
|
||||
END
|
||||
|
||||
IDD_BUG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 434
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 368
|
||||
END
|
||||
|
||||
IDD_EXCLUDEPATHS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 405
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 306
|
||||
END
|
||||
|
||||
IDD_INSTALL, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 485
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 254
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10004 "Interrupted system call."
|
||||
10009 "Bad file number."
|
||||
10013 "Permission denied."
|
||||
10014 "Bad address."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10022 "Invalid argument."
|
||||
10024 "Too many open files."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10035 "Operation would block."
|
||||
10036 "Operation now in progress."
|
||||
10037 "Operation already in progress."
|
||||
10038 "Socket operation on nonsocket."
|
||||
10039 "Destination address required."
|
||||
10040 "Message too long."
|
||||
10041 "Protocol wrong type for socket."
|
||||
10042 "Protocol not available."
|
||||
10043 "Protocol not supported."
|
||||
10044 "Socket type not supported."
|
||||
10045 "Operation not supported on socket."
|
||||
10046 "Protocol family not supported."
|
||||
10047 "Address family not supported by protocol family."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10048 "Address already in use."
|
||||
10049 "Cannot assign requested address."
|
||||
10050 "Network is down."
|
||||
10051 "Network is unreachable."
|
||||
10052 "Network dropped connection on reset."
|
||||
10053 "Software caused connection abort."
|
||||
10054 "Connection reset by peer."
|
||||
10055 "No buffer space available."
|
||||
10056 "Socket is already connected."
|
||||
10057 "Socket is not connected."
|
||||
10058 "Cannot send after socket shutdown."
|
||||
10059 "Too many references: cannot splice."
|
||||
10060 "Connection timed out."
|
||||
10061 "Connection refused."
|
||||
10062 "Too many levels of symbolic links."
|
||||
10063 "File name too long."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10064 "Host is down."
|
||||
10065 "No route to host."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10091 "The network subsystem is unusable."
|
||||
10092 "The Windows Sockets DLL cannot support this application."
|
||||
10093 "Winsock not initialized."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
10101 "Disconnect."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
11001 "Host not found."
|
||||
11002 "Nonauthoritative host not found. Name service maybe not be functioning."
|
||||
11003 "Nonrecoverable error. Name service maybe not be functioning."
|
||||
11004 "Valid name, no data record of requested type."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
85
utils/xbox/vxconsole/vxconsole.vpc
Normal file
85
utils/xbox/vxconsole/vxconsole.vpc
Normal file
@@ -0,0 +1,85 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// VXCONSOLE.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\..\.."
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE;$SRCDIR\x360xdk\include\win32\vs2005"
|
||||
}
|
||||
|
||||
$Linker
|
||||
{
|
||||
$AdditionalDependencies "wsock32.lib comctl32.lib odbc32.lib odbccp32.lib xbdm.lib"
|
||||
$AdditionalLibraryDirectories "$SRCDIR\x360xdk\lib\win32\vs2005"
|
||||
$DelayLoadedDLLs "xbdm.dll"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "VXConsole"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "bindings.cpp"
|
||||
$File "bug.cpp"
|
||||
$File "common.cpp"
|
||||
$File "config.cpp"
|
||||
$File "cpu_profile.cpp"
|
||||
$File "exclude_paths.cpp"
|
||||
$File "fileio.cpp"
|
||||
$File "local_cmds.cpp"
|
||||
$File "progress.cpp"
|
||||
$File "remote_cmds.cpp"
|
||||
$File "show_materials.cpp"
|
||||
$File "show_memdump.cpp"
|
||||
$File "show_sounds.cpp"
|
||||
$File "show_textures.cpp"
|
||||
$File "sync_files.cpp"
|
||||
$File "sys_scriptlib.cpp"
|
||||
$File "sys_utils.cpp"
|
||||
$File "tex_profile.cpp"
|
||||
$File "timestamp_log.cpp"
|
||||
$File "vxconsole.cpp"
|
||||
$File "assert_dialog.cpp"
|
||||
$File "mem_profile.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "$SRCDIR\common\bugreporter\bugreporter.h"
|
||||
$File "$SRCDIR\common\xbox\xbox_vxconsole.h"
|
||||
$File "$SRCDIR\public\tier1\interface.h"
|
||||
$File "$SRCDIR\public\jpeglib\jpeglib.h"
|
||||
$File "$SRCDIR\public\tier0\platform.h"
|
||||
$File "$SRCDIR\public\tier1\strtools.h"
|
||||
$File "resource.h"
|
||||
$File "assert_resource.h"
|
||||
$File "sys_scriptlib.h"
|
||||
$File "sys_utils.h"
|
||||
$File "vxconsole.h"
|
||||
}
|
||||
|
||||
$Folder "Resource Files"
|
||||
{
|
||||
$File "icon_connect1.ico"
|
||||
$File "icon_connect2.ico"
|
||||
$File "icon_connect2a.ico"
|
||||
$File "icon_disconnect.ico"
|
||||
$File "vxconsole.ico"
|
||||
$File "vxconsole.rc"
|
||||
$File "assert_dialog.rc"
|
||||
}
|
||||
|
||||
$Folder "Link Libraries"
|
||||
{
|
||||
$DynamicFile "$SRCDIR\lib\common\jpeglib.lib"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user