From 1702c84521ab707326de720aea0a53136779300d Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sun, 25 Jan 2009 20:43:59 -0700 Subject: Repaired item weight and slot reporting. Signed-off-by: Ira Rice --- src/gui/inventorywindow.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/gui/inventorywindow.cpp') 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)); } -- cgit v1.2.3-70-g09d2