1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-04 21:34:41 +00:00

Slightly more sensible error/msgbox handling

This commit is contained in:
fgenesis 2013-06-23 18:50:10 +02:00
commit 26d056d924
15 changed files with 48 additions and 83 deletions

View file

@ -291,8 +291,7 @@ bool exists(const std::string &f, bool makeFatal, bool skipVFS)
if (makeFatal && !e)
{
errorLog(std::string("Could not open [" + f + "]"));
exit(0);
exit_error("Could not open [" + f + "]");
}
return e;
@ -316,10 +315,10 @@ void drawCircle(float radius, int stepSize)
#endif
}
void fatalError(const std::string &message)
void exit_error(const std::string &message)
{
msg(message);
exit(0);
errorLog(message);
exit(1);
}
std::string parseCommand(const std::string &line, const std::string &command)
@ -424,8 +423,7 @@ void errorLog(const std::string &s)
}
else
{
//msg("Core Not Initialized");
//MessageBox(0, s.c_str(), "ErrorLog (Core Not Initalized)", MB_OK);
messageBox("Error!", s);
}
}
@ -775,17 +773,18 @@ std::vector<std::string> getFileList(std::string path, std::string type, int par
return list;
}
std::string msg(const std::string &message)
void messageBox(const std::string& title, const std::string &msg)
{
core->msg(message);
return message;
}
void msgVector(const std::string &name, const Vector &vec)
{
std::ostringstream os;
os << name << ": (" << vec.x <<", " << vec.y << ", " << vec.z << ")";
msg (os.str());
#ifdef BBGE_BUILD_WINDOWS
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
#elif defined(BBGE_BUILD_MACOSX)
cocoaMessageBox(title, msg);
#elif defined(BBGE_BUILD_UNIX)
// !!! FIXME: probably don't want the whole GTK+ dependency in here...
fprintf(stderr, "%s: %s\n", title.c_str(), msg.c_str());
#else
#error Please define your platform.
#endif
}
Vector getNearestPointOnLine(Vector a, Vector b, Vector c)

View file

@ -257,11 +257,9 @@ bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord
std::string parseCommand(const std::string &line, const std::string &command);
std::string msg(const std::string &message);
void messageBox(const std::string &title, const std::string& msg);
void msgVector(const std::string &name, const Vector &vec);
void fatalError(const std::string &message);
void exit_error(const std::string &message);
unsigned hash(const std::string &string);

View file

@ -817,7 +817,7 @@ bool Core::getMetaState()
void Core::errorLog(const std::string &s)
{
messageBox("Message", s);
messageBox("Error!", s);
debugLog(s);
}
@ -827,16 +827,7 @@ void cocoaMessageBox(const std::string &title, const std::string &msg);
void Core::messageBox(const std::string &title, const std::string &msg)
{
#ifdef BBGE_BUILD_WINDOWS
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
#elif defined(BBGE_BUILD_MACOSX)
cocoaMessageBox(title, msg);
#elif defined(BBGE_BUILD_UNIX)
// !!! FIXME: probably don't want the whole GTK+ dependency in here...
fprintf(stderr, "%s: %s\n", title.c_str(), msg.c_str());
#else
#error Please define your platform.
#endif
::messageBox(title, msg);
}
void Core::debugLog(const std::string &s)
@ -1267,7 +1258,7 @@ void Core::init()
if((SDL_Init(0))==-1)
{
exit(0);
exit_error("Failed to init SDL");
}
#endif
@ -1910,16 +1901,15 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
{
errorLog(std::string("SDL Error: ") + std::string(SDL_GetError()));
exit(0);
exit_error(std::string("SDL Error: ") + std::string(SDL_GetError()));
}
#if BBGE_BUILD_OPENGL_DYNAMIC
if (SDL_GL_LoadLibrary(NULL) == -1)
{
errorLog(std::string("SDL_GL_LoadLibrary Error: ") + std::string(SDL_GetError()));
std::string err = std::string("SDL_GL_LoadLibrary Error: ") + std::string(SDL_GetError());
SDL_Quit();
exit(0);
exit_error(err);
}
#endif
}
@ -1943,9 +1933,8 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
{
std::ostringstream os;
os << "Couldn't set resolution [" << width << "x" << height << "]\n" << SDL_GetError();
errorLog(os.str());
SDL_Quit();
exit(0);
exit_error(os.str());
}
#if BBGE_BUILD_OPENGL_DYNAMIC
@ -1953,9 +1942,8 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
{
std::ostringstream os;
os << "Couldn't load OpenGL symbols we need\n";
errorLog(os.str());
SDL_Quit();
exit(0);
exit_error(os.str());
}
#endif
}
@ -2625,13 +2613,6 @@ void Core::setDockIcon(const std::string &ident)
{
}
void Core::msg(const std::string &message)
{
#ifdef BBGE_BUILD_WINDOWS
MessageBox(0, message.c_str(), "Message", MB_OK);
#endif
}
void Core::setMousePosition(const Vector &p)
{
Vector lp = core->mouse.position;
@ -4847,14 +4828,13 @@ void Core::setupFileAccess()
debugLog("Init VFS...");
if(!ttvfs::checkCompat())
exit(1);
exit_error("ttvfs not compatible");
vfs.AddArchiveLoader(new ttvfs::VFSZipArchiveLoader);
if(!vfs.LoadFileSysRoot(false))
{
errorLog("Failed to setup file access");
exit(1);
exit_error("Failed to setup file access");
}
vfs.Prepare();

View file

@ -1175,8 +1175,6 @@ public:
void saveSizedScreenshotTGA(const std::string &filename, int sz, int crop34);
void saveCenteredScreenshotTGA(const std::string &filename, int sz);
virtual void msg(const std::string &message);
bool minimized;
std::string getEnqueuedJumpState();
int cullRadius;

View file

@ -507,8 +507,7 @@ Animation* AnimationLayer::getCurrentAnimation()
{
std::ostringstream os;
os << "skel: " << s->filenameLoaded << " currentAnimation: " << currentAnimation << " is out of range\n error in anim file?";
errorLog(os.str());
exit(-1);
exit_error(os.str());
return 0;
}
return &s->animations[currentAnimation];

View file

@ -288,7 +288,7 @@ void StateManager::registerStateObject(StateObject *stateObject, const std::stri
//getNameFromDerivedClassTypeName(c);
if (stateObject->name.empty())
{
fatalError("StateManager::registerStateObject - Empty name.");
exit_error("StateManager::registerStateObject - Empty name.");
}
if (!stateObjects[stateObject->name])

View file

@ -446,7 +446,6 @@ void Texture::loadPNG(const std::string &file)
width = 64;
height = 64;
Texture::textureError = TEXERR_FILENOTFOUND;
//exit(1);
return;
}
@ -483,7 +482,6 @@ void Texture::loadPNG(const std::string &file)
width = 64;
height = 64;
Texture::textureError = TEXERR_FILENOTFOUND;
//exit(1);
}

View file

@ -306,12 +306,12 @@ Vector VectorPath::getValue(float usePercent)
if (!from && !target)
{
msg ("returning first value");
errorLog("returning first value");
return pathNodes[0].value;
}
else if (!from && target)
{
msg("Unexpected Path node result (UPDATE: Could use current value as from?)");
errorLog("Unexpected Path node result (UPDATE: Could use current value as from?)");
}
else if (from && !target)
{