summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-26 00:27:05 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-26 00:32:19 +0100
commitdfcc6397848d4597b386b688f689352de6c19ae2 (patch)
treea6e8c9afd6a49ea96e4498080a96d3e06ecaebd7 /src/gui/inventorywindow.cpp
parentcd20fb3432498b8871401bdd65a143197e2a6538 (diff)
downloadmana-client-dfcc6397848d4597b386b688f689352de6c19ae2.tar.gz
mana-client-dfcc6397848d4597b386b688f689352de6c19ae2.tar.bz2
mana-client-dfcc6397848d4597b386b688f689352de6c19ae2.tar.xz
mana-client-dfcc6397848d4597b386b688f689352de6c19ae2.zip
Remove redundancy, fix variable names and other code cleanups
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 0b554469..5a5d8db6 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -136,34 +136,28 @@ void InventoryWindow::logic()
// redesign of InventoryWindow and ItemContainer probably.
updateButtons();
+ const int usedSlots = player_node->getInventory()->getNumberOfSlotsUsed();
+ const std::string usedSlotsStr = toString(usedSlots);
+
if (mMaxWeight != player_node->getMaxWeight() ||
mTotalWeight != player_node->getTotalWeight() ||
- mUsedSlots != toString(player_node->getInventory()->getNumberOfSlotsUsed()))
+ mUsedSlots != usedSlotsStr)
{
mTotalWeight = player_node->getTotalWeight();
mMaxWeight = player_node->getMaxWeight();
- mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
+ mUsedSlots = usedSlotsStr;
// Weight Bar coloration
- if (int(player_node->getTotalWeight()) < int(player_node->getMaxWeight() / 3))
- {
+ if (mTotalWeight < (int) (mMaxWeight / 3))
mWeightBar->setColor(0, 0, 255); // Blue
- }
- else if (int(player_node->getTotalWeight()) <
- int((player_node->getMaxWeight() / 3) * 2))
- {
+ else if (mTotalWeight < (int) ((mMaxWeight * 2) / 3))
mWeightBar->setColor(255, 255, 0); // Yellow
- }
else
- {
mWeightBar->setColor(255, 0, 0); // Red
- }
// Adjust progress bars
- mSlotsBar->setProgress((float)
- player_node->getInventory()->getNumberOfSlotsUsed() / mMaxSlots);
- mWeightBar->setProgress((float) player_node->getTotalWeight() /
- player_node->getMaxWeight());
+ mSlotsBar->setProgress((float) usedSlots / mMaxSlots);
+ mWeightBar->setProgress((float) mTotalWeight / mMaxWeight);
mSlotsBar->setText(strprintf("%s/%d", mUsedSlots.c_str(), mMaxSlots));
mWeightBar->setText(strprintf("%s/%s",