summaryrefslogtreecommitdiff
path: root/src/gui/popupmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r--src/gui/popupmenu.cpp108
1 files changed, 62 insertions, 46 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 7f82d1b5..62e44794 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,6 +29,7 @@
#include "windowcontainer.h"
#include "../being.h"
+#include "../beingmanager.h"
#include "../floor_item.h"
#include "../item.h"
#include "../localplayer.h"
@@ -48,7 +48,7 @@ extern std::string tradePartnerName;
PopupMenu::PopupMenu():
Window(),
- mBeing(NULL),
+ mBeingId(0),
mFloorItem(NULL),
mItem(NULL)
{
@@ -56,7 +56,7 @@ PopupMenu::PopupMenu():
setTitleBarHeight(0);
setShowTitle(false);
- mBrowserBox = new BrowserBox();
+ mBrowserBox = new BrowserBox;
mBrowserBox->setPosition(4, 4);
mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND);
mBrowserBox->setOpaque(false);
@@ -66,38 +66,38 @@ 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
// 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()));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name)) {
- case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str()));
-
- case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str()));
- mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str()));
- break;
-
- case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
- mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str()));
- break;
-
- case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
- break;
+ case PlayerRelation::NEUTRAL:
+ mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str()));
+
+ case PlayerRelation::FRIEND:
+ mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str()));
+ break;
+
+ case PlayerRelation::DISREGARDED:
+ mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
+ mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str()));
+ break;
+
+ case PlayerRelation::IGNORED:
+ mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str()));
+ break;
}
//mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@");
@@ -144,45 +144,60 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
void PopupMenu::handleLink(const std::string& link)
{
+ Being *being = beingManager->findBeing(mBeingId);
+
// 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 +208,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 +256,13 @@ 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 +273,7 @@ void PopupMenu::handleLink(const std::string& link)
setVisible(false);
- mBeing = NULL;
+ mBeingId = 0;
mFloorItem = NULL;
mItem = NULL;
}