From 87b0a85fe66d304b1c6bc7a6b128013065db1913 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Mon, 3 Apr 2017 01:34:29 +0200 Subject: [PATCH 1/2] Minor item group fixes : * Slot properly saved for right/left hand (couldn't equip 1H sword + dagger before) * Ingame macro edition for item group * Use the correct index (db index and not item list index) to autoEquip an item * non ascii characters (accentued characters and stuff like that) are now correctly displayed in interface / commands output --HG-- branch : develop --- .../data/gamedev/interfaces_v3/actions.xml | 15 +++++++ code/ryzom/client/src/commands.cpp | 40 +++++++++++++++---- .../src/interface_v3/action_handler_item.cpp | 5 ++- code/ryzom/client/src/item_group_manager.cpp | 20 ++++++++-- 4 files changed, 67 insertions(+), 13 deletions(-) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml b/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml index 8696de32a..d628a6996 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/actions.xml @@ -220,6 +220,21 @@ + + + + + + + + + + + + + + + diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 978cc144a..8ba5f769f 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -233,14 +233,20 @@ NLMISC_COMMAND(equipGroup, "equip group ", "name") if(CItemGroupManager::getInstance()->equipGroup(args[0])) { ucstring msg = CI18N::get("cmdEquipGroupSuccess"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { ucstring msg = CI18N::get("cmdEquipGroupError"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; } @@ -261,7 +267,10 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1]))) { ucstring msg = CI18N::get("cmdMoveGroupSuccess"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); pIM->displaySystemInfo(msg); return true; @@ -269,7 +278,10 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") else { ucstring msg = CI18N::get("cmdMoveGroupError"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); pIM->displaySystemInfo(msg); return false; @@ -297,14 +309,20 @@ NLMISC_COMMAND(createGroup, "create group [true](create a for ev msg = CI18N::get("cmdCreateGroupSuccess2"); else msg = CI18N::get("cmdCreateGroupSuccess1"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { ucstring msg = CI18N::get("cmdCreateGroupError"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; } @@ -325,14 +343,20 @@ NLMISC_COMMAND(deleteGroup, "delete group ", "name") if(CItemGroupManager::getInstance()->deleteGroup(args[0])) { ucstring msg = CI18N::get("cmdDeleteGroupSuccess"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { ucstring msg = CI18N::get("cmdDeleteGroupError"); - strFindReplace(msg, "%name", args[0]); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(args[0]); + strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; } diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index e8c07f837..d15ae130c 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -2041,7 +2041,10 @@ class CHandlerItemMenuCheck : public IActionHandler { std::string name = groupNames[i]; std::string ahParams = "name=" + name; - pGroupMenu->addLine(ucstring(name), "", "", name); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(name); + pGroupMenu->addLine(nameUC, "", "", name); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); if(pNewSubMenu) diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index 12486666a..90b8424a6 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -492,8 +492,10 @@ bool CItemGroupManager::createGroup(std::string name, bool removeUnequiped) { SLOT_EQUIPMENT::TSlotEquipment slot = (SLOT_EQUIPMENT::TSlotEquipment)i; //Instead of doing two separate for, just be a bit tricky for hand equipment - if(slot == SLOT_EQUIPMENT::HANDR || slot == SLOT_EQUIPMENT::HANDL) - pCS = CInventoryManager::getInstance()->getHandSheet((uint32)(slot - SLOT_EQUIPMENT::HANDL)); + if(slot == SLOT_EQUIPMENT::HANDR) + pCS = CInventoryManager::getInstance()->getHandSheet(0); + else if(slot == SLOT_EQUIPMENT::HANDL) + pCS = CInventoryManager::getInstance()->getHandSheet(1); else pCS = CInventoryManager::getInstance()->getEquipSheet(i); if(!pCS) continue; @@ -537,7 +539,10 @@ void CItemGroupManager::listGroup() { CItemGroup group = _Groups[i]; ucstring msg = NLMISC::CI18N::get("cmdListGroupLine"); - NLMISC::strFindReplace(msg, "%name", group.name); + //Use ucstring because group name can contain accentued characters (and stuff like that) + ucstring nameUC; + nameUC.fromUtf8(group.name); + NLMISC::strFindReplace(msg, "%name", nameUC); NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size())); pIM->displaySystemInfo(msg); } @@ -607,7 +612,14 @@ std::vector CItemGroupManager::matchingItems(CItemGroup *group, SLOT_EQUIPMENT::TSlotEquipment slot; if(group->contains(pCS, slot)) { - out.push_back(CInventoryItem(pCS, inventory, i, slot)); + //Sometimes, index in the list differ from the index in DB, and we need the index in DB, not the one from the list + std::string dbPath = pCS->getSheet(); + std::size_t found = dbPath.find_last_of(":"); + std::string indexS = dbPath.substr(found+1); + uint32 index; + NLMISC::fromString(indexS, index); + if(i != index) nldebug("Index from list is %d, where index from DB is %d", i, index); + out.push_back(CInventoryItem(pCS, inventory, index, slot)); } } From cf3cf69c3914ac9e7e08e9212a9b8caa7e3ca479 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Mon, 3 Apr 2017 01:43:26 +0200 Subject: [PATCH 2/2] Don't fake invalid action if there is nothing to fake (no item equiped) --HG-- branch : develop --- code/ryzom/client/src/item_group_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index 90b8424a6..6584060ff 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -476,7 +476,8 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) } // For some reason, there is no (visual) invalidation (server still blocks any action), force one // Unfortunately, there is no clean way to do this, so we'll simulate one - fakeInvalidActions((NLMISC::TGameCycle)maxEquipTime); + if(maxEquipTime > 0) + fakeInvalidActions((NLMISC::TGameCycle)maxEquipTime); return true; }