summaryrefslogtreecommitdiff
path: root/src/log.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-05 15:59:17 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-05 15:59:17 +0100
commit3405b046701e9c08972c1e622259164fc88ac487 (patch)
tree5ecc642c6bf67a9875d2850337b31f9715733c54 /src/log.cpp
parentadb3ae667df8a3d1b4235a98605685af0f0c1805 (diff)
downloadmana-3405b046701e9c08972c1e622259164fc88ac487.tar.gz
mana-3405b046701e9c08972c1e622259164fc88ac487.tar.bz2
mana-3405b046701e9c08972c1e622259164fc88ac487.tar.xz
mana-3405b046701e9c08972c1e622259164fc88ac487.zip
Use SDL2 to show a simple message box on error
Replacing the various OS-specific ways implemented for macOS, Windows and Linux (based on xmessage).
Diffstat (limited to 'src/log.cpp')
-rw-r--r--src/log.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/log.cpp b/src/log.cpp
index 1a37abae..47fe5e0f 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -21,18 +21,13 @@
#include "log.h"
-#ifdef _WIN32
-#include <windows.h>
-#elif __APPLE__
-void MacDialogBox(const std::string &error);
-#endif
+#include <SDL.h>
#include <sys/time.h>
#include <iostream>
#include <sstream>
#include <cstdarg>
#include <cstdio>
-#include <cstdlib>
Logger::Logger():
mLogToStandardOut(true)
@@ -106,16 +101,7 @@ void Logger::log(const char *log_text, ...)
void Logger::error(const std::string &error_text)
{
log("Error: %s", error_text.c_str());
-#ifdef _WIN32
- MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
-#elif defined __APPLE__
- MacDialogBox(error_text);
-#elif defined __linux__ || __linux
std::cerr << "Error: " << error_text << std::endl;
- std::string msg="xmessage \"" + error_text + "\"";
- system(msg.c_str());
-#else
- std::cerr << "Error: " << error_text << std::endl;
-#endif
+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", error_text.c_str(), NULL);
exit(1);
}