summaryrefslogtreecommitdiff
path: root/src/gui/storagewindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/storagewindow.cpp')
-rw-r--r--src/gui/storagewindow.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index 579725c4..c07653b1 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -104,6 +104,9 @@ StorageWindow::StorageWindow(Inventory *inventory):
instances.push_back(this);
setVisible(true);
+
+ mInventory->addInventoyListener(this);
+ slotsChanged(mInventory);
}
StorageWindow::~StorageWindow()
@@ -111,26 +114,6 @@ StorageWindow::~StorageWindow()
instances.remove(this);
}
-void StorageWindow::logic()
-{
- if (!isVisible())
- return;
-
- Window::logic();
-
- const int usedSlots = mInventory->getNumberOfSlotsUsed();
-
- if (mUsedSlots != usedSlots)
- {
- mUsedSlots = usedSlots;
-
- mSlotsBar->setProgress((float) mUsedSlots / mInventory->getSize());
-
- mSlotsBar->setText(strprintf("%d/%d", mUsedSlots,
- mInventory->getSize()));
- }
-}
-
void StorageWindow::action(const gcn::ActionEvent &event)
{
if (event.getId() == "store")
@@ -202,6 +185,15 @@ Item *StorageWindow::getSelectedItem() const
return mItems->getSelectedItem();
}
+void StorageWindow::slotsChanged(Inventory* inventory)
+{
+ const int usedSlots = mInventory->getNumberOfSlotsUsed();
+
+ mSlotsBar->setProgress((float) usedSlots / mInventory->getSize());
+
+ mSlotsBar->setText(strprintf("%d/%d", usedSlots, mInventory->getSize()));
+}
+
void StorageWindow::addStore(Item *item, int amount)
{
Net::getInventoryHandler()->moveItem(Net::InventoryHandler::INVENTORY,