diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-28 23:41:36 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-28 23:41:36 -0700 |
commit | 5a3c174a53ed90224dc4fc49744c656eb9d358fa (patch) | |
tree | 2ce68b58ba1f10d9b54d9f1de168a9a9c78ad5f4 | |
parent | 0e2a2f39a2137ea1caae96256431c7d35fc2e6ec (diff) | |
download | mana-5a3c174a53ed90224dc4fc49744c656eb9d358fa.tar.gz mana-5a3c174a53ed90224dc4fc49744c656eb9d358fa.tar.bz2 mana-5a3c174a53ed90224dc4fc49744c656eb9d358fa.tar.xz mana-5a3c174a53ed90224dc4fc49744c656eb9d358fa.zip |
Added coloring of item names by type. TODO: Allow this to be
customizable through the color interface so that if someone is
colorblind to a certain color and it doesn't show up well, they can
change it (or even people who just don't like the default color).
Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r-- | src/gui/itempopup.cpp | 35 | ||||
-rw-r--r-- | src/gui/itempopup.h | 3 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 4 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 12 |
4 files changed, 45 insertions, 9 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 402f9e05..9b84b39e 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -97,6 +97,7 @@ ItemPopup::ItemPopup(): void ItemPopup::setItem(const ItemInfo &item) { mItemName->setCaption(item.getName()); + mItemName->setForegroundColor(getColor(item.getType())); mItemName->setWidth(boldFont->getWidth(item.getName())); mItemDesc->setTextWrapped(item.getDescription(), 196); mItemEffect->setTextWrapped(item.getEffect(), 196); @@ -154,6 +155,40 @@ void ItemPopup::setItem(const ItemInfo &item) (2 * getFont()->getHeight())); } +gcn::Color ItemPopup::getColor(const std::string& type) +{ + gcn::Color color; + + if (type.compare("generic") == 0) + color = 0x21a5b1; + else if (type.compare("equip-head") == 0) + color = 0x527fa4; + else if (type.compare("usable") == 0) + color = 0x268d24; + else if (type.compare("equip-torso") == 0) + color = 0xd12aa4; + else if (type.compare("equip-1hand") == 0) + color = 0xf42a2a; + else if (type.compare("equip-legs") == 0) + color = 0x718218; + else if (type.compare("equip-feet") == 0) + color = 0xf44ca5; + else if (type.compare("equip-2hand") == 0) + color = 0xf46d0e; + else if (type.compare("equip-shield") == 0) + color = 0x9c2424; + else if (type.compare("equip-ring") == 0) + color = 0xf4ea17; + else if (type.compare("equip-arms") == 0) + color = 0x9c24e8; + else if (type.compare("equip-ammo") == 0) + color = 0xbe8717; + else + color = 0x000000; + + return color; +} + unsigned int ItemPopup::getNumRows() { return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() + diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 0c729231..3c8f575d 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -27,6 +27,7 @@ #include "textbox.h" #include "window.h" +#include "../guichanfwd.h" #include "../item.h" class ItemPopup : public Window @@ -46,6 +47,8 @@ class ItemPopup : public Window ScrollArea *mItemDescScroll; ScrollArea *mItemEffectScroll; ScrollArea *mItemWeightScroll; + + gcn::Color getColor(const std::string& type); }; #endif // ITEMPOPUP_H__ diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 384efdf1..752ea38b 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -84,7 +84,7 @@ void ItemDB::load() logger->log(_("ItemDB: Redefinition of item ID %d"), id); } - int type = XML::getProperty(node, "type", 0); + std::string type = XML::getProperty(node, "type", "other"); int weight = XML::getProperty(node, "weight", 0); int view = XML::getProperty(node, "view", 0); @@ -152,7 +152,7 @@ void ItemDB::load() CHECK_PARAM(description, ""); // CHECK_PARAM(effect, ""); // CHECK_PARAM(type, 0); - CHECK_PARAM(weight, 0); + // CHECK_PARAM(weight, 0); // CHECK_PARAM(slot, 0); #undef CHECK_PARAM diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 86725ca2..c03dec28 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -47,7 +47,7 @@ class ItemInfo * Constructor. */ ItemInfo(): - mType(0), + mType(""), mWeight(0), mView(0), mAttackType(ACTION_DEFAULT) @@ -81,14 +81,12 @@ class ItemInfo void setEffect(const std::string &effect) { mEffect = effect; } - const std::string& - getEffect() const { return mEffect; } + const std::string& getEffect() const { return mEffect; } - void setType(short type) + void setType(const std::string& type) { mType = type; } - short getType() const - { return mType; } + const std::string& getType() const { return mType; } void setWeight(short weight) { mWeight = weight; } @@ -118,7 +116,7 @@ class ItemInfo std::string mName; std::string mDescription; /**< Short description. */ std::string mEffect; /**< Description of effects. */ - char mType; /**< Item type. */ + std::string mType; /**< Item type. */ short mWeight; /**< Weight in grams. */ int mView; /**< Item ID of how this item looks. */ int mId; /**< Item ID */ |