From c3a633ae507670c29969d8d5520d115a01d33e6f Mon Sep 17 00:00:00 2001 From: bensaine Date: Sun, 21 Nov 2021 00:33:15 -0500 Subject: [PATCH 1/4] add: srcInvIndex --- .../src/interface_v3/action_handler_item.cpp | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 9bbf9fbc8..af962e918 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -562,7 +562,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet //===================================================================================================================== - static void sendExchangeAddToServer(uint16 srcSlotIndex, uint16 destSlotIndex, uint16 quantitySrc) + static void sendExchangeAddToServer(unint16 srcInvIndex, uint16 srcSlotIndex, uint16 destSlotIndex, uint16 quantitySrc) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -571,6 +571,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { // Swap all the Src (quantity= quantitySrc) to dest + out.serial(srcInvIndex); out.serial(srcSlotIndex); out.serial(destSlotIndex); out.serial(quantitySrc); @@ -615,7 +616,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server - sendExchangeAddToServer((uint16)src->getIndexInDB(), (uint8)dest->getIndexInDB(), (uint16)quantitySrc); + sendExchangeAddToServer((uint16) src->getInventoryIndex(), (uint16)src->getIndexInDB(), (uint8)dest->getIndexInDB(), (uint16)quantitySrc); } else { @@ -725,7 +726,7 @@ static void validateStackItem(CDBCtrlSheet *pCSSrc, CDBCtrlSheet *pCSDst, sint32 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server - sendExchangeAddToServer((uint16)pCSSrc->getIndexInDB(), (uint8)pCSDst->getIndexInDB(), (uint16)val); + sendExchangeAddToServer((uint16)pCSSrc->getInventoryIndex(), (uint16)pCSSrc->getIndexInDB(), (uint8)pCSDst->getIndexInDB(), (uint16)val); } } } @@ -1049,9 +1050,21 @@ class CCanDropToExchange : public IActionHandler if (!pCSSrc || !pCSDst) return; // Exchange can only be done from bag to exchange inventories - - if (pCSSrc->getSecondIndexInDB() == INVENTORIES::bag && - pCSDst->getSecondIndexInDB() == INVENTORIES::exchange) + uint32 srcInventory = pCSSrc->getSecondIndexInDB(); + if ( + (srcInventory == INVENTORIES::bag || + srcInventory == INVENTORIES::pet_animal1 || + srcInventory == INVENTORIES::pet_animal2 || + srcInventory == INVENTORIES::pet_animal3 || + srcInventory == INVENTORIES::pet_animal4 || + srcInventory == INVENTORIES::pet_animal5 || + srcInventory == INVENTORIES::pet_animal6 || + srcInventory == INVENTORIES::pet_animal7 || + srcInventory == INVENTORIES::guild || + srcInventory == INVENTORIES::player_room) + && getInventory().isInventoryAvailable((INVENTORIES::TInventory) pCSSrc->getSecondIndexInDB()) + && pCSDst->getSecondIndexInDB() == INVENTORIES::exchange + ) { if (checkCanExchangeItem(pCSSrc)) { From e1527b724b47ce2fb0f286a74894c93e4302d6d1 Mon Sep 17 00:00:00 2001 From: bensaine Date: Sun, 21 Nov 2021 01:09:53 -0500 Subject: [PATCH 2/4] fix: typo --- ryzom/client/src/interface_v3/action_handler_item.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index af962e918..46171b6c1 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -562,7 +562,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet //===================================================================================================================== - static void sendExchangeAddToServer(unint16 srcInvIndex, uint16 srcSlotIndex, uint16 destSlotIndex, uint16 quantitySrc) + static void sendExchangeAddToServer(uint16 srcInvIndex, uint16 srcSlotIndex, uint16 destSlotIndex, uint16 quantitySrc) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -616,7 +616,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server - sendExchangeAddToServer((uint16) src->getInventoryIndex(), (uint16)src->getIndexInDB(), (uint8)dest->getIndexInDB(), (uint16)quantitySrc); + sendExchangeAddToServer((uint16) src->getSecondIndexInDB(), (uint16)src->getIndexInDB(), (uint8)dest->getIndexInDB(), (uint16)quantitySrc); } else { @@ -726,7 +726,7 @@ static void validateStackItem(CDBCtrlSheet *pCSSrc, CDBCtrlSheet *pCSDst, sint32 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server - sendExchangeAddToServer((uint16)pCSSrc->getInventoryIndex(), (uint16)pCSSrc->getIndexInDB(), (uint8)pCSDst->getIndexInDB(), (uint16)val); + sendExchangeAddToServer((uint16)pCSSrc->getSecondIndexInDB(), (uint16)pCSSrc->getIndexInDB(), (uint8)pCSDst->getIndexInDB(), (uint16)val); } } } From b4ce38099fdfa8af56c651142dbcc480fc245791 Mon Sep 17 00:00:00 2001 From: bensaine Date: Wed, 1 Dec 2021 12:28:34 -0500 Subject: [PATCH 3/4] add: sorting (initial draft) --- .../src/interface_v3/action_handler_item.cpp | 13 ++ .../src/interface_v3/dbgroup_list_sheet.cpp | 2 + .../src/interface_v3/dbgroup_list_sheet.h | 4 + .../interface_v3/dbgroup_list_sheet_text.cpp | 2 + .../interface_v3/dbgroup_list_sheet_text.h | 4 + .../interface_v3/dbgroup_list_sheet_trade.cpp | 4 +- .../src/interface_v3/inventory_manager.cpp | 168 ++++++++++-------- .../src/interface_v3/inventory_manager.h | 16 +- ryzom/client/src/net_manager.cpp | 2 +- 9 files changed, 137 insertions(+), 78 deletions(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 46171b6c1..a8055996a 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1666,6 +1666,19 @@ class CHandlerDragNDrop : public IActionHandler }; REGISTER_ACTION_HANDLER( CHandlerDragNDrop, "drag_n_drop" ); +// ********************************************************************************************************** +class CHandlerSortInv : public IActionHandler +{ + void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + { + std::string inv = getParam(sParams, "inv"); + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo("CHandlerSortInv "+inv); + CInventoryManager *pInv = CInventoryManager::getInstance(); + pInv->sortInv(INVENTORIES::toInventory(inv)); + } +}; +REGISTER_ACTION_HANDLER( CHandlerSortInv, "sort_inv" ); // ********************************************************************************************************** static void sendToServerEnchantMessage(uint8 invent, uint16 slot) diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 487b77c99..4c438d984 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -58,6 +58,8 @@ CDBGroupListSheet::CDBGroupListSheet(const TCtorParam ¶m) _MinRows= 1; _MaxRows= INT_MAX; _MaxItems= INT_MAX; + _SortBy = 0; + _SortDir = 0; _NbColumns= 2; _WSlot= 24; _WSpace= 0; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index 211d872dc..b1f1f29c1 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -78,6 +78,8 @@ public: // Called when the list changed for a reason or another and should be reconstructed to possibly sort items virtual void sort() { } void needToSort() { _NeedToSort = true; invalidateCoords(); } + void setSortBy(sint32 sortBy) { _SortBy = sortBy; } + void setSortDir(sint32 sortDir) { _SortDir = sortDir; } /** (useful for list only) Force the validity of an element, even if its sheetId==0 * (empty slot displayed instead) @@ -173,6 +175,8 @@ protected: bool _Array : 1; bool _Squarify : 1; + sint32 _SortBy; + sint32 _SortDir; bool _CanDrop : 1; bool _Draggable : 1; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 8cc114508..dcbd0e9db 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -44,6 +44,8 @@ CDBGroupListSheetText::CDBGroupListSheetText(const TCtorParam ¶m) _TextTemplate(TCtorParam()) { _MaxItems = INT_MAX; + _SortBy = 0; + _SortDir = 0; _WSlot= 24; _HSlot= 24; _HSpace = 0; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index 329d7bcea..d45ce122a 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -184,6 +184,8 @@ public: // Called when the list changed for a reason or another and should be reconstructed to possibly sort items virtual void sort() { } void needToSort() { _NeedToSort = true; invalidateCoords(); } + void setSortBy(sint32 sortBy) { _SortBy = sortBy; } + void setSortDir(sint32 sortDir) { _SortDir = sortDir; } /// Gets. sint32 getWSlot() const {return _WSlot;} @@ -253,6 +255,8 @@ protected: std::vector _SheetChildren; bool _NeedToSort; + sint32 _SortBy; + sint32 _SortDir; // Drag'n'Drop sint32 _Scrolling; sint64 _LastTimeScrolled; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 0d93baccb..d1147ddf3 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -720,9 +720,7 @@ void CDBGroupListSheetTrade::sort() for (i = 0; i < _SheetChildren.size(); ++i) { vTemp[i].SheetText = _SheetChildren[i]; - - CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; - initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); + initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, 0, i); } std::sort(vTemp.begin(), vTemp.end()); diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp index 1bb3c478f..e16c83cbb 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -35,6 +35,7 @@ #include "../net_manager.h" #include "../user_entity.h" #include "../global.h" +#include #include "nel/misc/algo.h" @@ -864,7 +865,7 @@ void CInventoryManager::wearBagItem(sint32 bagEntryIndex) BagItemEquipped[bagEntryIndex]= true; grayItem (LIST_BAG_TEXT, bagEntryIndex, true); grayItem (LIST_BAG_ICONS, bagEntryIndex, true); - sortBag(); + sortAll(); } } @@ -876,7 +877,7 @@ void CInventoryManager::unwearBagItem(sint32 bagEntryIndex) BagItemEquipped[bagEntryIndex]= false; grayItem (LIST_BAG_TEXT, bagEntryIndex, false); grayItem (LIST_BAG_ICONS, bagEntryIndex, false); - sortBag(); + sortAll(); } } @@ -2114,11 +2115,12 @@ bool CTempInvManager::isOpened() // *************************************************************************** #define BAG_ITEM_NOT_SORTED 1000000 // Used for sorting -void initStructForItemSort(vector&vTemp, sint32 sheetId, sint32 quality, sint32 indexInList, sint32 indexInDB) +void initStructForItemSort(vector&vTemp, CDBCtrlSheet *ctrl, sint32 sortBy, sint32 indexInList) { // Default value is the linear pos in the db (in case its not an item) - vTemp[indexInList].Pos = toString("%08d", indexInDB); - + vTemp[indexInList].Pos = toString("%08d", ctrl->getIndexInDB()); + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + sint32 sheetId = ctrl->getSheetId(); // if not empty if (sheetId != 0) { @@ -2126,7 +2128,18 @@ void initStructForItemSort(vector&vTemp, sint32 sheetId, sint32 qua if ((pItem != NULL) && (pItem->Type == CEntitySheet::ITEM)) { CItemSheet *pIS = safe_cast(pItem); - vTemp[indexInList].Pos = toString("%02d", pIS->Family); + std::map primarySort = { + {0, pIS->Family}, + {1, ctrl->getQuantity()}, + {2, ctrl->getQuality()}, + {3, (pIS->Bulk*100)*(ctrl->getQuantity())}, + {4, (ctrl->getItemWeight())*(ctrl->getQuantity())} + }; + // Sort by + vTemp[indexInList].Pos = toString("%08d", primarySort[sortBy]); + + // Secondary sort + vTemp[indexInList].Pos += toString("%02d", pIS->Family); vTemp[indexInList].Pos += toString("%03d", pIS->ItemType); // add some specific sort for raw material @@ -2142,14 +2155,14 @@ void initStructForItemSort(vector&vTemp, sint32 sheetId, sint32 qua vTemp[indexInList].Pos += toString("%02d%02d", 0, 0); - vTemp[indexInList].Pos += toString("%03d", quality); + vTemp[indexInList].Pos += toString("%03d", ctrl->getQuality()); // add sort by name vTemp[indexInList].Pos += CSheetId(sheetId).toString(); // add at last the index in DB. to avoid resort for items that are exaclty the same - vTemp[indexInList].Pos += toString("%03d", indexInDB); + vTemp[indexInList].Pos += toString("%03d", ctrl->getIndexInDB()); } } } @@ -2484,22 +2497,32 @@ void CDBGroupListSheetBag::onSwap (sint /* nDraggedSheet */, sint /* nDroppedShe void CDBGroupListSheetBag::sort() { vector vTemp; - + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo("CDBGroupListSheetBag"); vTemp.resize (_MaxItems); uint i; for (i = 0; i < _MaxItems; ++i) { vTemp[i].SheetText = _SheetChildren[i]; - - CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; - initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); + //pIM->displaySystemInfo(to_string((int) _SortBy)); + initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, _SortBy, i); } - std::sort(vTemp.begin(), vTemp.end()); + pIM->displaySystemInfo("CDBGroupListSheetBag sort_dir "+to_string(_SortDir)+typeid(_SortDir).name()); + if (_SortDir == 0) { + // sort ASC + std::sort(vTemp.begin(), vTemp.end()); + } else if (_SortDir == 1) { + // sort DESC + std::sort(vTemp.rbegin(), vTemp.rend()); + } for (i = 0; i < _MaxItems; ++i) - { + { + if (vTemp[i].Pos.find('e') != std::string::npos) + pIM->displaySystemInfo(vTemp[i].Pos); + _SheetChildren[i] = vTemp[i].SheetText; } } @@ -2525,19 +2548,24 @@ bool CDBGroupIconListBag::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) void CDBGroupIconListBag::sort() { vector vTemp; - + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo("CDBGroupIconListBag"); vTemp.resize (_MaxItems); uint i; for (i = 0; i < _MaxItems; ++i) { vTemp[i].SheetIcon = _SheetChildren[i]; - - CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; - initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); + initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, _SortBy, i); } - std::sort(vTemp.begin(), vTemp.end()); + if (_SortDir == 0) { + // sort ASC + std::sort(vTemp.begin(), vTemp.end()); + } else { + // sort DESC + std::sort(vTemp.rbegin(), vTemp.rend()); + } for (i = 0; i < _MaxItems; ++i) { @@ -2636,9 +2664,7 @@ void CDBGroupListSheetFilterExchangeable::sort() for (i = 0; i < _MaxItems; ++i) { vTemp[i].SheetIcon = _SheetChildren[i]; - - CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; - initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); + initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, 0, i); } std::sort(vTemp.begin(), vTemp.end()); @@ -3743,61 +3769,59 @@ void CInventoryManager::debugItemInfoCache() const } // *************************************************************************** -void CInventoryManager::sortBag() +void CInventoryManager::sortAll() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo("sortAll"); + sortInv(INVENTORIES::bag); + sortInv(INVENTORIES::player_room); + sortInv(INVENTORIES::guild); + sortInv(INVENTORIES::pet_animal1); + sortInv(INVENTORIES::pet_animal2); + sortInv(INVENTORIES::pet_animal3); + sortInv(INVENTORIES::pet_animal4); + sortInv(INVENTORIES::pet_animal5); + sortInv(INVENTORIES::pet_animal6); + sortInv(INVENTORIES::pet_animal7); +} + +void CInventoryManager::sortInv(INVENTORIES::TInventory inv) +{ + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CDBManager *pDM = NLGUI::CDBManager::getInstance(); + CWidgetManager *pWM = CWidgetManager::getInstance(); CDBGroupIconListBag *pIconList; CDBGroupListSheetBag *pList; - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ROOM_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ROOM_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA0_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA0_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA1_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA1_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA2_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA2_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA3_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA3_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA4_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA4_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA5_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA5_TEXT)); - if (pList != NULL) pList->needToSort(); - - pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA6_ICONS)); - if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA6_TEXT)); - if (pList != NULL) pList->needToSort(); + pIM->displaySystemInfo("sortInv " + INVENTORIES::toString(inv)); + std::map> invToProp = { + { INVENTORIES::bag, {LIST_BAG_ICONS, LIST_BAG_TEXT, BAG_SORT} }, + { INVENTORIES::player_room, {LIST_ROOM_ICONS, LIST_ROOM_TEXT, ROOM_SORT} }, + { INVENTORIES::guild, {LIST_GUILD_ICONS, LIST_GUILD_TEXT, GUILD_SORT} }, + { INVENTORIES::pet_animal1, {LIST_PA0_ICONS, LIST_PA0_TEXT, PA0_SORT} }, + { INVENTORIES::pet_animal2, {LIST_PA1_ICONS, LIST_PA1_TEXT, PA1_SORT} }, + { INVENTORIES::pet_animal3, {LIST_PA2_ICONS, LIST_PA2_TEXT, PA2_SORT} }, + { INVENTORIES::pet_animal4, {LIST_PA3_ICONS, LIST_PA3_TEXT, PA3_SORT} }, + { INVENTORIES::pet_animal5, {LIST_PA4_ICONS, LIST_PA4_TEXT, PA4_SORT} }, + { INVENTORIES::pet_animal6, {LIST_PA5_ICONS, LIST_PA5_TEXT, PA5_SORT} }, + { INVENTORIES::pet_animal7, {LIST_PA6_ICONS, LIST_PA6_TEXT, PA6_SORT} } + }; + + sint32 sortBy = pDM->getDbProp(invToProp[inv][2]+":SORT_BY")->getValue32(); + sint32 sortDir = pDM->getDbProp(invToProp[inv][2]+":SORT_DIR")->getValue32(); + pIM->displaySystemInfo("sortInv " + INVENTORIES::toString(inv) + " sortBy: " + toString(sortBy) + " sortDir: " + toString(sortDir) + " debug "+invToProp[inv][2]); + pIconList = dynamic_cast(pWM->getElementFromId(invToProp[inv][0])); + if (pIconList != NULL) { + pIconList->needToSort(); + pIconList->setSortBy(sortBy); + pIconList->setSortDir(sortDir); + } + pList = dynamic_cast(pWM->getElementFromId(invToProp[inv][1])); + if (pList != NULL) { + pList->needToSort(); + pList->setSortBy(sortBy); + pList->setSortDir(sortDir); + } } // *************************************************************************** diff --git a/ryzom/client/src/interface_v3/inventory_manager.h b/ryzom/client/src/interface_v3/inventory_manager.h index d5bd763f1..d49f247e2 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.h +++ b/ryzom/client/src/interface_v3/inventory_manager.h @@ -309,7 +309,8 @@ public: void debugItemInfoWaiters(); void debugItemInfoCache() const; - void sortBag(); + void sortInv(INVENTORIES::TInventory invId); + void sortAll(); // Animal Inventories // Is the inventory present? if true, it may still not be available for modification (eg: animal too far) @@ -526,7 +527,7 @@ struct SSortStruct }; // Helper to sort with only one way for bag and trade -void initStructForItemSort(std::vector&vTemp, sint32 sheetId, sint32 quality, sint32 indexInList, sint32 indexInDB); +void initStructForItemSort(std::vector&vTemp, CDBCtrlSheet *ctrl, sint32 sortBy, sint32 indexInList); // *************************************************************************** @@ -832,6 +833,17 @@ private: #define LIST_PA6_TEXT "ui:interface:inv_pa6:content:iil:bag_list" #define LIST_PA6_ICONS "ui:interface:inv_pa6:content:iil:bag_icons" +#define BAG_SORT "UI:SAVE:INV_BAG" +#define ROOM_SORT "UI:SAVE:INV_ROOM" +#define GUILD_SORT "UI:SAVE:INV_GUILD" +#define PA0_SORT "UI:SAVE:INV_PA0" +#define PA1_SORT "UI:SAVE:INV_PA1" +#define PA2_SORT "UI:SAVE:INV_PA2" +#define PA3_SORT "UI:SAVE:INV_PA3" +#define PA4_SORT "UI:SAVE:INV_PA4" +#define PA5_SORT "UI:SAVE:INV_PA5" +#define PA6_SORT "UI:SAVE:INV_PA6" + // Theorically never used #define LIST_BAG2_TEXT "ui:interface:inv_bag:content:iil:bag_list" #define LIST_BAG2_ICONS "ui:interface:inv_bag:content:iil:bag_icons" diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 549732372..61cd99174 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -2865,7 +2865,7 @@ void updateInventoryFromStream (NLMISC::CBitMemStream &impulse, const CInventory } } - CInventoryManager::getInstance()->sortBag(); + CInventoryManager::getInstance()->sortAll(); } catch (const Exception &e) { From b72a71e87c3222652097cde03da48a23270895f3 Mon Sep 17 00:00:00 2001 From: Ben Saine Date: Wed, 1 Dec 2021 17:30:11 +0000 Subject: [PATCH 4/4] Revert "add: sorting (initial draft)" This reverts commit b4ce38099fdfa8af56c651142dbcc480fc245791 --- .../src/interface_v3/action_handler_item.cpp | 13 -- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 - .../src/interface_v3/dbgroup_list_sheet.h | 4 - .../interface_v3/dbgroup_list_sheet_text.cpp | 2 - .../interface_v3/dbgroup_list_sheet_text.h | 4 - .../interface_v3/dbgroup_list_sheet_trade.cpp | 4 +- .../src/interface_v3/inventory_manager.cpp | 168 ++++++++---------- .../src/interface_v3/inventory_manager.h | 16 +- ryzom/client/src/net_manager.cpp | 2 +- 9 files changed, 78 insertions(+), 137 deletions(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index a8055996a..46171b6c1 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1666,19 +1666,6 @@ class CHandlerDragNDrop : public IActionHandler }; REGISTER_ACTION_HANDLER( CHandlerDragNDrop, "drag_n_drop" ); -// ********************************************************************************************************** -class CHandlerSortInv : public IActionHandler -{ - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) - { - std::string inv = getParam(sParams, "inv"); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->displaySystemInfo("CHandlerSortInv "+inv); - CInventoryManager *pInv = CInventoryManager::getInstance(); - pInv->sortInv(INVENTORIES::toInventory(inv)); - } -}; -REGISTER_ACTION_HANDLER( CHandlerSortInv, "sort_inv" ); // ********************************************************************************************************** static void sendToServerEnchantMessage(uint8 invent, uint16 slot) diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 4c438d984..487b77c99 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -58,8 +58,6 @@ CDBGroupListSheet::CDBGroupListSheet(const TCtorParam ¶m) _MinRows= 1; _MaxRows= INT_MAX; _MaxItems= INT_MAX; - _SortBy = 0; - _SortDir = 0; _NbColumns= 2; _WSlot= 24; _WSpace= 0; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index b1f1f29c1..211d872dc 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -78,8 +78,6 @@ public: // Called when the list changed for a reason or another and should be reconstructed to possibly sort items virtual void sort() { } void needToSort() { _NeedToSort = true; invalidateCoords(); } - void setSortBy(sint32 sortBy) { _SortBy = sortBy; } - void setSortDir(sint32 sortDir) { _SortDir = sortDir; } /** (useful for list only) Force the validity of an element, even if its sheetId==0 * (empty slot displayed instead) @@ -175,8 +173,6 @@ protected: bool _Array : 1; bool _Squarify : 1; - sint32 _SortBy; - sint32 _SortDir; bool _CanDrop : 1; bool _Draggable : 1; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index dcbd0e9db..8cc114508 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -44,8 +44,6 @@ CDBGroupListSheetText::CDBGroupListSheetText(const TCtorParam ¶m) _TextTemplate(TCtorParam()) { _MaxItems = INT_MAX; - _SortBy = 0; - _SortDir = 0; _WSlot= 24; _HSlot= 24; _HSpace = 0; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index d45ce122a..329d7bcea 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -184,8 +184,6 @@ public: // Called when the list changed for a reason or another and should be reconstructed to possibly sort items virtual void sort() { } void needToSort() { _NeedToSort = true; invalidateCoords(); } - void setSortBy(sint32 sortBy) { _SortBy = sortBy; } - void setSortDir(sint32 sortDir) { _SortDir = sortDir; } /// Gets. sint32 getWSlot() const {return _WSlot;} @@ -255,8 +253,6 @@ protected: std::vector _SheetChildren; bool _NeedToSort; - sint32 _SortBy; - sint32 _SortDir; // Drag'n'Drop sint32 _Scrolling; sint64 _LastTimeScrolled; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index d1147ddf3..0d93baccb 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -720,7 +720,9 @@ void CDBGroupListSheetTrade::sort() for (i = 0; i < _SheetChildren.size(); ++i) { vTemp[i].SheetText = _SheetChildren[i]; - initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, 0, i); + + CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; + initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); } std::sort(vTemp.begin(), vTemp.end()); diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp index e16c83cbb..1bb3c478f 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -35,7 +35,6 @@ #include "../net_manager.h" #include "../user_entity.h" #include "../global.h" -#include #include "nel/misc/algo.h" @@ -865,7 +864,7 @@ void CInventoryManager::wearBagItem(sint32 bagEntryIndex) BagItemEquipped[bagEntryIndex]= true; grayItem (LIST_BAG_TEXT, bagEntryIndex, true); grayItem (LIST_BAG_ICONS, bagEntryIndex, true); - sortAll(); + sortBag(); } } @@ -877,7 +876,7 @@ void CInventoryManager::unwearBagItem(sint32 bagEntryIndex) BagItemEquipped[bagEntryIndex]= false; grayItem (LIST_BAG_TEXT, bagEntryIndex, false); grayItem (LIST_BAG_ICONS, bagEntryIndex, false); - sortAll(); + sortBag(); } } @@ -2115,12 +2114,11 @@ bool CTempInvManager::isOpened() // *************************************************************************** #define BAG_ITEM_NOT_SORTED 1000000 // Used for sorting -void initStructForItemSort(vector&vTemp, CDBCtrlSheet *ctrl, sint32 sortBy, sint32 indexInList) +void initStructForItemSort(vector&vTemp, sint32 sheetId, sint32 quality, sint32 indexInList, sint32 indexInDB) { // Default value is the linear pos in the db (in case its not an item) - vTemp[indexInList].Pos = toString("%08d", ctrl->getIndexInDB()); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint32 sheetId = ctrl->getSheetId(); + vTemp[indexInList].Pos = toString("%08d", indexInDB); + // if not empty if (sheetId != 0) { @@ -2128,18 +2126,7 @@ void initStructForItemSort(vector&vTemp, CDBCtrlSheet *ctrl, sint32 if ((pItem != NULL) && (pItem->Type == CEntitySheet::ITEM)) { CItemSheet *pIS = safe_cast(pItem); - std::map primarySort = { - {0, pIS->Family}, - {1, ctrl->getQuantity()}, - {2, ctrl->getQuality()}, - {3, (pIS->Bulk*100)*(ctrl->getQuantity())}, - {4, (ctrl->getItemWeight())*(ctrl->getQuantity())} - }; - // Sort by - vTemp[indexInList].Pos = toString("%08d", primarySort[sortBy]); - - // Secondary sort - vTemp[indexInList].Pos += toString("%02d", pIS->Family); + vTemp[indexInList].Pos = toString("%02d", pIS->Family); vTemp[indexInList].Pos += toString("%03d", pIS->ItemType); // add some specific sort for raw material @@ -2155,14 +2142,14 @@ void initStructForItemSort(vector&vTemp, CDBCtrlSheet *ctrl, sint32 vTemp[indexInList].Pos += toString("%02d%02d", 0, 0); - vTemp[indexInList].Pos += toString("%03d", ctrl->getQuality()); + vTemp[indexInList].Pos += toString("%03d", quality); // add sort by name vTemp[indexInList].Pos += CSheetId(sheetId).toString(); // add at last the index in DB. to avoid resort for items that are exaclty the same - vTemp[indexInList].Pos += toString("%03d", ctrl->getIndexInDB()); + vTemp[indexInList].Pos += toString("%03d", indexInDB); } } } @@ -2497,32 +2484,22 @@ void CDBGroupListSheetBag::onSwap (sint /* nDraggedSheet */, sint /* nDroppedShe void CDBGroupListSheetBag::sort() { vector vTemp; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->displaySystemInfo("CDBGroupListSheetBag"); + vTemp.resize (_MaxItems); uint i; for (i = 0; i < _MaxItems; ++i) { vTemp[i].SheetText = _SheetChildren[i]; - //pIM->displaySystemInfo(to_string((int) _SortBy)); - initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, _SortBy, i); - } - pIM->displaySystemInfo("CDBGroupListSheetBag sort_dir "+to_string(_SortDir)+typeid(_SortDir).name()); - if (_SortDir == 0) { - // sort ASC - std::sort(vTemp.begin(), vTemp.end()); - } else if (_SortDir == 1) { - // sort DESC - std::sort(vTemp.rbegin(), vTemp.rend()); + CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; + initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); } - for (i = 0; i < _MaxItems; ++i) - { - if (vTemp[i].Pos.find('e') != std::string::npos) - pIM->displaySystemInfo(vTemp[i].Pos); + std::sort(vTemp.begin(), vTemp.end()); + for (i = 0; i < _MaxItems; ++i) + { _SheetChildren[i] = vTemp[i].SheetText; } } @@ -2548,25 +2525,20 @@ bool CDBGroupIconListBag::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) void CDBGroupIconListBag::sort() { vector vTemp; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->displaySystemInfo("CDBGroupIconListBag"); + vTemp.resize (_MaxItems); uint i; for (i = 0; i < _MaxItems; ++i) { vTemp[i].SheetIcon = _SheetChildren[i]; - initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, _SortBy, i); - } - if (_SortDir == 0) { - // sort ASC - std::sort(vTemp.begin(), vTemp.end()); - } else { - // sort DESC - std::sort(vTemp.rbegin(), vTemp.rend()); + CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; + initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); } + std::sort(vTemp.begin(), vTemp.end()); + for (i = 0; i < _MaxItems; ++i) { _SheetChildren[i] = vTemp[i].SheetIcon; @@ -2664,7 +2636,9 @@ void CDBGroupListSheetFilterExchangeable::sort() for (i = 0; i < _MaxItems; ++i) { vTemp[i].SheetIcon = _SheetChildren[i]; - initStructForItemSort (vTemp, _SheetChildren[i]->Ctrl, 0, i); + + CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; + initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB()); } std::sort(vTemp.begin(), vTemp.end()); @@ -3769,59 +3743,61 @@ void CInventoryManager::debugItemInfoCache() const } // *************************************************************************** -void CInventoryManager::sortAll() +void CInventoryManager::sortBag() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->displaySystemInfo("sortAll"); - sortInv(INVENTORIES::bag); - sortInv(INVENTORIES::player_room); - sortInv(INVENTORIES::guild); - sortInv(INVENTORIES::pet_animal1); - sortInv(INVENTORIES::pet_animal2); - sortInv(INVENTORIES::pet_animal3); - sortInv(INVENTORIES::pet_animal4); - sortInv(INVENTORIES::pet_animal5); - sortInv(INVENTORIES::pet_animal6); - sortInv(INVENTORIES::pet_animal7); -} - -void CInventoryManager::sortInv(INVENTORIES::TInventory inv) -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBManager *pDM = NLGUI::CDBManager::getInstance(); - CWidgetManager *pWM = CWidgetManager::getInstance(); CDBGroupIconListBag *pIconList; CDBGroupListSheetBag *pList; - pIM->displaySystemInfo("sortInv " + INVENTORIES::toString(inv)); - std::map> invToProp = { - { INVENTORIES::bag, {LIST_BAG_ICONS, LIST_BAG_TEXT, BAG_SORT} }, - { INVENTORIES::player_room, {LIST_ROOM_ICONS, LIST_ROOM_TEXT, ROOM_SORT} }, - { INVENTORIES::guild, {LIST_GUILD_ICONS, LIST_GUILD_TEXT, GUILD_SORT} }, - { INVENTORIES::pet_animal1, {LIST_PA0_ICONS, LIST_PA0_TEXT, PA0_SORT} }, - { INVENTORIES::pet_animal2, {LIST_PA1_ICONS, LIST_PA1_TEXT, PA1_SORT} }, - { INVENTORIES::pet_animal3, {LIST_PA2_ICONS, LIST_PA2_TEXT, PA2_SORT} }, - { INVENTORIES::pet_animal4, {LIST_PA3_ICONS, LIST_PA3_TEXT, PA3_SORT} }, - { INVENTORIES::pet_animal5, {LIST_PA4_ICONS, LIST_PA4_TEXT, PA4_SORT} }, - { INVENTORIES::pet_animal6, {LIST_PA5_ICONS, LIST_PA5_TEXT, PA5_SORT} }, - { INVENTORIES::pet_animal7, {LIST_PA6_ICONS, LIST_PA6_TEXT, PA6_SORT} } - }; - - sint32 sortBy = pDM->getDbProp(invToProp[inv][2]+":SORT_BY")->getValue32(); - sint32 sortDir = pDM->getDbProp(invToProp[inv][2]+":SORT_DIR")->getValue32(); - pIM->displaySystemInfo("sortInv " + INVENTORIES::toString(inv) + " sortBy: " + toString(sortBy) + " sortDir: " + toString(sortDir) + " debug "+invToProp[inv][2]); - pIconList = dynamic_cast(pWM->getElementFromId(invToProp[inv][0])); - if (pIconList != NULL) { - pIconList->needToSort(); - pIconList->setSortBy(sortBy); - pIconList->setSortDir(sortDir); - } - pList = dynamic_cast(pWM->getElementFromId(invToProp[inv][1])); - if (pList != NULL) { - pList->needToSort(); - pList->setSortBy(sortBy); - pList->setSortDir(sortDir); - } + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ROOM_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ROOM_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA0_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA0_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA1_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA1_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA2_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA2_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA3_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA3_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA4_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA4_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA5_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA5_TEXT)); + if (pList != NULL) pList->needToSort(); + + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA6_ICONS)); + if (pIconList != NULL) pIconList->needToSort(); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA6_TEXT)); + if (pList != NULL) pList->needToSort(); } // *************************************************************************** diff --git a/ryzom/client/src/interface_v3/inventory_manager.h b/ryzom/client/src/interface_v3/inventory_manager.h index d49f247e2..d5bd763f1 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.h +++ b/ryzom/client/src/interface_v3/inventory_manager.h @@ -309,8 +309,7 @@ public: void debugItemInfoWaiters(); void debugItemInfoCache() const; - void sortInv(INVENTORIES::TInventory invId); - void sortAll(); + void sortBag(); // Animal Inventories // Is the inventory present? if true, it may still not be available for modification (eg: animal too far) @@ -527,7 +526,7 @@ struct SSortStruct }; // Helper to sort with only one way for bag and trade -void initStructForItemSort(std::vector&vTemp, CDBCtrlSheet *ctrl, sint32 sortBy, sint32 indexInList); +void initStructForItemSort(std::vector&vTemp, sint32 sheetId, sint32 quality, sint32 indexInList, sint32 indexInDB); // *************************************************************************** @@ -833,17 +832,6 @@ private: #define LIST_PA6_TEXT "ui:interface:inv_pa6:content:iil:bag_list" #define LIST_PA6_ICONS "ui:interface:inv_pa6:content:iil:bag_icons" -#define BAG_SORT "UI:SAVE:INV_BAG" -#define ROOM_SORT "UI:SAVE:INV_ROOM" -#define GUILD_SORT "UI:SAVE:INV_GUILD" -#define PA0_SORT "UI:SAVE:INV_PA0" -#define PA1_SORT "UI:SAVE:INV_PA1" -#define PA2_SORT "UI:SAVE:INV_PA2" -#define PA3_SORT "UI:SAVE:INV_PA3" -#define PA4_SORT "UI:SAVE:INV_PA4" -#define PA5_SORT "UI:SAVE:INV_PA5" -#define PA6_SORT "UI:SAVE:INV_PA6" - // Theorically never used #define LIST_BAG2_TEXT "ui:interface:inv_bag:content:iil:bag_list" #define LIST_BAG2_ICONS "ui:interface:inv_bag:content:iil:bag_icons" diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 61cd99174..549732372 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -2865,7 +2865,7 @@ void updateInventoryFromStream (NLMISC::CBitMemStream &impulse, const CInventory } } - CInventoryManager::getInstance()->sortAll(); + CInventoryManager::getInstance()->sortBag(); } catch (const Exception &e) {