From 632f8133a287df6a7faa7233ea1169c4e3f60094 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 29 Oct 2020 10:50:39 +0800 Subject: [PATCH] Fix merge --- nel/src/gui/view_text.cpp | 5 +- .../src/interface_v3/action_handler_item.cpp | 165 +++++++++++++++--- 2 files changed, 146 insertions(+), 24 deletions(-) diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index d8552f153..4f0b71c60 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -1022,7 +1022,10 @@ namespace NLGUI if (_MultiLine) { - setTextFormatTaged(CI18N::get(propPtr)); + if (NLMISC::startsWith(propPtr, "u:")) + setTextFormatTaged(std::string(propPtr).substr(2)); + else + setTextFormatTaged(CI18N::get(propPtr)); } else { diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 23992f4f6..d108e6a21 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -156,27 +156,35 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() // Select all the text for easier selection editBoxShort->setSelectionAll(); } + group->setActive(true); } else { + ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)).toUtf8()); + display->setTextFormatTaged(localDesc.toUtf8()); else { ucstring text = itemInfo.CustomText; - string::size_type delimiter = text.find(' '); - if(text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') + if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(ucstring(text.substr(4, delimiter-4)).toString().c_str()); - if (delimiter == string::npos) - group->setActive(false); - else - text = text.substr(delimiter, text.size()-delimiter); + pGH->browse(text.substr(4, text.size()-4).toString().c_str()); + text = localDesc; + } + else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') + { + string code = text.substr(4, text.size()-4).toString(); + if (!code.empty()) + CLuaManager::getInstance().executeLuaScript(code); + text = localDesc; + } + if (!text.empty()) + { + display->setTextFormatTaged(text.toUtf8()); + group->setActive(true); } - - display->setTextFormatTaged(text.toUtf8()); } } } @@ -287,33 +295,37 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() display->setActive(true); editButtons->setActive(false); closeButton->setActive(true); - group->setActive(true); + group->setActive(false); editBoxShort->setInputString(std::string()); editBoxLarge->setInputString(std::string()); - display->setTextFormatTaged(std::string()); + display->setTextFormatTaged(ucstring()); // Finish the display or add the waiter if (getInventory().isItemInfoUpToDate(ItemSlotId)) { - // If we already have item info + ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)).toUtf8()); + display->setTextFormatTaged(localDesc.toUtf8()); else { ucstring text = itemInfo.CustomText; - string::size_type delimiter = text.find(' '); - if(text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') + if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(ucstring(text.substr(4, delimiter-4)).toString().c_str()); - if (delimiter == string::npos) - group->setActive(false); - else - text = text.substr(delimiter, text.size()-delimiter); + pGH->browse(text.substr(4, text.size()-4).toUtf8().c_str()); + text = localDesc; } - display->setTextFormatTaged(text.toUtf8()); + else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') + { + string code = text.substr(4, text.size()-4).toUtf8(); + if (!code.empty()) + CLuaManager::getInstance().executeLuaScript(code); + text = localDesc; + } + if (!text.empty()) + display->setTextFormatTaged(text.toUtf8()); } } else @@ -434,7 +446,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 @@ -1676,6 +1688,10 @@ class CHandlerItemCristalReload : public IActionHandler CDBCtrlSheet *pCS = dynamic_cast(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()); } }; @@ -1753,6 +1769,7 @@ class CHandlerItemMenuCheck : public IActionHandler CViewTextMenu *pCrisReload = dynamic_cast(pMenu->getView("cris_reload")); CViewTextMenu *pTeleportUse = dynamic_cast(pMenu->getView("teleport_use")); CViewTextMenu *pItemConsume = dynamic_cast(pMenu->getView("item_consume")); + CViewTextMenu *pItemExecute = dynamic_cast(pMenu->getView("item_execute")); CViewTextMenu *pXpCatalyserUse = dynamic_cast(pMenu->getView("xp_catalyser_use")); CViewTextMenu *pDrop = dynamic_cast(pMenu->getView("drop")); CViewTextMenu *pDestroy = dynamic_cast(pMenu->getView("destroy")); @@ -1780,6 +1797,7 @@ 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); @@ -1854,6 +1872,61 @@ class CHandlerItemMenuCheck : public IActionHandler { pItemInfos->setActive(true); } + // item has a label? + if (!pIS->Scroll.Label.empty()) + { + CGroupMenu *menu = dynamic_cast( + 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(); @@ -1984,6 +2057,7 @@ 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); @@ -2003,6 +2077,7 @@ 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); @@ -2181,6 +2256,24 @@ 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( + CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html") + ); + if (pGH) pGH->browse(itemSheet->Scroll.WebCommand.c_str()); + } + } + return; +} // *************************************************************************** class CHandlerTeleportUse : public IActionHandler @@ -2209,6 +2302,8 @@ class CHandlerTeleportUse : public IActionHandler LoadingBackground = TeleportKaravanBackground; break; } + if (pIS->Scroll.Label.empty()) + checkItemCommand(pIS); } } }; @@ -2223,12 +2318,28 @@ class CHandlerItemConsume : public IActionHandler CDBCtrlSheet *pCS = dynamic_cast(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(CWidgetManager::getInstance()->getCtrlLaunchingModal()); + if (pCS) + checkItemCommand(pCS->asItemSheet()); + return; + } +}; +REGISTER_ACTION_HANDLER( CHandlerItemExecute, "item_execute" ); // *************************************************************************** class CHandlerValidateItemTextEdition : public IActionHandler @@ -2252,6 +2363,10 @@ 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); } }; @@ -2293,6 +2408,10 @@ class CHandlerXpCatalyserUse : public IActionHandler CDBCtrlSheet *pCS = dynamic_cast(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())); }