Skip to content

Commit

Permalink
Fix overlay glows on utility ring buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
seblindfors committed Jun 24, 2024
1 parent a216a98 commit bacc864
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ConsolePort/ConsolePort.toc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Title: Console Port
## Notes: Game controller addon
## AddonCompartmentFunc: ConsolePort
## Version: 2.9.2
## Version: 2.9.3

## Author: Sebastian Lindfors
## X-Website: https://github.com/seblindfors/ConsolePort
Expand Down
34 changes: 11 additions & 23 deletions ConsolePort/Libs/Local/ActionButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,10 @@ function Lib.SkinUtility.SkinChargeCooldown(self, skin, reset)
end

do -- Lib.SkinUtility.SkinOverlayGlow
local function MockOverlay(self, onShow, onHide)
local IsPlaying, Stop = function() return true end, nop;
local overlay = {
animIn = { IsPlaying = IsPlaying, Stop = Stop, Play = GenerateClosure(onShow, self) };
animOut = { IsPlaying = IsPlaying, Stop = Stop, Play = GenerateClosure(onHide, self) };
};
return overlay;
end

function Lib.SkinUtility.SkinOverlayGlow(self, onShow, onHide)
if self.__LBGoverlaySkin then return end;
if self:IsVisible() then
self.__LBGoverlay = MockOverlay(self, onShow, onHide)
end
self:HookScript('OnHide', function(self) self.__LBGoverlay = nil end)
self:HookScript('OnShow', function(self) self.__LBGoverlay = MockOverlay(self, onShow, onHide) end)
self.ShowOverlayGlow = onShow;
self.HideOverlayGlow = onHide;
self.__LBGoverlaySkin = true;
end
end -- Lib.SkinUtility.SkinOverlayGlow
Expand Down Expand Up @@ -419,11 +407,11 @@ end
end -- LBG hook

---------------------------------------------------------------
do -- Round LBG replacement
do Lib.RoundGlow = {}; -- Round LBG replacement
---------------------------------------------------------------

Lib.unusedOverlays = Lib.unusedOverlays or {}
Lib.numOverlays = Lib.numOverlays or 0
Lib.RoundGlow.unusedOverlays = Lib.RoundGlow.unusedOverlays or {}
Lib.RoundGlow.numOverlays = Lib.RoundGlow.numOverlays or 0

local tinsert, tremove, tostring = table.insert, table.remove, tostring
local AnimateTexCoords = AnimateTexCoords
Expand All @@ -432,7 +420,7 @@ local function OverlayGlowAnimOutFinished(animGroup)
local overlay = animGroup:GetParent()
local frame = overlay:GetParent()
overlay:Hide()
tinsert(Lib.unusedOverlays, overlay)
tinsert(Lib.RoundGlow.unusedOverlays, overlay)
frame.__LBGoverlay = nil
end

Expand Down Expand Up @@ -509,10 +497,10 @@ local function AnimIn_OnFinished(group)
end

local function CreateOverlayGlow()
Lib.numOverlays = Lib.numOverlays + 1
Lib.RoundGlow.numOverlays = Lib.RoundGlow.numOverlays + 1

-- create frame and textures
local name = 'CPButtonGlowOverlay' .. tostring(Lib.numOverlays)
local name = 'CPButtonGlowOverlay' .. tostring(Lib.RoundGlow.numOverlays)
local overlay = CreateFrame('Frame', name, UIParent)

-- spark
Expand Down Expand Up @@ -578,14 +566,14 @@ local function CreateOverlayGlow()
end

local function GetOverlayGlow()
local overlay = tremove(Lib.unusedOverlays)
local overlay = tremove(Lib.RoundGlow.unusedOverlays)
if not overlay then
overlay = CreateOverlayGlow()
end
return overlay
end

function Lib.ShowOverlayGlow(frame)
function Lib.RoundGlow.ShowOverlayGlow(frame)
if frame.__LBGoverlay then
if frame.__LBGoverlay.animOut:IsPlaying() then
frame.__LBGoverlay.animOut:Stop()
Expand All @@ -609,7 +597,7 @@ function Lib.ShowOverlayGlow(frame)
end
end

function Lib.HideOverlayGlow(frame)
function Lib.RoundGlow.HideOverlayGlow(frame)
if frame.__LBGoverlay then
if frame.__LBGoverlay.animIn:IsPlaying() then
frame.__LBGoverlay.animIn:Stop()
Expand Down
8 changes: 8 additions & 0 deletions ConsolePort/View/Pie/Utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ function Button:OnLoad()
self:Initialize()
self:SetScript('OnHide', self.OnClear)
self:SetScript('OnShow', self.UpdateLocal)
self:SetRotation(self.rotation or 0)
ActionButton.Skin.UtilityRingButton(self)
end

function Button:OnFocus()
Expand Down Expand Up @@ -986,5 +988,11 @@ function Button:UpdateLocal()
ActionButton.Skin.UtilityRingButton(self)
RunNextFrame(function()
self:GetParent():SetSliceText(self:GetID(), self.Name:GetText())
local spellId = self:GetSpellId()
if spellId and CPAPI.IsSpellOverlayed(spellId) then
self:ShowOverlayGlow()
else
self:HideOverlayGlow()
end
end)
end
4 changes: 2 additions & 2 deletions ConsolePort_Bar/Widget/Cluster/Cluster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ function Button:GetOverlayColor()
end

function Button:ShowOverlayGlow()
env.LIB.ShowOverlayGlow(self)
env.LIB.RoundGlow.ShowOverlayGlow(self)
end

function Button:HideOverlayGlow()
env.LIB.HideOverlayGlow(self)
env.LIB.RoundGlow.HideOverlayGlow(self)
end

---------------------------------------------------------------
Expand Down

0 comments on commit bacc864

Please sign in to comment.