diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-08-12 01:53:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-08-12 01:53:54 +0300 |
commit | fca4273667f15afba055d3c296094f2f41c7ae91 (patch) | |
tree | d2a24602a4a60814a5927384570d2873bed83225 /src/gui | |
parent | 44e80c70513022b6c378f64d6bf5d25dda7b0e7f (diff) | |
download | manaverse-fca4273667f15afba055d3c296094f2f41c7ae91.tar.gz manaverse-fca4273667f15afba055d3c296094f2f41c7ae91.tar.bz2 manaverse-fca4273667f15afba055d3c296094f2f41c7ae91.tar.xz manaverse-fca4273667f15afba055d3c296094f2f41c7ae91.zip |
Add ability to add comments to npcs.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/beingpopup.cpp | 6 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 24 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 5 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 3 |
4 files changed, 32 insertions, 6 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index e5dc602a0..8d7b26c1b 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -89,6 +89,12 @@ void BeingPopup::show(int x, int y, Being *b) b->updateComment(); + if (b->getType() == Being::NPC && b->getComment().empty()) + { + setVisible(false); + return; + } + mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace()); if (gui) { 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; } diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index afa4bdfa2..3a7f27d4b 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -78,9 +78,13 @@ class PlayerListener : public gcn::ActionListener void setDialog(TextDialog *dialog) { mDialog = dialog; } + void setType(int type) + { mType = type; } + private: std::string mNick; TextDialog *mDialog; + int mType; }; /** @@ -171,6 +175,7 @@ class PopupMenu : public Popup, public LinkHandler TextDialog *mDialog; Button *mButton; std::string mNick; + int mType; /** * Shared code for the various showPopup functions. diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ba8414699..2ca59f524 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -684,7 +684,8 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) const int y = getMouseY() + static_cast<int>(mPixelViewY); mHoverBeing = actorSpriteManager->findBeingByPixel(x, y, true); - if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER) + if (mHoverBeing && (mHoverBeing->getType() == Being::PLAYER + || mHoverBeing->getType() == Being::NPC)) { mTextPopup->setVisible(false); if (mShowBeingPopup) |