From: Aleksi Blinnikka Date: Tue, 21 Apr 2020 12:58:28 +0000 (+0300) Subject: Add incoming ability glow and fix periodic aura update X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/9fb47ba879ec613725953c2044ce7e6419af2e3f Add incoming ability glow and fix periodic aura update --- diff --git a/kehys/frame.lua b/kehys/frame.lua index 1719b94..0e17ed7 100644 --- a/kehys/frame.lua +++ b/kehys/frame.lua @@ -55,6 +55,8 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes, f.tankcd = {}; -- tank CD auras f.stacks = {}; -- stacking aura tracking f.buff1 = {}; -- custom buff indicator 1 + f.incoming = {}; -- incoming ability indicator + f.rounds = 0; -- set up periodic updates updaters[f] = function() if f.updating then @@ -93,7 +95,11 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes, f.base:SetAllPoints(); f.base:SetColorTexture(1, 1, 1); f.base:SetVertexColor(unpack(addon.Colors.Base)); - f.background = f:CreateTexture(nil, "BACKGROUND", nil, 1); + f.glow = f:CreateTexture(nil, "BACKGROUND", nil, 1); + f.glow:SetAllPoints(); + f.glow:SetColorTexture(1, 1, 1); + f.glow:SetVertexColor(unpack(addon.Colors.Glow)); + f.background = f:CreateTexture(nil, "BACKGROUND", nil, 2); f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1); f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1); f.background:SetColorTexture(0.7, 0.7, 0.7); diff --git a/kehys/incoming.lua b/kehys/incoming.lua new file mode 100644 index 0000000..0e3f150 --- /dev/null +++ b/kehys/incoming.lua @@ -0,0 +1,52 @@ +-- incoming.lua +-- 2020 Aleksi Blinnikka +local _; +local UnitGUID, UnitIsEnemy = UnitGUID, UnitIsEnemy; + +local _, addon = ...; +local guids = addon.FrameGuids; +local abilities = { + [260741] = true, -- Jagged Nettles (Waycrest Manor) +}; + +local frame = CreateFrame("Frame", "kehysIncoming"); + +local function event(_, event, target, cast, id) + if event == "PLAYER_REGEN_ENABLED" then + for _, f in pairs(guids) do + f.incoming = {}; + end + return + end + if abilities[id] and UnitIsEnemy("player", target) then + local f = guids[UnitGUID(target .. "target")]; + if f then + if event == "UNIT_SPELLCAST_START" then + if f.incoming[id] then + f.incoming[id] = f.incoming[id] + 1; + else + f.incoming[id] = 1; + end + elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_CHANNEL_START" then + if f.incoming[id] then + f.incoming[id] = f.incoming[id] - 1; + if f.incoming[id] == 0 then + f.incoming[id] = nil; + end + end + end + end + end +end + +local function setup() + frame:UnregisterAllEvents(); + frame:SetScript("OnEvent", event); + frame:RegisterEvent("UNIT_SPELLCAST_START"); + frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START"); + frame:RegisterEvent("UNIT_SPELLCAST_STOP"); + frame:RegisterEvent("PLAYER_REGEN_ENABLED"); +end + +frame:SetScript("OnEvent", setup); +frame:RegisterEvent("PLAYER_LOGIN"); diff --git a/kehys/kehys.toc b/kehys/kehys.toc index 035d226..9d935fe 100644 --- a/kehys/kehys.toc +++ b/kehys/kehys.toc @@ -14,3 +14,4 @@ events.lua frame.lua raid.lua auras.lua +incoming.lua diff --git a/kehys/setup.lua b/kehys/setup.lua index 70ed926..4628d9f 100644 --- a/kehys/setup.lua +++ b/kehys/setup.lua @@ -11,6 +11,7 @@ addon.Clickheal = {}; addon.Colors = { Base = {0, 0, 0}, + Glow = {0.7, 1, 0.7}, HealthColor = {0.3, 0.3, 0.3}, ShieldColor = {0, 0.7, 1}, ShieldhlColor = {0.5, 0.8, 1}, diff --git a/kehys/updater.lua b/kehys/updater.lua index bb8fba1..a3bd53c 100644 --- a/kehys/updater.lua +++ b/kehys/updater.lua @@ -21,7 +21,6 @@ local ignoredAuras = { [315176] = true, -- Grasping Tendrils }; -local rounds = 0; function addon.FrameUpdate(frame) assert(type(frame) == "table", "FrameUpdate received invalid frame parameter!"); @@ -124,15 +123,15 @@ function addon.FrameUpdate(frame) elseif frame.healpred:IsShown() then frame.healpred:Hide(); end - rounds = rounds + 1; - if (rounds > 8) then + frame.rounds = frame.rounds + 1; + if (frame.rounds > 7) then frame.tankcd = {}; frame.alert = {}; frame.stacks = {}; frame.heal = {}; frame.buff1 = {}; addon.SetAuras(frame.unit, frame.guid); - rounds = 0; + frame.rounds = 0; end -- tank CD marker if next(frame.tankcd) then @@ -154,6 +153,12 @@ function addon.FrameUpdate(frame) elseif frame.buffind1:IsShown() then frame.buffind1:Hide(); end + -- incoming ability + if next(frame.incoming) then + if not frame.glow:IsShown() then frame.glow:Show() end + elseif frame.glow:IsShown() then + frame.glow:Hide(); + end -- overlays if next(frame.alert) then -- major