summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-03 15:09:13 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-03 17:03:33 +0300
commit9d33bb1bdaf0f19ccaa742a316af9620b05b825d (patch)
tree19949d567f0bbf4017475ffd824be66b36b5f7b9 /src
parent284acf8f76bd2201bd64b847a2564206f77a4278 (diff)
downloadplus-9d33bb1bdaf0f19ccaa742a316af9620b05b825d.tar.gz
plus-9d33bb1bdaf0f19ccaa742a316af9620b05b825d.tar.bz2
plus-9d33bb1bdaf0f19ccaa742a316af9620b05b825d.tar.xz
plus-9d33bb1bdaf0f19ccaa742a316af9620b05b825d.zip
Add into items.xml option useButton.
For now unused.
Diffstat (limited to 'src')
-rw-r--r--src/resources/db/itemdb.cpp17
-rw-r--r--src/resources/iteminfo.cpp1
-rw-r--r--src/resources/iteminfo.h7
-rw-r--r--src/resources/itemtypemap.h3
-rw-r--r--src/resources/itemtypemapdata.h56
5 files changed, 66 insertions, 18 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index f40fdbbd6..0cad05f39 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -126,6 +126,19 @@ static ItemType::Type itemTypeFromString(const std::string &name)
return ItemType::UNUSABLE;
}
+static std::string useButtonFromItemType(const ItemType::Type &type)
+{
+ const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
+ for (size_t f = 0; f < sz; f ++)
+ {
+ const ItemTypeMap &item = itemTypeMap[f];
+ if (item.type == type)
+ return gettext(item.useButton.c_str());
+ }
+ logger->log("Unknown item type");
+ return std::string();
+}
+
static void initStatic()
{
mConstructed = true;
@@ -243,6 +256,7 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
const int pet = XML::getProperty(node, "pet", 0);
const int maxFloorOffset = XML::getIntProperty(
node, "maxFloorOffset", mapTileSize, 0, mapTileSize);
+ std::string useButton = XML::getProperty(node, "useButton", "");
std::string colors;
if (serverVersion >= 1)
{
@@ -291,6 +305,9 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
itemInfo->setName(name.empty() ? _("unnamed") : name);
itemInfo->setDescription(description);
itemInfo->setType(itemTypeFromString(typeStr));
+ if (useButton.empty())
+ useButton = useButtonFromItemType(itemInfo->getType());
+ itemInfo->setUseButton(useButton);
itemInfo->addTag(mTags["All"]);
itemInfo->setPet(pet);
itemInfo->setProtected(XML::getBoolProperty(
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 608fb6c20..1d44c2eda 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -46,6 +46,7 @@ ItemInfo::ItemInfo() :
mName(),
mDescription(),
mEffect(),
+ mUseButton(),
mType(ItemType::UNUSABLE),
mWeight(0),
mView(0),
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index eb22b10d5..4c8ece517 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -96,6 +96,12 @@ class ItemInfo final
void setType(const ItemType::Type type)
{ mType = type; }
+ void setUseButton(const std::string &str)
+ { mUseButton = str; }
+
+ const std::string &getUseButton() const A_WARN_UNUSED
+ { return mUseButton; }
+
ItemType::Type getType() const A_WARN_UNUSED
{ return mType; }
@@ -267,6 +273,7 @@ class ItemInfo final
std::string mName;
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
+ std::string mUseButton;
ItemType::Type mType; /**< Item type. */
int mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
diff --git a/src/resources/itemtypemap.h b/src/resources/itemtypemap.h
index c8dc48197..08ec73ca0 100644
--- a/src/resources/itemtypemap.h
+++ b/src/resources/itemtypemap.h
@@ -21,12 +21,15 @@
#ifndef RESOURCES_ITEMTYPEMAP_H
#define RESOURCES_ITEMTYPEMAP_H
+#include "resources/itemtype.h"
+
#include "localconsts.h"
struct ItemTypeMap final
{
std::string name;
ItemType::Type type;
+ std::string useButton;
};
#endif // RESOURCES_ITEMTYPEMAP_H
diff --git a/src/resources/itemtypemapdata.h b/src/resources/itemtypemapdata.h
index c232dbe52..b1412414c 100644
--- a/src/resources/itemtypemapdata.h
+++ b/src/resources/itemtypemapdata.h
@@ -23,28 +23,48 @@
#include "localconsts.h"
+#include "utils/gettext.h"
+
#include "resources/itemtypemap.h"
ItemTypeMap itemTypeMap[] =
{
- {"generic", ItemType::UNUSABLE},
- {"other", ItemType::UNUSABLE},
- {"usable", ItemType::USABLE},
- {"equip-1hand", ItemType::EQUIPMENT_ONE_HAND_WEAPON},
- {"equip-2hand", ItemType::EQUIPMENT_TWO_HANDS_WEAPON},
- {"equip-torso", ItemType::EQUIPMENT_TORSO},
- {"equip-arms", ItemType::EQUIPMENT_ARMS},
- {"equip-head", ItemType::EQUIPMENT_HEAD},
- {"equip-legs", ItemType::EQUIPMENT_LEGS},
- {"equip-shield", ItemType::EQUIPMENT_SHIELD},
- {"equip-ring", ItemType::EQUIPMENT_RING},
- {"equip-charm", ItemType::EQUIPMENT_CHARM},
- {"equip-necklace", ItemType::EQUIPMENT_NECKLACE},
- {"equip-neck", ItemType::EQUIPMENT_NECKLACE},
- {"equip-feet", ItemType::EQUIPMENT_FEET},
- {"equip-ammo", ItemType::EQUIPMENT_AMMO},
- {"racesprite", ItemType::SPRITE_RACE},
- {"hairsprite", ItemType::SPRITE_HAIR},
+ // TRANSLATORS: inventory button
+ {"generic", ItemType::UNUSABLE, N_("Use")},
+ // TRANSLATORS: inventory button
+ {"other", ItemType::UNUSABLE, N_("Use")},
+ // TRANSLATORS: inventory button
+ {"usable", ItemType::USABLE, N_("Use")},
+ // TRANSLATORS: inventory button
+ {"equip-1hand", ItemType::EQUIPMENT_ONE_HAND_WEAPON, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-2hand", ItemType::EQUIPMENT_TWO_HANDS_WEAPON, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-torso", ItemType::EQUIPMENT_TORSO, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-arms", ItemType::EQUIPMENT_ARMS, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-head", ItemType::EQUIPMENT_HEAD, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-legs", ItemType::EQUIPMENT_LEGS, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-shield", ItemType::EQUIPMENT_SHIELD, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-ring", ItemType::EQUIPMENT_RING, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-charm", ItemType::EQUIPMENT_CHARM, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-necklace", ItemType::EQUIPMENT_NECKLACE, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-neck", ItemType::EQUIPMENT_NECKLACE, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-feet", ItemType::EQUIPMENT_FEET, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"equip-ammo", ItemType::EQUIPMENT_AMMO, N_("Equip")},
+ // TRANSLATORS: inventory button
+ {"racesprite", ItemType::SPRITE_RACE, N_("Use")},
+ // TRANSLATORS: inventory button
+ {"hairsprite", ItemType::SPRITE_HAIR, N_("Use")},
};
#endif // RESOURCES_ITEMTYPEMAPDATA_H