diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/inventorywindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 2 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 66 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 2 |
4 files changed, 42 insertions, 29 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index e8457337..347c36ac 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -39,6 +39,7 @@ #include "../inventory.h" #include "../item.h" +#include "../localplayer.h" #include "../resources/iteminfo.h" diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index a46a3fbb..83e98687 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -28,7 +28,7 @@ #include "window.h" -#include "../localplayer.h" +#include "../inventory.h" class Item; class ItemContainer; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 7f82d1b5..ebaba977 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -30,6 +30,7 @@ #include "windowcontainer.h" #include "../being.h" +#include "../beingmanager.h" #include "../floor_item.h" #include "../item.h" #include "../localplayer.h" @@ -48,7 +49,7 @@ extern std::string tradePartnerName; PopupMenu::PopupMenu(): Window(), - mBeing(NULL), + mBeingId(0), mFloorItem(NULL), mItem(NULL) { @@ -66,16 +67,16 @@ PopupMenu::PopupMenu(): void PopupMenu::showPopup(int x, int y, Being *being) { - mBeing = being; + mBeingId = being->getId(); mBrowserBox->clearRows(); - switch (mBeing->getType()) + switch (being->getType()) { case Being::PLAYER: { - // Players can be traded with. Later also attack, follow and + // Players can be traded with. Later also follow and // add as buddy will be options in this menu. - const std::string &name = mBeing->getName(); + const std::string &name = being->getName(); mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); @@ -144,45 +145,56 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) void PopupMenu::handleLink(const std::string& link) { + Being *being = beingManager->findBeing(mBeingId); + + if (!being) + { + mBeingId = 0; + mFloorItem = NULL; + mItem = NULL; + setVisible(false); + return; + } + // Talk To action - if (link == "talk" && mBeing && mBeing->getType() == Being::NPC && + if (link == "talk" && being && being->getType() == Being::NPC && current_npc == 0) { - dynamic_cast<NPC*>(mBeing)->talk(); + dynamic_cast<NPC*>(being)->talk(); } // Trade action - else if (link == "trade" && mBeing && mBeing->getType() == Being::PLAYER) + else if (link == "trade" && being && being->getType() == Being::PLAYER) { - player_node->trade(mBeing); - tradePartnerName = mBeing->getName(); + player_node->trade(being); + tradePartnerName = being->getName(); } // Attack action - else if (link == "attack" && mBeing && mBeing->getType() == Being::PLAYER) + else if (link == "attack" && being && being->getType() == Being::PLAYER) { - player_node->attack(mBeing, true); + player_node->attack(being, true); } - else if (link == "unignore" && mBeing && mBeing->getType() == Being::PLAYER) + else if (link == "unignore" && being && being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::NEUTRAL); + player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL); } - else if (link == "ignore" && mBeing && mBeing->getType() == Being::PLAYER) + else if (link == "ignore" && being && being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::IGNORED); + player_relations.setRelation(being->getName(), PlayerRelation::IGNORED); } - else if (link == "disregard" && mBeing && - mBeing->getType() == Being::PLAYER) + else if (link == "disregard" && being && + being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::DISREGARDED); + player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED); } - else if (link == "friend" && mBeing && mBeing->getType() == Being::PLAYER) + else if (link == "friend" && being && being->getType() == Being::PLAYER) { - player_relations.setRelation(mBeing->getName(), PlayerRelation::FRIEND); + player_relations.setRelation(being->getName(), PlayerRelation::FRIEND); } /* @@ -193,12 +205,12 @@ void PopupMenu::handleLink(const std::string& link) /* // Add Buddy action - else if ((link == "buddy") && mBeing && mBeing->isPlayer()) + else if ((link == "buddy") && being && being->isPlayer()) { if (!buddyWindow->isVisible()) buddyWindow->setVisible(true); - buddyWindow->addBuddy(mBeing->getName()); + buddyWindow->addBuddy(being->getName()); }*/ // Pick Up Floor Item action @@ -241,12 +253,12 @@ void PopupMenu::handleLink(const std::string& link) { new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem); } - else if (link == "party-invite" && mBeing && - mBeing->getType() == Being::PLAYER) + else if (link == "party-invite" && being && + being->getType() == Being::PLAYER) { MessageOut outMsg(player_node->getNetwork()); outMsg.writeInt16(CMSG_PARTY_INVITE); - outMsg.writeInt32(mBeing->getId()); + outMsg.writeInt32(being->getId()); } // Unknown actions @@ -257,7 +269,7 @@ void PopupMenu::handleLink(const std::string& link) setVisible(false); - mBeing = NULL; + mBeingId = 0; mFloorItem = NULL; mItem = NULL; } diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index c62014f9..89152751 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -67,7 +67,7 @@ class PopupMenu : public Window, public LinkHandler private: BrowserBox* mBrowserBox; - Being* mBeing; + int mBeingId; FloorItem* mFloorItem; Item *mItem; |