display MessageBox in win32 on fatal errors

This commit is contained in:
Eduardo Bart 2011-11-17 00:31:06 -02:00
parent 69ae043001
commit 69a70f28a5
9 changed files with 24 additions and 8 deletions

View File

@ -15,4 +15,4 @@ Module
- textmessage - textmessage
- chat - chat
- outfit - outfit
- tibiafiles

@ -1 +0,0 @@
Subproject commit 8bb3b7d6d86e561be4622fbe7dbef208446a0319

View File

@ -22,6 +22,7 @@
#include "logger.h" #include "logger.h"
#include "eventdispatcher.h" #include "eventdispatcher.h"
#include <framework/platform/platform.h>
Logger g_logger; Logger g_logger;
@ -47,6 +48,7 @@ void Logger::log(Fw::LogLevel level, std::string message)
if(level == Fw::LogFatal) { if(level == Fw::LogFatal) {
m_terminated = true; m_terminated = true;
g_platform.displayFatalError(message);
exit(-1); exit(-1);
} }
} }

View File

@ -42,7 +42,7 @@ void ModuleManager::discoverAndLoadModules()
for(const ModulePtr& module : m_modules) { for(const ModulePtr& module : m_modules) {
if(!module->isLoaded() && module->autoLoad()) { if(!module->isLoaded() && module->autoLoad()) {
if(!module->load()) if(!module->load())
logFatal("cannot continue to run"); logFatal("A required module has failed to load, cannot continue to run.");
} }
} }
} }

View File

@ -52,7 +52,7 @@ void ResourceManager::init(const char* argv0, const char *appName)
} }
if(!found) if(!found)
logFatal("could not find modules directory"); logFatal("Could not find modules directory.");
// setup write directory // setup write directory
std::string dir = g_platform.getAppUserDir(); std::string dir = g_platform.getAppUserDir();

View File

@ -82,6 +82,8 @@ public:
/// Get the app user directory, the place to save files configurations files /// Get the app user directory, the place to save files configurations files
std::string getAppUserDir(); std::string getAppUserDir();
void displayFatalError(const std::string& message);
private: private:
int m_lastTicks; int m_lastTicks;
}; };

View File

@ -289,7 +289,7 @@ void Platform::init(PlatformListener* platformListener, const char *appName)
wc.lpszClassName = win32.appName.c_str(); // Set The Class Name wc.lpszClassName = win32.appName.c_str(); // Set The Class Name
if(!RegisterClassA(&wc)) if(!RegisterClassA(&wc))
logFatal("FATAL ERROR: Failed to register the window class."); logFatal("Failed to register the window class.");
// force first tick // force first tick
updateTicks(); updateTicks();
@ -737,3 +737,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
return 0; return 0;
} }
void Platform::displayFatalError(const std::string& message)
{
MessageBoxA(NULL, message.c_str(), "Fatal Error", MB_OK | MB_ICONERROR);
}

View File

@ -962,3 +962,8 @@ std::string Platform::getAppUserDir()
logError("Couldn't create directory for saving configuration file. (",sdir.str(),")"); logError("Couldn't create directory for saving configuration file. (",sdir.str(),")");
return sdir.str(); return sdir.str();
} }
void Platform::displayFatalError(const std::string& message)
{
// nothing to do
}

View File

@ -80,9 +80,6 @@ void OTClient::init(std::vector<std::string> args)
// initialize event dispatcher // initialize event dispatcher
g_dispatcher.init(); g_dispatcher.init();
// initialize network
//g_network.init();
// initialize the ui // initialize the ui
g_ui.init(); g_ui.init();
@ -91,6 +88,11 @@ void OTClient::init(std::vector<std::string> args)
// discover and load modules // discover and load modules
g_modules.discoverAndLoadModules(); g_modules.discoverAndLoadModules();
g_modules.getModule("otclient")->load(); g_modules.getModule("otclient")->load();
ModulePtr tibiaFilesModule = g_modules.getModule("tibiafiles");
if(!tibiaFilesModule || !tibiaFilesModule->isLoaded()) {
logFatal("Could not find or load 'tibiafiles' module, this module contains SPR and DAT files.\n"
"Please download it and place in modules directory, then try running again.");
}
// now that everything is initialized, setup configurations // now that everything is initialized, setup configurations
setupConfigurations(); setupConfigurations();