diff --git a/engine/common/system.h b/engine/common/system.h index 2a9853ae..170c78af 100644 --- a/engine/common/system.h +++ b/engine/common/system.h @@ -25,33 +25,14 @@ extern "C" { #include #include #include - -#ifdef XASH_SDL -#include - -#define MSGBOX( x ) SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Xash Error", x, NULL ) -#define MSGBOX2( x ) SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Host Error", x, host.hWnd ) -#define MSGBOX3( x ) SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Host Recursive Error", x, host.hWnd ) -#elif defined(__ANDROID__) && !defined(XASH_DEDICATED) -#define MSGBOX( x ) Android_MessageBox( "Xash Error", x ) -#define MSGBOX2( x ) Android_MessageBox( "Host Error", x ) -#define MSGBOX3( x ) Android_MessageBox( "Host Recursive Error", x ) -#elif defined _WIN32 -#define MSGBOX( x ) MessageBox( NULL, x, "Xash Error", MB_OK|MB_SETFOREGROUND|MB_ICONSTOP ) -#define MSGBOX2( x ) MessageBox( host.hWnd, x, "Host Error", MB_OK|MB_SETFOREGROUND|MB_ICONSTOP ) -#define MSGBOX3( x ) MessageBox( host.hWnd, x, "Host Recursive Error", MB_OK|MB_SETFOREGROUND|MB_ICONSTOP ) -#else -#define BORDER1 "======================================\n" -#define MSGBOX( x ) fprintf( stderr, BORDER1 "Xash Error: %s\n" BORDER1, x ) -#define MSGBOX2( x ) fprintf( stderr, BORDER1 "Host Error: %s\n" BORDER1, x ) -#define MSGBOX3( x ) fprintf( stderr, BORDER1 "Host Recursive Error: %s\n" BORDER1, x ) -#endif - #include "xash3d_types.h" - #include "const.h" #include "crtlib.h" +#include "platform/platform.h" +#define MSGBOX( x ) Platform_MessageBox( "Xash Error", (x), false ); +#define MSGBOX2( x ) Platform_MessageBox( "Host Error", (x), true ); +#define MSGBOX3( x ) Platform_MessageBox( "Host Recursive Error", (x), true ); #define ASSERT( exp ) if(!( exp )) Sys_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) /* diff --git a/engine/platform/platform.h b/engine/platform/platform.h index 687b4239..0b180b0a 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -31,6 +31,7 @@ GNU General Public License for more details. double Platform_DoubleTime( void ); void Platform_Sleep( int msec ); void Platform_ShellExecute( const char *path, const char *parms ); +void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ); // commented out, as this is an optional feature or maybe implemented in system API directly // see system.c // qboolean Sys_DebuggerPresent( void ); diff --git a/engine/platform/posix/sys_posix.c b/engine/platform/posix/sys_posix.c index 5f6907f2..6291f005 100644 --- a/engine/platform/posix/sys_posix.c +++ b/engine/platform/posix/sys_posix.c @@ -88,3 +88,13 @@ void Platform_ShellExecute( const char *path, const char *parms ) Con_Reportf( S_WARN "Could not find "OPEN_COMMAND" utility\n" ); } } + +#ifdef XASH_DEDICATED +void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) +{ + fprintf( stderr, + "======================================\n" + "%s: %s\n" + "======================================\n, title, message ); +} +#endif diff --git a/engine/platform/sdl/sys_sdl.c b/engine/platform/sdl/sys_sdl.c index 143def4f..8a2e6391 100644 --- a/engine/platform/sdl/sys_sdl.c +++ b/engine/platform/sdl/sys_sdl.c @@ -37,3 +37,8 @@ void Platform_Sleep( int msec ) SDL_Delay( msec ); } #endif // XASH_TIMER == TIMER_SDL + +void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) +{ + SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, title, message, parentMainWindow ? host.hWnd : NULL ); +} diff --git a/engine/platform/win32/sys_win.c b/engine/platform/win32/sys_win.c index c8f2d1a0..bcaedb5c 100644 --- a/engine/platform/win32/sys_win.c +++ b/engine/platform/win32/sys_win.c @@ -54,3 +54,10 @@ void Platform_ShellExecute( const char *path, const char *parms ) ShellExecute( NULL, "open", path, parms, NULL, SW_SHOW ); } + +#ifdef XASH_DEDICATED +void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) +{ + MessageBox( parentMainWindow ? host.hWnd : NULL, message, title, MB_OK|MB_SETFOREGROUND|MB_ICONSTOP ); +} +#endif