From 991389a535985af072f830b89e5113da82650fe5 Mon Sep 17 00:00:00 2001 From: Nikos Giagtzoglou Date: Sat, 22 Nov 2008 11:43:53 +0100 Subject: Inventory window now displays amount of slots used Patch by Nikos, with some improvements by vargavind. --- src/gui/inventorywindow.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/gui/inventorywindow.cpp') 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 #include - #include #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() -- cgit v1.2.3-70-g09d2