Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
Inky 6 years ago
commit 4f14b5667e

@ -137,9 +137,6 @@ namespace NLGUI
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void setActionHandler(uint lineIndex, const std::string &ah = "");
void setActionHandlerParam(uint lineIndex, const std::string &params = "");
void openSubMenu (sint32 nb);
void hideSubMenus ();
@ -333,8 +330,6 @@ namespace NLGUI
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void setActionHandler(uint lineIndex, const std::string &ah = "");
void setActionHandlerParam(uint lineIndex, const std::string &params = "");
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),

@ -1663,28 +1663,6 @@ namespace NLGUI
return _Lines[lineIndex].AHParams;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setActionHandler(uint lineIndex, const std::string &ah)
{
if (lineIndex > _Lines.size())
{
nlwarning("Bad index");
return;
}
_Lines[lineIndex].AHName = ah;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setActionHandlerParam(uint lineIndex, const std::string &params)
{
if (lineIndex > _Lines.size())
{
nlwarning("Bad index");
return;
}
_Lines[lineIndex].AHParams = params;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setSelectable(uint lineIndex, bool selectable)
{
@ -2618,20 +2596,6 @@ namespace NLGUI
return _RootMenu ? _RootMenu->getActionHandlerParam(lineIndex) : "";
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setActionHandler(uint lineIndex, const std::string &ah)
{
if (_RootMenu)
_RootMenu->setActionHandler(lineIndex, ah);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setActionHandlerParam(uint lineIndex, const std::string &params)
{
if (_RootMenu)
_RootMenu->setActionHandlerParam(lineIndex, params);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/)
{

@ -427,11 +427,6 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item)
if (!val.empty())
CraftPlan = CSheetId(val);
// commands and menu label
TRANSLATE_VAL( Scroll.LuaCommand, "basics.Scroll.LuaCommand" );
TRANSLATE_VAL( Scroll.WebCommand, "basics.Scroll.WebCommand" );
TRANSLATE_VAL( Scroll.Label, "basics.Scroll.Label" );
// Special according to Family;
switch(Family)
{
@ -731,9 +726,6 @@ void CItemSheet::serial(NLMISC::IStream &f)
// **** Serial Help Infos
f.serialEnum(ItemOrigin);
// item commands
f.serial(Scroll);
// Different Serial according to family
switch(Family)
{
@ -773,9 +765,8 @@ void CItemSheet::serial(NLMISC::IStream &f)
case ITEMFAMILY::TELEPORT:
f.serial(Teleport);
break;
// keep for readability
case ITEMFAMILY::SCROLL:
//f.serial(Scroll);
f.serial(Scroll);
break;
case ITEMFAMILY::CONSUMABLE:
f.serial(Consumable);

@ -255,16 +255,10 @@ public:
struct CScroll
{
std::string Texture;
std::string LuaCommand;
std::string WebCommand;
std::string Label;
void serial(NLMISC::IStream &f)
{
f.serial(Texture);
f.serial(LuaCommand);
f.serial(WebCommand);
f.serial(Label);
}
};

@ -442,7 +442,7 @@ static TStackMode CurrentStackMode;
static void validateStackItem(CDBCtrlSheet *src, CDBCtrlSheet *dest, sint32 quantity, TStackMode stackMode);
static void checkItemCommand(const CItemSheet *itemSheet);
//=====================================================================================================================
/** Send a swap item msg to the server
@ -1684,10 +1684,6 @@ class CHandlerItemCristalReload : public IActionHandler
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getCtrlLaunchingModal());
if (pCS == NULL) return;
const CItemSheet *pIS = pCS->asItemSheet();
if (pIS && pIS->Scroll.Label.empty())
checkItemCommand(pIS);
sendToServerEnchantMessage((uint8)pCS->getInventoryIndex(), (uint16)pCS->getIndexInDB());
}
};
@ -1765,7 +1761,6 @@ class CHandlerItemMenuCheck : public IActionHandler
CViewTextMenu *pCrisReload = dynamic_cast<CViewTextMenu*>(pMenu->getView("cris_reload"));
CViewTextMenu *pTeleportUse = dynamic_cast<CViewTextMenu*>(pMenu->getView("teleport_use"));
CViewTextMenu *pItemConsume = dynamic_cast<CViewTextMenu*>(pMenu->getView("item_consume"));
CViewTextMenu *pItemExecute = dynamic_cast<CViewTextMenu*>(pMenu->getView("item_execute"));
CViewTextMenu *pXpCatalyserUse = dynamic_cast<CViewTextMenu*>(pMenu->getView("xp_catalyser_use"));
CViewTextMenu *pDrop = dynamic_cast<CViewTextMenu*>(pMenu->getView("drop"));
CViewTextMenu *pDestroy = dynamic_cast<CViewTextMenu*>(pMenu->getView("destroy"));
@ -1793,7 +1788,6 @@ class CHandlerItemMenuCheck : public IActionHandler
if(pCrisReload) pCrisReload->setActive(false);
if(pTeleportUse) pTeleportUse->setActive(false);
if(pItemConsume) pItemConsume->setActive(false);
if(pItemExecute) pItemExecute->setActive(false);
if(pXpCatalyserUse) pXpCatalyserUse->setActive(false);
if(pItemTextDisplay) pItemTextDisplay->setActive(false);
if(pItemTextEdition) pItemTextEdition->setActive(false);
@ -1868,61 +1862,6 @@ class CHandlerItemMenuCheck : public IActionHandler
{
pItemInfos->setActive(true);
}
// item has a label?
if (!pIS->Scroll.Label.empty())
{
CGroupMenu *menu = dynamic_cast<CGroupMenu *>(
CWidgetManager::getInstance()->getElementFromId("ui:interface:item_menu_in_bag")
);
// add the label to default menu
if (!pIS->Scroll.LuaCommand.empty() || !pIS->Scroll.WebCommand.empty())
menu->setActionHandler(4, menu->getActionHandler(4));
else
{
// replace default menu and redirect action handler
if (pCrisEnchant && pCrisEnchant->getActive())
{
pCrisEnchant->setActive(false);
menu->setActionHandler(4, menu->getActionHandler(0));
}
if (pCrisReload && pCrisReload->getActive())
{
pCrisReload->setActive(false);
menu->setActionHandler(4, menu->getActionHandler(1));
}
if (pTeleportUse && pTeleportUse->getActive())
{
pTeleportUse->setActive(false);
menu->setActionHandler(4, menu->getActionHandler(2));
}
if (pItemConsume && pItemConsume->getActive())
{
pItemConsume->setActive(false);
menu->setActionHandler(4, menu->getActionHandler(3));
}
if (pXpCatalyserUse && pXpCatalyserUse->getActive())
{
pXpCatalyserUse->setActive(false);
menu->setActionHandler(4, menu->getActionHandler(5));
}
if (pItemTextDisplay && pItemTextDisplay->getActive())
{
pItemTextDisplay->setActive(false);
menu->setActionHandler(4, menu->getActionHandler(6));
menu->setActionHandlerParam(4, menu->getActionHandlerParam(6));
}
}
if (!bIsLockedByOwner)
{
if (pCS->getInventoryIndex() == INVENTORIES::bag)
pItemExecute->setActive(true);
// enchant and reload can be used from anywhere
if (pIS->Family == ITEMFAMILY::CRYSTALLIZED_SPELL || pIS->Family == ITEMFAMILY::ITEM_SAP_RECHARGE)
pItemExecute->setActive(true);
pItemExecute->setText(CI18N::get(pIS->Scroll.Label));
}
}
}
CInventoryManager &invMngr= getInventory();
@ -2053,7 +1992,6 @@ class CHandlerItemMenuCheck : public IActionHandler
if(pCrisReload) pCrisReload->setGrayed(true);
if(pTeleportUse) pTeleportUse->setGrayed(true);
if(pItemConsume) pItemConsume->setGrayed(true);
if(pItemExecute) pItemExecute->setGrayed(true);
if(pXpCatalyserUse) pXpCatalyserUse->setGrayed(true);
if(pDrop) pDrop->setGrayed(true);
if(pDestroy) pDestroy->setGrayed(true);
@ -2073,7 +2011,6 @@ class CHandlerItemMenuCheck : public IActionHandler
if(pCrisReload) pCrisReload->setGrayed(false);
if(pTeleportUse) pTeleportUse->setGrayed(false);
if(pItemConsume) pItemConsume->setGrayed(false);
if(pItemExecute) pItemExecute->setGrayed(false);
if(pXpCatalyserUse) pXpCatalyserUse->setGrayed(false);
if(pDrop) pDrop->setGrayed(false);
if(pDestroy) pDestroy->setGrayed(false);
@ -2254,24 +2191,6 @@ static void sendMsgStopUseXpCat( bool isRingCatalyser )
}
}
// ***************************************************************************
static void checkItemCommand(const CItemSheet *itemSheet)
{
if (itemSheet)
{
if (!itemSheet->Scroll.LuaCommand.empty())
CLuaManager::getInstance().executeLuaScript(itemSheet->Scroll.LuaCommand);
// webig
if (!itemSheet->Scroll.WebCommand.empty())
{
CGroupHTML *pGH = dynamic_cast<CGroupHTML*>(
CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")
);
if (pGH) pGH->browse(itemSheet->Scroll.WebCommand.c_str());
}
}
return;
}
// ***************************************************************************
class CHandlerTeleportUse : public IActionHandler
@ -2300,8 +2219,6 @@ class CHandlerTeleportUse : public IActionHandler
LoadingBackground = TeleportKaravanBackground;
break;
}
if (pIS->Scroll.Label.empty())
checkItemCommand(pIS);
}
}
};
@ -2316,28 +2233,12 @@ class CHandlerItemConsume : public IActionHandler
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getCtrlLaunchingModal());
if (pCS == NULL) return;
const CItemSheet *pIS = pCS->asItemSheet();
if (pIS && pIS->Scroll.Label.empty())
checkItemCommand(pIS);
// use the item
sendMsgUseItem(uint16(pCS->getIndexInDB()));
}
};
REGISTER_ACTION_HANDLER( CHandlerItemConsume, "item_consume" );
// ***************************************************************************
class CHandlerItemExecute : public IActionHandler
{
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getCtrlLaunchingModal());
if (pCS)
checkItemCommand(pCS->asItemSheet());
return;
}
};
REGISTER_ACTION_HANDLER( CHandlerItemExecute, "item_execute" );
// ***************************************************************************
class CHandlerValidateItemTextEdition : public IActionHandler
@ -2361,10 +2262,6 @@ class CHandlerItemTextDisplay : public IActionHandler
if (pCSItem == NULL || windowName.empty())
return;
const CItemSheet *pIS = pCSItem->asItemSheet();
if (pIS && pIS->Scroll.Label.empty())
checkItemCommand(pIS);
CInterfaceItemEdition::getInstance()->setCurrWindow(pCSItem, windowName, false);
}
};
@ -2406,10 +2303,6 @@ class CHandlerXpCatalyserUse : public IActionHandler
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getCtrlLaunchingModal());
if (pCS == NULL) return;
const CItemSheet *pIS = pCS->asItemSheet();
if (pIS && pIS->Scroll.Label.empty())
checkItemCommand(pIS);
// use the item
sendMsgUseItem(uint16(pCS->getIndexInDB()));
}

Loading…
Cancel
Save