From e580ef08d69268ee53cca8a91949adf436e800cc Mon Sep 17 00:00:00 2001 From: jak1 Date: Tue, 3 Nov 2020 12:00:11 +0100 Subject: added 'store all' button shown: when in storage window --- src/gui/windows/inventorywindow.cpp | 31 ++++++++++++++++++++++++++++++- src/gui/windows/inventorywindow.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 28d83b10f..f86410a8c 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -98,6 +98,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) : mCartButton(nullptr), mEquipmentButton(nullptr), mStoreButton(nullptr), + mStoreAllButton(nullptr), mRetrieveButton(nullptr), mInvCloseButton(nullptr), mWeightBar(nullptr), @@ -231,6 +232,12 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) : "drop", BUTTON_SKIN, this); + mStoreAllButton = new Button(this, + // TRANSLATORS: storage button + _("Store all"), + "storeall", + BUTTON_SKIN, + this); mOutfitButton = new Button(this, // TRANSLATORS: inventory outfits button _("O"), @@ -280,6 +287,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) : place(0, 2, invenScroll, 11, 1).setPadding(3); place(0, 3, mUseButton, 1, 1); place(1, 3, mDropButton, 1, 1); + place(2, 3, mStoreAllButton, 1, 1); + ContainerPlacer placer = getPlacer(10, 3); placer(0, 0, mShopButton, 1, 1); placer(1, 0, mOutfitButton, 1, 1); @@ -503,6 +512,22 @@ void InventoryWindow::action(const ActionEvent &event) 0); } } + else if (eventId == "storeall") + { + if (storageWindow != nullptr) + { + for (int i = 0; i < mInventory->getNumberOfSlotsUsed(); i++) + { + Item *const item = mInventory->getItem(i); + if (item == nullptr) + continue; + inventoryHandler->moveItem2(InventoryType::Inventory, + item->getInvIndex(), + item->getQuantity(), + InventoryType::Storage); + } + } + } else if (eventId == "sort") { mItems->setSortType(mSortDropDown->getSelected()); @@ -520,7 +545,6 @@ void InventoryWindow::action(const ActionEvent &event) mItems->setFilter(ItemDB::getTagId(tagName)); return; } - Item *const item = mItems->getSelectedItem(); if (item == nullptr) @@ -984,8 +1008,13 @@ void InventoryWindow::updateDropButton() // TRANSLATORS: inventory button mDropButton->setCaption(_("Store")); } + if (isStorageActive()) + { + mStoreAllButton->setVisible(Visible_true); + } else { + mStoreAllButton->setVisible(Visible_false); const Item *const item = mItems->getSelectedItem(); if ((item != nullptr) && item->getQuantity() > 1) { diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 2f1baf356..2da114185 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -189,6 +189,7 @@ class InventoryWindow final : public Window, Button *mCartButton; Button *mEquipmentButton; Button *mStoreButton; + Button *mStoreAllButton; Button *mRetrieveButton; Button *mInvCloseButton; -- cgit v1.2.3-70-g09d2