diff options
author | Ira Rice <irarice@gmail.com> | 2008-11-13 22:13:02 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-11-13 22:13:02 +0000 |
commit | 717e8babd1124a4c6c685a6386a84f58148d4931 (patch) | |
tree | 5070f4eaa0f7bb716207dfb744dfae497f73ab4b /src/gui | |
parent | 0436733dc9e412b12272fa7332831c9185c3d19b (diff) | |
download | mana-717e8babd1124a4c6c685a6386a84f58148d4931.tar.gz mana-717e8babd1124a4c6c685a6386a84f58148d4931.tar.bz2 mana-717e8babd1124a4c6c685a6386a84f58148d4931.tar.xz mana-717e8babd1124a4c6c685a6386a84f58148d4931.zip |
Added a slot display so that players can track how much space they've used.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/inventorywindow.cpp | 22 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 2 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 936416d1..1b2e5c63 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -34,6 +34,7 @@ #include "scrollarea.h" #include "viewport.h" +#include "../inventory.h" #include "../item.h" #include "../localplayer.h" @@ -73,6 +74,11 @@ InventoryWindow::InventoryWindow(): "Maximum Weight: " + mMaxWeight + " g"; mWeightLabel = new TextBox(); mWeightLabel->setPosition(8, 8); + mSlots = "Slots: " + + toString(player_node->getInventory()->getNumberOfSlotsUsed()) + + "/" + toString(player_node->getInventory()->getSize()); + mSlotsLabel = new TextBox(); + mItemEffectLabel = new TextBox(); draw(); @@ -83,6 +89,7 @@ InventoryWindow::InventoryWindow(): add(mItemDescriptionLabel); add(mItemEffectLabel); add(mWeightLabel); + add(mSlotsLabel); mUseButton->setSize(60, mUseButton->getHeight()); @@ -107,6 +114,10 @@ void InventoryWindow::logic() mWeight = "Total Weight: " + mTotalWeight + " g - " + "Maximum Weight: " + mMaxWeight + " g"; + mSlots = "Slots: " + + toString(player_node->getInventory()->getNumberOfSlotsUsed()) + + "/" + toString(player_node->getInventory()->getSize()); + draw(); } } @@ -222,12 +233,19 @@ void InventoryWindow::draw() mItemEffectLabel->getY() - 5 - (mItemDescriptionLabel->getNumberOfRows()*15), width - 16, (mItemDescriptionLabel->getNumberOfRows()*15))); + mSlotsLabel->setMinWidth(width - 16); + mSlotsLabel->setTextWrapped(mSlots); + mSlotsLabel->setDimension(gcn::Rectangle(8, + mItemDescriptionLabel->getY() - 5 - (mSlotsLabel->getNumberOfRows()*15), + width - 16, + (mSlotsLabel->getNumberOfRows()*15))); mInvenScroll->setSize(width - 16, - mItemDescriptionLabel->getY() - (mWeightLabel->getNumberOfRows()*15) - 18); + mSlotsLabel->getY() - (mWeightLabel->getNumberOfRows()*15) - 18); mInvenScroll->setPosition(8, (mWeightLabel->getNumberOfRows()*15) + 10); - setMinHeight(130 + (mWeightLabel->getNumberOfRows()*15) + + setMinHeight(130 + (mSlotsLabel->getNumberOfRows()*15) + + (mWeightLabel->getNumberOfRows()*15) + (mItemDescriptionLabel->getNumberOfRows()*15) + (mItemEffectLabel->getNumberOfRows()*15) + (mItemNameLabel->getNumberOfRows()*15)); diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index e6170dac..055bfad9 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -92,12 +92,14 @@ class InventoryWindow : public Window, gcn::ActionListener, std::string mWeight; std::string mTotalWeight; std::string mMaxWeight; + std::string mSlots; gcn::Button *mUseButton, *mDropButton; gcn::ScrollArea *mInvenScroll; TextBox *mItemNameLabel; TextBox *mItemDescriptionLabel; TextBox *mItemEffectLabel; TextBox *mWeightLabel; + TextBox *mSlotsLabel; }; extern InventoryWindow *inventoryWindow; |