diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-14 23:23:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-14 23:36:38 +0300 |
commit | bf9bccc30a186e338f96c230a4f63cc924c77bd8 (patch) | |
tree | e46dbc2f022842982d89164ee598e1bcf827aa39 /src/gui/popupmenu.cpp | |
parent | fb0f86589ae9e2d582383cea43e0a391e8d4739d (diff) | |
download | manaplus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.tar.gz manaplus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.tar.bz2 manaplus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.tar.xz manaplus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.zip |
Add ability to add comments to any players.
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r-- | src/gui/popupmenu.cpp | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index aaf47f36a..0c5e7a365 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -103,6 +103,8 @@ PopupMenu::PopupMenu(): mBrowserBox->setLinkHandler(this); mRenameListener.setMapItem(0); mRenameListener.setDialog(0); + mPlayerListener.setNick(""); + mPlayerListener.setDialog(0); add(mBrowserBox); } @@ -240,6 +242,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items"))); mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress"))); + mBrowserBox->addRow(strprintf( + "@@addcomment|%s@@", _("Add comment"))); if (player_relations.getDefault() & PlayerRelation::TRADE) { @@ -391,7 +395,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mBrowserBox->addRow("##3---"); mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow"))); mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation"))); - + mBrowserBox->addRow(strprintf("@@addcomment|%s@@", _("Add comment"))); if (player_node->isInParty() && player_node->getParty()) { @@ -642,6 +646,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move"))); mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items"))); mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress"))); + mBrowserBox->addRow(strprintf( + "@@addcomment|%s@@", _("Add comment"))); if (player_relations.getDefault() & PlayerRelation::TRADE) { @@ -690,6 +696,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) } } } + else + { + mBrowserBox->addRow(strprintf( + "@@addcomment|%s@@", _("Add comment"))); + mBrowserBox->addRow("##3---"); + } } mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); @@ -1170,6 +1182,27 @@ void PopupMenu::handleLink(const std::string &link, { Net::getBeingHandler()->undress(being); } + else if (link == "addcomment" && !mNick.empty()) + { + // TRANSLATORS: number of chars in string should be near original + TextDialog *dialog = new TextDialog(_("Player comment "), + // TRANSLATORS: number of chars in string should be near original + _("Comment: ")); + mPlayerListener.setDialog(dialog); + mPlayerListener.setNick(mNick); + + if (being) + { + being->updateComment(); + dialog->setText(being->getComment()); + } + else + { + dialog->setText(Being::loadComment(mNick)); + } + dialog->setActionEventId("ok"); + dialog->addActionListener(&mPlayerListener); + } else if (link == "guild-kick" && !mNick.empty()) { if (player_node) @@ -1923,3 +1956,23 @@ void RenameListener::action(const gcn::ActionEvent &event) } mDialog = 0; } + +PlayerListener::PlayerListener() : + mNick(""), + mDialog(0) +{ +} + +void PlayerListener::action(const gcn::ActionEvent &event) +{ + if (event.getId() == "ok" && !mNick.empty() && mDialog) + { + std::string comment = mDialog->getText(); + Being* being = actorSpriteManager->findBeingByName( + mNick, Being::PLAYER); + if (being) + being->setComment(comment); + Being::saveComment(mNick, comment); + } + mDialog = 0; +} |