summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-13 02:55:05 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-13 02:55:05 +0000
commit682d6a9e44e583c088ed5970d69ef6bd9db7fd23 (patch)
tree73079cdd7d9b57d104c8db400f09aabc3d833122 /src/main.cpp
parent3657bf87641144b605d49767cf466f04242c29c9 (diff)
downloadmana-client-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.tar.gz
mana-client-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.tar.bz2
mana-client-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.tar.xz
mana-client-682d6a9e44e583c088ed5970d69ef6bd9db7fd23.zip
Got rid of Allegro ok dialog completely. Now just the yes_no dialog remaining.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 57422e63..61de436f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,6 +25,7 @@
#include "gui/char_server.h"
#include "gui/char_select.h"
#include "gui/inventory.h"
+#include "gui/ok_dialog.h"
#include "./sound/sound.h"
#include "./graphic/graphic.h"
@@ -97,8 +98,31 @@ Sound sound;
// ini file configuration reader
Configuration config;
+
+/**
+ * Listener used for responding to map start error dialog.
+ */
+class MapStartErrorListener : public gcn::ActionListener {
+ void action(const std::string &eventId) {
+ if (eventId == "ok") {
+ state = LOGIN;
+ }
+ }
+} mapStartErrorListener;
+
+/**
+ * Listener used for responding to init warning.
+ */
+class InitWarningListener : public gcn::ActionListener {
+ void action(const std::string &eventId) {
+ if (eventId == "ok") {
+ state = LOGIN;
+ }
+ }
+} initWarningListener;
+
void request_exit() {
- state = EXIT;
+ state = EXIT;
}
/**
@@ -314,9 +338,11 @@ void init_engine() {
SOUND_SID id = sound.loadItem("./data/sound/wavs/level.ogg");
sound.startItem(id, 70);
*/
- } catch (const char *err) {
- ok("Sound Engine", err);
- warning(err);
+ }
+ catch (const char *err) {
+ state = ERROR;
+ new OkDialog("Sound Engine", err, &initWarningListener);
+ warning(err);
}
#endif /* not WIN32 */
}
@@ -353,9 +379,21 @@ int main() {
sound.stopBgm();
#endif /* not WIN32 */
status("GAME");
- map_start();
- if (state == GAME)
+ try {
+ map_start();
game();
+ }
+ catch (const char* err) {
+ state = ERROR;
+ new OkDialog("Error", err, &mapStartErrorListener);
+ }
+ break;
+ case ERROR:
+ // Redraw GUI
+ blit(login_wallpaper, buffer, 0, 0, 0, 0, 800, 600);
+ guiGraphics->setTarget(buffer);
+ gui->update();
+ blit(buffer, screen, 0, 0, 0, 0, 800, 600);
break;
default:
state = EXIT;