From 9ece55c266e20e35468717821fa0e83f622c32d3 Mon Sep 17 00:00:00 2001 From: dvipid Date: Thu, 10 Jan 2019 22:38:48 -0500 Subject: [PATCH] Fixes tooltip for mount macro buttons. --- ButtonForge/Button.lua | 21 ++++++++++----------- ButtonForge/Util.lua | 15 ++++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ButtonForge/Button.lua b/ButtonForge/Button.lua index 89dd67f..9de1a4e 100644 --- a/ButtonForge/Button.lua +++ b/ButtonForge/Button.lua @@ -1268,19 +1268,15 @@ function Button:TranslateMacro() self.MacroTargetDead = TargetDead; local SpellName, SpellRank, SpellId = GetMacroSpell(self.MacroIndex); if (SpellName) then - --[[local CompanionType, CompanionIndex = Util.LookupCompanion(SpellName); + local CompanionType, CompanionID = Util.LookupCompanion(SpellName); if (CompanionType) then self.CompanionType = CompanionType; - self.CompanionIndex = CompanionIndex; - local SpellId = select(3, GetCompanionInfo(CompanionType, CompanionIndex)); - self.CompanionSpellName = GetSpellInfo(SpellId); - self.MacroMode = "companion"; - else]] - self.SpellName = SpellName; - self.SpellNameRank = GetSpellInfo(SpellName); --BFA fix: Cache is indexed by name and the old function returned the ID - self.SpellId = SpellId; - self.MacroMode = "spell"; - --end + self.CompanionIndex = CompanionID; + end + self.SpellName = SpellName; + self.SpellNameRank = GetSpellInfo(SpellName); --BFA fix: Cache is indexed by name and the old function returned the ID + self.SpellId = SpellId; + self.MacroMode = "spell"; else local ItemName, ItemLink = GetMacroItem(self.MacroIndex); if (ItemName) then @@ -1730,6 +1726,9 @@ function Button:UpdateTooltipMacro() local Index, BookType = Util.LookupSpellIndex(self.SpellNameRank); if (Index) then GameTooltip:SetSpellBookItem(Index, BookType); + elseif (self.CompanionType == "MOUNT") then + GameTooltip_SetDefaultAnchor(GameTooltip, self.Widget); --It appears that the sethyperlink (specifically this one) requires that the anchor be constantly refreshed!? + GameTooltip:SetHyperlink("spell:"..self.SpellName); end elseif (self.MacroMode == "item") then local EquippedSlot = Util.LookupItemNameEquippedSlot(self.ItemId); diff --git a/ButtonForge/Util.lua b/ButtonForge/Util.lua index c81f0f8..2e094cb 100644 --- a/ButtonForge/Util.lua +++ b/ButtonForge/Util.lua @@ -1875,7 +1875,8 @@ end Companion Functions -------------------------------------------]] function Util.CacheCompanions() - --[[Util.Critters = {}; + Util.Critters = {}; + --[[ for i = 1, GetNumCompanions("CRITTER") do local Id, Name = GetCompanionInfo("CRITTER", i); if (not Name) then @@ -1884,14 +1885,14 @@ function Util.CacheCompanions() Util.Critters[Name] = i; end]] - --[[Util.Mounts = {}; - for i = 1, C_MountJournal.GetNumMounts() do - local Name, Id = C_MountJournal.GetDisplayedMountInfo(i); - if (not Name) then + Util.Mounts = {}; + for i, mountID in pairs(C_MountJournal.GetMountIDs()) do + local creatureName, spellID = C_MountJournal.GetMountInfoByID(mountID); + if (not creatureName) then return; end - Util.Mounts[Name] = i; - end]] + Util.Mounts[spellID] = mountID; + end Util.CompanionsCached = true; end