Skip to content

Commit

Permalink
Put combat text into its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkub committed Oct 7, 2016
1 parent f8c6e5c commit a482e92
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
18 changes: 3 additions & 15 deletions GoodNewsEveryone.lua
Expand Up @@ -15,7 +15,6 @@ function ns.OnLoad()
if not ns.db.showanchor then ns.anchor:Hide() end

ns.RegisterEvent("UNIT_AURA")
ns.RegisterEvent("COMBAT_TEXT_UPDATE")

local _, myclass = UnitClass("player")
if myclass == "MAGE" then
Expand All @@ -25,6 +24,9 @@ function ns.OnLoad()
end

ns.UNIT_AURA('UNIT_AURA', 'player')

-- Do this here because we know it'll happen after all modules have init'd
ns.BUFF_IDS = nil
end


Expand Down Expand Up @@ -52,20 +54,6 @@ function ns.UNIT_AURA(event, unit)
elseif ns.active[spellname] then ns.active[spellname]:Hide() end
end
end


function ns.COMBAT_TEXT_UPDATE(event, action, name, ...)
if action ~= "SPELL_ACTIVE" or ns.exclude[name] then return end

name = name:gsub("!$", "")

local icon = select(3, GetSpellInfo(name)) or ns.spells[name]
if not icon then return ns.Print('Unknown spell:', name, ...) end

local f = ns.active[name] or ns.GetFrame()
f.msg, f.spell, f.stacks = ns.GetMsg(name, icon), name, 1
f.duration, f.expires, f.not_usable = nil
f:Show()
end


Expand Down
1 change: 1 addition & 0 deletions GoodNewsEveryone.toc
Expand Up @@ -31,6 +31,7 @@ frames\alert_scaler.lua
frames\anchor.lua

modules\buffs.lua
modules\combat_text.lua
modules\debuffs.lua
modules\expiring_debuffs.lua
modules\power.lua
Expand Down
2 changes: 0 additions & 2 deletions modules/buffs.lua
Expand Up @@ -36,8 +36,6 @@ function ns.OnLoadBuffs()
end
end

ns.BUFF_IDS = nil

local frame = CreateFrame("Frame")
frame:RegisterEvent("UNIT_AURA")
frame:SetScript("OnEvent", OnEvent)
Expand Down
33 changes: 33 additions & 0 deletions modules/combat_text.lua
@@ -0,0 +1,33 @@

local myname, ns = ...


local EXCLUDE = {}
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent", function(self, event, action, name, ...)
if action ~= "SPELL_ACTIVE" then return end

name = name:gsub("!$", "")
if EXCLUDE[name] then return end

local _, _, icon = GetSpellInfo(name)
if not icon then return ns.Print("Unknown spell activation:", name, ...) end

local f = ns.active[name] or ns.GetFrame()
f.msg, f.spell, f.stacks = ns.GetMsg(name, icon), name, 1
f.duration, f.expires, f.not_usable = nil
f:Show()
end)
frame:RegisterEvent("COMBAT_TEXT_UPDATE")


function ns.OnLoadCombatText()
if ns.BUFF_IDS then
for k,v in pairs(ns.BUFF_IDS) do
local i, _, icon = GetSpellInfo(v)
if i then
EXCLUDE[i] = icon
end
end
end
end

0 comments on commit a482e92

Please sign in to comment.