diff options
author | Ira Rice <irarice@gmail.com> | 2009-03-25 19:14:04 -0600 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-03-25 19:14:04 -0600 |
commit | bfa4a2e11e0c31418d21a91eca7495589c50c11e (patch) | |
tree | 8f5202581b2877018dd0fc6c7b3529572dcae0dd /src/gui | |
parent | 34b7a86d06eba936c0642bc66ba104e4669d6b01 (diff) | |
download | mana-bfa4a2e11e0c31418d21a91eca7495589c50c11e.tar.gz mana-bfa4a2e11e0c31418d21a91eca7495589c50c11e.tar.bz2 mana-bfa4a2e11e0c31418d21a91eca7495589c50c11e.tar.xz mana-bfa4a2e11e0c31418d21a91eca7495589c50c11e.zip |
Merged relevent changes from TMW commit
dfcc6397848d4597b386b688f689352de6c19ae2
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/inventorywindow.cpp | 40 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.h | 2 |
4 files changed, 24 insertions, 26 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)); } } diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 83e98687..5035bf1c 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -78,9 +78,9 @@ class InventoryWindow : public Window, gcn::ActionListener, std::string mWeight; std::string mSlots; - std::string mUsedSlots; - std::string mTotalWeight; - std::string mMaxWeight; + int mUsedSlots; + int mTotalWeight; + int mMaxWeight; gcn::Button *mUseButton, *mDropButton; gcn::ScrollArea *mInvenScroll; diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index f3cc4f83..3dbf6d1a 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -34,7 +34,7 @@ Image *ResizeGrip::gripImage = 0; int ResizeGrip::mInstances = 0; float ResizeGrip::mAlpha = config.getValue("guialpha", 0.8); -ResizeGrip::ResizeGrip(std::string image) +ResizeGrip::ResizeGrip(const std::string &image) { if (mInstances == 0) { diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 7c96af45..83af24da 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -40,7 +40,7 @@ class ResizeGrip : public gcn::Widget /** * Constructor. */ - ResizeGrip(std::string image = "graphics/gui/resize.png"); + ResizeGrip(const std::string &image = "graphics/gui/resize.png"); /** * Destructor. |