Fixed: #1364 Only transfer bonus item infos when context help string is used for tooltip

This commit is contained in:
kaetemi 2011-09-23 00:14:51 +02:00
parent 9501c90654
commit 3346764013
4 changed files with 45 additions and 27 deletions

View file

@ -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

View file

@ -2977,30 +2977,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
{
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<CDBCtrlSheet*>(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();
}
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<CDBCtrlSheet*>(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
{

View file

@ -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
*/

View file

@ -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() )
{