|
|
|
@ -29,7 +29,10 @@ WIN32 CONSOLE
@@ -29,7 +29,10 @@ WIN32 CONSOLE
|
|
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
{ |
|
|
|
|
char title[64]; |
|
|
|
|
string title; |
|
|
|
|
string previousTitle; |
|
|
|
|
UINT previousCodePage; |
|
|
|
|
UINT previousOutputCodePage; |
|
|
|
|
HWND hWnd; |
|
|
|
|
HANDLE hInput; |
|
|
|
|
HANDLE hOutput; |
|
|
|
@ -45,6 +48,7 @@ typedef struct
@@ -45,6 +48,7 @@ typedef struct
|
|
|
|
|
string lineBuffer[COMMAND_HISTORY]; |
|
|
|
|
qboolean inputEnabled; |
|
|
|
|
qboolean consoleVisible; |
|
|
|
|
qboolean attached; |
|
|
|
|
|
|
|
|
|
// log stuff
|
|
|
|
|
qboolean log_active; |
|
|
|
@ -129,7 +133,7 @@ static void Wcon_PrintInternal( const char *msg, int length )
@@ -129,7 +133,7 @@ static void Wcon_PrintInternal( const char *msg, int length )
|
|
|
|
|
|
|
|
|
|
void Wcon_ShowConsole( qboolean show ) |
|
|
|
|
{ |
|
|
|
|
if( !s_wcd.hWnd || show == s_wcd.consoleVisible ) |
|
|
|
|
if( !s_wcd.hWnd || show == s_wcd.consoleVisible || s_wcd.attached ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
s_wcd.consoleVisible = show; |
|
|
|
@ -482,6 +486,7 @@ void Wcon_WinPrint( const char *pMsg )
@@ -482,6 +486,7 @@ void Wcon_WinPrint( const char *pMsg )
|
|
|
|
|
Wcon_PrintInternal( s_wcd.consoleText, s_wcd.consoleTextLen ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( !s_wcd.attached ) |
|
|
|
|
Wcon_UpdateStatusLine(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -509,7 +514,16 @@ void Wcon_CreateConsole( void )
@@ -509,7 +514,16 @@ void Wcon_CreateConsole( void )
|
|
|
|
|
s_wcd.log_active = true; // always make log
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s_wcd.attached = ( AttachConsole( ATTACH_PARENT_PROCESS ) != 0 ); |
|
|
|
|
if( s_wcd.attached ) { |
|
|
|
|
GetConsoleTitle( &s_wcd.previousTitle, sizeof( s_wcd.previousTitle )); |
|
|
|
|
s_wcd.previousCodePage = GetConsoleCP(); |
|
|
|
|
s_wcd.previousOutputCodePage = GetConsoleOutputCP(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
AllocConsole(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SetConsoleTitle( s_wcd.title ); |
|
|
|
|
SetConsoleCP( CP_UTF8 ); |
|
|
|
|
SetConsoleOutputCP( CP_UTF8 ); |
|
|
|
@ -525,6 +539,8 @@ void Wcon_CreateConsole( void )
@@ -525,6 +539,8 @@ void Wcon_CreateConsole( void )
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( !s_wcd.attached ) |
|
|
|
|
{ |
|
|
|
|
SetWindowPos( s_wcd.hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOREPOSITION | SWP_SHOWWINDOW ); |
|
|
|
|
|
|
|
|
|
// show console if needed
|
|
|
|
@ -543,6 +559,7 @@ void Wcon_CreateConsole( void )
@@ -543,6 +559,7 @@ void Wcon_CreateConsole( void )
|
|
|
|
|
ShowWindow( s_wcd.hWnd, SW_HIDE ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
================ |
|
|
|
@ -573,11 +590,22 @@ void Wcon_DestroyConsole( void )
@@ -573,11 +590,22 @@ void Wcon_DestroyConsole( void )
|
|
|
|
|
|
|
|
|
|
Sys_CloseLog(); |
|
|
|
|
|
|
|
|
|
if( !s_wcd.attached ) |
|
|
|
|
{ |
|
|
|
|
if( s_wcd.hWnd ) |
|
|
|
|
{ |
|
|
|
|
ShowWindow( s_wcd.hWnd, SW_HIDE ); |
|
|
|
|
s_wcd.hWnd = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// reverts title & code page for console window that was before starting Xash3D
|
|
|
|
|
SetConsoleCP( s_wcd.previousCodePage ); |
|
|
|
|
SetConsoleOutputCP( s_wcd.previousOutputCodePage ); |
|
|
|
|
SetConsoleTitle( &s_wcd.previousTitle ); |
|
|
|
|
Con_Printf( "Press Enter to continue...\n" ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FreeConsole(); |
|
|
|
|
|
|
|
|
@ -595,8 +623,8 @@ returned input text
@@ -595,8 +623,8 @@ returned input text
|
|
|
|
|
*/ |
|
|
|
|
char *Wcon_Input( void ) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
|
int eventsCount; |
|
|
|
|
DWORD i; |
|
|
|
|
DWORD eventsCount; |
|
|
|
|
static INPUT_RECORD events[1024]; |
|
|
|
|
|
|
|
|
|
if( !s_wcd.inputEnabled ) |
|
|
|
@ -642,7 +670,7 @@ set server status string in console
@@ -642,7 +670,7 @@ set server status string in console
|
|
|
|
|
*/ |
|
|
|
|
void Wcon_SetStatus( const char *pStatus ) |
|
|
|
|
{ |
|
|
|
|
if( host.type != HOST_DEDICATED ) |
|
|
|
|
if( host.type != HOST_DEDICATED || s_wcd.attached ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
Q_strncpy( s_wcd.statusLine, pStatus, sizeof( s_wcd.statusLine ) - 1 ); |
|
|
|
|