diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-05 14:45:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-05 14:45:04 +0300 |
commit | 90dd756673b47eed42e0941838033ba9fae59e1c (patch) | |
tree | 533f783533f4b577366cbbd084ef318538e5457d | |
parent | fe1943114fb8a2e417b8f67483e143fcdc1cc213 (diff) | |
download | manaverse-90dd756673b47eed42e0941838033ba9fae59e1c.tar.gz manaverse-90dd756673b47eed42e0941838033ba9fae59e1c.tar.bz2 manaverse-90dd756673b47eed42e0941838033ba9fae59e1c.tar.xz manaverse-90dd756673b47eed42e0941838033ba9fae59e1c.zip |
Remember sort order in inventory and storage between restarts.
-rw-r--r-- | src/defaults.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 42 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.h | 2 |
3 files changed, 44 insertions, 2 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 40b8fec66..9c5a3472f 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -342,6 +342,8 @@ DefaultsData* getConfigDefaults() AddDEF("doubleClick", true); AddDEF("useDiagonalSpeed", true); AddDEF("protectedItems", ""); + AddDEF("inventorySortOrder", 0); + AddDEF("storageSortOrder", 0); return configData; } 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. */ |