summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-03 18:00:02 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-03 18:00:02 +0300
commit87dc57caff1b01f4abe2cc14bfc56f5bc130fbb6 (patch)
tree926e4cf6c72f2b9f7ada2a715ca79adc88a53157 /src/resources
parent3a9f3469e65e1c45a8cdf9c6ae21e73c90b87d22 (diff)
downloadManaVerse-87dc57caff1b01f4abe2cc14bfc56f5bc130fbb6.tar.gz
ManaVerse-87dc57caff1b01f4abe2cc14bfc56f5bc130fbb6.tar.bz2
ManaVerse-87dc57caff1b01f4abe2cc14bfc56f5bc130fbb6.tar.xz
ManaVerse-87dc57caff1b01f4abe2cc14bfc56f5bc130fbb6.zip
Add item attribute useButton2 and use it in inventory.
Diffstat (limited to 'src/resources')
-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.h1
-rw-r--r--src/resources/itemtypemapdata.h105
5 files changed, 95 insertions, 36 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 0cad05f39..080254bb0 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -139,6 +139,19 @@ static std::string useButtonFromItemType(const ItemType::Type &type)
return std::string();
}
+static std::string useButton2FromItemType(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.useButton2.c_str());
+ }
+ logger->log("Unknown item type");
+ return std::string();
+}
+
static void initStatic()
{
mConstructed = true;
@@ -257,6 +270,7 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
const int maxFloorOffset = XML::getIntProperty(
node, "maxFloorOffset", mapTileSize, 0, mapTileSize);
std::string useButton = XML::getProperty(node, "useButton", "");
+ std::string useButton2 = XML::getProperty(node, "useButton2", "");
std::string colors;
if (serverVersion >= 1)
{
@@ -308,6 +322,9 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
if (useButton.empty())
useButton = useButtonFromItemType(itemInfo->getType());
itemInfo->setUseButton(useButton);
+ if (useButton2.empty())
+ useButton2 = useButton2FromItemType(itemInfo->getType());
+ itemInfo->setUseButton2(useButton2);
itemInfo->addTag(mTags["All"]);
itemInfo->setPet(pet);
itemInfo->setProtected(XML::getBoolProperty(
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 1d44c2eda..8e1284fad 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -47,6 +47,7 @@ ItemInfo::ItemInfo() :
mDescription(),
mEffect(),
mUseButton(),
+ mUseButton2(),
mType(ItemType::UNUSABLE),
mWeight(0),
mView(0),
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 4c8ece517..dca71128e 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -102,6 +102,12 @@ class ItemInfo final
const std::string &getUseButton() const A_WARN_UNUSED
{ return mUseButton; }
+ void setUseButton2(const std::string &str)
+ { mUseButton2 = str; }
+
+ const std::string &getUseButton2() const A_WARN_UNUSED
+ { return mUseButton2; }
+
ItemType::Type getType() const A_WARN_UNUSED
{ return mType; }
@@ -274,6 +280,7 @@ class ItemInfo final
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
std::string mUseButton;
+ std::string mUseButton2;
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 08ec73ca0..789d9211b 100644
--- a/src/resources/itemtypemap.h
+++ b/src/resources/itemtypemap.h
@@ -30,6 +30,7 @@ struct ItemTypeMap final
std::string name;
ItemType::Type type;
std::string useButton;
+ std::string useButton2;
};
#endif // RESOURCES_ITEMTYPEMAP_H
diff --git a/src/resources/itemtypemapdata.h b/src/resources/itemtypemapdata.h
index 5a5ad8fea..8cd7437e9 100644
--- a/src/resources/itemtypemapdata.h
+++ b/src/resources/itemtypemapdata.h
@@ -29,42 +29,75 @@
ItemTypeMap itemTypeMap[] =
{
- // TRANSLATORS: inventory button
- {"generic", ItemType::UNUSABLE, std::string()},
- // 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, std::string()},
- // TRANSLATORS: inventory button
- {"hairsprite", ItemType::SPRITE_HAIR, std::string()},
+ {"generic", ItemType::UNUSABLE,
+ std::string(), std::string()
+ },
+ {"other", ItemType::UNUSABLE,
+ // TRANSLATORS: inventory button
+ N_("Use"), N_("Use")
+ },
+ {"usable", ItemType::USABLE,
+ // TRANSLATORS: inventory button
+ N_("Use"), N_("Use")
+ },
+ {"equip-1hand", ItemType::EQUIPMENT_ONE_HAND_WEAPON,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-2hand", ItemType::EQUIPMENT_TWO_HANDS_WEAPON,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-torso", ItemType::EQUIPMENT_TORSO,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-arms", ItemType::EQUIPMENT_ARMS,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-head", ItemType::EQUIPMENT_HEAD,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-legs", ItemType::EQUIPMENT_LEGS,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-shield", ItemType::EQUIPMENT_SHIELD,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-ring", ItemType::EQUIPMENT_RING,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-charm", ItemType::EQUIPMENT_CHARM,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-necklace", ItemType::EQUIPMENT_NECKLACE,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-neck", ItemType::EQUIPMENT_NECKLACE,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-feet", ItemType::EQUIPMENT_FEET,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"equip-ammo", ItemType::EQUIPMENT_AMMO,
+ // TRANSLATORS: inventory button
+ N_("Equip"), N_("Unequip")
+ },
+ {"racesprite", ItemType::SPRITE_RACE,
+ std::string(), std::string()
+ },
+ {"hairsprite", ItemType::SPRITE_HAIR,
+ std::string(), std::string()
+ }
};
#endif // RESOURCES_ITEMTYPEMAPDATA_H