diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-02-24 15:21:11 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-02-24 15:51:39 -0700 |
commit | d039422e70e47a762ef61de619e9e98780b12664 (patch) | |
tree | d0cb68147e6fe37a8c85e4907766976bf79547b4 /src/gui/storagewindow.cpp | |
parent | 84cf9bcc38028696d02c03cd523b7997906b9f01 (diff) | |
download | mana-d039422e70e47a762ef61de619e9e98780b12664.tar.gz mana-d039422e70e47a762ef61de619e9e98780b12664.tar.bz2 mana-d039422e70e47a762ef61de619e9e98780b12664.tar.xz mana-d039422e70e47a762ef61de619e9e98780b12664.zip |
Move StorageWindow to instancing intead of global
Also make storage under eAthena more flexible.
Reviewed-by: Dennis Friis
Diffstat (limited to 'src/gui/storagewindow.cpp')
-rw-r--r-- | src/gui/storagewindow.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index ff0ba162..bf54afb9 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -52,9 +52,11 @@ #include <string> -StorageWindow::StorageWindow(int invSize): +StorageWindow::WindowList StorageWindow::instances; + +StorageWindow::StorageWindow(Inventory *inventory): Window(_("Storage")), - mMaxSlots(invSize), + mInventory(inventory), mItemDesc(false) { setWindowName("Storage"); @@ -70,19 +72,19 @@ StorageWindow::StorageWindow(int invSize): mCloseButton = new Button(_("Close"), "close", this); - mItems = new ItemContainer(player_node->getStorage(), true); + mItems = new ItemContainer(mInventory, true); mItems->addSelectionListener(this); gcn::ScrollArea *invenScroll = new ScrollArea(mItems); invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mUsedSlots = player_node->getStorage()->getNumberOfSlotsUsed(); + mUsedSlots = mInventory->getNumberOfSlotsUsed(); mSlotsLabel = new Label(_("Slots:")); mSlotsBar = new ProgressBar(0.0f, 100, 20, gcn::Color(225, 200, 25)); - mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mMaxSlots)); - mSlotsBar->setProgress((float) mUsedSlots / mMaxSlots); + mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mInventory->getSize())); + mSlotsBar->setProgress((float) mUsedSlots / mInventory->getSize()); setMinHeight(130); setMinWidth(200); @@ -98,10 +100,14 @@ StorageWindow::StorageWindow(int invSize): layout.setRowHeight(0, mStoreButton->getHeight()); loadWindowState(); + + instances.push_back(this); + setVisible(true); } StorageWindow::~StorageWindow() { + instances.remove(this); } void StorageWindow::logic() @@ -111,15 +117,16 @@ void StorageWindow::logic() Window::logic(); - const int usedSlots = player_node->getStorage()->getNumberOfSlotsUsed(); + const int usedSlots = mInventory->getNumberOfSlotsUsed(); if (mUsedSlots != usedSlots) { mUsedSlots = usedSlots; - mSlotsBar->setProgress((float) mUsedSlots / mMaxSlots); + mSlotsBar->setProgress((float) mUsedSlots / mInventory->getSize()); - mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mMaxSlots)); + mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, + mInventory->getSize())); } } @@ -173,7 +180,7 @@ void StorageWindow::mouseClicked(gcn::MouseEvent &event) */ const int mx = event.getX() + getX(); const int my = event.getY() + getY(); - viewport->showPopup(mx, my, item, false); + viewport->showPopup(this, mx, my, item, false); } if (event.getButton() == gcn::MouseEvent::LEFT) { @@ -211,4 +218,6 @@ void StorageWindow::removeStore(Item *item, int amount) void StorageWindow::close() { Net::getInventoryHandler()->closeStorage(Net::InventoryHandler::STORAGE); + + scheduleDelete(); } |