From 3e9f042981a5ef65b3834a4c5468c7bbe2094b5b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 23 Sep 2011 00:14:51 +0200 Subject: [PATCH] Fixed: #1364 Only transfer bonus item infos when context help string is used for tooltip --- .../ryzom/client/src/interface_v3/ctrl_base.h | 2 + .../client/src/interface_v3/dbctrl_sheet.cpp | 65 +++++++++++-------- .../client/src/interface_v3/dbctrl_sheet.h | 3 + .../src/interface_v3/interface_manager.cpp | 2 +- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.h b/code/ryzom/client/src/interface_v3/ctrl_base.h index 0033dce6b..bf0f5f10c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.h +++ b/code/ryzom/client/src/interface_v3/ctrl_base.h @@ -68,6 +68,8 @@ public: /// Get the ContextHelp for this control. Default is to return _ContextHelp virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;} + /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. + virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); } // Get the name of the context help window. Default to "context_help" virtual std::string getContextHelpWindowName() const; /// Get the ContextHelp ActionHandler. If "", noop diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 42f438202..ce551a0b7 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -2975,32 +2975,9 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } else if(getType() == CCtrlSheetInfo::SheetType_Item) { - const CItemSheet *item= asItemSheet(); - if(item) - { - if (item->Family == ITEMFAMILY::CRYSTALLIZED_SPELL || item->Family == ITEMFAMILY::JEWELRY || item->Family == ITEMFAMILY::ARMOR) - { - string luaMethodName = ( (item->Family == ITEMFAMILY::CRYSTALLIZED_SPELL) ? "updateCrystallizedSpellTooltip" : "updateBuffItemTooltip"); - CDBCtrlSheet *ctrlSheet = const_cast(this); - if ( ! getInventory().isItemInfoUpToDate(getInventory().getItemSlotId(ctrlSheet))) - { - // Prepare the waiter - ControlSheetTooltipUpdater.ItemSheet= ctrlSheet->getSheetId(); - ControlSheetTooltipUpdater.LuaMethodName = luaMethodName; - ControlSheetTooltipUpdater.ItemSlotId= getInventory().getItemSlotId(ctrlSheet); - ControlSheetTooltipUpdater.CtrlSheet = ctrlSheet; - - // Add the waiter - getInventory().addItemInfoWaiter(&ControlSheetTooltipUpdater); - } - - help = ControlSheetTooltipUpdater.infoValidated(ctrlSheet, luaMethodName); - - } - else - help= getItemActualName(); - - } + const CItemSheet *item = asItemSheet(); + if (item) + help = getItemActualName(); else help= _ContextHelp; } @@ -3106,6 +3083,42 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } } +// *************************************************************************** +void CDBCtrlSheet::getContextHelpToolTip(ucstring &help) const +{ + // Special case for buff items and spell crystals, only for tooltips + if (getType() == CCtrlSheetInfo::SheetType_Item) + { + const CItemSheet *item = asItemSheet(); + if (item) + { + if (item->Family == ITEMFAMILY::CRYSTALLIZED_SPELL + || item->Family == ITEMFAMILY::JEWELRY || item->Family == ITEMFAMILY::ARMOR) + { + string luaMethodName = (item->Family == ITEMFAMILY::CRYSTALLIZED_SPELL) ? "updateCrystallizedSpellTooltip" : "updateBuffItemTooltip"; + CDBCtrlSheet *ctrlSheet = const_cast(this); + if ( ! getInventory().isItemInfoUpToDate(getInventory().getItemSlotId(ctrlSheet))) + { + // Prepare the waiter + ControlSheetTooltipUpdater.ItemSheet= ctrlSheet->getSheetId(); + ControlSheetTooltipUpdater.LuaMethodName = luaMethodName; + ControlSheetTooltipUpdater.ItemSlotId= getInventory().getItemSlotId(ctrlSheet); + ControlSheetTooltipUpdater.CtrlSheet = ctrlSheet; + + // Add the waiter + getInventory().addItemInfoWaiter(&ControlSheetTooltipUpdater); + } + + help = ControlSheetTooltipUpdater.infoValidated(ctrlSheet, luaMethodName); + return; + } + } + } + + // Default + getContextHelp(help); +} + // *************************************************************************** bool CDBCtrlSheet::canDropItem(CDBCtrlSheet *src) const { diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 5f4425419..2cf34e722 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -355,6 +355,9 @@ public: /// Special ContextHelp for ctrl sheet. virtual void getContextHelp(ucstring &help) const; + /// Special ContextHelp for ctrl sheet. + virtual void getContextHelpToolTip(ucstring &help) const; + /** true if an item of another ctrlSheet can be dropped on this slot. * also return true if src is 0, or if _ItemSlot==UNDEFINED */ diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 9762193d9..180a25763 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2372,7 +2372,7 @@ void CInterfaceManager::drawContextHelp () if(newCtrl) { // get the text - newCtrl->getContextHelp(_ContextHelpText); + newCtrl->getContextHelpToolTip(_ContextHelpText); // UserDefined context help if( !newCtrl->getContextHelpActionHandler().empty() ) {