From c3a633ae507670c29969d8d5520d115a01d33e6f Mon Sep 17 00:00:00 2001 From: bensaine Date: Sun, 21 Nov 2021 00:33:15 -0500 Subject: [PATCH 01/17] 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 02/17] 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 03/17] 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 04/17] 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) { From 013aad73d2a24e7111888bd5eaf811691ec4c21e Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 18 Dec 2021 22:18:18 +0200 Subject: [PATCH 05/17] Fix initial fullscreen window on OpenGL/Windows --- .../3d/driver/opengl/driver_opengl_window.cpp | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 35dc433a8..68ad77a6a 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -3105,13 +3105,24 @@ void CDriverGL::setWindowSize(uint32 width, uint32 height) SetWindowPos(_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, flags); // init window width and height - RECT clientRect; - GetClientRect(_win, &clientRect); - _CurrentMode.Width = uint16(clientRect.right-clientRect.left); - _CurrentMode.Height = uint16(clientRect.bottom-clientRect.top); - GetWindowRect(_win, &clientRect); - _WindowX = clientRect.left; - _WindowY = clientRect.top; + if (_CurrentMode.Windowed) + { + // TODO: this gives wrong info for initial fullscreen window so limit for windowed only for now + RECT clientRect; + GetClientRect(_win, &clientRect); + _CurrentMode.Width = uint16(clientRect.right-clientRect.left); + _CurrentMode.Height = uint16(clientRect.bottom-clientRect.top); + GetWindowRect(_win, &clientRect); + _WindowX = clientRect.left; + _WindowY = clientRect.top; + } + else + { + _CurrentMode.Width = width; + _CurrentMode.Height = height; + _WindowX = 0; + _WindowY = 0; + } #elif defined(NL_OS_MAC) From 0df3879358dd0fd202b5785ef41a3be500642840 Mon Sep 17 00:00:00 2001 From: Nuno Date: Sun, 19 Dec 2021 22:18:37 +0100 Subject: [PATCH 06/17] Reapply changes reverted into atys-live because bad merge --- ryzom/client/src/commands.cpp | 12 ++++++ .../src/interface_v3/action_handler_game.cpp | 24 ++++++++--- .../src/interface_v3/action_handler_item.cpp | 28 ++++++------- .../src/interface_v3/action_phrase_faber.cpp | 42 +++++++++++++++++++ .../client/src/interface_v3/dbctrl_sheet.cpp | 3 +- .../interface_expr_user_fct_game.cpp | 6 ++- 6 files changed, 94 insertions(+), 21 deletions(-) diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index 00d2b9e4f..18f2eb779 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -408,6 +408,18 @@ NLMISC_COMMAND(afk, "Set the player as 'away from keyboard'","[]") return true; } +NLMISC_COMMAND(selfkill, "Kill the player ","") +{ + CBitMemStream out; + if(!GenericMsgHeaderMngr.pushNameToStream("COMMAND:SELFKILL", out)) + { + nlwarning("Unknown message name COMMAND:SELFKILL"); + return false; + } + NetMngr.push(out); + return true; +} + bool randomCheckCharset(std::string const& str) { std::string::const_iterator it, itEnd = str.end(); diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index f05ffb271..06a97671d 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -1095,6 +1095,20 @@ public: REGISTER_ACTION_HANDLER( CHandlerContextWebPage, "context_web_page"); +// *************************************************************************** +class CHandlerFullMap : public IActionHandler +{ +public: + void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + + CLuaManager::getInstance().executeLuaScript("game:openFullMap()", true); + } +}; +REGISTER_ACTION_HANDLER( CHandlerFullMap, "fullmap"); + + // *************************************************************************** @@ -1958,7 +1972,7 @@ public: bool womanTitle = false; if (pChar != NULL) womanTitle = pChar->getGender() == GSGENDER::female; - + copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); // Sometimes translation contains another title @@ -2665,9 +2679,9 @@ class CAHAddShape : public IActionHandler instance.setPos(CVector((float)x, (float)y, (float)z)); instance.setRotQuat(dir.getRot()); } - + instance.setTransformMode(UTransformable::RotEuler); - + // if the shape is a particle system, additionnal parameters are user params UParticleSystemInstance psi; psi.cast (instance); @@ -3402,7 +3416,7 @@ class CHandlerGameConfigVREnable : public IActionHandler // VR_CONFIG CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_ENABLE_BUTTON)); - if (pBut) + if (pBut) { // hide or show device list depending on enabled or not updateVRDevicesComboUI(pBut->getPushed()); @@ -3541,7 +3555,7 @@ class CHandlerGameConfigApply : public IActionHandler NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:AUTO_CHANNEL")->setValue32(pCS->getPushed()); CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_ENABLE_BUTTON)); - if (pBut) + if (pBut) { // store the new config variables ClientCfg.VREnable = pBut->getPushed(); diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 9bbf9fbc8..da7e95fd8 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -208,7 +208,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() { if(_CurrItemSheet && !WindowName.empty()) { - + const CItemSheet *pIS = _CurrItemSheet->asItemSheet(); if ((pIS != NULL) && ITEMFAMILY::isTextCustomizable(pIS->Family) ) { @@ -342,7 +342,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // ******************************************************************************************** void CInterfaceItemEdition::CItemEditionWindow::end() { - + CDBCtrlSheet *pCSItem = _CurrItemSheet; std::string windowName = WindowName; if(pCSItem && !windowName.empty()) @@ -371,7 +371,7 @@ void CInterfaceItemEdition::CItemEditionWindow::end() editBoxShort->setActive(false); editShort->setActive(false); editBoxLarge->setActive(false); - editLarge->setActive(false); + editLarge->setActive(false); display->setActive(false); editButtons->setActive(false); closeButton->setActive(false); @@ -413,7 +413,7 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() textValid = editLarge->getActive(); text = editBoxLarge->getInputString(); } - + if (textValid) { CBitMemStream out; @@ -1722,7 +1722,7 @@ void CItemMenuInBagInfoWaiter::infoReceived() void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - + // get the dialog stack CInterfaceGroup* pMenu = dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:item_menu_in_bag") ); if(!pMenu) return; @@ -1960,16 +1960,15 @@ class CHandlerItemMenuCheck : public IActionHandler for(i=0;isetActive(invId!=INVENTORIES::guild && - (uint)invId!=INVENTORIES::pet_animal+i && + pMoveToPa[i]->setActive((uint)invId!=INVENTORIES::pet_animal+i && invMngr.isInventoryPresent((INVENTORIES::TInventory)(INVENTORIES::pet_animal+i)) ); } if (pMoveToGuild) - pMoveToGuild->setActive(invId==INVENTORIES::bag && invMngr.isInventoryPresent(INVENTORIES::guild)); + pMoveToGuild->setActive(invId!=INVENTORIES::guild && invMngr.isInventoryPresent(INVENTORIES::guild)); if (pMoveToRoom) - pMoveToRoom->setActive(invId==INVENTORIES::bag && invMngr.isInventoryPresent(INVENTORIES::player_room)); + pMoveToRoom->setActive(invId!=INVENTORIES::player_room && invMngr.isInventoryPresent(INVENTORIES::player_room)); // std case: can drop / destroy if(pDrop) pDrop->setActive(invId!=INVENTORIES::guild); @@ -2037,7 +2036,7 @@ class CHandlerItemMenuCheck : public IActionHandler if (pMoveSubMenu) pMoveSubMenu->setActive(false); } - if (bIsLockedByOwner) + if (bIsLockedByOwner) { if (pLockUnlock) pLockUnlock->setHardText("uimUnlockItem"); // Cannot drop/destroy if locked by owner @@ -2050,7 +2049,8 @@ class CHandlerItemMenuCheck : public IActionHandler } // Only show lock menu item if inventory contains the info - if (pLockUnlock) pLockUnlock->setActive(pCS->canOwnerLock()); + if (invId!=INVENTORIES::guild) + if (pLockUnlock) pLockUnlock->setActive(pCS->canOwnerLock()); // **** Gray Entries @@ -2207,7 +2207,7 @@ class CHandlerItemMenuBaseCheck : public IActionHandler CViewTextMenu *pDestroy = dynamic_cast(pMenu->getView("destroy")); CViewTextMenu *pLockUnlock = dynamic_cast(pMenu->getView("lockunlock")); - if (pCS->getLockedByOwner()) + if (pCS->getLockedByOwner()) { pLockUnlock->setHardText("uimUnlockItem"); // Cannot destroy if locked by owner @@ -2364,7 +2364,7 @@ class CHandlerItemTextDisplay : public IActionHandler std::string const& windowName = sParams; CInterfaceManager *pIM = CInterfaceManager::getInstance(); CDBCtrlSheet *pCSItem = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); - if (pCSItem == NULL || windowName.empty()) + if (pCSItem == NULL || windowName.empty()) return; const CItemSheet *pIS = pCSItem->asItemSheet(); @@ -2385,7 +2385,7 @@ class CHandlerItemTextEdition : public IActionHandler std::string const& windowName = sParams; CInterfaceManager *pIM = CInterfaceManager::getInstance(); CDBCtrlSheet *pCSItem = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); - if (pCSItem == NULL || windowName.empty()) + if (pCSItem == NULL || windowName.empty()) return; CInterfaceItemEdition::getInstance()->setCurrWindow(pCSItem, windowName, true); diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 7625be010..05e5735e1 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -50,6 +50,10 @@ using namespace NLMISC; // *************************************************************************** const std::string FaberPlanDB= "UI:PHRASE:FABER:FABER_PLAN:SHEET"; +const std::string FaberPlanHpBuffDB= "UI:PHRASE:FABER:FABER_PLAN:HP_BUFF"; +const std::string FaberPlanSapBuffDB= "UI:PHRASE:FABER:FABER_PLAN:SAP_BUFF"; +const std::string FaberPlanStaBuffDB= "UI:PHRASE:FABER:FABER_PLAN:STA_BUFF"; +const std::string FaberPlanFocusBuffDB= "UI:PHRASE:FABER:FABER_PLAN:FOCUS_BUFF"; const std::string MPFaberDB= "UI:PHRASE:FABER:MP_BUILD"; const std::string MPSelectionDB= "UI:PHRASE:FABER:MP_SELECT"; const std::string MPQuantityDb= "UI:PHRASE:FABER:MP_QUANTITY"; @@ -170,6 +174,16 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn if(node) node->setValue32(0); + // Reset buff values + node = NLGUI::CDBManager::getInstance()->getDbProp(FaberPlanHpBuffDB, false); + if (node) node->setValue32(0); + node = NLGUI::CDBManager::getInstance()->getDbProp(FaberPlanSapBuffDB, false); + if (node) node->setValue32(0); + node = NLGUI::CDBManager::getInstance()->getDbProp(FaberPlanStaBuffDB, false); + if (node) node->setValue32(0); + node = NLGUI::CDBManager::getInstance()->getDbProp(FaberPlanFocusBuffDB, false); + if (node) node->setValue32(0); + // Reset the result item node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetDB, false); if(node) @@ -1565,6 +1579,14 @@ void CActionPhraseFaber::updateItemResult() uint phraseSlot= pPM->getMemorizedPhrase(_ExecuteFromMemoryLine, _ExecuteFromMemoryIndex); const CSPhraseCom &phrase= pPM->getPhrase(phraseSlot); uint32 recommendedPropId= pBM->getBrickPropId("cr_recommended"); + uint32 crHp = pBM->getBrickPropId("cr_hp"); + uint32 crSap = pBM->getBrickPropId("cr_sap"); + uint32 crSta = pBM->getBrickPropId("cr_sta"); + uint32 crFocus = pBM->getBrickPropId("cr_focus"); + sint32 hpBuff = 0; + sint32 sapBuff = 0; + sint32 staBuff = 0; + sint32 focusBuff = 0; for(i=0;igetBrick(phrase.Bricks[i]); @@ -1578,10 +1600,30 @@ void CActionPhraseFaber::updateItemResult() // minimze the level minLevel= min(minLevel, sint32(brick->Properties[j].Value)); } + + if (brick->Properties[j].PropId == crHp) + hpBuff = sint32(brick->Properties[j].Value); + if (brick->Properties[j].PropId == crSap) + sapBuff = sint32(brick->Properties[j].Value); + if (brick->Properties[j].PropId == crSta) + staBuff = sint32(brick->Properties[j].Value); + if (brick->Properties[j].PropId == crFocus) + focusBuff = sint32(brick->Properties[j].Value); } } } + { + NLGUI::CDBManager *cdb = NLGUI::CDBManager::getInstance(); + NLMISC::CCDBNodeLeaf *node = cdb->getDbProp(FaberPlanHpBuffDB, false); + if (node) node->setValue32(hpBuff); + node = cdb->getDbProp(FaberPlanSapBuffDB, false); + if (node) node->setValue32(sapBuff); + node = cdb->getDbProp(FaberPlanStaBuffDB, false); + if (node) node->setValue32(staBuff); + node = cdb->getDbProp(FaberPlanFocusBuffDB, false); + if (node) node->setValue32(focusBuff); + } // **** Parse all MPs setuped, to compute level and stats uint totalItemPartMPReq= 0; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 599e99716..0b8cda2ee 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -2534,7 +2534,8 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti // there is max 4 icons sint32 hArea = (hSheet / 4); sint32 xIcon = x; - sint32 yIcon = y; + // move buff icons up a row, quantity text is displayed on bottom-left corner + sint32 yIcon = y + hArea; for (uint i = 0; i < _BuffIcons.size(); ++i) { sint32 wIcon = _BuffIcons[i].IconW; diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 4c21fee47..b6dde9379 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -799,7 +799,11 @@ static DECLARE_INTERFACE_USER_FCT(getAnimalInventoryStateText) // According to server status, change the inventory text uint status= (uint)args[0].getInteger(); - if(ANIMAL_STATUS::isInStable((ANIMAL_STATUS::EAnimalStatus)status)) + if(ANIMAL_STATUS::isInBag((ANIMAL_STATUS::EAnimalStatus)status)) + { + result.setString("uiAnimalInBag"); + } + else if(ANIMAL_STATUS::isInStable((ANIMAL_STATUS::EAnimalStatus)status)) { result.setString("uiAnimalInStable"); } From 36e83e32f444a89957243ee2d526cb36e89505b3 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 20 Dec 2021 08:46:36 +0200 Subject: [PATCH 07/17] Fix moving fullscreen window between monitors --- nel/src/3d/driver/opengl/driver_opengl_window.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 68ad77a6a..bb48473d3 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2064,6 +2064,8 @@ bool CDriverGL::setMode(const GfxMode& amode) // if window is visible, then also restore mouse relative position. if (!mode.DisplayDevice.empty() && mode.DisplayDevice != current.DisplayDevice) { + setWindowStyle(EWSWindowed); + int screen = DefaultScreen(_dpy); Window root = RootWindow(_dpy, screen); uint mouseX = mode.Width / 2; @@ -2090,6 +2092,7 @@ bool CDriverGL::setMode(const GfxMode& amode) XMoveWindow(_dpy, _win, newX, newY); _WindowX = newX; _WindowY = newY; + setWindowStyle(EWSFullscreen); } } #endif From 5df8ec43a04d377bfaf2b745d32b4c49e6574118 Mon Sep 17 00:00:00 2001 From: Ben Saine Date: Wed, 22 Dec 2021 17:10:55 +0000 Subject: [PATCH 08/17] Resolve "Encoding issues in client beta (after core4 merge)" --- nel/include/nel/gui/view_text.h | 4 +++- nel/src/gui/view_text.cpp | 38 ++++++++------------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index cc92cf47d..e7405a2dd 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -282,8 +282,10 @@ namespace NLGUI bool _FontSizeCoef; bool _Embolden; bool _Oblique; - // width of the font in pixel. Just a Hint for tabing format (computed with '_') + // width of the font in pixel. float _FontWidth; + // width of tabs + float _TabWidth; // strings to use when computing font size std::string _FontSizingChars; std::string _FontSizingFallback; diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index 89f31d40d..814f88469 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -95,6 +95,7 @@ namespace NLGUI _FontWidth= 0; _FontHeight = 0; _FontLegHeight = 0; + _TabWidth= 0; _TextSelection= false; _TextSelectionStart= 0; @@ -1284,7 +1285,7 @@ namespace NLGUI px += firstSpace; // skip tabulation before current word if(currWord.Format.TabX) - px= max(px, (float)(_XReal * _Scale + currWord.Format.TabX*_FontWidth)); + px= max(px, (float)(_XReal * _Scale + currWord.Format.TabX*_TabWidth)); // draw. We take floorf px to avoid filtering of letters that are not located on a pixel boundary float fx = px / _Scale; @@ -1767,7 +1768,7 @@ namespace NLGUI getFormatTagChange(i, formatTagIndex, wordFormat); // Ensure the line witdh count the tab - rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); + rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_TabWidth); } NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); @@ -1951,7 +1952,7 @@ namespace NLGUI // compute size of spaces/Tab + word newLineWidth = lineWidth + numSpaces * _SpaceWidth; - newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_FontWidth); + newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_TabWidth); newLineWidth+= si.StringWidth; } // @@ -3113,8 +3114,6 @@ namespace NLGUI TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); -#if 1 - UTextContext::CStringInfo si = TextContext->getStringInfo("XO"); float xoHeight = si.StringHeight; @@ -3145,34 +3144,14 @@ namespace NLGUI si = TextContext->getStringInfo(" "); _SpaceWidth = si.StringWidth; - // Font Width (used for ) + // Font Width si = TextContext->getStringInfo("O"); _FontWidth = si.StringWidth; -#else - - // Letter size - UTextContext::CStringInfo si = TextContext->getStringInfo(_FontSizingChars); - - // font generator changes unknown glyphs to dot '.'. use fallback if it looks odd - if (_FontSize > (si.StringHeight + si.StringLine)) - { - si = TextContext->getStringInfo(_FontSizingFallback); - } - - // add a padding of 1 pixel else the top will be truncated - _FontHeight = si.StringHeight + 1; - _FontLegHeight = si.StringLine; - - // Space width - si = TextContext->getStringInfo(" "); - _SpaceWidth = si.StringWidth; - - // Font Width (used for ) + // Tab Width (used for {Txx}) + // if not set to "_", breaks item help window si = TextContext->getStringInfo("_"); - _FontWidth = si.StringWidth; - -#endif + _TabWidth = si.StringWidth; } @@ -3641,6 +3620,7 @@ namespace NLGUI f.serial(_Localized); SERIAL_SINT(_FontSize); SERIAL_UINT(_FontWidth); + SERIAL_UINT(_TabWidth); SERIAL_UINT(_FontHeight); SERIAL_UINT(_FontLegHeight); f.serial(_SpaceWidth); From c012e7ffcf98a7e5d75b01807e58b1cebdcf1615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Meelis=20M=C3=A4gi?= Date: Thu, 23 Dec 2021 09:20:17 +0000 Subject: [PATCH 09/17] Fix CViewText always returning localization key --- nel/include/nel/gui/view_text.h | 5 +++-- nel/src/gui/view_text.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index cc92cf47d..eed7a7a87 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -119,8 +119,8 @@ namespace NLGUI void enableStringSelection(uint start, uint end); void disableStringSelection(); - /// Get - std::string getText() const { return _HardText.empty() ? _Text : _HardText; } + /// Get displayed text + std::string getText() const { return _Text; } #ifdef RYZOM_LUA_UCSTRING ucstring getTextAsUtf16() const; // Compatibility ucstring getHardTextAsUtf16() const; // Compatibility @@ -188,6 +188,7 @@ namespace NLGUI /// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const; + /// If localized, return localization key (ie "uiLanguage"), else return displayed text. std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; } void setHardText (const std::string &ht); //< Localizes strings starting with "ui" #ifdef RYZOM_LUA_UCSTRING diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index 89f31d40d..b0382eb52 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -1468,7 +1468,7 @@ namespace NLGUI } } - nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(getText(), "ui"))) == (_HardText.empty() == _Text.empty()))); + nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(getHardText(), "ui"))) == (_HardText.empty() == _Text.empty()))); } // *************************************************************************** From 9cff221a1e1aa26a6d334bbdd745e4b58834af8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Meelis=20M=C3=A4gi?= Date: Fri, 24 Dec 2021 10:39:52 +0000 Subject: [PATCH 10/17] Add ScreenShotDirectory entry to client.cfg --- ryzom/client/src/client_cfg.cpp | 2 ++ ryzom/client/src/client_cfg.h | 1 + .../src/interface_v3/action_handler_misc.cpp | 19 ++++++++----------- .../src/interface_v3/action_handler_misc.h | 1 - ryzom/client/src/main_loop.cpp | 3 --- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ryzom/client/src/client_cfg.cpp b/ryzom/client/src/client_cfg.cpp index 8a68b1140..c2ff6d927 100644 --- a/ryzom/client/src/client_cfg.cpp +++ b/ryzom/client/src/client_cfg.cpp @@ -412,6 +412,7 @@ CClientConfig::CClientConfig() CameraRecorderPrefix = "cam_rec"; CameraRecorderBlend = true; + ScreenShotDirectory = "screenshots"; ScreenShotWidth = 0; ScreenShotHeight = 0; ScreenShotFullDetail = true; @@ -1139,6 +1140,7 @@ void CClientConfig::setValues() READ_BOOL_FV(CameraRecorderBlend) // Screenshot + READ_STRING_FV(ScreenShotDirectory) READ_INT_FV(ScreenShotWidth) READ_INT_FV(ScreenShotHeight) READ_BOOL_FV(ScreenShotFullDetail) diff --git a/ryzom/client/src/client_cfg.h b/ryzom/client/src/client_cfg.h index 60be270fa..45a4cd6da 100644 --- a/ryzom/client/src/client_cfg.h +++ b/ryzom/client/src/client_cfg.h @@ -304,6 +304,7 @@ struct CClientConfig bool CameraRecorderBlend; /// Screen shot + string ScreenShotDirectory; uint ScreenShotWidth; // If 0 : normal screen shot, else custom screen shot without interface uint ScreenShotHeight; bool ScreenShotFullDetail; // If set to true, then load balancing will be disabled for the duration of the screenshot diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 91e00807d..4c4b9e814 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -62,9 +62,6 @@ extern NLMISC::CLog g_log; //////////// //static CCDBNodeLeaf *MenuColorWidgetValue = NULL; // db entry for the color menu widget (Red) - -static const string ScreenshotsDirectory("screenshots/"); // don't forget the final / - void preRenderNewSky (); // *************************************************************************** @@ -602,11 +599,6 @@ void displayScreenShotSavedInfo(const string &filename) pIM->displaySystemInfo(msg); } -void initScreenshot() -{ - if (!CFile::isExists(ScreenshotsDirectory)) CFile::createDirectory(ScreenshotsDirectory); -} - bool screenshotZBuffer(const std::string &filename) { std::string::size_type pos = filename.find("."); @@ -672,6 +664,11 @@ bool screenshotZBuffer(const std::string &filename) static std::string findNewScreenShotFileName(std::string filename) { + // make screenshot directory if it does not exist + if (!CFile::isExists(ClientCfg.ScreenShotDirectory)) + CFile::createDirectory(ClientCfg.ScreenShotDirectory); + + filename = CPath::standardizePath(ClientCfg.ScreenShotDirectory) + filename; static char cstime[25]; time_t dtime; time(&dtime); @@ -698,7 +695,7 @@ void screenShotTGA() CBitmap btm; getBuffer (btm); - string filename = findNewScreenShotFileName(ScreenshotsDirectory+"screenshot.tga"); + string filename = findNewScreenShotFileName("screenshot.tga"); COFile fs(filename); if (!btm.writeTGA(fs, 24, false)) @@ -720,7 +717,7 @@ void screenShotPNG() CBitmap btm; getBuffer (btm); - string filename = findNewScreenShotFileName(ScreenshotsDirectory+"screenshot.png"); + string filename = findNewScreenShotFileName("screenshot.png"); COFile fs(filename); if (!btm.writePNG(fs, 24)) @@ -742,7 +739,7 @@ void screenShotJPG() CBitmap btm; getBuffer (btm); - string filename = findNewScreenShotFileName(ScreenshotsDirectory+"screenshot.jpg"); + string filename = findNewScreenShotFileName("screenshot.jpg"); COFile fs(filename); if (!btm.writeJPG(fs)) diff --git a/ryzom/client/src/interface_v3/action_handler_misc.h b/ryzom/client/src/interface_v3/action_handler_misc.h index 61fbbc552..2c5ba5ece 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.h +++ b/ryzom/client/src/interface_v3/action_handler_misc.h @@ -181,7 +181,6 @@ public: /** Capture current content of framebuffer and save the result. If a custom size is asked in ClientCfg, then the scene is rendered again * instead (possibly multiple time) */ -void initScreenshot(); void screenShotTGA(); void screenShotPNG(); void screenShotJPG(); diff --git a/ryzom/client/src/main_loop.cpp b/ryzom/client/src/main_loop.cpp index 492d54623..56452ba4a 100644 --- a/ryzom/client/src/main_loop.cpp +++ b/ryzom/client/src/main_loop.cpp @@ -1000,9 +1000,6 @@ bool mainLoop() // initialize the structure for the ping. Ping.init(); - // initialize screenshots directory - initScreenshot(); - // Call a function for a demo to init. if (ClientCfg.Local) From e185ddc19f7fe2212323e0e05e3fa21657f7a616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Meelis=20M=C3=A4gi?= Date: Wed, 29 Dec 2021 11:49:38 +0000 Subject: [PATCH 11/17] Fix flying text for area magic/combat actions --- ryzom/client/src/character_cl.cpp | 38 ++++++++++---------- ryzom/client/src/user_entity.cpp | 4 +-- ryzom/common/src/game_share/multi_target.cpp | 37 +++++++++---------- ryzom/common/src/game_share/multi_target.h | 22 ++++++------ 4 files changed, 49 insertions(+), 52 deletions(-) diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index 68f8acfcb..c157c0f85 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -4553,13 +4553,20 @@ void CCharacterCL::applyBehaviourFlyingHPs(const CBehaviourContext &bc, const MB { nlassert(targetHitDates.size()==bc.Targets.Targets.size()); - if(!bc.Targets.Targets.empty()) + if (behaviour.DeltaHP == 0 || bc.Targets.Targets.empty()) + return; + + CRGBA deltaHPColor(0, 0, 0); + for (size_t i=0; iaddHPOutput(behaviour.DeltaHP, deltaHPColor, float(targetHitDates[i]-TimeInSec)); - } + target2->addHPOutput(bc.Targets.Targets[i].DeltaHP, deltaHPColor, float(targetHitDates[i]-TimeInSec)); } } } @@ -9705,7 +9706,7 @@ NLMISC_COMMAND(projectile, "Cast a projectile on another entity", " pos() - ch->pos()).norm(); bool resist = false; if (args.size() > 4) fromString(args[4], resist); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, resist, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, resist, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), -11)); } bc.BehavTime = TimeInSec; ch->applyBehaviour(bc); @@ -9743,7 +9744,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - ch->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(mainTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(mainTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), 1)); for(sint k = 1; k < (sint) (args.size() - 4); ++k) { uint secondaryTargetSlot; @@ -9753,7 +9754,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - mainTarget->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(secondaryTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(secondaryTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), k+1)); } } } @@ -9770,7 +9771,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - ch->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), k+1)); } } } @@ -9787,7 +9788,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - startSlot->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), k+1)); startSlot = target; } } @@ -10100,6 +10101,7 @@ NLMISC_COMMAND(attack, "simulate an attack", " selection(); target.Info = dsPower | (dsType << 3); + target.DeltaHP = -20; bc.Targets.Targets.push_back(target); bc.BehavTime = TimeInSec; bc.Behav.DeltaHP = -20; @@ -10154,7 +10156,7 @@ NLMISC_COMMAND(rangeAttack, "simulate a range attack", " [intensity] [loca CEntityCL *target = EntitiesMngr.entity(targetSlot); if (!target) return false; double dist = (target->pos() - entity->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), -10)); bc.Behav.DeltaHP = -10; entity->applyBehaviour(bc); return true; @@ -10188,7 +10190,7 @@ NLMISC_COMMAND(creatureAttack, "simulate a creature attack (2 attaques per creat { fromString(args[8], resist); } - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), -15)); bc.Behav.CreatureAttack.ActionDuration = 0; uint magicImpactIntensity = 1; if (args.size() > 3) diff --git a/ryzom/client/src/user_entity.cpp b/ryzom/client/src/user_entity.cpp index ca205c6de..265265344 100644 --- a/ryzom/client/src/user_entity.cpp +++ b/ryzom/client/src/user_entity.cpp @@ -491,8 +491,8 @@ void CUserEntity::updateVisualPropertyBehaviour(const NLMISC::TGameCycle &/* gam } CCDBNodeLeaf *targetList0 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_0)); CCDBNodeLeaf *targetList1 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); - CCDBNodeLeaf *targetList2 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); - CCDBNodeLeaf *targetList3 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); + CCDBNodeLeaf *targetList2 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_2)); + CCDBNodeLeaf *targetList3 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_3)); if (targetList0 && targetList1 && targetList2 && targetList3) { uint64 vp[4] = diff --git a/ryzom/common/src/game_share/multi_target.cpp b/ryzom/common/src/game_share/multi_target.cpp index 066d842c9..cef120b60 100644 --- a/ryzom/common/src/game_share/multi_target.cpp +++ b/ryzom/common/src/game_share/multi_target.cpp @@ -22,18 +22,16 @@ // *********************************************************************** void CMultiTarget::pack(uint64 *destVP, uint numVP) { - nlassert(numVP * 4 >= Targets.size()); // not enough room to stores visual properties! + nlassert(numVP * 2 >= Targets.size()); // not enough room to stores visual properties! CTarget invalidTarget; uint index = 0; for(uint k = 0; k < numVP; ++k) { - uint16 parts[4]; - for(uint l = 0; l < 4; ++l) - { - parts[l] = index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked(); - ++ index; - } - destVP[k] = (uint64) parts[0] | ((uint64) parts[1] << 16) | ((uint64) parts[2] << 32) | ((uint64) parts[3] << 48); + destVP[k] = index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked(); + ++index; + + destVP[k] |= uint64(index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked()) << 32; + ++index; } } @@ -43,18 +41,15 @@ void CMultiTarget::unpack(const uint64 *srcVP, uint numVP) Targets.clear(); for(uint k = 0; k < numVP; ++k) { - for(uint l = 0; l < 4; ++l) - { - CTarget t; - t.setPacked((uint16) ((srcVP[k] >> (16 * l)) & 0xffff)); - if (t.TargetSlot != CLFECOMMON::INVALID_SLOT) - { - Targets.push_back(t); - } - else - { - return; - } - } + CTarget t; + t.setPacked(uint32(srcVP[k])); + if(t.TargetSlot == CLFECOMMON::INVALID_SLOT) + return; + Targets.push_back(t); + + t.setPacked(uint32(srcVP[k] >> 32)); + if(t.TargetSlot == CLFECOMMON::INVALID_SLOT) + return; + Targets.push_back(t); } } diff --git a/ryzom/common/src/game_share/multi_target.h b/ryzom/common/src/game_share/multi_target.h index 5b3fd8101..dcc6c9d6c 100644 --- a/ryzom/common/src/game_share/multi_target.h +++ b/ryzom/common/src/game_share/multi_target.h @@ -39,20 +39,21 @@ public: uint8 TargetSlot; // the slot that is targetted uint8 Info; // Damage shield for melee 5:3 format (damage shield io : power ) // Distance for range attacks (that do not have damage shield) format is 7:1 + sint16 DeltaHP; // public: - CTarget(uint8 slot = CLFECOMMON::INVALID_SLOT, bool resist = false, uint8 dist = 0) : TargetSlot(slot) + CTarget(uint8 slot = CLFECOMMON::INVALID_SLOT, bool resist = false, uint8 dist = 0, sint16 deltaHp = 0) : TargetSlot(slot), DeltaHP(deltaHp) { Info = (resist == 0 ? 0 : 0x80) | (dist & 0x7f); } - uint16 getPacked() const; - void setPacked(uint16 value); + uint32 getPacked() const; + void setPacked(uint32 value); }; typedef std::vector TTargetVect; // the list of targets TTargetVect Targets; public: /** create packed version of targets (to store in visual properties) - * each VP encodes 4 targets + * each VP encodes 2 targets * caller must provide enough room to store the result (assertion is raised otherwise) */ void pack(uint64 *destVP, uint numVP); @@ -65,19 +66,18 @@ public: //////////// // ******************************************************************************************* -inline uint16 CMultiTarget::CTarget::getPacked() const +inline uint32 CMultiTarget::CTarget::getPacked() const { //return (uint16) TargetSlot | ((uint16) (Resist ? 1 : 0) << 15) | ((uint16) Distance << 8); - return (uint16) TargetSlot | (uint16(Info) << 8); + return ((uint32) TargetSlot) | ((uint32) Info << 8) | ((uint32) DeltaHP << 16); } // ******************************************************************************************* -inline void CMultiTarget::CTarget::setPacked(uint16 value) +inline void CMultiTarget::CTarget::setPacked(uint32 value) { - TargetSlot = uint8(value & 0xff); - /*Distance = (uint8) ((value >> 8) & 0x7f); - Resist = (value & 0x8000) != 0;*/ - Info = value >> 8; + TargetSlot = uint8(value); + Info = uint8(value >> 8); + DeltaHP = sint16(value >> 16); } #endif From 663de25cbeb9f917c49ba98f8e5f0b6ecafb0caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Meelis=20M=C3=A4gi?= Date: Mon, 3 Jan 2022 10:20:02 +0000 Subject: [PATCH 12/17] Fixed cleanup of html downloads --- nel/include/nel/gui/group_html.h | 1 + nel/src/gui/group_html.cpp | 25 +++++++++++++++---------- nel/src/gui/view_bitmap.cpp | 8 +++++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index 8b6ad19b6..4f972b191 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -969,6 +969,7 @@ namespace NLGUI // stop all curl downalods (html and data) void releaseDownloads(); + void releaseDataDownloads(); void checkDownloads(); // _CurlWWW download finished diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 107ab107a..de7e6effe 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -299,6 +299,11 @@ namespace NLGUI void CGroupHTML::ImageDownloadCB::finish() { + // Image setTexture will remove itself from Images while iterating over it. + // Do the swap to keep iterator safe. + std::vector vec; + vec.swap(Images); + // tmpdest file does not exist if download skipped (ie cache was used) if (CFile::fileExists(tmpdest) || CFile::getFileSize(tmpdest) == 0) { @@ -322,7 +327,7 @@ namespace NLGUI // to temp file temporarily. that forces driver to reload texture from disk // ITexture::touch() seem not to do this. // cache was updated, first set texture as temp file - for(std::vector::iterator it = Images.begin(); it != Images.end(); ++it) + for(std::vector::iterator it = vec.begin(); it != vec.end(); ++it) { SImageInfo &img = *it; Parent->setImage(img.Image, tmpdest, img.Type); @@ -339,7 +344,7 @@ namespace NLGUI } // even if image was cached, incase there was 'http://' image set to CViewBitmap - for(std::vector::iterator it = Images.begin(); it != Images.end(); ++it) + for(std::vector::iterator it = vec.begin(); it != vec.end(); ++it) { SImageInfo &img = *it; Parent->setImage(img.Image, dest, img.Type); @@ -1053,6 +1058,13 @@ namespace NLGUI _CurlWWW = NULL; } + releaseDataDownloads(); + } + + void CGroupHTML::releaseDataDownloads() + { + LOG_DL("Clear pointers to %d curls", Curls.size()); + // remove all queued and already started downloads for(std::list::iterator it = Curls.begin(); it != Curls.end(); ++it) { @@ -3080,14 +3092,7 @@ namespace NLGUI paragraphChange (); - // clear the pointer to the current image download since all the button are deleted - LOG_DL("Clear pointers to %d curls", Curls.size()); - - // remove image refs from downloads - /*for(std::list::iterator it = Curls.begin(); it != Curls.end(); ++it) - { - it->imgs.clear(); - }*/ + releaseDataDownloads(); } // *************************************************************************** diff --git a/nel/src/gui/view_bitmap.cpp b/nel/src/gui/view_bitmap.cpp index 89c944a18..1896ced40 100644 --- a/nel/src/gui/view_bitmap.cpp +++ b/nel/src/gui/view_bitmap.cpp @@ -481,7 +481,13 @@ namespace NLGUI } else { - _HtmlDownload = NULL; + if (_HtmlDownload) + { + CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:webig:content:html")); + if (groupHtml) + groupHtml->removeImageDownload(_HtmlDownload, dynamic_cast(this)); + _HtmlDownload = NULL; + } _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); } } From aebab35cadb59648f7b710d5c66e29065558f586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Meelis=20M=C3=A4gi?= Date: Mon, 3 Jan 2022 10:20:26 +0000 Subject: [PATCH 13/17] Fix crash when --nopatch is used without argument --- ryzom/client/src/far_tp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ryzom/client/src/far_tp.cpp b/ryzom/client/src/far_tp.cpp index 6bd05172a..3461c824f 100644 --- a/ryzom/client/src/far_tp.cpp +++ b/ryzom/client/src/far_tp.cpp @@ -466,7 +466,7 @@ void CLoginStateMachine::run() /// check the data to check if patch needed CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_PostLogin, "login_step_post_login")); - if (!ClientCfg.PatchWanted || (Args.haveArg("n") && Args.getLongArg("nopatch").front() == "1")) + if (!ClientCfg.PatchWanted || Args.haveLongArg("nopatch")) { // client don't want to be patched ! _CurrentState = st_display_eula; From 3b2553e3dd07a38068477007b0a1e4644cebab1a Mon Sep 17 00:00:00 2001 From: Ben Saine Date: Mon, 3 Jan 2022 10:22:46 +0000 Subject: [PATCH 14/17] Resolve "Allow drag and drop between zig and guild" --- .../src/interface_v3/inventory_manager.cpp | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp index 1bb3c478f..04ad896bc 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -2903,32 +2903,6 @@ class CHandlerInvCanDropTo : public IActionHandler if ((pListDstText != NULL) || (pListDstIcon != NULL)) { bool bCanDrop = true; - // WE CANT DND if we want to dnd from other bag than BAG to guild bag - if (pListDstIcon != NULL) - { - if (pListDstIcon->getInvType() == CInventoryManager::InvGuild) - if (strnicmp(pCSSrc->getSheet().c_str(),"LOCAL:INVENTORY:BAG", 19) != 0) - bCanDrop = false; - } - if (pListDstText != NULL) - { - if (pListDstText->getInvType() == CInventoryManager::InvGuild) - if (strnicmp(pCSSrc->getSheet().c_str(),"LOCAL:INVENTORY:BAG", 19) != 0) - bCanDrop = false; - } - // WE CANT DND if we want to dnd from guild bag to other bag than BAG - if (pListDstIcon != NULL) - { - if (pListDstIcon->getInvType() != CInventoryManager::InvBag) - if (strnicmp(pCSSrc->getSheet().c_str(),"SERVER:GUILD:INVENTORY", 19) == 0) - bCanDrop = false; - } - if (pListDstText != NULL) - { - if (pListDstText->getInvType() != CInventoryManager::InvBag) - if (strnicmp(pCSSrc->getSheet().c_str(),"SERVER:GUILD:INVENTORY", 19) == 0) - bCanDrop = false; - } // WE CANT DND when packer/mount is too far if (pListDstIcon != NULL) @@ -3100,7 +3074,6 @@ class CHandlerInvDropTo : public IActionHandler else if (((pListDstText != NULL) && (pListDstText->getInvType() == CInventoryManager::InvGuild)) || ((pListDstIcon != NULL) && (pListDstIcon->getInvType() == CInventoryManager::InvGuild))) { - if (strnicmp(pCSSrc->getSheet().c_str(), "LOCAL:INVENTORY:BAG", 19) == 0) CAHManager::getInstance()->runActionHandler("proc", pCSSrc, "move_to_guild"); } else if (((pListDstText != NULL) && (pListDstText->getInvType() == CInventoryManager::InvRoom)) || From 855410f3d0788d2e05d3984dc1aac93b8497fe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves=20=28Ulukyn=29?= Date: Thu, 13 Jan 2022 16:28:47 +0000 Subject: [PATCH 15/17] Resolve "Add ability to have translated titles with untraslated fields" --- ryzom/client/src/string_manager_client.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index 1ff55c54b..74f650b1e 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -1630,7 +1630,7 @@ const char *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetI const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, bool women) { vector listInfos = getTitleInfos(titleId, women); - + if (!listInfos.empty()) { _TitleWords.push_back(listInfos[0]); @@ -1681,7 +1681,19 @@ vector CStringManagerClient::getTitleInfos(const string &titleId, bool w { if (titleId[0] != '#') { - listInfos[0] = getSpecialWord(listInfos[0], women); + // Check special case like SON_OF|jane|joe (with SON_OF = "Son of {1} and {2}") + vector titleReps; + splitString(listInfos[0], string("|"), titleReps); + if (titleReps.size() > 1) + { + listInfos[0] = getSpecialWord(titleReps[0], women); + for(uint i=1; i < titleReps.size(); ++i ) + { + while(strFindReplace(listInfos[0], toString("{%d}", i), titleReps[i])); + } + } + else + listInfos[0] = getSpecialWord(listInfos[0], women); } } From 22b4c074e867a7dcf95ed9243cc39229ce9601cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves=20=28Ulukyn=29?= Date: Thu, 13 Jan 2022 16:28:52 +0000 Subject: [PATCH 16/17] Resolve "Remove Open menu option from scroll items when item use a Scroll.Label" --- ryzom/client/src/interface_v3/action_handler_item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 67f0d18ee..ff4034b3d 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1881,7 +1881,7 @@ class CHandlerItemMenuCheck : public IActionHandler } if (pItemTextDisplay && pIS->Family == ITEMFAMILY::SCROLL) { - if (pCS->getInventoryIndex()==INVENTORIES::bag) + if (pCS->getInventoryIndex()==INVENTORIES::bag && pIS->Scroll.Label.empty()) pItemTextDisplay->setActive(true); pItemInfos->setActive(false); } From 357934fcdec7ae66213d4729ee1b879ab7ec5793 Mon Sep 17 00:00:00 2001 From: Ben Saine Date: Mon, 17 Jan 2022 16:41:29 +0000 Subject: [PATCH 17/17] Resolve "Dragging from player trade to inventory takes two tries" --- ryzom/client/src/interface_v3/action_handler_item.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index ff4034b3d..f931f1d76 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -747,6 +747,10 @@ public: CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); + + // end drag + getInventory().endDrag(); + if ((pCSSrc == NULL) || (pCSDst == NULL)) return; if (pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item)