main.cpp: Always display errors in a message box

This commit is contained in:
Jonas Kulla 2014-12-23 19:08:50 +01:00
parent b39964a49a
commit 03a6c657c4
1 changed files with 12 additions and 8 deletions

View File

@ -172,20 +172,24 @@ static void printRgssVersion(int ver)
Debug() << buf; Debug() << buf;
} }
static void showInitError(const std::string &msg)
{
Debug() << msg;
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "mkxp", msg.c_str(), 0);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* initialize SDL first */ /* initialize SDL first */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{ {
Debug() << "Error initializing SDL:" << SDL_GetError(); showInitError(std::string("Error initializing SDL: ") + SDL_GetError());
return 0; return 0;
} }
if (!EventThread::allocUserEvents()) if (!EventThread::allocUserEvents())
{ {
Debug() << "Error allocating SDL user events"; showInitError("Error allocating SDL user events");
return 0; return 0;
} }
@ -212,7 +216,7 @@ int main(int argc, char *argv[])
int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG; int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG;
if (IMG_Init(imgFlags) != imgFlags) if (IMG_Init(imgFlags) != imgFlags)
{ {
Debug() << "Error initializing SDL_image:" << SDL_GetError(); showInitError(std::string("Error initializing SDL_image: ") + SDL_GetError());
SDL_Quit(); SDL_Quit();
return 0; return 0;
@ -220,7 +224,7 @@ int main(int argc, char *argv[])
if (TTF_Init() < 0) if (TTF_Init() < 0)
{ {
Debug() << "Error initializing SDL_ttf:" << SDL_GetError(); showInitError(std::string("Error initializing SDL_ttf: ") + SDL_GetError());
IMG_Quit(); IMG_Quit();
SDL_Quit(); SDL_Quit();
@ -229,7 +233,7 @@ int main(int argc, char *argv[])
if (Sound_Init() == 0) if (Sound_Init() == 0)
{ {
Debug() << "Error initializing SDL_sound:" << Sound_GetError(); showInitError(std::string("Error initializing SDL_sound: ") + Sound_GetError());
TTF_Quit(); TTF_Quit();
IMG_Quit(); IMG_Quit();
SDL_Quit(); SDL_Quit();
@ -263,7 +267,7 @@ int main(int argc, char *argv[])
if (!win) if (!win)
{ {
Debug() << "Error creating window:" << SDL_GetError(); showInitError(std::string("Error creating window: ") + SDL_GetError());
return 0; return 0;
} }