|
|
|
@ -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");
|
|
|
|
|