summaryrefslogtreecommitdiff
path: root/src/gui/popupmenu.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-12 01:53:54 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-12 01:53:54 +0300
commitfca4273667f15afba055d3c296094f2f41c7ae91 (patch)
treed2a24602a4a60814a5927384570d2873bed83225 /src/gui/popupmenu.cpp
parent44e80c70513022b6c378f64d6bf5d25dda7b0e7f (diff)
downloadplus-fca4273667f15afba055d3c296094f2f41c7ae91.tar.gz
plus-fca4273667f15afba055d3c296094f2f41c7ae91.tar.bz2
plus-fca4273667f15afba055d3c296094f2f41c7ae91.tar.xz
plus-fca4273667f15afba055d3c296094f2f41c7ae91.zip
Add ability to add comments to npcs.
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r--src/gui/popupmenu.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 9cf9e536e..14a326e41 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -22,6 +22,7 @@
#include "gui/popupmenu.h"
+#include "actorsprite.h"
#include "actorspritemanager.h"
#include "being.h"
#include "dropshortcut.h"
@@ -94,7 +95,8 @@ PopupMenu::PopupMenu():
mSpell(0),
mDialog(0),
mButton(0),
- mNick("")
+ mNick(""),
+ mType(Being::UNKNOWN)
{
mBrowserBox = new BrowserBox;
mBrowserBox->setPosition(4, 4);
@@ -105,6 +107,7 @@ PopupMenu::PopupMenu():
mRenameListener.setDialog(0);
mPlayerListener.setNick("");
mPlayerListener.setDialog(0);
+ mPlayerListener.setType(Being::UNKNOWN);
add(mBrowserBox);
}
@@ -116,6 +119,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBeingId = being->getId();
mNick = being->getName();
+ mType = being->getType();
mBrowserBox->clearRows();
const std::string &name = mNick;
@@ -278,6 +282,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell")));
mBrowserBox->addRow("##3---");
mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
+ mBrowserBox->addRow(strprintf("@@addcomment|%s@@",
+ _("Add comment")));
break;
case ActorSprite::MONSTER:
@@ -359,6 +365,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mNick = nick;
mBeingId = 0;
+ mType = Being::PLAYER;
mBrowserBox->clearRows();
const std::string &name = mNick;
@@ -599,6 +606,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
mBeingId = being->getId();
mNick = being->getName();
+ mType = being->getType();
mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
@@ -728,6 +736,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
else
{
mNick = name;
+ mType = Being::PLAYER;
mBrowserBox->addRow(strprintf(
"@@addcomment|%s@@", _("Add comment")));
mBrowserBox->addRow("##3---");
@@ -768,6 +777,7 @@ void PopupMenu::showChangePos(int x, int y)
mItem = 0;
mMapItem = 0;
mNick = "";
+ mType = Being::UNKNOWN;
setVisible(false);
}
}
@@ -1220,6 +1230,7 @@ void PopupMenu::handleLink(const std::string &link,
_("Comment: "));
mPlayerListener.setDialog(dialog);
mPlayerListener.setNick(mNick);
+ mPlayerListener.setType(mType);
if (being)
{
@@ -1228,7 +1239,7 @@ void PopupMenu::handleLink(const std::string &link,
}
else
{
- dialog->setText(Being::loadComment(mNick));
+ dialog->setText(Being::loadComment(mNick, mType));
}
dialog->setActionEventId("ok");
dialog->addActionListener(&mPlayerListener);
@@ -1560,6 +1571,7 @@ void PopupMenu::handleLink(const std::string &link,
mItemColor = 1;
mMapItem = 0;
mNick = "";
+ mType = Being::UNKNOWN;
}
void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
@@ -1870,6 +1882,7 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
return;
mNick = name;
+ mType = Being::MONSTER;
mBrowserBox->clearRows();
@@ -2001,7 +2014,8 @@ void RenameListener::action(const gcn::ActionEvent &event)
PlayerListener::PlayerListener() :
mNick(""),
- mDialog(0)
+ mDialog(0),
+ mType(Being::UNKNOWN)
{
}
@@ -2011,10 +2025,10 @@ void PlayerListener::action(const gcn::ActionEvent &event)
{
std::string comment = mDialog->getText();
Being* being = actorSpriteManager->findBeingByName(
- mNick, Being::PLAYER);
+ mNick, (ActorSprite::Type)mType);
if (being)
being->setComment(comment);
- Being::saveComment(mNick, comment);
+ Being::saveComment(mNick, comment, mType);
}
mDialog = 0;
}