Browse Source

platform: move MSGBOX implementation to platform backends

pull/2/head
Alibek Omarov 6 years ago
parent
commit
1a700fd06b
  1. 27
      engine/common/system.h
  2. 1
      engine/platform/platform.h
  3. 10
      engine/platform/posix/sys_posix.c
  4. 5
      engine/platform/sdl/sys_sdl.c
  5. 7
      engine/platform/win32/sys_win.c

27
engine/common/system.h

@ -25,33 +25,14 @@ extern "C" { @@ -25,33 +25,14 @@ extern "C" {
#include <setjmp.h>
#include <stdio.h>
#include <time.h>
#ifdef XASH_SDL
#include <SDL_messagebox.h>
#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__ )
/*

1
engine/platform/platform.h

@ -31,6 +31,7 @@ GNU General Public License for more details. @@ -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 );

10
engine/platform/posix/sys_posix.c

@ -88,3 +88,13 @@ void Platform_ShellExecute( const char *path, const char *parms ) @@ -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

5
engine/platform/sdl/sys_sdl.c

@ -37,3 +37,8 @@ void Platform_Sleep( int msec ) @@ -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 );
}

7
engine/platform/win32/sys_win.c

@ -54,3 +54,10 @@ void Platform_ShellExecute( const char *path, const char *parms ) @@ -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

Loading…
Cancel
Save