* Sys_Dialog for more user friendly error reporting
* (bug #3932) Recovery from bad video settings
This commit is contained in:
parent
4876413217
commit
005f870ebe
13 changed files with 564 additions and 120 deletions
|
@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include <conio.h>
|
||||
#include <wincrypt.h>
|
||||
#include <shlobj.h>
|
||||
#include <psapi.h>
|
||||
|
||||
// Used to determine where to store user-specific files
|
||||
static char homePath[ MAX_OSPATH ] = { 0 };
|
||||
|
@ -82,6 +83,24 @@ char *Sys_DefaultHomePath( void )
|
|||
return homePath;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_TempPath
|
||||
================
|
||||
*/
|
||||
const char *Sys_TempPath( void )
|
||||
{
|
||||
static TCHAR path[ MAX_PATH ];
|
||||
DWORD length;
|
||||
|
||||
length = GetTempPath( sizeof( path ), path );
|
||||
|
||||
if( length > sizeof( path ) || length == 0 )
|
||||
return Sys_DefaultHomePath( );
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_Milliseconds
|
||||
|
@ -543,8 +562,8 @@ 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 )
|
||||
if( Sys_Dialog( DT_YES_NO, va( "%s. Copy console log to clipboard?", error ),
|
||||
"Error" ) == DR_YES )
|
||||
{
|
||||
HGLOBAL memoryHandle;
|
||||
char *clipMemory;
|
||||
|
@ -575,6 +594,37 @@ void Sys_ErrorDialog( const char *error )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_Dialog
|
||||
|
||||
Display a win32 dialog box
|
||||
==============
|
||||
*/
|
||||
dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title )
|
||||
{
|
||||
UINT uType;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
default:
|
||||
case DT_INFO: uType = MB_ICONINFORMATION|MB_OK; break;
|
||||
case DT_WARNING: uType = MB_ICONWARNING|MB_OK; break;
|
||||
case DT_ERROR: uType = MB_ICONERROR|MB_OK; break;
|
||||
case DT_YES_NO: uType = MB_ICONQUESTION|MB_YESNO; break;
|
||||
case DT_OK_CANCEL: uType = MB_ICONWARNING|MB_OKCANCEL; break;
|
||||
}
|
||||
|
||||
switch( MessageBox( NULL, message, title, uType ) )
|
||||
{
|
||||
default:
|
||||
case IDOK: return DR_OK;
|
||||
case IDCANCEL: return DR_CANCEL;
|
||||
case IDYES: return DR_YES;
|
||||
case IDNO: return DR_NO;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
static qboolean SDL_VIDEODRIVER_externallySet = qfalse;
|
||||
#endif
|
||||
|
@ -658,8 +708,43 @@ Sys_SetEnv
|
|||
set/unset environment variables (empty value removes it)
|
||||
==============
|
||||
*/
|
||||
|
||||
void Sys_SetEnv(const char *name, const char *value)
|
||||
{
|
||||
_putenv(va("%s=%s", name, value));
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_PID
|
||||
==============
|
||||
*/
|
||||
int Sys_PID( void )
|
||||
{
|
||||
return GetCurrentProcessId( );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_PIDIsRunning
|
||||
==============
|
||||
*/
|
||||
qboolean Sys_PIDIsRunning( int pid )
|
||||
{
|
||||
DWORD processes[ 1024 ];
|
||||
DWORD numBytes, numProcesses;
|
||||
int i;
|
||||
|
||||
if( !EnumProcesses( processes, sizeof( processes ), &numBytes ) )
|
||||
return qfalse; // Assume it's not running
|
||||
|
||||
numProcesses = numBytes / sizeof( DWORD );
|
||||
|
||||
// Search for the pid
|
||||
for( i = 0; i < numProcesses; i++ )
|
||||
{
|
||||
if( processes[ i ] == pid )
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue