summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorNikos Giagtzoglou <gnikos21@yahoo.gr>2008-11-22 11:43:53 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-11-22 11:43:53 +0100
commit991389a535985af072f830b89e5113da82650fe5 (patch)
tree071ec4153b820a9c6404d5845443403b3cda83fb /src/gui/inventorywindow.cpp
parentc79d12b91ef0e49878a8e3f10486b910184acc69 (diff)
downloadmana-991389a535985af072f830b89e5113da82650fe5.tar.gz
mana-991389a535985af072f830b89e5113da82650fe5.tar.bz2
mana-991389a535985af072f830b89e5113da82650fe5.tar.xz
mana-991389a535985af072f830b89e5113da82650fe5.zip
Inventory window now displays amount of slots used
Patch by Nikos, with some improvements by vargavind.
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index d01a2112..6a5a8b37 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -24,11 +24,11 @@
#include <string>
#include <guichan/mouseinput.hpp>
-
#include <guichan/widgets/label.hpp>
#include "button.h"
#include "gui.h"
+#include "inventory.h"
#include "item_amount.h"
#include "itemcontainer.h"
#include "scrollarea.h"
@@ -64,10 +64,13 @@ InventoryWindow::InventoryWindow():
mItemNameLabel = new gcn::Label("Name:");
mItemDescriptionLabel = new gcn::Label("Description:");
mItemEffectLabel = new gcn::Label("Effect:");
- mWeightLabel = new gcn::Label("Total Weight: - Maximum Weight: ");
+ mWeightLabel = new gcn::Label("Weight:");
mWeightLabel->setPosition(8, 8);
mInvenScroll->setPosition(8,
mWeightLabel->getY() + mWeightLabel->getHeight() + 5);
+ mInvenSlotLabel = new gcn::Label("Slots used:");
+ mInvenSlotLabel->setPosition(mWeightLabel->getX()
+ + mWeightLabel->getWidth() + 100, 8);
add(mUseButton);
add(mDropButton);
@@ -76,6 +79,7 @@ InventoryWindow::InventoryWindow():
add(mItemDescriptionLabel);
add(mItemEffectLabel);
add(mWeightLabel);
+ add(mInvenSlotLabel);
mUseButton->setSize(60, mUseButton->getHeight());
@@ -92,8 +96,14 @@ void InventoryWindow::logic()
// Update weight information
mWeightLabel->setCaption(
- "Total Weight: " + toString(player_node->mTotalWeight) + " - "
- "Maximum Weight: " + toString(player_node->mMaxWeight));
+ "Weight: " + toString(player_node->mTotalWeight) +
+ "/" + toString(player_node->mMaxWeight));
+
+ // Update number of items in inventory
+ mInvenSlotLabel->setCaption(
+ "Slots used: "
+ + toString(player_node->getInventory()->getNumberOfSlotsUsed())
+ + "/" + toString(player_node->getInventory()->getInventorySize()));
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -201,6 +211,7 @@ void InventoryWindow::widgetResized(const gcn::Event &event)
mItemDescriptionLabel->getY() - mWeightLabel->getHeight() - 18);
mWeightLabel->setWidth(width - 16);
+ mInvenSlotLabel->setWidth(width - 16);
}
void InventoryWindow::updateButtons()