diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 42 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.h | 2 |
2 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index e72945b99..dde1bf709 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -136,12 +136,28 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): { setCaption(gettext(inventory->getName().c_str())); setWindowName(inventory->getName()); + switch (inventory->getType()) + { + case Inventory::INVENTORY: + case Inventory::CART: + case Inventory::TRADE: + case Inventory::NPC: + default: + mSortDropDown->setSelected(config.getIntValue( + "inventorySortOrder")); + break; + case Inventory::STORAGE: + mSortDropDown->setSelected(config.getIntValue( + "storageSortOrder")); + break; + }; } else { // TRANSLATORS: inventory window name setCaption(_("Inventory")); setWindowName("Inventory"); + mSortDropDown->setSelected(0); } listen(CHANNEL_ATTRIBUTES); @@ -173,8 +189,6 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): mFilter->addActionListener(this); mFilter->setActionEventId("tag_"); - mSortDropDown->setSelected(0); - StringVect tags = ItemDB::getTags(); const size_t sz = tags.size(); for (size_t f = 0; f < sz; f ++) @@ -270,6 +284,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): enableVisibleSound(true); slotsChanged(mInventory); + mItems->setSortType(mSortDropDown->getSelected()); widgetResized(gcn::Event(nullptr)); if (!isMainInventory()) setVisible(true); @@ -288,6 +303,28 @@ InventoryWindow::~InventoryWindow() mTextPopup = nullptr; } +void InventoryWindow::storeSortOrder() +{ + if (mInventory) + { + switch (mInventory->getType()) + { + case Inventory::INVENTORY: + case Inventory::CART: + case Inventory::TRADE: + case Inventory::NPC: + default: + config.setValue("inventorySortOrder", + mSortDropDown->getSelected()); + break; + case Inventory::STORAGE: + config.setValue("storageSortOrder", + mSortDropDown->getSelected()); + break; + }; + } +} + void InventoryWindow::action(const gcn::ActionEvent &event) { const std::string &eventId = event.getId(); @@ -337,6 +374,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) else if (eventId == "sort") { mItems->setSortType(mSortDropDown->getSelected()); + storeSortOrder(); return; } else if (eventId == "namefilter") diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 7a2d1ec9f..459e3bfa2 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -69,6 +69,8 @@ class InventoryWindow final : public Window, */ ~InventoryWindow(); + void storeSortOrder(); + /** * Called when receiving actions from the widgets. */ |