summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-24 20:42:22 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-24 20:42:22 +0300
commitb7bbb09d62b55bed26d432a6a2af9831c6ec9143 (patch)
tree895bf1e0d842088282f79bbc423ca1f825880254
parent3920b2449e3e55c396b3a5a46f37d965d71de42e (diff)
downloadplus-b7bbb09d62b55bed26d432a6a2af9831c6ec9143.tar.gz
plus-b7bbb09d62b55bed26d432a6a2af9831c6ec9143.tar.bz2
plus-b7bbb09d62b55bed26d432a6a2af9831c6ec9143.tar.xz
plus-b7bbb09d62b55bed26d432a6a2af9831c6ec9143.zip
Change ItemType into strong typed enum.
-rw-r--r--src/being/playerinfo.cpp3
-rw-r--r--src/enums/resources/itemtype.h47
-rw-r--r--src/gui/popups/itempopup.cpp2
-rw-r--r--src/gui/popups/itempopup.h4
-rw-r--r--src/gui/widgets/itemcontainer.cpp4
-rw-r--r--src/gui/windows/buydialog.cpp4
-rw-r--r--src/gui/windows/inventorywindow.cpp3
-rw-r--r--src/resources/db/itemdb.cpp6
-rw-r--r--src/resources/iteminfo.h6
-rw-r--r--src/resources/itemtypemap.h2
10 files changed, 40 insertions, 41 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index ecd83ad40..dbffe8b3e 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -276,7 +276,8 @@ void useEquipItem(const Item *const item, const Sfx sfx)
if (item)
{
#ifdef EATHENA_SUPPORT
- if (item->getType() == ItemType::CARD)
+ // IT_CARD
+ if (item->getType() == 6)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
diff --git a/src/enums/resources/itemtype.h b/src/enums/resources/itemtype.h
index 489dc3c44..29ad14b54 100644
--- a/src/enums/resources/itemtype.h
+++ b/src/enums/resources/itemtype.h
@@ -23,31 +23,28 @@
#ifndef RESOURCES_ITEMTYPE_H
#define RESOURCES_ITEMTYPE_H
-namespace ItemType
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(ItemType)
{
- /**
- * Enumeration of available Item types.
- */
- enum Type
- {
- UNUSABLE = 0,
- USABLE,
- EQUIPMENT_ONE_HAND_WEAPON,
- EQUIPMENT_TWO_HANDS_WEAPON,
- EQUIPMENT_TORSO,
- EQUIPMENT_ARMS, // 5
- CARD,
- EQUIPMENT_HEAD,
- EQUIPMENT_LEGS,
- EQUIPMENT_SHIELD,
- EQUIPMENT_RING,
- EQUIPMENT_NECKLACE, // 10
- EQUIPMENT_FEET,
- EQUIPMENT_AMMO,
- EQUIPMENT_CHARM,
- SPRITE_RACE,
- SPRITE_HAIR // 15
- };
-} // namespace ItemType
+ UNUSABLE = 0,
+ USABLE,
+ EQUIPMENT_ONE_HAND_WEAPON,
+ EQUIPMENT_TWO_HANDS_WEAPON,
+ EQUIPMENT_TORSO,
+ EQUIPMENT_ARMS, // 5
+ CARD,
+ EQUIPMENT_HEAD,
+ EQUIPMENT_LEGS,
+ EQUIPMENT_SHIELD,
+ EQUIPMENT_RING,
+ EQUIPMENT_NECKLACE, // 10
+ EQUIPMENT_FEET,
+ EQUIPMENT_AMMO,
+ EQUIPMENT_CHARM,
+ SPRITE_RACE,
+ SPRITE_HAIR // 15
+}
+enumEnd(ItemType);
#endif // RESOURCES_ITEMTYPE_H
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index f0ab5d167..065704cb8 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -325,7 +325,7 @@ std::string ItemPopup::getCardsString(const int *const cards)
return label->setForegroundColorAll(getThemeColor(name2), \
getThemeColor(name2##_OUTLINE)); \
}
-void ItemPopup::setLabelColor(Label *label, const ItemType::Type type) const
+void ItemPopup::setLabelColor(Label *label, const ItemTypeT type) const
{
switch (type)
{
diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h
index 7f5481627..fc0320614 100644
--- a/src/gui/popups/itempopup.h
+++ b/src/gui/popups/itempopup.h
@@ -82,14 +82,14 @@ class ItemPopup final : public Popup
TextBox *mItemEffect A_NONNULLPOINTER;
TextBox *mItemWeight A_NONNULLPOINTER;
TextBox *mItemCards A_NONNULLPOINTER;
- ItemType::Type mItemType;
+ ItemTypeT mItemType;
Icon *mIcon A_NONNULLPOINTER;
std::string mLastName;
int mLastId;
ItemColor mLastColor;
void setLabelColor(Label *label,
- const ItemType::Type type) const A_NONNULL(2);
+ const ItemTypeT type) const A_NONNULL(2);
};
extern ItemPopup *itemPopup;
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 02ad10ee9..96bdb1dcc 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -158,8 +158,8 @@ namespace
const ItemInfo &info1 = pair1->mItem->getInfo();
const ItemInfo &info2 = pair2->mItem->getInfo();
- const ItemType::Type t1 = info1.getType();
- const ItemType::Type t2 = info2.getType();
+ const ItemTypeT t1 = info1.getType();
+ const ItemTypeT t2 = info2.getType();
if (t1 == t2)
{
return (info1.getName() < info2.getName());
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 47ec11db2..c6be959de 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -160,8 +160,8 @@ namespace
if (!item1 || !item2)
return false;
- const ItemType::Type type1 = item1->getInfo().getType();
- const ItemType::Type type2 = item2->getInfo().getType();
+ const ItemTypeT type1 = item1->getInfo().getType();
+ const ItemTypeT type2 = item2->getInfo().getType();
if (type1 == type2)
return item1->getPrice() < item2->getPrice();
return type1 < type2;
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 881e10c1a..5485bd98a 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -1047,7 +1047,8 @@ void InventoryWindow::combineItems(const int index1,
if (!item2)
return;
- if (item1->getType() != ItemType::CARD)
+ // IT_CARD
+ if (item1->getType() != 6)
{
const Item *tmpItem = item1;
item1 = item2;
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 86a22a8fc..3ef3c8bd4 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -173,7 +173,7 @@ void ItemDB::setStatsList(const std::vector<ItemDB::Stat> &stats)
extraStats = stats;
}
-static ItemType::Type itemTypeFromString(const std::string &name)
+static ItemTypeT itemTypeFromString(const std::string &name)
{
const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
for (size_t f = 0; f < sz; f ++)
@@ -186,7 +186,7 @@ static ItemType::Type itemTypeFromString(const std::string &name)
return ItemType::UNUSABLE;
}
-static std::string useButtonFromItemType(const ItemType::Type &type)
+static std::string useButtonFromItemType(const ItemTypeT &type)
{
const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
for (size_t f = 0; f < sz; f ++)
@@ -203,7 +203,7 @@ static std::string useButtonFromItemType(const ItemType::Type &type)
return std::string();
}
-static std::string useButton2FromItemType(const ItemType::Type &type)
+static std::string useButton2FromItemType(const ItemTypeT &type)
{
const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
for (size_t f = 0; f < sz; f ++)
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 59b6a0b99..f9c622d3f 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -100,7 +100,7 @@ class ItemInfo final
const std::string &getEffect() const A_WARN_UNUSED
{ return mEffect; }
- void setType(const ItemType::Type type)
+ void setType(const ItemTypeT type)
{ mType = type; }
void setUseButton(const std::string &str)
@@ -115,7 +115,7 @@ class ItemInfo final
const std::string &getUseButton2() const A_WARN_UNUSED
{ return mUseButton2; }
- ItemType::Type getType() const A_WARN_UNUSED
+ ItemTypeT getType() const A_WARN_UNUSED
{ return mType; }
void setWeight(const int weight)
@@ -329,7 +329,7 @@ class ItemInfo final
std::string mEffect; /**< Description of effects. */
std::string mUseButton;
std::string mUseButton2;
- ItemType::Type mType; /**< Item type. */
+ ItemTypeT mType; /**< Item type. */
int mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
int mId; /**< Item ID */
diff --git a/src/resources/itemtypemap.h b/src/resources/itemtypemap.h
index ccf70068b..6718c8413 100644
--- a/src/resources/itemtypemap.h
+++ b/src/resources/itemtypemap.h
@@ -30,7 +30,7 @@
struct ItemTypeMap final
{
std::string name;
- ItemType::Type type;
+ ItemTypeT type;
std::string useButton;
std::string useButton2;
};