diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-16 15:55:33 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-16 15:55:33 +0000 |
commit | 5f6a6445d0156cb9728878688e09884b6a2b0188 (patch) | |
tree | 00259b472eb01869222107c38c279dc510c86481 /src/game.cpp | |
parent | 57b3e0e1f0b835ff2982e9f66c7af402caecd3c1 (diff) | |
download | mana-5f6a6445d0156cb9728878688e09884b6a2b0188.tar.gz mana-5f6a6445d0156cb9728878688e09884b6a2b0188.tar.bz2 mana-5f6a6445d0156cb9728878688e09884b6a2b0188.tar.xz mana-5f6a6445d0156cb9728878688e09884b6a2b0188.zip |
Made a dialog from exit confirmation.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index 8c90f329..a8166fae 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -54,10 +54,14 @@ int startX = 0, startY = 0; int gameTime = 0; OkDialog *deathNotice = NULL; +ConfirmDialog *exitConfirm = NULL; #define EMOTION_TIME 150 #define MAX_TIME 10000 +/** + * Listener used for handling death message. + */ class DeatchNoticeListener : public gcn::ActionListener { public: void action(const std::string &eventId) { @@ -69,6 +73,18 @@ class DeatchNoticeListener : public gcn::ActionListener { } deathNoticeListener; /** + * Listener used for exitting handling. + */ +class ExitListener : public gcn::ActionListener { + void action(const std::string &eventId) { + if (eventId == "yes") { + state = EXIT; + } + exitConfirm = NULL; + } +} exitListener; + +/** * Advances game logic counter. */ Uint32 nextTick(Uint32 interval, void *param) @@ -284,8 +300,13 @@ void do_input() if (event.key.keysym.sym == SDLK_ESCAPE) { - quitDialog->setVisible(true); - quitDialog->requestMoveToTop(); + // Spawn confirm dialog for quitting + if (!exitConfirm) + { + exitConfirm = new ConfirmDialog( + "Quit", "Are you sure you want to quit?", + (gcn::ActionListener*)&exitListener); + } } if (keysym.sym == SDLK_g && !chatWindow->isFocused()) |