summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-30 07:19:36 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-30 07:19:36 -0600
commit2bf40f6f1f94cb85d95b8e9ce2942c9d4ce9bd1a (patch)
tree49fb5a1e363584800f967a4a163fb3e746228722 /src
parentbbf4d657e77fd39887b9941af1fe75a5ec27d988 (diff)
downloadmana-2bf40f6f1f94cb85d95b8e9ce2942c9d4ce9bd1a.tar.gz
mana-2bf40f6f1f94cb85d95b8e9ce2942c9d4ce9bd1a.tar.bz2
mana-2bf40f6f1f94cb85d95b8e9ce2942c9d4ce9bd1a.tar.xz
mana-2bf40f6f1f94cb85d95b8e9ce2942c9d4ce9bd1a.zip
Merge item types to remove more #ifdefs
Diffstat (limited to 'src')
-rw-r--r--src/gui/itempopup.cpp67
-rw-r--r--src/gui/itempopup.h4
-rw-r--r--src/gui/palette.cpp16
-rw-r--r--src/gui/palette.h1
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/resources/itemdb.cpp4
-rw-r--r--src/resources/iteminfo.h11
7 files changed, 46 insertions, 61 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 66729605..8d51c765 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -112,9 +112,7 @@ void ItemPopup::setItem(const ItemInfo &item)
mItemEffect->setTextWrapped(item.getEffect(), 196);
mItemWeight->setTextWrapped(_("Weight: ") +
Units::formatWeight(item.getWeight()), 196);
-#ifdef EATHENA_SUPPORT
mItemType = item.getType();
-#endif
int minWidth = mItemName->getWidth();
@@ -162,44 +160,43 @@ void ItemPopup::setItem(const ItemInfo &item)
void ItemPopup::updateColors()
{
-#ifdef EATHENA_SUPPORT
mItemName->setForegroundColor(getColor(mItemType));
-#endif
graphics->setColor(guiPalette->getColor(Palette::TEXT));
}
-gcn::Color ItemPopup::getColor(const std::string &type)
+gcn::Color ItemPopup::getColor(short type)
{
- gcn::Color color;
-
- if (type.compare("generic") == 0)
- color = guiPalette->getColor(Palette::GENERIC);
- else if (type.compare("equip-head") == 0)
- color = guiPalette->getColor(Palette::HEAD);
- else if (type.compare("usable") == 0)
- color = guiPalette->getColor(Palette::USABLE);
- else if (type.compare("equip-torso") == 0)
- color = guiPalette->getColor(Palette::TORSO);
- else if (type.compare("equip-1hand") == 0)
- color = guiPalette->getColor(Palette::ONEHAND);
- else if (type.compare("equip-legs") == 0)
- color = guiPalette->getColor(Palette::LEGS);
- else if (type.compare("equip-feet") == 0)
- color = guiPalette->getColor(Palette::FEET);
- else if (type.compare("equip-2hand") == 0)
- color = guiPalette->getColor(Palette::TWOHAND);
- else if (type.compare("equip-shield") == 0)
- color = guiPalette->getColor(Palette::SHIELD);
- else if (type.compare("equip-ring") == 0)
- color = guiPalette->getColor(Palette::RING);
- else if (type.compare("equip-arms") == 0)
- color = guiPalette->getColor(Palette::ARMS);
- else if (type.compare("equip-ammo") == 0)
- color = guiPalette->getColor(Palette::AMMO);
- else
- color = guiPalette->getColor(Palette::UNKNOWN_ITEM);
-
- return color;
+ switch (type)
+ {
+ case ITEM_UNUSABLE:
+ return guiPalette->getColor(Palette::GENERIC);
+ case ITEM_USABLE:
+ return guiPalette->getColor(Palette::USABLE);
+ case ITEM_EQUIPMENT_ONE_HAND_WEAPON:
+ return guiPalette->getColor(Palette::ONEHAND);
+ case ITEM_EQUIPMENT_TWO_HANDS_WEAPON:
+ return guiPalette->getColor(Palette::TWOHAND);
+ case ITEM_EQUIPMENT_TORSO:
+ return guiPalette->getColor(Palette::TORSO);
+ case ITEM_EQUIPMENT_ARMS:
+ return guiPalette->getColor(Palette::ARMS);
+ case ITEM_EQUIPMENT_HEAD:
+ return guiPalette->getColor(Palette::HEAD);
+ case ITEM_EQUIPMENT_LEGS:
+ return guiPalette->getColor(Palette::LEGS);
+ case ITEM_EQUIPMENT_SHIELD:
+ return guiPalette->getColor(Palette::SHIELD);
+ case ITEM_EQUIPMENT_RING:
+ return guiPalette->getColor(Palette::RING);
+ case ITEM_EQUIPMENT_NECKLACE:
+ return guiPalette->getColor(Palette::NECKLACE);
+ case ITEM_EQUIPMENT_FEET:
+ return guiPalette->getColor(Palette::FEET);
+ case ITEM_EQUIPMENT_AMMO:
+ return guiPalette->getColor(Palette::AMMO);
+ default:
+ return guiPalette->getColor(Palette::UNKNOWN_ITEM);
+ }
}
std::string ItemPopup::getItemName()
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index 0e386ef7..37f6f81b 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -72,12 +72,12 @@ class ItemPopup : public Popup
TextBox *mItemDesc;
TextBox *mItemEffect;
TextBox *mItemWeight;
- std::string mItemType;
+ short mItemType;
ScrollArea *mItemDescScroll;
ScrollArea *mItemEffectScroll;
ScrollArea *mItemWeightScroll;
- static gcn::Color getColor(const std::string &type);
+ static gcn::Color getColor(short type);
};
#endif // ITEMPOPUP_H
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index b176fcff..f226d512 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -20,16 +20,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <math.h>
-
#include "palette.h"
-#include "gui.h"
-#include "../configuration.h"
-#include "../game.h"
+#include "configuration.h"
+#include "game.h"
+
+#include "gui/gui.h"
-#include "../utils/gettext.h"
-#include "../utils/stringutils.h"
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include <math.h>
const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0);
@@ -119,6 +120,7 @@ Palette::Palette() :
addColor(TWOHAND, 0xf46d0e, STATIC, indent + _("2 Handed Weapons"));
addColor(SHIELD, 0x9c2424, STATIC, indent + _("Shield"));
addColor(RING, 0x0000ff, STATIC, indent + _("Ring"));
+ addColor(NECKLACE, 0xff00ff, STATIC, indent + _("Necklace"));
addColor(ARMS, 0x9c24e8, STATIC, indent + _("Arms"));
addColor(AMMO, 0x8b6311, STATIC, indent + _("Ammo"));
diff --git a/src/gui/palette.h b/src/gui/palette.h
index b2994351..47863cb0 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -84,6 +84,7 @@ class Palette : public gcn::ListModel
ENTRY(TWOHAND)\
ENTRY(SHIELD)\
ENTRY(RING)\
+ ENTRY(NECKLACE)\
ENTRY(ARMS)\
ENTRY(AMMO)\
ENTRY(PARTICLE)\
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 039ed91e..bf4df760 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -451,7 +451,7 @@ void LocalPlayer::useItem(Item *item)
MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE);
outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
outMsg.writeInt32(item->getId());
- // Note: id is dest of item, usually player_node->account_ID ??
+ // Note: id isn't used, but the server wants it
}
#endif
@@ -461,7 +461,7 @@ void LocalPlayer::dropItem(Item *item, int quantity)
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::drop(item->getInvIndex(), quantity);
#else
- // TODO: Fix wrong coordinates of drops, serverside?
+ // TODO: Fix wrong coordinates of drops, serverside? (what's wrong here?)
MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP);
outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
outMsg.writeInt16(quantity);
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index db919b64..d9994892 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -147,12 +147,8 @@ void ItemDB::load()
itemInfo->setImageName(image);
itemInfo->setName(name.empty() ? _("Unnamed") : name);
itemInfo->setDescription(description);
-#ifdef TMWSERV_SUPPORT
int type = itemTypeFromString(typeStr);
itemInfo->setType(type);
-#else
- itemInfo->setType(typeStr);
-#endif
itemInfo->setView(view);
itemInfo->setWeight(weight);
itemInfo->setWeaponType(weaponType);
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index bcee1fbd..327d0e9f 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -158,18 +158,11 @@ class ItemInfo
const std::string &getEffect() const { return mEffect; }
-#ifdef TMWSERV_SUPPORT
void setType(short type)
{ mType = type; }
short getType() const
{ return mType; }
-#else
- void setType(const std::string &type)
- { mType = type; }
-
- const std::string &getType() const { return mType; }
-#endif
void setWeight(short weight)
{ mWeight = weight; }
@@ -205,11 +198,7 @@ class ItemInfo
std::string mName;
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
-#ifdef TMWSERV_SUPPORT
char mType; /**< Item type. */
-#else
- std::string mType; /**< Item type. */
-#endif
std::string mParticle; /**< Particle effect used with this item */
short mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */