From 7fccfcafc99fe8a81bee1e2cc32e3e383d238dc2 Mon Sep 17 00:00:00 2001 From: tma Date: Fri, 30 Nov 2007 18:32:52 +0000 Subject: * Add con_log.c to log all console output * Add con_passive.c to cut down on #ifdef DEDICATED in sys_main.c * Add Sys_ErrorDialog to report ERR_FATALs to the user + On Windows use a MessageBox and offer to copy the console log to the clipboard + On everything else print to the terminal and save the console log as crashlog.txt git-svn-id: svn://svn.icculus.org/quake3/trunk@1222 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/sys/sys_win32.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'code/sys/sys_win32.c') diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 64a57a2..18724b3 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -525,3 +525,43 @@ void Sys_Sleep( int msec ) WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), msec ); } +/* +============== +Sys_ErrorDialog + +Display an error message +============== +*/ +void Sys_ErrorDialog( const char *error ) +{ + if( MessageBox( NULL, va( "%s. Copy console log to clipboard?", error ), + NULL, MB_YESNO|MB_ICONERROR ) == IDYES ) + { + HGLOBAL memoryHandle; + char *clipMemory; + + memoryHandle = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, CON_LogSize( ) + 1 ); + clipMemory = (char *)GlobalLock( memoryHandle ); + + if( clipMemory ) + { + char *p = clipMemory; + char buffer[ 1024 ]; + unsigned int size; + + while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 ) + { + Com_Memcpy( p, buffer, size ); + p += size; + } + + *p = '\0'; + + if( OpenClipboard( NULL ) && EmptyClipboard( ) ) + SetClipboardData( CF_TEXT, memoryHandle ); + + GlobalUnlock( clipMemory ); + CloseClipboard( ); + } + } +} -- cgit v1.2.3