summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-26 11:38:12 -0700
committerIra Rice <irarice@gmail.com>2009-01-26 11:38:12 -0700
commita1d19e32e1206e406409ca68db6f344535e16519 (patch)
treea9502376d859148a892b24ed8fa67990f1ac8a12
parent7a618a7f4f7c2efe2a6973cc37bc8283025e4782 (diff)
downloadmana-client-a1d19e32e1206e406409ca68db6f344535e16519.tar.gz
mana-client-a1d19e32e1206e406409ca68db6f344535e16519.tar.bz2
mana-client-a1d19e32e1206e406409ca68db6f344535e16519.tar.xz
mana-client-a1d19e32e1206e406409ca68db6f344535e16519.zip
Modified item popups to show the weight of the item as well. TODO:
modify itemdb to pull the item weight information from the server instead of the client, so as to always have the server and client in sync. Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/gui/itempopup.cpp71
-rw-r--r--src/gui/itempopup.h2
-rw-r--r--src/resources/itemdb.cpp6
3 files changed, 62 insertions, 17 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index f9916a89..42ef88ae 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -20,6 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/font.hpp>
+
#include <guichan/widgets/label.hpp>
#include "gui.h"
@@ -34,6 +36,7 @@
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
+#include "../utils/tostring.h"
ItemPopup::ItemPopup():
Window()
@@ -52,37 +55,50 @@ ItemPopup::ItemPopup():
mItemDesc = new TextBox();
mItemDesc->setEditable(false);
mItemDesc->setMinWidth(186);
+ mItemDesc->setTextWrapped("");
mItemDescScroll = new ScrollArea(mItemDesc);
mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mItemDescScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mItemDescScroll->setDimension(gcn::Rectangle(0, 0, 196, 14));
+ mItemDescScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight()));
mItemDescScroll->setOpaque(false);
- mItemDescScroll->setPosition(2, 15);
+ mItemDescScroll->setPosition(2, getFont()->getHeight());
// Item Effect
mItemEffect = new TextBox();
mItemEffect->setEditable(false);
mItemEffect->setMinWidth(186);
+ mItemEffect->setTextWrapped("");
mItemEffectScroll = new ScrollArea(mItemEffect);
mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mItemEffectScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mItemEffectScroll->setDimension(gcn::Rectangle(0, 0, 196, 14));
+ mItemEffectScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight()));
mItemEffectScroll->setOpaque(false);
- mItemEffectScroll->setPosition(2, 35);
+ mItemEffectScroll->setPosition(2, (2 * getFont()->getHeight()) + 5);
+
+ // Item Weight
+ mItemWeight = new TextBox();
+ mItemWeight->setEditable(false);
+ mItemWeight->setMinWidth(186);
+ mItemWeight->setTextWrapped("");
+ mItemWeightScroll = new ScrollArea(mItemWeight);
+
+ mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mItemWeightScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mItemWeightScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight()));
+ mItemWeightScroll->setOpaque(false);
+ mItemWeightScroll->setPosition(2, (3 * getFont()->getHeight()) + 10);
add(mItemName);
add(mItemDescScroll);
add(mItemEffectScroll);
+ add(mItemWeightScroll);
setLocationRelativeTo(getParent());
// LEEOR / TODO: This causes an exception error.
//moveToBottom(getParent());
-
- mItemDesc->setTextWrapped( "" );
- mItemEffect->setTextWrapped( "" );
}
void ItemPopup::setItem(const ItemInfo &item)
@@ -92,30 +108,57 @@ void ItemPopup::setItem(const ItemInfo &item)
mItemDesc->setMinWidth(width - 10);
mItemEffect->setMinWidth(width - 10);
+ mItemWeight->setMinWidth(width - 10);
mItemName->setCaption(item.getName());
mItemDesc->setTextWrapped(item.getDescription());
mItemEffect->setTextWrapped(item.getEffect());
+ mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
+ _(" grams"));
int numRowsDesc = mItemDesc->getNumberOfRows();
int numRowsEffect = mItemEffect->getNumberOfRows();
+ int numRowsWeight = mItemWeight->getNumberOfRows();
+
+ mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ numRowsDesc * getFont()->getHeight()));
+
+ mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ numRowsEffect * getFont()->getHeight()));
+
+ mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196,
+ numRowsWeight * getFont()->getHeight()));
if(item.getEffect() == "")
- setContentSize(200, (numRowsDesc * 14) + 30);
+ {
+ setContentSize(200, (numRowsDesc * getFont()->getHeight() +
+ (3 * getFont()->getHeight())));
+
+ mItemWeightScroll->setPosition(2,
+ (numRowsDesc * getFont()->getHeight()) +
+ (2 * getFont()->getHeight()));
+ }
else
- setContentSize(200, (numRowsDesc * 14) + (numRowsEffect * 14) + 30);
-
- mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196, numRowsDesc * 14));
+ {
+ setContentSize(200, (numRowsDesc * getFont()->getHeight()) +
+ (numRowsEffect * getFont()->getHeight()) +
+ (3 * getFont()->getHeight()));
- mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196, numRowsEffect * 14));
+ mItemWeightScroll->setPosition(2,
+ (numRowsDesc * getFont()->getHeight()) +
+ (numRowsEffect * getFont()->getHeight()) +
+ (2 * getFont()->getHeight()));
+ }
mItemDescScroll->setPosition(2, 20);
- mItemEffectScroll->setPosition(2, (numRowsDesc * 15) + 25);
+ mItemEffectScroll->setPosition(2, (numRowsDesc * getFont()->getHeight()) +
+ (2 * getFont()->getHeight()));
}
unsigned int ItemPopup::getNumRows()
{
- return mItemDesc->getNumberOfRows(), mItemEffect->getNumberOfRows();
+ return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() +
+ mItemWeight->getNumberOfRows();
}
void ItemPopup::view(int x, int y)
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index 8ae2c98f..0c729231 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -42,8 +42,10 @@ class ItemPopup : public Window
gcn::Label *mItemName;
TextBox *mItemDesc;
TextBox *mItemEffect;
+ TextBox *mItemWeight;
ScrollArea *mItemDescScroll;
ScrollArea *mItemEffectScroll;
+ ScrollArea *mItemWeightScroll;
};
#endif // ITEMPOPUP_H__
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index c32c3459..773febd7 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -84,7 +84,7 @@ void ItemDB::load()
}
int type = XML::getProperty(node, "type", 0);
- //int weight = XML::getProperty(node, "weight", 0);
+ int weight = XML::getProperty(node, "weight", 0);
int view = XML::getProperty(node, "view", 0);
std::string name = XML::getProperty(node, "name", "");
@@ -103,7 +103,7 @@ void ItemDB::load()
itemInfo->setEffect(effect);
itemInfo->setType(type);
itemInfo->setView(view);
- //itemInfo->setWeight(weight);
+ itemInfo->setWeight(weight);
itemInfo->setWeaponType(weaponType);
for_each_xml_child_node(itemChild, node)
@@ -158,7 +158,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