summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-25 19:14:04 -0600
committerIra Rice <irarice@gmail.com>2009-03-25 19:14:04 -0600
commitbfa4a2e11e0c31418d21a91eca7495589c50c11e (patch)
tree8f5202581b2877018dd0fc6c7b3529572dcae0dd /src/gui/inventorywindow.cpp
parent34b7a86d06eba936c0642bc66ba104e4669d6b01 (diff)
downloadmana-client-bfa4a2e11e0c31418d21a91eca7495589c50c11e.tar.gz
mana-client-bfa4a2e11e0c31418d21a91eca7495589c50c11e.tar.bz2
mana-client-bfa4a2e11e0c31418d21a91eca7495589c50c11e.tar.xz
mana-client-bfa4a2e11e0c31418d21a91eca7495589c50c11e.zip
Merged relevent changes from TMW commit
dfcc6397848d4597b386b688f689352de6c19ae2 Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index f6e81fc5..b72a6ff0 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -44,7 +44,6 @@
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-#include "../utils/stringutils.h"
InventoryWindow::InventoryWindow(int invSize):
Window(_("Inventory")),
@@ -77,9 +76,9 @@ InventoryWindow::InventoryWindow(int invSize):
mInvenScroll = new ScrollArea(mItems);
mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mTotalWeight = toString(player_node->mTotalWeight);
- mMaxWeight = toString(player_node->mMaxWeight);
- mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
+ mTotalWeight = player_node->mTotalWeight;
+ mMaxWeight = player_node->mMaxWeight;
+ mUsedSlots = player_node->getInventory()->getNumberOfSlotsUsed();
mSlotsLabel = new Label(_("Slots: "));
mWeightLabel = new Label(_("Weight: "));
@@ -120,21 +119,22 @@ void InventoryWindow::logic()
// redesign of InventoryWindow and ItemContainer probably.
updateButtons();
- if ((mMaxWeight != toString(player_node->mMaxWeight)) ||
- mTotalWeight != toString(player_node->mTotalWeight) ||
- mUsedSlots != toString(player_node->getInventory()->getNumberOfSlotsUsed()))
+ const int usedSlots = player_node->getInventory()->getNumberOfSlotsUsed();
+
+ if (mMaxWeight != player_node->mMaxWeight ||
+ mTotalWeight != player_node->mTotalWeight ||
+ mUsedSlots != usedSlots)
{
- mTotalWeight = toString(player_node->mTotalWeight);
- mMaxWeight = toString(player_node->mMaxWeight);
- mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
+ mTotalWeight = player_node->mTotalWeight;
+ mMaxWeight = player_node->mMaxWeight;
+ mUsedSlots = usedSlots;
// Weight Bar coloration
- if (int(player_node->mTotalWeight) < int(player_node->mMaxWeight / 3))
+ if (mTotalWeight < (mMaxWeight / 3))
{
mWeightBar->setColor(0, 0, 255); // Blue
}
- else if (int(player_node->mTotalWeight) <
- int((player_node->mMaxWeight / 3) * 2))
+ else if (mTotalWeight < ((mMaxWeight / 3) * 2))
{
mWeightBar->setColor(255, 255, 0); // Yellow
}
@@ -144,14 +144,12 @@ void InventoryWindow::logic()
}
// Adjust progress bars
- mSlotsBar->setProgress((float)
- player_node->getInventory()->getNumberOfSlotsUsed() / mMaxSlots);
- mWeightBar->setProgress((float) player_node->mTotalWeight /
- player_node->mMaxWeight);
-
- mSlotsBar->setText(strprintf("%s/%d", mUsedSlots.c_str(), mMaxSlots));
- mWeightBar->setText(strprintf("%sg/%sg", mTotalWeight.c_str(),
- mMaxWeight.c_str()));
+ mSlotsBar->setProgress((float) mUsedSlots / mMaxSlots);
+ mWeightBar->setProgress((float) mTotalWeight / mMaxWeight);
+
+ mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mMaxSlots));
+ mWeightBar->setText(strprintf("%dg/%dg", mTotalWeight,
+ mMaxWeight));
}
}