From ad5bfca7d5df9201e5460e68ca149674bac5ac2c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 10 Sep 2015 11:41:28 +0300 Subject: Show name on named items. --- src/gui/popups/itempopup.cpp | 53 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index a9afe136a..56e907620 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -23,10 +23,13 @@ #include "gui/popups/itempopup.h" +#include "actormanager.h" #include "configuration.h" #include "item.h" #include "units.h" +#include "being/being.h" + #include "gui/gui.h" #include "gui/fonts/font.h" @@ -41,6 +44,7 @@ #include "resources/iteminfo.h" #include "resources/resourcemanager.h" +#include "net/beinghandler.h" #include "net/serverfeatures.h" #include "debug.h" @@ -267,21 +271,48 @@ std::string ItemPopup::getCardsString(const int *const cards) std::string label; - for (int f = 0; f < maxCards; f ++) + switch (cards[0]) { - const int id = cards[f]; - if (id) + case 0xfe: // named item + { + const int32_t charId = cards[2] + 65536 * cards[3]; + std::string name = actorManager->findCharById(charId); + if (name.empty()) + { + name = toString(charId); + beingHandler->requestNameByCharId(charId); + } + // TRANSLATORS: named item description + label.append(strprintf(_("Item named: %s"), name.c_str())); + return label; + } + case 0x00FFU: // forged item + { + return label; + } + case 0xFF00U: { - if (!label.empty()) - label.append(" / "); - const ItemInfo &info = ItemDB::get(id); - label.append(info.getName()); + return label; + } + default: + { + for (int f = 0; f < maxCards; f ++) + { + const int id = cards[f]; + if (id) + { + if (!label.empty()) + label.append(" / "); + const ItemInfo &info = ItemDB::get(id); + label.append(info.getName()); + } + } + if (label.empty()) + return label; + // TRANSLATORS: popup label + return _("Cards: ") + label; } } - if (label.empty()) - return label; - // TRANSLATORS: popup label - return _("Cards: ") + label; } #define caseSetColor(name1, name2) \ -- cgit v1.2.3-70-g09d2