From 6c9bbb8c0bee4ca63e36b18b55bd2f2f3fa8bdba Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Thu, 9 Mar 2017 18:54:12 +0100 Subject: [PATCH] Allow support for room / guild movement --HG-- branch : item_group --- .../data/gamedev/interfaces_v3/widgets.xml | 12 +++++- code/ryzom/client/src/client_cfg.cpp | 4 +- code/ryzom/client/src/client_cfg.h | 3 ++ code/ryzom/client/src/commands.cpp | 37 +++++++++++++++++-- .../src/interface_v3/action_handler_item.cpp | 22 ++++++++--- code/ryzom/client/src/item_group_manager.cpp | 15 +++++++- code/ryzom/client/src/item_group_manager.h | 1 + 7 files changed, 81 insertions(+), 13 deletions(-) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml index 3c25c911a..70aea48b1 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml @@ -1847,7 +1847,17 @@ name="uimMtPaMount3" handler="item_group_move" params="pet_animal4" /> - + + + + + diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 7f308c8d2..3b7badcfc 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -589,7 +589,7 @@ CClientConfig::CClientConfig() FollowOnAtk = true; AtkOnSelect = false; TransparentUnderCursor = false; - + ItemGroupAllowGuild = false; // PREFERENCES FPV = false; CameraHeight = 2.5f; @@ -1440,6 +1440,8 @@ void CClientConfig::setValues() READ_BOOL_FV(FollowOnAtk); READ_BOOL_FV(AtkOnSelect); READ_BOOL_DEV(TransparentUnderCursor); + // + READ_BOOL_FV(ItemGroupAllowGuild); ///////////////// diff --git a/code/ryzom/client/src/client_cfg.h b/code/ryzom/client/src/client_cfg.h index 3a143ec1f..dd150dd49 100644 --- a/code/ryzom/client/src/client_cfg.h +++ b/code/ryzom/client/src/client_cfg.h @@ -571,6 +571,9 @@ struct CClientConfig /// Makes entities transparent if they are under cursor bool TransparentUnderCursor; + /// Allow item group to move from / to guild room + bool ItemGroupAllowGuild; + ///////////////// // PREFERENCES // diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 511d4f536..b05c5c71b 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -209,6 +209,11 @@ NLMISC_COMMAND(who, "Display all players currently in region","[listGroup(); + return true; +} NLMISC_COMMAND(equipGroup, "equip group ", "name") { @@ -225,14 +230,38 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") NLMISC_COMMAND(createGroup, "create group ", "name") { - if(args.empty()) return false; - return CItemGroupManager::getInstance()->createGroup(args[0]); + if(args.empty()) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo(ucstring("Cannot create a group without name.")); + return false; + } + if(!CItemGroupManager::getInstance()->createGroup(args[0])) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + std::string msg = "A group named " + args[0] + "already exist, cannot create one with the same name."; + pIM->displaySystemInfo(ucstring(msg)); + return false; + } + return true; } NLMISC_COMMAND(deleteGroup, "delete group ", "name") { - if(args.empty()) return false; - return CItemGroupManager::getInstance()->deleteGroup(args[0]); + if(args.empty()) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo(ucstring("Cannot delete a group without name.")); + return false; + } + if(!CItemGroupManager::getInstance()->deleteGroup(args[0])) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + std::string msg = "Cannot delete group " + args[0] + " : no group with this name found."; + pIM->displaySystemInfo(msg); + return false; + } + return true; } NLMISC_COMMAND(naked, "get naked !", "") 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 2c9a7f952..67699e329 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1759,8 +1759,12 @@ class CHandlerItemMenuCheck : public IActionHandler CViewTextMenu *pMoveToRoom = dynamic_cast(pMenu->getView("room")); CViewTextMenu *pMoveToPa[MAX_INVENTORY_ANIMAL]; CViewTextMenu *pGroupSubMenu = dynamic_cast(pMenu->getView("item_group")); - CViewTextMenu *pGroupMoveToBag = dynamic_cast(pMenu->getView("group_bag")); CViewTextMenu *pGroupName = dynamic_cast(pMenu->getView("group_name")); + CViewTextMenu *pGroupMoveSubMenu = dynamic_cast(pMenu->getView("group_move")); + CViewTextMenu *pGroupMoveToBag = dynamic_cast(pMenu->getView("group_bag")); + CViewTextMenu *pGroupMoveToGuild = dynamic_cast(pMenu->getView("group_guild")); + CViewTextMenu *pGroupMoveToRoom = dynamic_cast(pMenu->getView("group_room")); + CViewTextMenu *pGroupMoveToPa[MAX_INVENTORY_ANIMAL]; bool bIsLockedByOwner = pCS->getLockedByOwner(); @@ -1912,10 +1916,12 @@ class CHandlerItemMenuCheck : public IActionHandler if (pMoveToGuild) pMoveToGuild->setActive(invId==INVENTORIES::bag && invMngr.isInventoryPresent(INVENTORIES::guild)); - + if (pGroupMoveToGuild) + pGroupMoveToGuild->setActive(ClientCfg.ItemGroupAllowGuild && invId==INVENTORIES::bag && invMngr.isInventoryPresent(INVENTORIES::guild)); if (pMoveToRoom) pMoveToRoom->setActive(invId==INVENTORIES::bag && invMngr.isInventoryPresent(INVENTORIES::player_room)); - + if (pGroupMoveToRoom) + pGroupMoveToRoom->setActive(invId==INVENTORIES::bag && invMngr.isInventoryPresent(INVENTORIES::player_room)); // std case: can drop / destroy if(pDrop) pDrop->setActive(invId!=INVENTORIES::guild); if(pDestroy) pDestroy->setActive(invId!=INVENTORIES::guild); @@ -1924,20 +1930,24 @@ class CHandlerItemMenuCheck : public IActionHandler // hide the move entry completely? bool someMovePossible= false; - if(pMoveSubMenu) + bool someGroupMovePossible = false; + if(pMoveSubMenu && pGroupMoveSubMenu) { if(pMoveToBag) someMovePossible= someMovePossible || pMoveToBag->getActive(); - if(pGroupMoveToBag) someMovePossible= someMovePossible || pGroupMoveToBag->getActive(); + if(pGroupMoveToBag) someGroupMovePossible= someGroupMovePossible || pGroupMoveToBag->getActive(); for(i=0;igetActive(); - if(pGroupMoveToPa[i]) someMovePossible= someMovePossible || pGroupMoveToPa[i]->getActive(); + if(pGroupMoveToPa[i]) someGroupMovePossible= someGroupMovePossible || pGroupMoveToPa[i]->getActive(); } if(pMoveToGuild) someMovePossible= someMovePossible || pMoveToGuild->getActive(); if(pMoveToRoom) someMovePossible= someMovePossible || pMoveToRoom->getActive(); + if(pGroupMoveToGuild) someGroupMovePossible= someGroupMovePossible || pGroupMoveToGuild->getActive(); + if(pGroupMoveToRoom) someGroupMovePossible= someGroupMovePossible || (ClientCfg.ItemGroupAllowGuild && pGroupMoveToRoom->getActive()); pMoveSubMenu->setActive(someMovePossible); + pGroupMoveSubMenu->setActive(someGroupMovePossible); } // Equip diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index 0ff17d269..30e8d02b6 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -27,7 +27,7 @@ #include "net_manager.h" #include "connection.h" // Used to access PlayerSelectedFileName for xml filename #include "nel/gui/db_manager.h" - +#include "interface_v3/interface_manager.h" CItemGroupManager *CItemGroupManager::_Instance = NULL; CItemGroup::CItemGroup() @@ -391,6 +391,15 @@ bool CItemGroupManager::deleteGroup(std::string name) return true; } +void CItemGroupManager::listGroup() +{ + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + for(auto &group: _Groups) + { + pIM->displaySystemInfo(ucstring(group.name)); + } +} + //Used by AH std::string CItemGroupManager::getGroupName(CDBCtrlSheet* pCS) @@ -428,6 +437,10 @@ std::string CItemGroupManager::toDbPath(INVENTORIES::TInventory inventory) return LIST_PA2_TEXT; break; case INVENTORIES::TInventory::pet_animal4: return LIST_PA3_TEXT; break; + case INVENTORIES::TInventory::player_room: + return LIST_ROOM_TEXT;break; + case INVENTORIES::TInventory::guild: + return ClientCfg.ItemGroupAllowGuild ? LIST_GUILD_TEXT : ""; break; default: return ""; } diff --git a/code/ryzom/client/src/item_group_manager.h b/code/ryzom/client/src/item_group_manager.h index 27b73757d..daeefea51 100644 --- a/code/ryzom/client/src/item_group_manager.h +++ b/code/ryzom/client/src/item_group_manager.h @@ -83,6 +83,7 @@ public: bool equipGroup(std::string name, bool pullBefore=true); bool createGroup(std::string name); bool deleteGroup(std::string name); + void listGroup(); std::string getGroupName(CDBCtrlSheet *pCS); private: