From b8609879ee683da6a6cc15222b7d0d7f075095db Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Fri, 15 Sep 2017 03:11:44 +0300
Subject: If critical error happened, show message box (SDL2)

---
 src/logger.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(limited to 'src')

diff --git a/src/logger.cpp b/src/logger.cpp
index 455cc8621..8582d0b4b 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -42,6 +42,10 @@
 
 #include <sstream>
 
+#ifdef USE_SDL2
+#include <SDL_messagebox.h>
+#endif  // USE_SDl2
+
 #ifdef ENABLEDEBUGLOG
 #if defined(__ANDROID__)
 #include <android/log.h>
@@ -369,6 +373,12 @@ void Logger::flush()
 void Logger::safeError(const std::string &error_text)
 {
     log("Error: %s", error_text.c_str());
+#ifdef USE_SDL2
+    SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+        "Error",
+        error_text.c_str(),
+        nullptr);
+#else  // USE_SDL2
 #ifdef WIN32
     MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
 #elif defined __APPLE__
@@ -391,6 +401,7 @@ void Logger::safeError(const std::string &error_text)
 
     std::cerr << "Error: " << error_text << std::endl;
 #endif  // WIN32
+#endif  // USE_SDL2
 
     exit(1);
 }
@@ -399,6 +410,12 @@ void Logger::safeError(const std::string &error_text)
 void Logger::error(const std::string &error_text)
 {
     log("Error: %s", error_text.c_str());
+#ifdef USE_SDL2
+    SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+        "Error",
+        error_text.c_str(),
+        nullptr);
+#else  // USE_SDL2
 #ifdef WIN32
     MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
 #elif defined __APPLE__
@@ -421,6 +438,7 @@ void Logger::error(const std::string &error_text)
 
     std::cerr << "Error: " << error_text << std::endl;
 #endif  // WIN32
+#endif  // USE_SDL2
 
     exit(1);
 }
-- 
cgit v1.2.3-70-g09d2