diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-18 01:35:25 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-18 01:35:25 +0200 |
commit | 9ca2198b767e1bf810aa5b75657f0d18ce06a57b (patch) | |
tree | b2258d2ea07d84a3f1c52c91186c975a7c3e10b7 /src | |
parent | adfa29a6436c2bb1ff2f05ef83e2eb0fa99d6068 (diff) | |
download | mana-9ca2198b767e1bf810aa5b75657f0d18ce06a57b.tar.gz mana-9ca2198b767e1bf810aa5b75657f0d18ce06a57b.tar.bz2 mana-9ca2198b767e1bf810aa5b75657f0d18ce06a57b.tar.xz mana-9ca2198b767e1bf810aa5b75657f0d18ce06a57b.zip |
Add functions to make the item popup able to tell whether the item
is equipped or not.
It will be used quite soon to visually see the slot names.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itempopup.cpp | 32 | ||||
-rw-r--r-- | src/gui/itempopup.h | 11 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 60943756..de8378d5 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -123,6 +123,31 @@ ItemPopup::~ItemPopup() } } +void ItemPopup::setEquipmentText(const std::string& text) +{ + mItemEquipSlot = text; +} + +void ItemPopup::setNoItem() +{ + mIcon->setImage(0); + + std::string caption = _("No item"); + if (!mItemEquipSlot.empty()) + { + caption += " ("; + caption += mItemEquipSlot; + caption += ")"; + } + mItemName->setCaption(caption); + mItemName->adjustSize(); + + mItemName->setForegroundColor(Theme::getThemeColor(Theme::GENERIC)); + mItemName->setPosition(getPadding(), getPadding()); + + setContentSize(mItemName->getWidth() + 2 * getPadding(), 0); +} + void ItemPopup::setItem(const ItemInfo &item, bool showImage) { if (item.getName() == mItemName->getCaption()) @@ -157,7 +182,11 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) mItemType = item.getItemType(); - mItemName->setCaption(item.getName()); + std::string caption = item.getName(); + if (!mItemEquipSlot.empty()) + caption += " (" + mItemEquipSlot + ")"; + + mItemName->setCaption(caption); mItemName->adjustSize(); mItemName->setForegroundColor(getColorFromItemType(mItemType)); mItemName->setPosition(getPadding() + space, getPadding()); @@ -226,5 +255,6 @@ void ItemPopup::mouseMoved(gcn::MouseEvent &event) // When the mouse moved on top of the popup, hide it setVisible(false); + mItemEquipSlot.clear(); } diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index f054ddf5..95adcf45 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -49,6 +49,16 @@ class ItemPopup : public Popup ~ItemPopup(); /** + * Tells the item popup to say: No Item. + */ + void setNoItem(); + + /** + * Tells in which equipment slot the item is equipped. + */ + void setEquipmentText(const std::string& text = std::string()); + + /** * Sets the info to be displayed given a particular item. */ void setItem(const ItemInfo &item, bool showImage = false); @@ -60,6 +70,7 @@ class ItemPopup : public Popup TextBox *mItemDesc; TextBox *mItemEffect; TextBox *mItemWeight; + std::string mItemEquipSlot; ItemType mItemType; Icon *mIcon; }; |