Skip to content

Commit a3f8ccd

Browse files
committed
Added Glow borders for buffs/debuffs and icon indicators (CF issue #1091)
BugFix: "by group" layouts did not obey the groups detached configuration (CF issue #1123)
1 parent 344bc5c commit a3f8ccd

10 files changed

+441
-158
lines changed

GridIndicatorEffects.lua

+106-19
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,126 @@ local function SetScaleEffect(indicator, frame, status)
3333
end
3434
end
3535

36+
local function UpdateScale(self, parent, unit)
37+
local status, state = self:GetCurrentStatus(unit)
38+
SetScaleEffect( self, self.GetBlinkFrame(self,parent), status )
39+
self:OnUpdate(parent, unit, status)
40+
end
41+
42+
-- glowing border effect
43+
local LCG = LibStub("LibCustomGlow-1.0")
44+
45+
local function InitGlowPixelAnimation(indicator)
46+
local dbx = indicator.dbx
47+
local key = indicator.name
48+
local funcStart = LCG.PixelGlow_Start
49+
local funcStop = LCG.PixelGlow_Stop
50+
local color = dbx.glow_color
51+
local linesCount = dbx.glow_linesCount or 8
52+
local frequency = dbx.glow_frequency or 0.25
53+
local thickness = dbx.glow_thickness or 2
54+
return function( frame, enabled )
55+
if enabled ~= frame.__glowEnabled then
56+
frame.__glowEnabled = enabled
57+
if enabled then
58+
funcStart( frame, color, linesCount, frequency, nil, thickness, 0, 0, false, key )
59+
else
60+
funcStop( frame, key )
61+
end
62+
end
63+
end
64+
end
65+
66+
local function InitGlowAutoCastAnimation(indicator)
67+
local dbx = indicator.dbx
68+
local key = indicator.name
69+
local funcStart = LCG.AutoCastGlow_Start
70+
local funcStop = LCG.AutoCastGlow_Stop
71+
local color = dbx.glow_color
72+
local particlesCount = dbx.glow_particlesCount or 4
73+
local frequency = dbx.glow_frequency or 0.12
74+
local particlesScale = dbx.glow_particlesScale or 1
75+
return function( frame, enabled )
76+
if enabled ~= frame.__glowEnabled then
77+
frame.__glowEnabled = enabled
78+
if enabled then
79+
funcStart( frame, color, particlesCount, frequency, particlesScale, 0 , 0, key )
80+
else
81+
funcStop( frame, key )
82+
end
83+
end
84+
end
85+
end
86+
87+
local function InitGlowButtonAnimation(indicator)
88+
local dbx = indicator.dbx
89+
local key = indicator.name
90+
local funcStart = LCG.ButtonGlow_Start
91+
local funcStop = LCG.ButtonGlow_Stop
92+
local color = dbx.glow_color
93+
local frequency = dbx.glow_frequency or 0.12
94+
return function( frame, enabled )
95+
if enabled ~= frame.__glowEnabled then
96+
frame.__glowEnabled = enabled
97+
if enabled then
98+
funcStart( frame, color, frequency )
99+
else
100+
funcStop( frame )
101+
end
102+
end
103+
end
104+
end
105+
106+
local glowEffectsInit = { InitGlowPixelAnimation, InitGlowAutoCastAnimation, InitGlowButtonAnimation }
107+
108+
local function UpdateGlow(self, parent, unit)
109+
local status, state = self:GetCurrentStatus(unit)
110+
self.glowAnim( self.GetBlinkFrame(self,parent), state=="blink" )
111+
self:OnUpdate(parent, unit, status)
112+
end
113+
114+
local function UpdateGlowScale(self, parent, unit)
115+
local status, state = self:GetCurrentStatus(unit)
116+
local frame = self.GetBlinkFrame(self,parent)
117+
self.glowAnim( frame, state=="blink" )
118+
SetScaleEffect( self, frame, status )
119+
self:OnUpdate(parent, unit, status)
120+
end
121+
36122
-- Blink effect
37123
local function CreateBlinkAnimation(frame, dbx)
38124
local anim = frame:CreateAnimationGroup()
39125
local alpha = anim:CreateAnimation("Alpha")
126+
anim.settings = alpha
40127
anim:SetLooping("REPEAT")
41128
alpha:SetOrder(1)
42-
alpha:SetFromAlpha(1)
43-
alpha:SetToAlpha(0.1)
44-
alpha:SetDuration(1/dbx.blinkFrequency)
129+
alpha:SetFromAlpha( 1 )
130+
alpha:SetToAlpha( 0.1 )
131+
alpha:SetDuration( 1 / (dbx.blink_frequency or 2) )
45132
frame.blinkAnim = anim
46133
return anim
47134
end
48135

49136
local function SetBlinkEffect(indicator, frame, enabled)
50137
local anim = frame.blinkAnim
51138
if enabled then
52-
(anim or CreateBlinkAnimation(frame,Grid2Frame.db.shared)):Play()
139+
(anim or CreateBlinkAnimation(frame,indicator.dbx)):Play()
53140
elseif anim then
54141
anim:Stop()
55142
end
56143
end
57144

58-
-- Indicator Update functions
59-
local function UpdateBlinkScale(self, parent, unit)
60-
local status, state = self:GetCurrentStatus(unit)
61-
local frame = self.GetBlinkFrame(self,parent)
62-
SetBlinkEffect( self, frame, state=="blink" )
63-
SetScaleEffect( self, frame, status )
64-
self:OnUpdate(parent, unit, status)
65-
end
66-
67-
local function UpdateScale(self, parent, unit)
145+
local function UpdateBlink(self, parent, unit)
68146
local status, state = self:GetCurrentStatus(unit)
69-
SetScaleEffect( self, self.GetBlinkFrame(self,parent), status )
147+
SetBlinkEffect( self, self.GetBlinkFrame(self,parent), state=="blink" )
70148
self:OnUpdate(parent, unit, status)
71149
end
72150

73-
local function UpdateBlink(self, parent, unit)
151+
local function UpdateBlinkScale(self, parent, unit)
74152
local status, state = self:GetCurrentStatus(unit)
75-
SetBlinkEffect( self, self.GetBlinkFrame(self,parent), state=="blink" )
153+
local frame = self.GetBlinkFrame(self,parent)
154+
SetBlinkEffect( self, frame, state=="blink" )
155+
SetScaleEffect( self, frame, status )
76156
self:OnUpdate(parent, unit, status)
77157
end
78158

@@ -82,8 +162,15 @@ function indicatorPrototype:UpdateDB()
82162
self:LoadDB()
83163
end
84164
if self.GetBlinkFrame then
85-
if Grid2Frame.db.shared.blinkType~="None" then
86-
self.Update = self.dbx.animEnabled and UpdateBlinkScale or UpdateBlink
165+
if Grid2Frame.db.shared.blinkType~="None" then -- now blinkType controls blink and glow effects
166+
local typ = self.dbx.highlightType
167+
if typ then -- border glow effects
168+
self.glowAnim = glowEffectsInit[ typ ]( self )
169+
self.Update = self.dbx.animEnabled and UpdateGlowScale or UpdateGlow
170+
else -- blink effect
171+
self.glowAnim = nil
172+
self.Update = self.dbx.animEnabled and UpdateBlinkScale or UpdateBlink
173+
end
87174
else
88175
self.Update = self.dbx.animEnabled and UpdateScale or indicatorPrototype.Update
89176
end

GridLayout.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ function Grid2Layout:SetHeaderProperties(header, dbx, setupIndex, headerName)
627627
header.headerType = dbx.type or 'player' -- player, pet, custom
628628
header.headerName = headerName or header.headerType -- player, pet, target, focus, boss, custom
629629
header.wasDetached = header.isDetached
630-
header.isDetached = setupIndex>1 and (dbx.detachHeader or p.detachedHeaders=='player' or p.detachedHeaders==dbx.type) or nil
630+
header.isDetached = setupIndex>1 and (dbx.detachHeader or p.detachedHeaders=='player' or p.detachedHeaders==header.headerType) or nil
631631
header.groupHorizontal = GetSetupValue( header.isDetached, p.groupHorizontals[header.headerName], p.horizontal )
632632
header.groupAnchor = GetSetupValue( header.isDetached, p.groupAnchors[header.headerName], p.groupAnchor )
633633
header.headerAnchor = GetSetupValue( header.isDetached, p.anchors[header.headerName], p.anchor )

Options/GridUtils.lua

+12-10
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,19 @@ do
231231
Display = { type = "header", order = 80, name = L["Display"] },
232232
StackText = { type = "header", order = 90, name = L["Stack Text"] },
233233
Cooldown = { type = "header", order = 125, name = L["Cooldown"] },
234-
Animation = { type = "header", order = 150, name = L["Animations"] },
234+
ZoomIn = { type = "header", order = 150, name = L["Zoom In"] },
235+
Highlight = { type = "header", order = 200, name = L["Highlight"] },
235236
-- statuses headers
236-
Stacks = { type = "header", order = 4.9, name = L["Stacks"] },
237-
Colors = { type = "header", order = 10, name = L["Colors"] },
238-
Thresholds = { type = "header", order = 50, name = L["Thresholds"], },
239-
Value = { type = "header", order = 90, name = L["Value"] },
240-
Text = { type = "header", order = 95, name = L["Text"] },
241-
Misc = { type = "header", order = 100, name = L["Misc"] },
242-
Auras = { type = "header", order = 150, name = L["Auras"] },
243-
DebuffFilter = { type = "header", order = 175, name = L["Filtered debuffs"] },
244-
AurasExpanded= { type = "header", order = 300, name = L["Display"] },
237+
Stacks = { type = "header", order = 4.9, name = L["Stacks"] },
238+
Colors = { type = "header", order = 10, name = L["Colors"] },
239+
Thresholds = { type = "header", order = 50, name = L["Thresholds"], },
240+
Highlights = { type = "header", order = 50, name = L["Highlight"], },
241+
Value = { type = "header", order = 90, name = L["Value"] },
242+
Text = { type = "header", order = 95, name = L["Text"] },
243+
Misc = { type = "header", order = 100, name = L["Misc"] },
244+
Auras = { type = "header", order = 150, name = L["Auras"] },
245+
DebuffFilter = { type = "header", order = 175, name = L["Filtered debuffs"] },
246+
AurasExpanded = { type = "header", order = 300, name = L["Display"] },
245247
}
246248
function Grid2Options:MakeHeaderOptions( options, key )
247249
options[ "header"..key ] = headers[key]

Options/modules/general/GridGeneral.lua

+21-47
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ Grid2Options:AddGeneralOptions( "General", "Themes", {
2828
},
2929
}, nil)
3030

31+
--==========================================================================
32+
-- Highlight effects: Blink and Glowing Border
33+
--==========================================================================
34+
35+
Grid2Options:AddGeneralOptions( "General", "Highlight", {
36+
effect = {
37+
type = "toggle",
38+
width = 'full',
39+
name = L["Enable blink and glow border effects on indicators"],
40+
desc = L["Enable this option to allow blink and glowing border effects on indicators. The effect activation is controlled by buffs and debuffs statuses."],
41+
order = 10,
42+
get = function () return Grid2Frame.db.shared.blinkType ~= 'None' end,
43+
set = function (_, v)
44+
Grid2Frame.db.shared.blinkType = v and 'Flash' or 'None'
45+
ReloadUI()
46+
end,
47+
confirm = function() return L["UI will be reloaded to change this option. Are you sure?"] end,
48+
}
49+
})
50+
3151
--==========================================================================
3252
-- Icons Zoom
3353
--==========================================================================
@@ -209,53 +229,6 @@ Grid2Options:AddGeneralOptions( "General", "Text Formatting", {
209229
},
210230
})
211231

212-
--==========================================================================
213-
-- Blink
214-
--==========================================================================
215-
216-
Grid2Options:AddGeneralOptions( "General", "blink", {
217-
effect = {
218-
type = "select",
219-
name = L["Blink effect"],
220-
desc = L["Select the type of Blink effect used by Grid2."],
221-
order = 10,
222-
get = function () return Grid2Frame.db.shared.blinkType end,
223-
set = function (_, v)
224-
Grid2Frame.db.shared.blinkType = v
225-
for _,indicator in ipairs(Grid2:GetIndicatorsSorted()) do
226-
if indicator.GetBlinkFrame then
227-
indicator:UpdateDB()
228-
end
229-
end
230-
Grid2Options:MakeStatusesOptions(Grid2Options.statusesOptions)
231-
end,
232-
values= { None = L["None"], Flash = L["Flash"] },
233-
},
234-
frequency = {
235-
type = "range",
236-
name = L["Blink Frequency"],
237-
desc = L["Adjust the frequency of the Blink effect."],
238-
disabled = function () return Grid2Frame.db.shared.blinkType == "None" end,
239-
min = 1,
240-
max = 10,
241-
step = .5,
242-
get = function ()
243-
return Grid2Frame.db.shared.blinkFrequency
244-
end,
245-
set = function (_, v)
246-
Grid2Frame.db.shared.blinkFrequency = v
247-
for _,indicator in ipairs(Grid2:GetIndicatorsSorted()) do
248-
if indicator.GetBlinkFrame then
249-
Grid2Frame:WithAllFrames(function (f)
250-
local anim = indicator:GetBlinkFrame(f).blinkAnim
251-
if anim then anim.settings:SetDuration(1/v) end
252-
end)
253-
end
254-
end
255-
end,
256-
},
257-
})
258-
259232
--==========================================================================
260233
-- Classic Auras Duration
261234
--==========================================================================
@@ -278,6 +251,7 @@ if Grid2.isVanilla then
278251
})
279252
end
280253

254+
281255
--==========================================================================
282256
-- Minimap
283257
--==========================================================================

0 commit comments

Comments
 (0)