]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_sdl.c
Show SDL message box on Sys_Error for SDL target. Removed Windows message box
[xonotic/darkplaces.git] / sys_sdl.c
index d3564bac89fb0a76a699f9da6ddd092ef9b213ed..757d9d8fdd08f3b60828a1c58f45f69d30f9451e 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
 
 #ifdef WIN32
 #ifdef _MSC_VER
-#if SDL_MAJOR_VERSION == 1
-#pragma comment(lib, "sdl.lib")
-#pragma comment(lib, "sdlmain.lib")
-#else
 #pragma comment(lib, "sdl2.lib")
 #pragma comment(lib, "sdl2main.lib")
 #endif
 #endif
-#endif
 
 #include "quakedef.h"
 
@@ -50,7 +45,7 @@ void Sys_Shutdown (void)
        SDL_Quit();
 }
 
-
+static qboolean nocrashdialog;
 void Sys_Error (const char *error, ...)
 {
        va_list argptr;
@@ -65,11 +60,10 @@ void Sys_Error (const char *error, ...)
        dpvsnprintf (string, sizeof (string), error, argptr);
        va_end (argptr);
 
-       Con_Printf ("Quake Error: %s\n", string);
-
-#ifdef WIN32
-       MessageBox(NULL, string, "Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
-#endif
+       Con_Errorf ("Engine Error: %s\n", string);
+       
+       if(!nocrashdialog)
+               SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Quake Error", string, NULL);
 
        Host_Shutdown ();
        exit (1);
@@ -173,7 +167,6 @@ char *Sys_ConsoleInput(void)
 
 char *Sys_GetClipboardData (void)
 {
-#if SDL_MAJOR_VERSION != 1
        char *data = NULL;
        char *cliptext;
 
@@ -187,31 +180,6 @@ char *Sys_GetClipboardData (void)
        }
 
        return data;
-#elif defined(WIN32)
-       char *data = NULL;
-       char *cliptext;
-
-       if (OpenClipboard (NULL) != 0)
-       {
-               HANDLE hClipboardData;
-
-               if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
-               {
-                       if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
-                       {
-                               size_t allocsize;
-                               allocsize = GlobalSize (hClipboardData) + 1;
-                               data = (char *)Z_Malloc (allocsize);
-                               strlcpy (data, cliptext, allocsize);
-                               GlobalUnlock (hClipboardData);
-                       }
-               }
-               CloseClipboard ();
-       }
-       return data;
-#else
-       return NULL;
-#endif
 }
 
 void Sys_InitConsole (void)
@@ -228,8 +196,16 @@ int main (int argc, char *argv[])
 
        com_argc = argc;
        com_argv = (const char **)argv;
+
+       // Sys_Error this early in startup might screw with automated
+       // workflows or something if we show the dialog by default.
+       nocrashdialog = true;
+
        Sys_ProvideSelfFD();
 
+       // COMMANDLINEOPTION: -nocrashdialog disables "Engine Error" crash dialog boxes
+       if(!COM_CheckParm("-nocrashdialog"))
+               nocrashdialog = false;
        // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
        if(COM_CheckParm("-noterminal"))
                outfd = -1;