diff --git a/.vscode/settings.json b/.vscode/settings.json index 493d95a..f223d5d 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,6 +36,7 @@ "GAME_LOCALE", "SetRaidTargetIconTexture", "PlayerCastingBarFrame", - "CellLayoutsPreviewButton" + "CellLayoutsPreviewButton", + "EventUtil" ] } \ No newline at end of file diff --git a/Snippets/AuraGlow.lua b/Snippets/AuraGlow.lua new file mode 100644 index 0000000..ea5c1cc --- /dev/null +++ b/Snippets/AuraGlow.lua @@ -0,0 +1,26 @@ +-- Run Snippet late to ensure addon is properly loaded +EventUtil.RegisterOnceFrameEventAndCallback("LOADING_SCREEN_DISABLED", function() + local Util = CUF.Util + + local function PostUpdate(icon, auraData) + if auraData.spellId == 393438 then + Util.GlowStart_Normal(icon) + else + Util.GlowStop(icon) + end + end + + -- Override PostUpdate for all auras + Util:IterateAllUnitButtons(function(button, unit) + -- Nil check + if not button:HasWidget("buffs") then return end + + -- NOTE: Only apply to player + -- if unit ~= "player" then return end + + -- can also iterate "button.widgets.debuffs" + for _, icon in ipairs(button.widgets.buffs) do + icon.PostUpdate = PostUpdate + end + end) +end) diff --git a/Util/Utils.lua b/Util/Utils.lua index a1ac857..e22d344 100644 --- a/Util/Utils.lua +++ b/Util/Utils.lua @@ -476,6 +476,95 @@ function Util.GetPositionRelativeToScreenCenter(frame) return relativeX, relativeY end +------------------------------------------------- +-- MARK: Glow +------------------------------------------------- + +local LCG = LibStub("LibCustomGlow-1.0") +---@class GlowFrame: Frame +---@field __glowing string? + +---@param frame GlowFrame|CellAuraIcon +---@param color RGBAOpt? +---@param N number? +---@param frequency number? +---@param length number? +---@param thickness number? +---@param xOffset number? +---@param yOffset number? +---@param border boolean? +---@param key string? +---@param frameLevel number? +function Util.GlowStart_Pixel(frame, color, N, frequency, length, thickness, xOffset, yOffset, border, key, frameLevel) + if frame.__glowing ~= "Pixel" then + Util.GlowStop(frame, key) + end + + LCG.PixelGlow_Start(frame, color, N, frequency, length, thickness, xOffset, yOffset, border, key, frameLevel) + frame.__glowing = "Pixel" +end + +---@param frame GlowFrame|CellAuraIcon +---@param color RGBAOpt? +---@param N number? +---@param frequency number? +---@param scale number? +---@param xOffset number? +---@param yOffset number? +---@param key string? +---@param frameLevel number? +function Util.GlowStart_Shine(frame, color, N, frequency, scale, xOffset, yOffset, key, frameLevel) + if frame.__glowing ~= "Shine" then + Util.GlowStop(frame, key) + end + + LCG.AutoCastGlow_Start(frame, color, N, frequency, scale, xOffset, yOffset, key, frameLevel) + frame.__glowing = "Shine" +end + +---@param frame GlowFrame|CellAuraIcon +---@param color RGBAOpt? +---@param duration number? +---@param startAnim boolean? +---@param xOffset number? +---@param yOffset number? +---@param key string? +---@param frameLevel number? +function Util.GlowStart_Proc(frame, color, duration, startAnim, xOffset, yOffset, key, frameLevel) + if frame.__glowing ~= "Proc" then + Util.GlowStop(frame, key) + end + + LCG.ProcGlow_Start(frame, color, duration, startAnim, xOffset, yOffset, key, frameLevel) + frame.__glowing = "Proc" +end + +---@param frame GlowFrame|CellAuraIcon +---@param color RGBAOpt? +---@param frequency number? +---@param frameLevel number? +function Util.GlowStart_Normal(frame, color, frequency, frameLevel) + if frame.__glowing ~= "Normal" then + Util.GlowStop(frame) + end + + LCG.ButtonGlow_Start(frame, color, frequency, frameLevel) + frame.__glowing = "Normal" +end + +---@param frame GlowFrame|CellAuraIcon +---@param key string? +function Util.GlowStop(frame, key) + if not frame.__glowing then return end + + LCG.ButtonGlow_Stop(frame, key) + LCG.PixelGlow_Stop(frame, key) + LCG.AutoCastGlow_Stop(frame, key) + LCG.ProcGlow_Stop(frame, key) + + frame.__glowing = nil +end + ------------------------------------------------- -- MARK: Formatting ------------------------------------------------- diff --git a/Widgets/Auras/Auras.lua b/Widgets/Auras/Auras.lua index 53512ab..b072c59 100644 --- a/Widgets/Auras/Auras.lua +++ b/Widgets/Auras/Auras.lua @@ -270,6 +270,15 @@ local function Icons_HidePreview(icons) end end +------------------------------------------------- +-- MARK: API Functions +------------------------------------------------- + +---@param icon CellAuraIcon +---@param auraDate AuraData +function Icon_PostUpdate(icon, auraDate) +end + ------------------------------------------------- -- MARK: Update ------------------------------------------------- @@ -351,6 +360,12 @@ function W:CreateAuraIcons(button, type) frame:SetScript("OnUpdate", Icon_OnUpdate) end end) + + icon:HookScript("OnHide", function() + Util.GlowStop(icon) + end) + + icon.PostUpdate = Icon_PostUpdate end auraIcons.SetEnabled = W.SetEnabled @@ -429,6 +444,7 @@ W:RegisterCreateWidgetFunc(const.WIDGET_KIND.DEBUFFS, W.CreateDebuffs) ---@field ShowStack fun(frame, show) Shared_ShowStack ---@field ShowAnimation fun(frame, show) BarIcon_ShowAnimation ---@field UpdatePixelPerfect fun(frame) BarIcon_UpdatePixelPerfect +---@field PostUpdate fun(self: CellAuraIcon, auraDate: AuraData) Icon_PostUpdate ---@field cooldown StatusBar ---@field GetCooldownDuration function ---@field ShowCooldown function @@ -437,6 +453,7 @@ W:RegisterCreateWidgetFunc(const.WIDGET_KIND.DEBUFFS, W.CreateDebuffs) ---@field preview CellAuraIcon.preview ---@field showDuration boolean ---@field _showDuration boolean +---@field __glowing string? ---@class CellAuraIcons: Frame ---@field indicatorType "icons" diff --git a/Widgets/Auras/Handler.lua b/Widgets/Auras/Handler.lua index 06d4486..6c1554e 100644 --- a/Widgets/Auras/Handler.lua +++ b/Widgets/Auras/Handler.lua @@ -185,6 +185,8 @@ local function UpdateAuraIcons(icons) auraData.refreshing ) icons[icons._auraCount].index = auraData.index -- Tooltip + + icons[icons._auraCount]:PostUpdate(auraData) end -- Resize