diff options
author | Jan-Fabian Humann <malastare@gmx.net> | 2005-05-22 19:36:19 +0000 |
---|---|---|
committer | Jan-Fabian Humann <malastare@gmx.net> | 2005-05-22 19:36:19 +0000 |
commit | 4852d95f4bd03f2e258744e2dc7ef91d4aa9f349 (patch) | |
tree | 9e0efde60adf4b96395290495062d63f9046b45e | |
parent | 2a1af1a5dbcca1c890f38f20385e5d2639fd48db (diff) | |
download | mana-4852d95f4bd03f2e258744e2dc7ef91d4aa9f349.tar.gz mana-4852d95f4bd03f2e258744e2dc7ef91d4aa9f349.tar.bz2 mana-4852d95f4bd03f2e258744e2dc7ef91d4aa9f349.tar.xz mana-4852d95f4bd03f2e258744e2dc7ef91d4aa9f349.zip |
requestTradeDialog is modal now
-rw-r--r-- | src/engine.cpp | 8 | ||||
-rw-r--r-- | src/engine.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/gui/requesttrade.cpp | 30 | ||||
-rw-r--r-- | src/gui/requesttrade.h | 7 |
5 files changed, 16 insertions, 35 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 2049d53f..938068b7 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -33,7 +33,6 @@ #include "main.h" #include "being.h" #include "floor_item.h" -#include "gui/requesttrade.h" char itemCurrenyQ[10] = "0"; int map_x, map_y, camera_x, camera_y; @@ -62,7 +61,6 @@ Minimap *minimap; EquipmentWindow *equipmentWindow; ChargeDialog *chargeDialog; TradeWindow *tradeWindow; -RequestTradeDialog *requestTradeDialog; BuddyWindow *buddyWindow; Menu *menu; std::map<int, Spriteset*> monsterset; @@ -162,7 +160,6 @@ Engine::Engine() chargeDialog = new ChargeDialog(); tradeWindow = new TradeWindow(); buddyWindow = new BuddyWindow(); - requestTradeDialog = new RequestTradeDialog(); /* Menu items */ std::vector<MenuItem*> items; @@ -186,9 +183,6 @@ Engine::Engine() inventoryWindow->getY() + inventoryWindow->getHeight()); buddyWindow->setPosition(10, minimap->getHeight() + 30); - requestTradeDialog->setPosition(screen->w - statusWindow->getWidth() - - requestTradeDialog->getWidth() - 10, - chatWindow->getHeight() + 15); equipmentWindow->setPosition(5,140); menu->setPosition(5,140); @@ -209,7 +203,6 @@ Engine::Engine() chargeDialog->setVisible(false); tradeWindow->setVisible(false); buddyWindow->setVisible(false); - requestTradeDialog->setVisible(false); menu->setVisible(false); // Do not focus any text field @@ -255,7 +248,6 @@ Engine::~Engine() delete newSkillWindow; delete tradeWindow; delete buddyWindow; - delete requestTradeDialog; // Delete sprite sets //delete monsterset; diff --git a/src/engine.h b/src/engine.h index f8edd270..05bcec68 100644 --- a/src/engine.h +++ b/src/engine.h @@ -43,7 +43,6 @@ #include "gui/chargedialog.h" #include "gui/menu.h" #include "gui/trade.h" -#include "gui/requesttrade.h" #include "resources/resourcemanager.h" #include "map.h" #include "graphic/spriteset.h" @@ -70,7 +69,6 @@ extern StatsWindow *statsWindow; extern Setup *setupWindow; extern EquipmentWindow *equipmentWindow; extern ChargeDialog* chargeDialog; -extern RequestTradeDialog *requestTradeDialog; extern TradeWindow *tradeWindow; extern BuddyWindow *buddyWindow; extern Menu *menu; diff --git a/src/game.cpp b/src/game.cpp index ee52b0c3..3865b575 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -37,6 +37,7 @@ #include "gui/stats.h" #include "gui/ok_dialog.h" #include "gui/confirm_dialog.h" +#include "gui/requesttrade.h" #include "net/protocol.h" #include "resources/mapreader.h" #include <SDL.h> @@ -786,8 +787,7 @@ void do_parse() // Trade: Receiving a request to trade case 0x00e5: - //printf("Getting a call from %s\n", RFIFOP(2)); - requestTradeDialog->request(RFIFOP(2)); + new RequestTradeDialog(RFIFOP(2)); break; // Trade: Response diff --git a/src/gui/requesttrade.cpp b/src/gui/requesttrade.cpp index 9cbdf7b2..66ca6480 100644 --- a/src/gui/requesttrade.cpp +++ b/src/gui/requesttrade.cpp @@ -26,8 +26,8 @@ #include "../game.h" #include "../net/network.h" -RequestTradeDialog::RequestTradeDialog(): - Window("Request for Trade") +RequestTradeDialog::RequestTradeDialog(const char *name): + Window("Request for Trade", true) { nameLabel[0] = new gcn::Label(""); nameLabel[1] = new gcn::Label(""); @@ -56,6 +56,15 @@ RequestTradeDialog::RequestTradeDialog(): add(acceptButton); add(cancelButton); + std::stringstream cap[2]; + cap[0] << name << " wants to trade with you."; + cap[1] << "Do you want to accept?"; + + nameLabel[0]->setCaption(cap[0].str()); + nameLabel[0]->adjustSize(); + nameLabel[1]->setCaption(cap[1].str()); + nameLabel[1]->adjustSize(); + setLocationRelativeTo(getParent()); } @@ -66,19 +75,6 @@ RequestTradeDialog::~RequestTradeDialog() for (int i = 0; i < 2; i++) { delete nameLabel[i]; } -} - -void RequestTradeDialog::request(const char *name) -{ - std::stringstream cap; - std::stringstream captwo; - cap << name << " wants to trade with you."; - captwo << "Do you want to accept?"; - nameLabel[0]->setCaption(cap.str()); - nameLabel[0]->adjustSize(); - nameLabel[1]->setCaption(captwo.str()); - nameLabel[1]->adjustSize(); - setVisible(true); } void RequestTradeDialog::action(const std::string& eventId) @@ -88,13 +84,13 @@ void RequestTradeDialog::action(const std::string& eventId) WFIFOW(0) = net_w_value(0x00e6); WFIFOB(2) = net_b_value(3); WFIFOSET(3); - setVisible(false); + scheduleDelete(); } else if (eventId == "cancel") { // 0xff packet means cancel WFIFOW(0) = net_w_value(0x00e6); WFIFOB(2) = net_b_value(4); WFIFOSET(3); - setVisible(false); + scheduleDelete(); } } diff --git a/src/gui/requesttrade.h b/src/gui/requesttrade.h index 3d6c4c22..3573cb69 100644 --- a/src/gui/requesttrade.h +++ b/src/gui/requesttrade.h @@ -43,7 +43,7 @@ class RequestTradeDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - RequestTradeDialog(); + RequestTradeDialog(const char *name); /** * Destructor. @@ -51,11 +51,6 @@ class RequestTradeDialog : public Window, public gcn::ActionListener ~RequestTradeDialog(); /** - * Changes caption and brings window to the top - */ - void request(const char *name); - - /** * Called when receiving actions from the widgets. */ void action(const std::string& eventId); |