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 /src/gui/windows/inventorywindow.cpp | |
parent | fe1943114fb8a2e417b8f67483e143fcdc1cc213 (diff) | |
download | plus-90dd756673b47eed42e0941838033ba9fae59e1c.tar.gz plus-90dd756673b47eed42e0941838033ba9fae59e1c.tar.bz2 plus-90dd756673b47eed42e0941838033ba9fae59e1c.tar.xz plus-90dd756673b47eed42e0941838033ba9fae59e1c.zip |
Remember sort order in inventory and storage between restarts.
Diffstat (limited to 'src/gui/windows/inventorywindow.cpp')
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 42 |
1 files changed, 40 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") |