diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-01-24 22:10:02 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-01-24 22:10:02 +0100 |
commit | d055bee5e6b45737ab89b3f8c70c6d0db7a22eb3 (patch) | |
tree | 081556c8fa27ce16372b1657e469ccd8587dd4e5 /src/gui/itempopup.cpp | |
parent | f663f5bbb75b850ae22f451a22d112b6c62b2ad6 (diff) | |
download | mana-d055bee5e6b45737ab89b3f8c70c6d0db7a22eb3.tar.gz mana-d055bee5e6b45737ab89b3f8c70c6d0db7a22eb3.tar.bz2 mana-d055bee5e6b45737ab89b3f8c70c6d0db7a22eb3.tar.xz mana-d055bee5e6b45737ab89b3f8c70c6d0db7a22eb3.zip |
Refactored the item loading in a more extensible and per protocol way.
This will greatly help into upgrading the need of
each protocol separately.
This is the first step to a new item and equipment system for manaserv.
A subclassing of the EquipmentWindow will be done in the next commit,
as requested by Thorbjorn.
Reviewed-by: Thorbjorn.
Diffstat (limited to 'src/gui/itempopup.cpp')
-rw-r--r-- | src/gui/itempopup.cpp | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 9b2df34d..60943756 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -34,6 +34,8 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include "net/net.h" + #include "resources/image.h" #include "resources/resourcemanager.h" #include "resources/theme.h" @@ -42,6 +44,43 @@ #include <guichan/widgets/label.hpp> +#define ITEMPOPUP_WRAP_WIDTH 196 + +static gcn::Color getColorFromItemType(ItemType type) +{ + switch (type) + { + case ITEM_UNUSABLE: + return Theme::getThemeColor(Theme::GENERIC); + case ITEM_USABLE: + return Theme::getThemeColor(Theme::USABLE); + case ITEM_EQUIPMENT_ONE_HAND_WEAPON: + return Theme::getThemeColor(Theme::ONEHAND); + case ITEM_EQUIPMENT_TWO_HANDS_WEAPON: + return Theme::getThemeColor(Theme::TWOHAND); + case ITEM_EQUIPMENT_TORSO: + return Theme::getThemeColor(Theme::TORSO); + case ITEM_EQUIPMENT_ARMS: + return Theme::getThemeColor(Theme::ARMS); + case ITEM_EQUIPMENT_HEAD: + return Theme::getThemeColor(Theme::HEAD); + case ITEM_EQUIPMENT_LEGS: + return Theme::getThemeColor(Theme::LEGS); + case ITEM_EQUIPMENT_SHIELD: + return Theme::getThemeColor(Theme::SHIELD); + case ITEM_EQUIPMENT_RING: + return Theme::getThemeColor(Theme::RING); + case ITEM_EQUIPMENT_NECKLACE: + return Theme::getThemeColor(Theme::NECKLACE); + case ITEM_EQUIPMENT_FEET: + return Theme::getThemeColor(Theme::FEET); + case ITEM_EQUIPMENT_AMMO: + return Theme::getThemeColor(Theme::AMMO); + default: + return Theme::getThemeColor(Theme::UNKNOWN_ITEM); + } +} + ItemPopup::ItemPopup(): Popup("ItemPopup"), mIcon(0) @@ -116,15 +155,13 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) mIcon->setImage(0); } - //mItemType = item.getType(); + mItemType = item.getItemType(); mItemName->setCaption(item.getName()); mItemName->adjustSize(); - mItemName->setForegroundColor(Theme::UNKNOWN_ITEM); // TODO + mItemName->setForegroundColor(getColorFromItemType(mItemType)); mItemName->setPosition(getPadding() + space, getPadding()); -#define ITEMPOPUP_WRAP_WIDTH 196 - mItemDesc->setTextWrapped(item.getDescription(), ITEMPOPUP_WRAP_WIDTH); { const std::vector<std::string> &effect = item.getEffect(); @@ -183,41 +220,6 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) (numRowsDesc + 1) * fontHeight); } -gcn::Color ItemPopup::getColor(ItemType type) -{ - switch (type) - { - case ITEM_UNUSABLE: - return Theme::getThemeColor(Theme::GENERIC); - case ITEM_USABLE: - return Theme::getThemeColor(Theme::USABLE); - case ITEM_EQUIPMENT_ONE_HAND_WEAPON: - return Theme::getThemeColor(Theme::ONEHAND); - case ITEM_EQUIPMENT_TWO_HANDS_WEAPON: - return Theme::getThemeColor(Theme::TWOHAND); - case ITEM_EQUIPMENT_TORSO: - return Theme::getThemeColor(Theme::TORSO); - case ITEM_EQUIPMENT_ARMS: - return Theme::getThemeColor(Theme::ARMS); - case ITEM_EQUIPMENT_HEAD: - return Theme::getThemeColor(Theme::HEAD); - case ITEM_EQUIPMENT_LEGS: - return Theme::getThemeColor(Theme::LEGS); - case ITEM_EQUIPMENT_SHIELD: - return Theme::getThemeColor(Theme::SHIELD); - case ITEM_EQUIPMENT_RING: - return Theme::getThemeColor(Theme::RING); - case ITEM_EQUIPMENT_NECKLACE: - return Theme::getThemeColor(Theme::NECKLACE); - case ITEM_EQUIPMENT_FEET: - return Theme::getThemeColor(Theme::FEET); - case ITEM_EQUIPMENT_AMMO: - return Theme::getThemeColor(Theme::AMMO); - default: - return Theme::getThemeColor(Theme::UNKNOWN_ITEM); - } -} - void ItemPopup::mouseMoved(gcn::MouseEvent &event) { Popup::mouseMoved(event); |