summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-09 23:58:34 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-09 23:58:34 +0200
commit9b680f95087290315c24a04535f1626acd8ec9a7 (patch)
treefbfd4e40e8eeaf0c077266a95e701e01688279e2 /src
parent4893acb9cdbd83349f88668ca932f7fddd3e8288 (diff)
downloadmana-client-9b680f95087290315c24a04535f1626acd8ec9a7.tar.gz
mana-client-9b680f95087290315c24a04535f1626acd8ec9a7.tar.bz2
mana-client-9b680f95087290315c24a04535f1626acd8ec9a7.tar.xz
mana-client-9b680f95087290315c24a04535f1626acd8ec9a7.zip
Actually use ItemType instead of short
Plus some random cleanups.
Diffstat (limited to 'src')
-rw-r--r--src/gui/equipmentwindow.cpp1
-rw-r--r--src/gui/itempopup.cpp35
-rw-r--r--src/gui/itempopup.h9
-rw-r--r--src/gui/widgets/scrollarea.h7
-rw-r--r--src/resources/itemdb.cpp3
-rw-r--r--src/resources/iteminfo.h6
6 files changed, 31 insertions, 30 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 89be2c5e..d9ada6f4 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -72,7 +72,6 @@ EquipmentWindow::EquipmentWindow():
mSelected(-1)
{
mItemPopup = new ItemPopup;
- mItemPopup->setOpaque(false);
// Control that shows the Player
mPlayerBox = new PlayerBox;
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 6226acab..278b06e2 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -31,8 +31,6 @@
#include "graphics.h"
#include "units.h"
-#include "resources/iteminfo.h"
-
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -52,11 +50,13 @@ ItemPopup::ItemPopup():
mItemDesc->setEditable(false);
mItemDescScroll = new ScrollArea(mItemDesc);
+ const int fontHeight = getFont()->getHeight();
+
mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mItemDescScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mItemDescScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight()));
+ mItemDescScroll->setDimension(gcn::Rectangle(0, 0, 196, fontHeight));
mItemDescScroll->setOpaque(false);
- mItemDescScroll->setPosition(2, getFont()->getHeight());
+ mItemDescScroll->setPosition(2, fontHeight);
// Item Effect
mItemEffect = new TextBox;
@@ -65,10 +65,10 @@ ItemPopup::ItemPopup():
mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mItemEffectScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mItemEffectScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight()));
+ mItemEffectScroll->setDimension(gcn::Rectangle(0, 0, 196, fontHeight));
mItemEffectScroll->setOpaque(false);
- mItemEffectScroll->setPosition(2, (2 * getFont()->getHeight()) +
- (2 * getPadding()));
+ mItemEffectScroll->setPosition(2, (2 * fontHeight) +
+ (2 * getPadding()));
// Item Weight
mItemWeight = new TextBox;
@@ -77,10 +77,9 @@ ItemPopup::ItemPopup():
mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mItemWeightScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mItemWeightScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight()));
+ mItemWeightScroll->setDimension(gcn::Rectangle(0, 0, 196, fontHeight));
mItemWeightScroll->setOpaque(false);
- mItemWeightScroll->setPosition(2, (3 * getFont()->getHeight()) +
- (4 * getPadding()));
+ mItemWeightScroll->setPosition(2, 3 * fontHeight + 4 * getPadding());
add(mItemName);
add(mItemDescScroll);
@@ -131,14 +130,14 @@ void ItemPopup::setItem(const ItemInfo &item)
const int numRowsWeight = mItemWeight->getNumberOfRows();
const int height = getFont()->getHeight();
- mItemDescScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsDesc *
- height));
+ mItemDescScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
+ numRowsDesc * height));
- mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsEffect
- * height));
+ mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
+ numRowsEffect * height));
- mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsWeight
- * height));
+ mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth,
+ numRowsWeight * height));
if (item.getEffect().empty())
{
@@ -164,7 +163,7 @@ void ItemPopup::updateColors()
graphics->setColor(guiPalette->getColor(Palette::TEXT));
}
-gcn::Color ItemPopup::getColor(short type)
+gcn::Color ItemPopup::getColor(ItemType type)
{
switch (type)
{
@@ -204,7 +203,7 @@ std::string ItemPopup::getItemName() const
return mItemName->getCaption();
}
-unsigned int ItemPopup::getNumRows()
+unsigned int ItemPopup::getNumRows() const
{
return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() +
mItemWeight->getNumberOfRows();
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index 8f110bc3..c08b188a 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -25,7 +25,8 @@
#include "gui/widgets/popup.h"
-class ItemInfo;
+#include "resources/iteminfo.h"
+
class ScrollArea;
class TextBox;
@@ -50,7 +51,7 @@ class ItemPopup : public Popup
/**
* Gets the number of rows that the item popup currently has.
*/
- unsigned int getNumRows();
+ unsigned int getNumRows() const;
/**
* Gets the name of the currently stored item in this popup.
@@ -72,12 +73,12 @@ class ItemPopup : public Popup
TextBox *mItemDesc;
TextBox *mItemEffect;
TextBox *mItemWeight;
- short mItemType;
+ ItemType mItemType;
ScrollArea *mItemDescScroll;
ScrollArea *mItemEffectScroll;
ScrollArea *mItemWeightScroll;
- static gcn::Color getColor(short type);
+ static gcn::Color getColor(ItemType type);
};
#endif // ITEMPOPUP_H
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index e9aa5ed2..700de32b 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -40,17 +40,20 @@ class ScrollArea : public gcn::ScrollArea
{
public:
/**
- * Constructor.
+ * Constructor that takes no content. Needed for use with the DropDown
+ * class.
*/
ScrollArea();
/**
* Constructor.
+ *
+ * @param content the initial content to show in the scroll area
*/
ScrollArea(gcn::Widget *content);
/**
- * Destructor.
+ * Destructor. Also deletes the content.
*/
~ScrollArea();
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index cf7b976b..036bdea8 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -143,8 +143,7 @@ void ItemDB::load()
itemInfo->setImageName(image);
itemInfo->setName(name.empty() ? _("Unnamed") : name);
itemInfo->setDescription(description);
- int type = itemTypeFromString(typeStr);
- itemInfo->setType(type);
+ itemInfo->setType(itemTypeFromString(typeStr));
itemInfo->setView(view);
itemInfo->setWeight(weight);
itemInfo->setWeaponType(weaponType);
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 5c76af40..3329d95b 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -156,10 +156,10 @@ class ItemInfo
const std::string &getEffect() const { return mEffect; }
- void setType(short type)
+ void setType(ItemType type)
{ mType = type; }
- short getType() const
+ ItemType getType() const
{ return mType; }
void setWeight(short weight)
@@ -196,7 +196,7 @@ class ItemInfo
std::string mName;
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
- char mType; /**< Item type. */
+ ItemType mType; /**< Item type. */
std::string mParticle; /**< Particle effect used with this item */
short mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */