summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine.cpp19
-rw-r--r--src/engine.h3
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/confirm_dialog.cpp3
4 files changed, 24 insertions, 3 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index a16c7e2c..65fbc431 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -66,8 +66,24 @@ EquipmentWindow *equipmentWindow;
ChargeDialog *chargeDialog;
TradeWindow *tradeWindow;
RequestTradeDialog *requestTradeDialog;
+ConfirmDialog *quitDialog;
std::vector<Spriteset*> monsterset;
+/**
+ * Listener used for exitting handling.
+ */
+class ExitListener : public gcn::ActionListener {
+ void action(const std::string &eventId) {
+ if (eventId == "yes") {
+ state = EXIT;
+ }
+ else
+ {
+ quitDialog->setVisible(false);
+ }
+ }
+} exitListener;
+
char hairtable[16][4][2] = {
// S(x,y) W(x,y) N(x,y) E(x,y)
{ { 0, 0}, {-1, 2}, {-1, 2}, { 0, 2} }, // STAND
@@ -164,6 +180,7 @@ Engine::Engine()
chargeDialog = new ChargeDialog();
tradeWindow = new TradeWindow();
requestTradeDialog = new RequestTradeDialog();
+ quitDialog = new ConfirmDialog("Quit", "Are you sure you want to quit ?", (gcn::ActionListener*)&exitListener);
// Initialize window posisitons
chatWindow->setPosition(0, screen->h - chatWindow->getHeight());
statusWindow->setPosition(screen->w - statusWindow->getWidth() - 5, 5);
@@ -204,6 +221,7 @@ Engine::Engine()
chargeDialog->setVisible(false);
tradeWindow->setVisible(false);
requestTradeDialog->setVisible(false);
+ quitDialog->setVisible(false);
// Do not focus any text field
gui->focusNone();
@@ -254,6 +272,7 @@ Engine::~Engine()
delete itemAmountWindow;
delete tradeWindow;
delete requestTradeDialog;
+ delete quitDialog;
// Delete sprite sets
//delete monsterset;
diff --git a/src/engine.h b/src/engine.h
index 5eebb498..09a366a6 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -32,7 +32,6 @@
#include "gui/chat.h"
#include "gui/inventory.h"
#include "gui/shop.h"
-#include "gui/chat.h"
#include "gui/inventory.h"
#include "gui/status.h"
#include "gui/stats.h"
@@ -44,6 +43,7 @@
#include "gui/item_amount.h"
#include "gui/trade.h"
#include "gui/requesttrade.h"
+#include "gui/confirm_dialog.h"
#include "resources/resourcemanager.h"
#include "map.h"
#include "graphic/spriteset.h"
@@ -73,6 +73,7 @@ extern EquipmentWindow *equipmentWindow;
extern ChargeDialog* chargeDialog;
extern RequestTradeDialog *requestTradeDialog;
extern TradeWindow *tradeWindow;
+extern ConfirmDialog *quitDialog;
extern std::vector<Spriteset*> monsterset;
char get_x_offset(char, char);
char get_y_offset(char, char);
diff --git a/src/game.cpp b/src/game.cpp
index 95bbf384..a4fd8aa7 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -284,7 +284,7 @@ void do_input()
if (event.key.keysym.sym == SDLK_ESCAPE)
{
- state = EXIT;
+ quitDialog->setVisible(true);
}
if (keysym.sym == SDLK_g && !chatWindow->isFocused())
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 84712f26..f9513002 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -88,6 +88,7 @@ ConfirmDialog::~ConfirmDialog()
void ConfirmDialog::action(const std::string &eventId)
{
if (eventId == "yes" || eventId == "no") {
- windowContainer->scheduleDelete(this);
+ // I prefer it to be a window, not a dialog
+ //windowContainer->scheduleDelete(this);
}
}