summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-10 13:38:15 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-10 13:38:15 +0300
commit3d2779c31490e4ac32bf72380703b9785b4e00be (patch)
tree5e031ea09c985af905973899fab78049d08475e3
parent44f9d02a86b4d2457965774f9dd6be9ce069d6ce (diff)
downloadplus-3d2779c31490e4ac32bf72380703b9785b4e00be.tar.gz
plus-3d2779c31490e4ac32bf72380703b9785b4e00be.tar.bz2
plus-3d2779c31490e4ac32bf72380703b9785b4e00be.tar.xz
plus-3d2779c31490e4ac32bf72380703b9785b4e00be.zip
Add support for change text in pet menu item "Return to egg".
-rw-r--r--src/gui/popups/popupmenu.cpp17
-rw-r--r--src/resources/beinginfo.cpp9
-rw-r--r--src/resources/beinginfo.h7
-rw-r--r--src/resources/db/petdb.cpp6
4 files changed, 36 insertions, 3 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 9c80415f6..8c43d1a20 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -390,9 +390,20 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
// TRANSLATORS: pet rename item
mBrowserBox->addRow("/setpetname", _("Rename"));
mBrowserBox->addRow("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet return to egg
- mBrowserBox->addRow("pet to egg", _("Return to egg"));
+ const BeingInfo *const info = being->getInfo();
+ std::string msg;
+ if (info)
+ msg = info->getString(0);
+ if (!msg.empty())
+ {
+ mBrowserBox->addRow("pet to egg", msg.c_str());
+ }
+ else
+ {
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: pet return to egg
+ mBrowserBox->addRow("pet to egg", _("Return to egg"));
+ }
mBrowserBox->addRow("##3---");
}
else
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index d27339483..0cd311554 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -58,6 +58,7 @@ BeingInfo::BeingInfo() :
mSounds(),
mAttacks(),
mMenu(),
+ mStrings(),
mBlockWalkMask(BlockMask::WALL
| BlockMask::AIR
| BlockMask::WATER),
@@ -239,3 +240,11 @@ const std::vector<BeingMenuItem> &BeingInfo::getMenu() const
{
return mMenu;
}
+
+std::string BeingInfo::getString(const int idx) const
+{
+ const std::map<int, std::string>::const_iterator it = mStrings.find(idx);
+ if (it == mStrings.end())
+ return "";
+ return (*it).second;
+}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 942644708..e98d48a41 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -327,6 +327,12 @@ class BeingInfo final
const std::vector<BeingMenuItem> &getMenu() const A_CONST;
+ void setString(const int idx,
+ const std::string &value)
+ { mStrings[idx] = value; }
+
+ std::string getString(const int idx) const A_WARN_UNUSED;
+
static void init();
static void clear();
@@ -339,6 +345,7 @@ class BeingInfo final
ItemSoundEvents mSounds;
Attacks mAttacks;
std::vector<BeingMenuItem> mMenu;
+ std::map<int, std::string> mStrings;
unsigned char mBlockWalkMask;
BlockTypeT mBlockType;
const std::map <ItemColor, ColorDB::ItemColorData> *mColors;
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index c2f6508c3..6c56f3437 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -150,6 +150,12 @@ void PETDB::loadXmlFile(const std::string &fileName)
currentInfo->setAttackDirectionType(XML::getProperty(petNode,
"attackDirectionType", 4));
+ const std::string returnMessage = XML::langProperty(petNode,
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: pet return to egg
+ "removeMessage", _("Return to egg"));
+ currentInfo->setString(0, returnMessage);
+
SpriteDisplay display;
for_each_xml_child_node(spriteNode, petNode)
{