summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-25 20:43:59 -0700
committerIra Rice <irarice@gmail.com>2009-01-25 20:43:59 -0700
commit1702c84521ab707326de720aea0a53136779300d (patch)
tree1fe03173d44b8c20aeaf745de8dc230f6e8a59d0 /src
parent2273323d978cd85fb22f4dd3dfe0d018f72241fb (diff)
downloadmana-1702c84521ab707326de720aea0a53136779300d.tar.gz
mana-1702c84521ab707326de720aea0a53136779300d.tar.bz2
mana-1702c84521ab707326de720aea0a53136779300d.tar.xz
mana-1702c84521ab707326de720aea0a53136779300d.zip
Repaired item weight and slot reporting.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/inventorywindow.cpp27
-rw-r--r--src/gui/inventorywindow.h4
2 files changed, 17 insertions, 14 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 76f83996..52198180 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -47,7 +47,7 @@
InventoryWindow::InventoryWindow(int invSize):
Window(_("Inventory")),
- mSize(invSize),
+ mMaxSlots(invSize),
mItemDesc(false)
{
setWindowName(_("Inventory"));
@@ -68,15 +68,14 @@ InventoryWindow::InventoryWindow(int invSize):
mTotalWeight = toString(player_node->mTotalWeight);
mMaxWeight = toString(player_node->mMaxWeight);
+ mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
mWeight = strprintf(_("Weight: %d g / %d g"),
- player_node->mTotalWeight,
- player_node->mMaxWeight) + " " +
- strprintf(_("Slots used: %d / %d"),
- player_node->getInventory()->getNumberOfSlotsUsed(),
- mSize);
+ atoi(mTotalWeight.c_str()), atoi(mMaxWeight.c_str()));
+ mSlots = strprintf(_("Slots used: %d / %d"),
+ atoi(mUsedSlots.c_str()), mMaxSlots);
- mWeightLabel = new gcn::Label(mWeight);
+ mWeightLabel = new gcn::Label(mWeight + " " + mSlots);
setMinHeight(130);
setMinWidth(getFont()->getWidth(mWeight));
@@ -105,18 +104,20 @@ void InventoryWindow::logic()
updateButtons();
if ((mMaxWeight != toString(player_node->mMaxWeight)) ||
- mTotalWeight != toString(player_node->mTotalWeight))
+ mTotalWeight != toString(player_node->mTotalWeight) ||
+ mUsedSlots != toString(player_node->getInventory()->getNumberOfSlotsUsed()))
{
mTotalWeight = toString(player_node->mTotalWeight);
mMaxWeight = toString(player_node->mMaxWeight);
+ mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
// Adjust widgets
mWeight = strprintf(_("Weight: %d g / %d g"),
- player_node->mTotalWeight,
- player_node->mMaxWeight) + " " +
- strprintf(_("Slots used: %d / %d"),
- player_node->getInventory()->getNumberOfSlotsUsed(),
- mSize);
+ atoi(mTotalWeight.c_str()), atoi(mMaxWeight.c_str()));
+ mSlots = strprintf(_("Slots used: %d / %d"),
+ atoi(mUsedSlots.c_str()), mMaxSlots);
+
+ mWeightLabel->setCaption(mWeight + " " + mSlots);
setMinWidth(getFont()->getWidth(mWeight));
}
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index a1f8b858..da7c1cee 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -71,13 +71,15 @@ class InventoryWindow : public Window, gcn::ActionListener,
ItemContainer *mItems;
std::string mWeight;
+ std::string mSlots;
+ std::string mUsedSlots;
std::string mTotalWeight;
std::string mMaxWeight;
gcn::Button *mUseButton, *mDropButton;
gcn::ScrollArea *mInvenScroll;
gcn::Label *mWeightLabel;
- int mSize;
+ int mMaxSlots;
bool mItemDesc;
};