Support for an item beeing in multiple groups
--HG-- branch : item_group
This commit is contained in:
parent
5dcc7932ff
commit
c2049935a4
4 changed files with 262 additions and 102 deletions
|
@ -1819,46 +1819,196 @@
|
|||
name="uimItemTextEdit"
|
||||
handler="item_text_edition"
|
||||
params="ui:interface:edit_custom" />
|
||||
<!-- TODO glorf : ugly because i haven't found a way to do template with actions inside ... -->
|
||||
<action id="item_group"
|
||||
name="uiGroup">
|
||||
<action id="group_name" />
|
||||
<action id="group_equip"
|
||||
<action id="group0_name"
|
||||
name="you should not see this ingame">
|
||||
<action id="group0_equip"
|
||||
name="uimEquip"
|
||||
handler="item_group_equip"/>
|
||||
<action id="group_move"
|
||||
handler="item_group_equip"
|
||||
params="groupIndex=0" />
|
||||
<action id="group0_move"
|
||||
name="uimMoveTo">
|
||||
<action id="group_bag"
|
||||
<action id="group0_bag"
|
||||
name="uimMtBag"
|
||||
handler="item_group_move"
|
||||
params="bag" />
|
||||
<action id="group_pa0"
|
||||
params="groupIndex=0|destination=bag" />
|
||||
<action id="group0_pa0"
|
||||
name="uimMtPaMount0"
|
||||
handler="item_group_move"
|
||||
params="pet_animal1" /> <!-- Offset because they are named petanimal1/2/3/4 in Inventories::TEnumType -->
|
||||
<action id="group_pa1"
|
||||
params="groupIndex=0|destination=pet_animal1" /><!-- Offset because they are named petanimal1/2/3/4 in Inventories::TEnumType -->
|
||||
<action id="group0_pa1"
|
||||
name="uimMtPaMount1"
|
||||
handler="item_group_move"
|
||||
params="pet_animal2" />
|
||||
<action id="group_pa2"
|
||||
params="groupIndex=0|destination=pet_animal2" />
|
||||
<action id="group0_pa2"
|
||||
name="uimMtPaMount2"
|
||||
handler="item_group_move"
|
||||
params="pet_animal3" />
|
||||
<action id="group_pa3"
|
||||
params="groupIndex=0|destination=pet_animal3" />
|
||||
<action id="group0_pa3"
|
||||
name="uimMtPaMount3"
|
||||
handler="item_group_move"
|
||||
params="pet_animal4" />
|
||||
<action id="group_room"
|
||||
params="groupIndex=0|destination=pet_animal4" />
|
||||
<action id="group0_room"
|
||||
name="uimMtRoom"
|
||||
handler="item_group_move"
|
||||
params="player_room" />
|
||||
<action id="group_guild"
|
||||
params="groupIndex=0|destination=player_room" />
|
||||
<action id="group0_guild"
|
||||
name="uimMtGuild"
|
||||
handler="item_group_move"
|
||||
params="guild" />
|
||||
|
||||
</action>
|
||||
<!-- move !-->
|
||||
</action> <!-- item_group !-->
|
||||
params="groupIndex=0|destination=guild" /> </action> <!-- MOVE -->
|
||||
</action> <!--group0 -->
|
||||
<action id="group1_name"
|
||||
name="you should not see this ingame">
|
||||
<action id="group1_equip"
|
||||
name="uimEquip"
|
||||
handler="item_group_equip"
|
||||
params="groupIndex=1" />
|
||||
<action id="group1_move"
|
||||
name="uimMoveTo">
|
||||
<action id="group1_bag"
|
||||
name="uimMtBag"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=bag" />
|
||||
<action id="group1_pa0"
|
||||
name="uimMtPaMount0"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=pet_animal1" /><!-- Offset because they are named petanimal1/2/3/4 in Inventories::TEnumType -->
|
||||
<action id="group1_pa1"
|
||||
name="uimMtPaMount1"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=pet_animal2" />
|
||||
<action id="group1_pa2"
|
||||
name="uimMtPaMount2"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=pet_animal3" />
|
||||
<action id="group1_pa3"
|
||||
name="uimMtPaMount3"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=pet_animal4" />
|
||||
<action id="group1_room"
|
||||
name="uimMtRoom"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=player_room" />
|
||||
<action id="group1_guild"
|
||||
name="uimMtGuild"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=1|destination=guild" /> </action> <!-- MOVE -->
|
||||
</action> <!-- group1 -->
|
||||
<action id="group2_name"
|
||||
name="you should not see this ingame">
|
||||
<action id="group2_equip"
|
||||
name="uimEquip"
|
||||
handler="item_group_equip"
|
||||
params="groupIndex=2" />
|
||||
<action id="group2_move"
|
||||
name="uimMoveTo">
|
||||
<action id="group2_bag"
|
||||
name="uimMtBag"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=bag" />
|
||||
<action id="group2_pa0"
|
||||
name="uimMtPaMount0"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=pet_animal1" /><!-- Offset because they are named petanimal1/2/3/4 in Inventories::TEnumType -->
|
||||
<action id="group2_pa1"
|
||||
name="uimMtPaMount1"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=pet_animal2" />
|
||||
<action id="group2_pa2"
|
||||
name="uimMtPaMount2"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=pet_animal3" />
|
||||
<action id="group2_pa3"
|
||||
name="uimMtPaMount3"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=pet_animal4" />
|
||||
<action id="group2_room"
|
||||
name="uimMtRoom"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=player_room" />
|
||||
<action id="group2_guild"
|
||||
name="uimMtGuild"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=2|destination=guild" /> </action> <!-- MOVE -->
|
||||
</action> <!-- group2 -->
|
||||
<action id="group3_name"
|
||||
name="you should not see this ingame">
|
||||
<action id="group3_equip"
|
||||
name="uimEquip"
|
||||
handler="item_group_equip"
|
||||
params="groupIndex=3" />
|
||||
<action id="group3_move"
|
||||
name="uimMoveTo">
|
||||
<action id="group3_bag"
|
||||
name="uimMtBag"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=bag" />
|
||||
<action id="group3_pa0"
|
||||
name="uimMtPaMount0"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=pet_animal1" /><!-- Offset because they are named petanimal1/2/3/4 in Inventories::TEnumType -->
|
||||
<action id="group3_pa1"
|
||||
name="uimMtPaMount1"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=pet_animal2" />
|
||||
<action id="group3_pa2"
|
||||
name="uimMtPaMount2"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=pet_animal3" />
|
||||
<action id="group3_pa3"
|
||||
name="uimMtPaMount3"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=pet_animal4" />
|
||||
<action id="group3_room"
|
||||
name="uimMtRoom"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=player_room" />
|
||||
<action id="group3_guild"
|
||||
name="uimMtGuild"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=3|destination=guild" /> </action> <!-- MOVE -->
|
||||
</action> <!-- group3 -->
|
||||
<action id="group4_name"
|
||||
name="you should not see this ingame">
|
||||
<action id="group4_equip"
|
||||
name="uimEquip"
|
||||
handler="item_group_equip"
|
||||
params="groupIndex=4" />
|
||||
<action id="group4_move"
|
||||
name="uimMoveTo">
|
||||
<action id="group4_bag"
|
||||
name="uimMtBag"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=bag" />
|
||||
<!-- name is correctly set in code based on corresponding regular move -->
|
||||
<action id="group4_pa0"
|
||||
name="uimMtPaMount0"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=pet_animal1" /><!-- Offset because they are named petanimal1/2/3/4 in Inventories::TEnumType -->
|
||||
<action id="group4_pa1"
|
||||
name="uimMtPaMount1"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=pet_animal2" />
|
||||
<action id="group4_pa2"
|
||||
name="uimMtPaMount2"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=pet_animal3" />
|
||||
<action id="group4_pa3"
|
||||
name="uimMtPaMount3"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=pet_animal4" />
|
||||
<action id="group4_room"
|
||||
name="uimMtRoom"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=player_room" />
|
||||
<action id="group4_guild"
|
||||
name="uimMtGuild"
|
||||
handler="item_group_move"
|
||||
params="groupIndex=4|destination=guild" /> </action> <!-- MOVE -->
|
||||
</action> <!-- group4 -->
|
||||
</action> <!-- item_group -->
|
||||
|
||||
</group>
|
||||
<!-- MAX_INVENTORY_ANIMAL -->
|
||||
|
@ -1870,15 +2020,6 @@
|
|||
target="ui:interface:item_menu_in_bag:move:pa2:hardtext" />
|
||||
<link expr="switch(@%pa_beast3:TYPE, 'uimMtPaMount3', 'uimMtPaMount3', 'uimMtPaPacker3', 'uimMtPaDemon3')"
|
||||
target="ui:interface:item_menu_in_bag:move:pa3:hardtext" />
|
||||
<!-- Item group submenu -->
|
||||
<link expr="switch(@%pa_beast0:TYPE, 'uimMtPaMount0', 'uimMtPaMount0', 'uimMtPaPacker0', 'uimMtPaDemon0')"
|
||||
target="ui:interface:item_menu_in_bag:item_group:group_move:group_pa0:hardtext" />
|
||||
<link expr="switch(@%pa_beast1:TYPE, 'uimMtPaMount1', 'uimMtPaMount1', 'uimMtPaPacker1', 'uimMtPaDemon1')"
|
||||
target="ui:interface:item_menu_in_bag:item_group:group_move:group_pa1:hardtext" />
|
||||
<link expr="switch(@%pa_beast2:TYPE, 'uimMtPaMount2', 'uimMtPaMount2', 'uimMtPaPacker2', 'uimMtPaDemon2')"
|
||||
target="ui:interface:item_menu_in_bag:item_group:group_move:group_pa2:hardtext" />
|
||||
<link expr="switch(@%pa_beast3:TYPE, 'uimMtPaMount3', 'uimMtPaMount3', 'uimMtPaPacker3', 'uimMtPaDemon3')"
|
||||
target="ui:interface:item_menu_in_bag:item_group:group_move:group_pa3:hardtext" />
|
||||
<!-- item menu when we are in self -->
|
||||
<group type="menu"
|
||||
id="item_menu_in_self"
|
||||
|
|
|
@ -1758,28 +1758,17 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
CViewTextMenu *pMoveToGuild = dynamic_cast<CViewTextMenu*>(pMenu->getView("guild"));
|
||||
CViewTextMenu *pMoveToRoom = dynamic_cast<CViewTextMenu*>(pMenu->getView("room"));
|
||||
CViewTextMenu *pMoveToPa[MAX_INVENTORY_ANIMAL];
|
||||
CViewTextMenu *pGroupSubMenu = dynamic_cast<CViewTextMenu*>(pMenu->getView("item_group"));
|
||||
CViewTextMenu *pGroupName = dynamic_cast<CViewTextMenu*>(pMenu->getView("group_name"));
|
||||
CViewTextMenu *pGroupMoveSubMenu = dynamic_cast<CViewTextMenu*>(pMenu->getView("group_move"));
|
||||
CViewTextMenu *pGroupMoveToBag = dynamic_cast<CViewTextMenu*>(pMenu->getView("group_bag"));
|
||||
CViewTextMenu *pGroupMoveToGuild = dynamic_cast<CViewTextMenu*>(pMenu->getView("group_guild"));
|
||||
CViewTextMenu *pGroupMoveToRoom = dynamic_cast<CViewTextMenu*>(pMenu->getView("group_room"));
|
||||
|
||||
CViewTextMenu *pGroupMoveToPa[MAX_INVENTORY_ANIMAL];
|
||||
|
||||
bool bIsLockedByOwner = pCS->getLockedByOwner();
|
||||
|
||||
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
|
||||
{
|
||||
pMoveToPa[i]= dynamic_cast<CViewTextMenu*>(pMenu->getView(toString("pa%d", i)));
|
||||
pGroupMoveToPa[i]= dynamic_cast<CViewTextMenu*>(pMenu->getView(toString("group_pa%d", i)));
|
||||
|
||||
}
|
||||
CViewTextMenu *pItemInfos = dynamic_cast<CViewTextMenu*>(pMenu->getView("infos"));
|
||||
CViewTextMenu *pItemTextDisplay = dynamic_cast<CViewTextMenu*>(pMenu->getView("item_text_display"));
|
||||
CViewTextMenu *pItemTextEdition = dynamic_cast<CViewTextMenu*>(pMenu->getView("item_text_edition"));
|
||||
|
||||
|
||||
// **** Active Entries
|
||||
// Active Enchant / Reload for a subset of items
|
||||
if(pCrisEnchant) pCrisEnchant->setActive(false);
|
||||
|
@ -1790,13 +1779,7 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
if(pItemTextDisplay) pItemTextDisplay->setActive(false);
|
||||
if(pItemTextEdition) pItemTextEdition->setActive(false);
|
||||
|
||||
//Item GROUP logic
|
||||
if(pGroupSubMenu && pGroupName)
|
||||
{
|
||||
std::string groupName = CItemGroupManager::getInstance()->getGroupName(pCS);
|
||||
pGroupSubMenu->setActive(groupName != "");
|
||||
pGroupName->setHardText(groupName);
|
||||
}
|
||||
|
||||
if(pLockUnlock) pLockUnlock->setActive(true);
|
||||
|
||||
const CItemSheet *pIS = pCS->asItemSheet();
|
||||
|
@ -1876,11 +1859,9 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
{
|
||||
// cannot move to other animals! :)
|
||||
if(pMoveToBag) pMoveToBag->setActive(false);
|
||||
if(pGroupMoveToBag) pGroupMoveToBag->setActive(false);
|
||||
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
|
||||
{
|
||||
if(pMoveToPa[i]) pMoveToPa[i]->setActive(false);
|
||||
if(pGroupMoveToPa[i]) pGroupMoveToPa[i]->setActive(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1897,10 +1878,6 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
pMoveToBag->setActive( invId!=INVENTORIES::bag &&
|
||||
invMngr.isInventoryPresent(INVENTORIES::bag) &&
|
||||
(invId!=INVENTORIES::guild || invMngr.isInventoryPresent(INVENTORIES::guild)) );
|
||||
if(pGroupMoveToBag)
|
||||
pGroupMoveToBag->setActive( invId!=INVENTORIES::bag &&
|
||||
invMngr.isInventoryPresent(INVENTORIES::bag) &&
|
||||
(invId!=INVENTORIES::guild || invMngr.isInventoryPresent(INVENTORIES::guild)) );
|
||||
|
||||
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
|
||||
{
|
||||
|
@ -1908,20 +1885,12 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
pMoveToPa[i]->setActive(invId!=INVENTORIES::guild &&
|
||||
(uint)invId!=INVENTORIES::pet_animal+i &&
|
||||
invMngr.isInventoryPresent((INVENTORIES::TInventory)(INVENTORIES::pet_animal+i)) );
|
||||
if (pGroupMoveToPa[i])
|
||||
pGroupMoveToPa[i]->setActive(invId!=INVENTORIES::guild &&
|
||||
(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));
|
||||
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);
|
||||
|
@ -1930,24 +1899,18 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
|
||||
// hide the move entry completely?
|
||||
bool someMovePossible= false;
|
||||
bool someGroupMovePossible = false;
|
||||
if(pMoveSubMenu && pGroupMoveSubMenu)
|
||||
if(pMoveSubMenu)
|
||||
{
|
||||
if(pMoveToBag) someMovePossible= someMovePossible || pMoveToBag->getActive();
|
||||
if(pGroupMoveToBag) someGroupMovePossible= someGroupMovePossible || pGroupMoveToBag->getActive();
|
||||
|
||||
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
|
||||
{
|
||||
if(pMoveToPa[i]) someMovePossible= someMovePossible || pMoveToPa[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
|
||||
|
@ -2026,12 +1989,10 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
if(pLockUnlock) pLockUnlock->setGrayed(true);
|
||||
if(pMoveSubMenu) pMoveSubMenu->setGrayed(true);
|
||||
if(pMoveToBag) pMoveToBag->setGrayed(true);
|
||||
if(pGroupMoveToBag) pGroupMoveToBag->setGrayed(true);
|
||||
|
||||
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
|
||||
{
|
||||
if(pMoveToPa[i]) pMoveToPa[i]->setGrayed(true);
|
||||
if(pGroupMoveToPa[i]) pGroupMoveToPa[i]->setGrayed(true);
|
||||
}
|
||||
}
|
||||
// Gray Text entries according to Availables Destinations
|
||||
|
@ -2050,17 +2011,57 @@ class CHandlerItemMenuCheck : public IActionHandler
|
|||
|
||||
// check each inventory dest if available
|
||||
if(pMoveToBag) pMoveToBag->setGrayed(!invMngr.isInventoryAvailable(INVENTORIES::bag));
|
||||
if(pGroupMoveToBag) pGroupMoveToBag->setGrayed(!invMngr.isInventoryAvailable(INVENTORIES::bag));
|
||||
|
||||
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
|
||||
{
|
||||
if(pMoveToPa[i]) pMoveToPa[i]->setGrayed(!invMngr.isInventoryAvailable(
|
||||
(INVENTORIES::TInventory)(INVENTORIES::pet_animal+i)));
|
||||
if(pGroupMoveToPa[i]) pGroupMoveToPa[i]->setGrayed(!invMngr.isInventoryAvailable(
|
||||
(INVENTORIES::TInventory)(INVENTORIES::pet_animal+i)));
|
||||
}
|
||||
}
|
||||
|
||||
//Item GROUP logic
|
||||
// We go the lazy way here : group move have the same name/active/grayed state as regular move, just copy them.
|
||||
CViewTextMenu *pGroupSubMenu = dynamic_cast<CViewTextMenu*>(pMenu->getView("item_group"));
|
||||
std::vector<std::string> groupNames = CItemGroupManager::getInstance()->getGroupNames(pCS);
|
||||
if(pGroupSubMenu)
|
||||
{
|
||||
pGroupSubMenu->setActive(!groupNames.empty());
|
||||
}
|
||||
|
||||
for(int i=0;i< MAX_DIFFERENT_ITEM_GROUPS; i++)
|
||||
{
|
||||
//Disable the submenu if no matching group
|
||||
|
||||
std::string prefix = toString("group%d", i);
|
||||
CViewTextMenu *pGroupName = dynamic_cast<CViewTextMenu*>(pMenu->getView(prefix +"_name"));
|
||||
if(groupNames.size() <= i)
|
||||
{
|
||||
pGroupName->setActive(false);
|
||||
continue;
|
||||
}
|
||||
CViewTextMenu *pGroupMoveSubMenu = dynamic_cast<CViewTextMenu*>(pMenu->getView(prefix + "_move"));
|
||||
CViewTextMenu *pGroupMoveToBag = dynamic_cast<CViewTextMenu*>(pMenu->getView(prefix + "_bag"));
|
||||
CViewTextMenu *pGroupMoveToGuild = dynamic_cast<CViewTextMenu*>(pMenu->getView(prefix + "_guild"));
|
||||
CViewTextMenu *pGroupMoveToRoom = dynamic_cast<CViewTextMenu*>(pMenu->getView(prefix + "_room"));
|
||||
for(int j=0; j< MAX_INVENTORY_ANIMAL;j++)
|
||||
{
|
||||
CViewTextMenu *pGroupMoveToPa = dynamic_cast<CViewTextMenu*>(pMenu->getView(prefix + toString("_pa%d", j)));
|
||||
if(pGroupMoveToPa && pMoveToPa[j]) pGroupMoveToPa->setActive(pMoveToPa[j]->getActive());
|
||||
if(pGroupMoveToPa && pMoveToPa[j]) pGroupMoveToPa->setGrayed(pMoveToPa[j]->getGrayed());
|
||||
if(pGroupMoveToPa && pMoveToPa[j]) pGroupMoveToPa->setName(pMoveToPa[j]->getName());
|
||||
}
|
||||
if(pGroupName) pGroupName->setHardText(groupNames[i]);
|
||||
if(pMoveSubMenu && pGroupMoveSubMenu) pGroupMoveSubMenu->setActive(pMoveSubMenu->getActive());
|
||||
if(pMoveToBag && pGroupMoveToBag) pGroupMoveToBag->setActive(pMoveToBag->getActive());
|
||||
if(pMoveToGuild && pGroupMoveToGuild) pGroupMoveToGuild->setActive(pMoveToGuild->getActive());
|
||||
if(pMoveToRoom && pGroupMoveToRoom) pGroupMoveToRoom->setActive(pMoveToRoom->getActive());
|
||||
if(pMoveSubMenu && pGroupMoveSubMenu) pGroupMoveSubMenu->setGrayed(pMoveSubMenu->getGrayed());
|
||||
if(pMoveToBag && pGroupMoveToBag) pGroupMoveToBag->setGrayed(pMoveToBag->getGrayed());
|
||||
if(pMoveToGuild && pGroupMoveToGuild) pGroupMoveToGuild->setGrayed(pMoveToGuild->getGrayed());
|
||||
if(pMoveToRoom && pGroupMoveToRoom) pGroupMoveToRoom->setGrayed(pMoveToRoom->getGrayed());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER( CHandlerItemMenuCheck, "item_menu_check" );
|
||||
|
@ -2306,13 +2307,21 @@ class CHandlerItemGroupMove : public IActionHandler
|
|||
nlinfo("Wrong cast");
|
||||
return;
|
||||
}
|
||||
std::string groupName = CItemGroupManager::getInstance()->getGroupName(pCS);
|
||||
if(groupName.empty())
|
||||
uint32 groupIndex;
|
||||
fromString(getParam(sParams, "groupIndex"), groupIndex);
|
||||
std::string destination = getParam(sParams, "destination");
|
||||
std::vector<std::string> possibleGroups = CItemGroupManager::getInstance()->getGroupNames(pCS);
|
||||
if(possibleGroups.empty())
|
||||
{
|
||||
nlinfo("Trying to move a group with a caller not part of any group");
|
||||
return;
|
||||
}
|
||||
CItemGroupManager::getInstance()->moveGroup(groupName, INVENTORIES::toInventory(sParams));
|
||||
if(possibleGroups.size() <= groupIndex)
|
||||
{
|
||||
nlwarning("groupIndex > possiblesGroups, shouldn't happen");
|
||||
return;
|
||||
}
|
||||
CItemGroupManager::getInstance()->moveGroup(possibleGroups[groupIndex], INVENTORIES::toInventory(destination));
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER(CHandlerItemGroupMove, "item_group_move");
|
||||
|
@ -2321,7 +2330,7 @@ REGISTER_ACTION_HANDLER(CHandlerItemGroupMove, "item_group_move");
|
|||
// ***************************************************************************
|
||||
class CHandlerItemGroupEquip : public IActionHandler
|
||||
{
|
||||
void execute (CCtrlBase *caller, const std::string &/* sParams */)
|
||||
void execute (CCtrlBase *caller, const std::string & sParams)
|
||||
{
|
||||
CDBCtrlSheet* pCS = dynamic_cast<CDBCtrlSheet*>(caller);
|
||||
if(!pCS)
|
||||
|
@ -2329,13 +2338,20 @@ class CHandlerItemGroupEquip : public IActionHandler
|
|||
nlinfo("Wrong cast");
|
||||
return;
|
||||
}
|
||||
std::string groupName = CItemGroupManager::getInstance()->getGroupName(pCS);
|
||||
if(groupName.empty())
|
||||
uint32 groupIndex;
|
||||
fromString(getParam(sParams, "groupIndex"), groupIndex);
|
||||
std::vector<std::string> possibleGroups = CItemGroupManager::getInstance()->getGroupNames(pCS);
|
||||
if(possibleGroups.empty())
|
||||
{
|
||||
nlinfo("Trying to move a group with a caller not part of any group");
|
||||
return;
|
||||
}
|
||||
CItemGroupManager::getInstance()->equipGroup(groupName);
|
||||
if(possibleGroups.size() <= groupIndex)
|
||||
{
|
||||
nlwarning("groupIndex > possiblesGroups, shouldn't happen");
|
||||
return;
|
||||
}
|
||||
CItemGroupManager::getInstance()->equipGroup(possibleGroups[groupIndex]);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER(CHandlerItemGroupEquip, "item_group_equip");
|
||||
|
|
|
@ -413,16 +413,17 @@ void CItemGroupManager::listGroup()
|
|||
|
||||
//Used by AH
|
||||
|
||||
std::string CItemGroupManager::getGroupName(CDBCtrlSheet* pCS)
|
||||
std::vector<std::string> CItemGroupManager::getGroupNames(CDBCtrlSheet* pCS)
|
||||
{
|
||||
std::vector<std::string> out;
|
||||
for(int i=0;i<_Groups.size();i++)
|
||||
{
|
||||
CItemGroup group = _Groups[i];
|
||||
if(group.contains(pCS))
|
||||
return group.name;
|
||||
out.push_back(group.name);
|
||||
|
||||
}
|
||||
return "";
|
||||
return out;
|
||||
}
|
||||
|
||||
//Private methods
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "interface_v3/dbctrl_sheet.h"
|
||||
#include "game_share/inventories.h"
|
||||
|
||||
#define MAX_DIFFERENT_ITEM_GROUPS 5 //How many differents item grousp can a single item be part of
|
||||
// If you change this, remember to modify widgets.xml accordingly
|
||||
struct CInventoryItem {
|
||||
public:
|
||||
CDBCtrlSheet* pCS;
|
||||
|
@ -84,7 +86,7 @@ public:
|
|||
bool createGroup(std::string name);
|
||||
bool deleteGroup(std::string name);
|
||||
void listGroup();
|
||||
std::string getGroupName(CDBCtrlSheet *pCS);
|
||||
std::vector<std::string> getGroupNames(CDBCtrlSheet *pCS);
|
||||
|
||||
private:
|
||||
CItemGroup* findGroup(std::string name);
|
||||
|
|
Loading…
Reference in a new issue