]> 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 7bfb041f6c7345cf919d649cfbe3eb0a4b374bc3..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,7 +60,10 @@ void Sys_Error (const char *error, ...)
        dpvsnprintf (string, sizeof (string), error, argptr);
        va_end (argptr);
 
-       Con_Printf ("Quake Error: %s\n", string);
+       Con_Errorf ("Engine Error: %s\n", string);
+       
+       if(!nocrashdialog)
+               SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Quake Error", string, NULL);
 
        Host_Shutdown ();
        exit (1);
@@ -169,31 +167,19 @@ char *Sys_ConsoleInput(void)
 
 char *Sys_GetClipboardData (void)
 {
-#ifdef 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 ();
+       cliptext = SDL_GetClipboardText();
+       if (cliptext != NULL) {
+               size_t allocsize;
+               allocsize = strlen(cliptext) + 1;
+               data = (char *)Z_Malloc (allocsize);
+               strlcpy (data, cliptext, allocsize);
+               SDL_free(cliptext);
        }
+
        return data;
-#else
-       return NULL;
-#endif
 }
 
 void Sys_InitConsole (void)
@@ -210,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;