90 lines
1.9 KiB
Lua
90 lines
1.9 KiB
Lua
LCG = LibStub("LibCustomGlow-1.0")
|
|
---@table <string, boolean>
|
|
BusyFrames = {}
|
|
|
|
Units = {
|
|
"player",
|
|
"party1",
|
|
"party2",
|
|
"party3",
|
|
"party4",
|
|
"party5",
|
|
}
|
|
|
|
---@param unit string
|
|
---@return boolean, nil|string
|
|
function HasDispellableDebuff(unit)
|
|
for i = 1, 20 do
|
|
local debuff, _, _, _, type = UnitDebuff(unit, i)
|
|
if debuff == nil then
|
|
return false, nil
|
|
end
|
|
if type == "Magic" then
|
|
return true, nil
|
|
end
|
|
end
|
|
|
|
return false, nil
|
|
end
|
|
|
|
---@param frame Frame
|
|
---@return string, nil|string
|
|
function GetNameFromFrame(frame)
|
|
if frame == nil then
|
|
return "", "Frame is nil"
|
|
end
|
|
---@diagnostic disable-next-line: undefined-field
|
|
if frame.Name == nil then
|
|
return "", "Frame.Name is nil"
|
|
end
|
|
---@diagnostic disable-next-line: undefined-field
|
|
local name = frame.Name:GetText()
|
|
if name == nil then
|
|
return "", "Frame.Name.GetText is nil"
|
|
end
|
|
return name, nil
|
|
end
|
|
|
|
---@param name string
|
|
---@return Frame|nil
|
|
function GetFrameFromName(name)
|
|
return PartyCache[name]
|
|
end
|
|
|
|
---@param name string
|
|
---@return string
|
|
---@return number
|
|
function RemoveNamePadding(name)
|
|
return string.gsub(name, "|c%w%w%w%w%w%w%w%w", "", 1)
|
|
end
|
|
|
|
function MakeFrameGlow(frame)
|
|
local frameName = frame:GetName()
|
|
if frame ~= nil and BusyFrames[frameName] == nil then
|
|
---@type Frame
|
|
---@diagnostic disable-next-line: undefined-field
|
|
local healthBar = frame.Health
|
|
if healthBar ~= nil then
|
|
LCG.PixelGlow_Start(healthBar, {1, 1, 0, 1}, 16, 0.35, 8, 4)
|
|
BusyFrames[frameName] = true
|
|
C_Timer.After(1, function()
|
|
LCG.PixelGlow_Stop(healthBar)
|
|
BusyFrames[frameName] = nil
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
|
|
PartyCache = {}
|
|
function SetupPartyCache()
|
|
for i = 1, 5 do
|
|
-- /dump _G[string.format("ElvUF_RaidGroup1UnitButton%d", 1)].Name:GetText()
|
|
local raidFrame = _G[string.format("ElvUF_RaidGroup1UnitButton%d", i + 1)]
|
|
local name, err = GetNameFromFrame(raidFrame)
|
|
if err == nil then
|
|
name = RemoveNamePadding(name)
|
|
PartyCache[name] = raidFrame
|
|
end
|
|
end
|
|
end
|