diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 0d6142fdb0..4714cc9dc0 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -260,6 +260,117 @@ local function MatchesTriggerInfoMulti(triggerInfo, sourceGUID) end end +local function CheckScanFuncs(scanFuncs, unit, filter, key) + if scanFuncs then + for triggerInfo in pairs(scanFuncs) do + if triggerInfo.fetchTooltip then + local md = matchData[unit][filter][key] + md:UpdateTooltip(GetTime()) + end + if not triggerInfo.scanFunc or triggerInfo.scanFunc(time, matchData[unit][filter][key]) then + local id = triggerInfo.id + local triggernum = triggerInfo.triggernum + ReferenceMatchData(id, triggernum, unit, filter, key) + matchDataChanged[id] = matchDataChanged[id] or {} + matchDataChanged[id][triggernum] = true + end + end + end +end + +local TooltipHelper +if newAPI then + ---@class TooltipHelper + ---@field count number + ---@field tracks table> + TooltipHelper = { + count = 0, + frame = CreateFrame("Frame"), + tracks = { + + }, + --- @type fun(self: TooltipHelper, dataInstanceId: number, matchData: table) + Track = function(self, dataInstanceID, matchData) + self.tracks[dataInstanceID] = self.tracks[dataInstanceID] or {} + if not self.tracks[dataInstanceID][matchData] then + self.count = self.count + 1 + self.tracks[dataInstanceID][matchData] = true + if self.count == 1 then + self.frame:RegisterEvent("TOOLTIP_DATA_UPDATE") + end + end + end, + --- @type fun(self: TooltipHelper, dataInstanceId: number, matchData: table) + Untrack = function(self, dataInstanceID, matchData) + if self.tracks[dataInstanceID] then + if self.tracks[dataInstanceID][matchData] then + self.count = self.count - 1 + self.tracks[dataInstanceID][matchData] = nil + if not next(self.tracks[dataInstanceID]) then + self.tracks[dataInstanceID] = nil + end + if self.count == 0 then + self.frame:UnregisterEvent("TOOLTIP_DATA_UPDATE") + end + end + end + end, + --- @type fun(self: TooltipHelper) + Clear = function(self) + self.tracks = {} + self.frame:UnregisterEvent("TOOLTIP_DATA_UPDATE") + self.count = 0 + end, + + --- @type fun(self: TooltipHelper, matchData: table) + HandleMatchData = function(self, matchData) + if matchData:UpdateTooltip(GetTime()) then + local unit = matchData.unit + local key = matchData.auraInstanceID + local filter = matchData.filter + for id, triggerData in pairs(matchData.auras) do + for triggernum in pairs(triggerData) do + local matchDataByTriggerAndUnit = GetSubTable(matchDataByTrigger, id, triggernum, unit) + if matchDataByTriggerAndUnit and matchDataByTriggerAndUnit[key] then + matchDataByTriggerAndUnit[key] = nil + matchDataChanged[id] = matchDataChanged[id] or {} + matchDataChanged[id][triggernum] = true + end + end + end + wipe(matchData.auras) + + local sfn = GetSubTable(scanFuncName, unit, filter, matchData.name) + local sfng = GetSubTable(scanFuncNameGroup, unit, filter, matchData.name) + local sfs = GetSubTable(scanFuncSpellId, unit, filter, matchData.spellId) + local sfsg = GetSubTable(scanFuncSpellIdGroup, unit, filter, matchData.spellId) + local sfg = GetSubTable(scanFuncGeneral, unit, filter) + local sfgg = GetSubTable(scanFuncGeneralGroup, unit, filter) + + CheckScanFuncs(sfn, unit, filter, key) + CheckScanFuncs(sfng, unit, filter, key) + CheckScanFuncs(sfs, unit, filter, key) + CheckScanFuncs(sfsg, unit, filter, key) + CheckScanFuncs(sfg, unit, filter, key) + CheckScanFuncs(sfgg, unit, filter, key) + end + end, + + --- @type fun(self: TooltipHelper, dataInstanceID: number) + HandleEvent = function(self, dataInstanceID) + if self.tracks[dataInstanceID] then + for callbackData in pairs(self.tracks[dataInstanceID]) do + self:HandleMatchData(callbackData) + end + end + end + } + + TooltipHelper.frame:SetScript("OnEvent", function(frame, event, dataInstanceID) + TooltipHelper:HandleEvent(dataInstanceID) + end) +end + local function UpdateToolTipDataInMatchData(matchData, time) if matchData.tooltipUpdated == time then return @@ -267,10 +378,21 @@ local function UpdateToolTipDataInMatchData(matchData, time) local changed = false if matchData.unit and matchData.auraInstanceID then - local tooltip, _, tooltip1, tooltip2, tooltip3, tooltip4 = WeakAuras.GetAuraInstanceTooltipInfo(matchData.unit, matchData.auraInstanceID, matchData.filter) + local dataInstanceID, tooltip, _, tooltip1, tooltip2, tooltip3, tooltip4 = WeakAuras.GetAuraInstanceTooltipInfo(matchData.unit, matchData.auraInstanceID, matchData.filter) changed = matchData.tooltip ~= tooltip or matchData.tooltip1 ~= tooltip1 or matchData.tooltip2 ~= tooltip2 or matchData.tooltip3 ~= tooltip3 or matchData.tooltip4 ~= tooltip4 matchData.tooltip, matchData.tooltip1, matchData.tooltip2, matchData.tooltip3, matchData.tooltip4 = tooltip, tooltip1, tooltip2, tooltip3, tooltip4 + + local oldDataInstanceId = matchData.dataInstanceID + matchData.dataInstanceID = dataInstanceID + if dataInstanceID ~= oldDataInstanceId then + if dataInstanceID then + TooltipHelper:Track(dataInstanceID, matchData) + end + if oldDataInstanceId then + TooltipHelper:Untrack(oldDataInstanceId, matchData) + end + end elseif matchData.unit and matchData.index and matchData.filter then local tooltip, _, tooltip1, tooltip2, tooltip3, tooltip4 = WeakAuras.GetAuraTooltipInfo(matchData.unit, matchData.index, matchData.filter) changed = matchData.tooltip ~= tooltip or matchData.tooltip1 ~= tooltip1 @@ -1640,6 +1762,9 @@ local function CleanUpOutdatedMatchData(removeIndex, unit, filter) matchDataChanged[id][triggernum] = true end end + if data.dataInstanceID then + TooltipHelper:Untrack(data.dataInstanceID, data) + end matchData[unit][filter][auraInstanceID] = nil end end @@ -1679,6 +1804,9 @@ local function CleanUpMatchDataForUnit(unit, filter) end end end + if data.dataInstanceID then + TooltipHelper:Untrack(data.dataInstanceID, data) + end end end end @@ -1701,22 +1829,7 @@ local function DeactivateScanFuncs(toDeactivate) end end -local function CheckScanFuncs(scanFuncs, unit, filter, key) - if scanFuncs then - for triggerInfo in pairs(scanFuncs) do - if triggerInfo.fetchTooltip then - matchData[unit][filter][key]:UpdateTooltip(GetTime()) - end - if not triggerInfo.scanFunc or triggerInfo.scanFunc(time, matchData[unit][filter][key]) then - local id = triggerInfo.id - local triggernum = triggerInfo.triggernum - ReferenceMatchData(id, triggernum, unit, filter, key) - matchDataChanged[id] = matchDataChanged[id] or {} - matchDataChanged[id][triggernum] = true - end - end - end -end + local ScanUnitWithFilter do @@ -1795,6 +1908,9 @@ do matchDataChanged[id][triggernum] = true end end + if data.dataInstanceID then + TooltipHelper:Untrack(data.dataInstanceID, data) + end end end end @@ -2153,13 +2269,16 @@ local function EventHandler(frame, event, arg1, arg2, ...) end if arg1 then - -- Initial login has a bug where the tooltip information is not available, - -- so update tooltips 2s after login - C_Timer.After(2, function() - for unit, matchtDataPerUnit in pairs(matchData) do - EventHandler(frame, "UNIT_AURA", unit) - end - end) + -- Initial login has an where the tooltip information is not available, + -- so update tooltips 2s after login. + -- With newApi we have TOOLTIP_DATA_UPDATE to update the tooltips + if not newAPI then + C_Timer.After(3, function() + for unit, matchtDataPerUnit in pairs(matchData) do + EventHandler(frame, "UNIT_AURA", unit) + end + end) + end end elseif event == "RAID_TARGET_UPDATE" then @@ -2414,6 +2533,10 @@ function BuffTrigger.UnloadAll() PerUnitFrames:UnregisterAll() end + if newAPI then + TooltipHelper:Clear() + end + wipe(scanFuncName) wipe(scanFuncSpellId) wipe(scanFuncGeneral) diff --git a/WeakAuras/Media/Fonts/FiraSans-Black.ttf b/WeakAuras/Media/Fonts/FiraSans-Black.ttf new file mode 100644 index 0000000000..113cd3b44a Binary files /dev/null and b/WeakAuras/Media/Fonts/FiraSans-Black.ttf differ diff --git a/WeakAuras/Media/Fonts/FiraSans-Medium.ttf b/WeakAuras/Media/Fonts/FiraSans-Medium.ttf new file mode 100644 index 0000000000..001ebe7e63 Binary files /dev/null and b/WeakAuras/Media/Fonts/FiraSans-Medium.ttf differ diff --git a/WeakAuras/Media/Fonts/FiraSansCondensed-Black.ttf b/WeakAuras/Media/Fonts/FiraSansCondensed-Black.ttf new file mode 100644 index 0000000000..06e2a3e60b Binary files /dev/null and b/WeakAuras/Media/Fonts/FiraSansCondensed-Black.ttf differ diff --git a/WeakAuras/Media/Fonts/FiraSansCondensed-Medium.ttf b/WeakAuras/Media/Fonts/FiraSansCondensed-Medium.ttf new file mode 100644 index 0000000000..534c9708ab Binary files /dev/null and b/WeakAuras/Media/Fonts/FiraSansCondensed-Medium.ttf differ diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index a134d1dccb..d08c5a3dfc 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -2706,6 +2706,12 @@ end) -- register options font LSM:Register("font", "Fira Mono Medium", "Interface\\Addons\\WeakAuras\\Media\\Fonts\\FiraMono-Medium.ttf", LSM.LOCALE_BIT_western + LSM.LOCALE_BIT_ruRU) +-- Other Fira fonts +LSM:Register("font", "Fira Sans Black", "Interface\\Addons\\WeakAuras\\Media\\Fonts\\FiraSans-Black.ttf", LSM.LOCALE_BIT_western + LSM.LOCALE_BIT_ruRU) +LSM:Register("font", "Fira Sans Condensed Black", "Interface\\Addons\\WeakAuras\\Media\\Fonts\\FiraSansCondensed-Black.ttf", LSM.LOCALE_BIT_western + LSM.LOCALE_BIT_ruRU) +LSM:Register("font", "Fira Sans Condensed Medium", "Interface\\Addons\\WeakAuras\\Media\\Fonts\\FiraSansCondensed-Medium.ttf", LSM.LOCALE_BIT_western + LSM.LOCALE_BIT_ruRU) +LSM:Register("font", "Fira Sans Medium", "Interface\\Addons\\WeakAuras\\Media\\Fonts\\FiraSans-Medium.ttf", LSM.LOCALE_BIT_western + LSM.LOCALE_BIT_ruRU) + -- register plain white border LSM:Register("border", "Square Full White", [[Interface\AddOns\WeakAuras\Media\Textures\Square_FullWhite.tga]]) diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index c2cf9feef5..ef1569d51a 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -3921,11 +3921,14 @@ function WeakAuras.GetAuraInstanceTooltipInfo(unit, auraInstanceId, filter) else tooltipData = C_TooltipInfo.GetUnitDebuffByAuraInstanceID(unit, auraInstanceId, filter) end - local secondLine = tooltipData and tooltipData.lines[2] -- This is the line we want + if not tooltipData then + return nil, "", "none", 0 + end + local secondLine = tooltipData.lines[2] -- This is the line we want if secondLine and secondLine.leftText then tooltipText = secondLine.leftText end - return Private.ParseTooltipText(tooltipText) + return tooltipData.dataInstanceID, Private.ParseTooltipText(tooltipText) end end