(feature/LibGlow) add Proc Glow (#35)

This commit is contained in:
NoM0Re
2025-05-01 18:43:54 +02:00
committed by GitHub
parent 253de34f0f
commit 4d47aabcda
9 changed files with 414 additions and 9 deletions
+3 -1
View File
@@ -135,7 +135,7 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path
if (value and type(value) == "table") then
return ([[{ glow_action = %q, glow_frame_type = %q, glow_type = %q,
glow_frame = %q, use_glow_color = %s, glow_color = {%s, %s, %s, %s},
glow_lines = %d, glow_frequency = %f, glow_length = %f, glow_thickness = %f, glow_XOffset = %f, glow_YOffset = %f,
glow_startAnim = %s, glow_duration = %f, glow_lines = %d, glow_frequency = %f, glow_length = %f, glow_thickness = %f, glow_XOffset = %f, glow_YOffset = %f,
glow_scale = %f, glow_border = %s }]]):format(
value.glow_action or "",
value.glow_frame_type or "",
@@ -146,6 +146,8 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path
type(value.glow_color) == "table" and tostring(value.glow_color[2]) or "1",
type(value.glow_color) == "table" and tostring(value.glow_color[3]) or "1",
type(value.glow_color) == "table" and tostring(value.glow_color[4]) or "1",
value.glow_startAnim and "true" or "false",
value.glow_duration or 1,
value.glow_lines or 8,
value.glow_frequency or 0.25,
value.glow_length or 10,
@@ -811,4 +811,208 @@ end
tinsert(lib.glowList, "Action Button Glow")
lib.startList["Action Button Glow"] = lib.ButtonGlow_Start
lib.stopList["Action Button Glow"] = lib.ButtonGlow_Stop
lib.stopList["Action Button Glow"] = lib.ButtonGlow_Stop
-- ProcGlow
local ProcGlowBaseTexCoords = {
["Loop"] = {0.412598, 0.575195, 0.000976562, 0.391602},
["Start"] = {0.000488281, 0.411621, 0.000976562, 0.987305},
}
local function SetTile(texture, frame, rows, columns, frameScaleW, frameScaleH, key)
frame = frame - 1
local row = math.floor(frame / columns)
local column = frame % columns
local BaseTexCoord = ProcGlowBaseTexCoords[key]
local leftStart, rightEnd, topStart, bottomEnd = BaseTexCoord[1], BaseTexCoord[2], BaseTexCoord[3], BaseTexCoord[4]
local fullWidth = rightEnd - leftStart
local fullHeight = bottomEnd - topStart
local baseDeltaX = fullWidth / columns
local baseDeltaY = fullHeight / rows
local deltaX = baseDeltaX * frameScaleW
local deltaY = baseDeltaY * frameScaleH
local left = leftStart + baseDeltaX * column + (baseDeltaX - deltaX) / 2
local right = left + deltaX
local top = topStart + baseDeltaY * row + (baseDeltaY - deltaY) / 2
local bottom = top + deltaY
pcall(function()
texture:SetTexCoord(left, right, top, bottom)
end)
end
local StartFlipbook
local FlipbookAnimation_OnUpdate
FlipbookAnimation_OnUpdate = function(self, elapsed)
local data = self.flipbookData
if not data then return end
if data.animElapsed then
data.animElapsed = data.animElapsed + elapsed
if data.animElapsed >= 0.7 then
if self:IsShown() then
StartFlipbook(self, self.ProcLoop, 6, 5, 30, ((data.animOptions and (30 / data.animOptions)) or 30), nil, nil, "Loop")
end
data.animElapsed = nil
data.animOptions = nil
end
end
data.elapsedTime = data.elapsedTime + elapsed
local frameDuration = 1 / data.frameRate
if data.elapsedTime >= frameDuration then
data.elapsedTime = data.elapsedTime - frameDuration
data.currentFrame = data.currentFrame + 1
if data.currentFrame > data.totalFrames then
data.currentFrame = 1
end
SetTile(data.texture, data.currentFrame, data.rows, data.columns, 1, 1, data.key)
end
end
local function StopFlipbook(f)
f:SetScript("OnUpdate", nil)
if f.flipbookData and f.flipbookData.texture then
f.flipbookData.texture:Hide()
end
f.flipbookData = nil
end
StartFlipbook = function(f, texture, rows, columns, totalFrames, frameRate, startAnim, startOptionsDur, key)
StopFlipbook(f)
f.flipbookData = {
key = key,
texture = texture,
rows = rows,
columns = columns,
totalFrames = totalFrames,
frameRate = frameRate,
currentFrame = 1,
elapsedTime = 0,
animElapsed = startAnim,
animOptions = startOptionsDur,
}
texture:Show()
f:SetScript("OnUpdate", FlipbookAnimation_OnUpdate)
end
local function ProcGlowResetter(framePool, frame)
frame:Hide()
frame:ClearAllPoints()
frame:SetScript("OnShow", nil)
frame:SetScript("OnHide", nil)
frame:SetScript("OnUpdate", nil)
local parent = frame:GetParent()
if frame.name and parent[frame.name] then
parent[frame.name] = nil
end
end
local ProcGlowPool = CreateFramePool("Frame", GlowParent, nil, ProcGlowResetter)
lib.ProcGlowPool = ProcGlowPool
local function InitProcGlow(f)
-- Start-Flipbook
f.ProcStart = f:CreateTexture(nil, "ARTWORK")
f.ProcStart:SetBlendMode("ADD")
f.ProcStart:SetTexture([[Interface\AddOns\WeakAuras\Libs\LibCustomGlow-1.0\UIActionBarFX]])
f.ProcStart:SetTexCoord(0.0827148248, 0.1649413686, 0.000976562, 0.165364635) -- First Frame
f.ProcStart:SetAlpha(1)
f.ProcStart:SetSize(150, 150)
f.ProcStart:SetPoint("CENTER")
f.ProcStart:Hide()
-- Loop-Flipbook
f.ProcLoop = f:CreateTexture(nil, "ARTWORK")
f.ProcLoop:SetTexture([[Interface\AddOns\WeakAuras\Libs\LibCustomGlow-1.0\UIActionBarFX]])
f.ProcLoop:SetTexCoord(0.412598, 0.4451174, 0.000976562, 0.066080801666667) -- First Frame
f.ProcLoop:SetAlpha(1)
f.ProcLoop:SetAllPoints()
f.ProcLoop:Hide()
end
local function SetupProcGlow(f, options)
f.name = "_ProcGlow" .. options.key
f:SetScript("OnHide", function(self)
StopFlipbook(self)
end)
f:SetScript("OnShow", function(self)
StopFlipbook(self)
if self.startAnim then
local width, height = self:GetSize()
self.ProcStart:SetSize((width / 42 * 150) / 1.4, (height / 42 * 150) / 1.4)
StartFlipbook(self, self.ProcStart, 6, 5, 30, 30, 0, options.duration, "Start")
else
StartFlipbook(self, self.ProcLoop , 6, 5, 30, (30 / options.duration), nil, nil, "Loop")
end
end)
local color = options.color or {1, 1, 1, 1}
f.ProcStart:SetVertexColor(unpack(color))
f.ProcLoop:SetVertexColor(unpack(color))
f.startAnim = options.startAnim
end
local ProcGlowDefaults = {
frameLevel = 8,
color = nil,
startAnim = true,
xOffset = 0,
yOffset = 0,
duration = 1,
key = ""
}
function lib.ProcGlow_Start(r, options)
if not r then return end
options = options or {}
setmetatable(options, { __index = ProcGlowDefaults })
local key = "_ProcGlow" .. options.key
local f, new
if r[key] then
f = r[key]
else
f, new = ProcGlowPool:Acquire()
if new then
InitProcGlow(f)
end
r[key] = f
end
f:SetParent(r)
f:SetFrameLevel(r:GetFrameLevel() + options.frameLevel)
local width, height = r:GetSize()
local xOffset = options.xOffset + width * 0.2
local yOffset = options.yOffset + height * 0.2
f:SetPoint("TOPLEFT", r, "TOPLEFT", -xOffset, yOffset)
f:SetPoint("BOTTOMRIGHT", r, "BOTTOMRIGHT", xOffset, -yOffset)
SetupProcGlow(f, options)
f:Show()
end
function lib.ProcGlow_Stop(r, key)
key = key or ""
local f = r["_ProcGlow" .. key]
if f then
ProcGlowPool:Release(f)
end
end
table.insert(lib.glowList, "Proc Glow")
lib.startList["Proc Glow"] = lib.ProcGlow_Start
lib.stopList["Proc Glow"] = lib.ProcGlow_Stop
Binary file not shown.
+52
View File
@@ -15,6 +15,7 @@ local default = function(parentType)
glowType = "buttonOverlay",
glowLines = 8,
glowFrequency = 0.25,
glowDuration = 1,
glowLength = 10,
glowThickness = 1,
glowScale = 1,
@@ -70,6 +71,15 @@ local properties = {
bigStep = 0.1,
default = 0.25
},
glowDuration = {
display = L["Duration"],
setter = "SetGlowDuration",
type = "number",
softMin = 0.01,
softMax = 3,
bigStep = 0.1,
default = 1
},
glowLength = {
display = L["Length"],
setter = "SetGlowLength",
@@ -121,6 +131,11 @@ local properties = {
bigStep = 1,
default = 0
},
glowStartAnim = {
display = L["Start Animation"],
setter = "SetGlowStartAnim",
type = "bool",
},
}
local function glowStart(self, frame, color)
@@ -158,6 +173,15 @@ local function glowStart(self, frame, color)
nil,
0
)
elseif self.glowType == "Proc" then
self.glowStart(frame, {
color = color,
startAnim = self.glowStartAnim and true or false,
duration = self.glowDuration,
xOffset = self.glowXOffset,
yOffset = self.glowYOffset,
frameLevel = 0
})
end
end
@@ -216,6 +240,15 @@ local funcs = {
if self.parentRegionType ~= "aurabar" then
self.parent:AnchorSubRegion(self, "area")
end
elseif newType == "Proc" then
self.glowStart = LCG.ProcGlow_Start
self.glowStop = LCG.ProcGlow_Stop
if self.parentRegionType ~= "aurabar" then
self.parent:AnchorSubRegion(self, "area", "region")
end
else -- noop function in case of unsupported glow
self.glowStart = function() end
self.glowStop = function() end
end
self.glowType = newType
if isGlowing then
@@ -249,6 +282,12 @@ local funcs = {
self:SetVisible(true)
end
end,
SetGlowDuration = function(self, duration)
self.glowDuration = duration
if self.glow then
self:SetVisible(true)
end
end,
SetGlowLength = function(self, length)
self.glowLength = length
if self.glow then
@@ -273,6 +312,12 @@ local funcs = {
self:SetVisible(true)
end
end,
SetGlowStartAnim = function(self, enable)
self.glowStartAnim = enable
if self.glow then
self:SetVisible(true)
end
end,
SetGlowXOffset = function(self, xoffset)
self.glowXOffset = xoffset
if self.glow then
@@ -308,6 +353,9 @@ end
local function onRelease(subRegion)
subRegion.glowType = nil
if subRegion.glow then
subRegion:SetVisible(false)
end
subRegion:Hide()
subRegion:ClearAllPoints()
subRegion:SetParent(UIParent)
@@ -329,6 +377,8 @@ local function modify(parent, region, parentData, data, first)
region.glowBorder = data.glowBorder
region.glowXOffset = data.glowXOffset
region.glowYOffset = data.glowYOffset
region.glowStartAnim = data.glowStartAnim
region.glowDuration = data.glowDuration
region:SetGlowType(data.glowType)
region:SetVisible(data.glow)
@@ -355,6 +405,7 @@ function Private.getDefaultGlow(regionType)
glowType = "Pixel",
glowLines = 8,
glowFrequency = 0.25,
glowDuration = 1,
glowLength = 10,
glowThickness = 1,
glowScale = 1,
@@ -372,6 +423,7 @@ function Private.getDefaultGlow(regionType)
glowType = "buttonOverlay",
glowLines = 8,
glowFrequency = 0.25,
glowDuration = 1,
glowLength = 10,
glowThickness = 1,
glowScale = 1,
+1
View File
@@ -3520,6 +3520,7 @@ Private.glow_types = {
ACShine = L["Autocast Shine"],
Pixel = L["Pixel Glow"],
buttonOverlay = L["Action Button Glow"],
Proc = L["Proc Glow"]
}
Private.font_sizes = {
+11
View File
@@ -3143,6 +3143,8 @@ local function actionGlowStop(actions, frame, id)
LCG.PixelGlow_Stop(frame.__WAGlowFrame, id)
elseif actions.glow_type == "ACShine" then
LCG.AutoCastGlow_Stop(frame.__WAGlowFrame, id)
elseif actions.glow_type == "Proc" then
LCG.ProcGlow_Stop(frame.__WAGlowFrame, id)
end
end
@@ -3184,6 +3186,15 @@ local function actionGlowStart(actions, frame, id)
actions.glow_YOffset,
id
)
elseif actions.glow_type == "Proc" then
LCG.ProcGlow_Start(glow_frame, {
color = color,
startAnim = actions.glow_startAnim and true or false,
xOffset = actions.glow_XOffset,
yOffset = actions.glow_YOffset,
duration = actions.glow_duration or 1,
key = id
})
end
end
+72
View File
@@ -407,6 +407,40 @@ function OptionsPrivate.GetActionOptions(data)
end,
disabled = function() return not data.actions.start.use_glow_color end,
},
start_glow_startAnim = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Start Animation"],
order = 10.801,
get = function()
return data.actions.start.glow_startAnim and true or false
end,
hidden = function()
return not data.actions.start.do_glow
or data.actions.start.glow_action ~= "show"
or data.actions.start.glow_frame_type == nil
or data.actions.start.glow_type ~= "Proc"
end,
},
start_glow_duration = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Duration"],
order = 10.802,
softMin = 0.01,
softMax = 3,
step = 0.05,
get = function()
return data.actions.start.glow_duration or 1
end,
hidden = function()
return not data.actions.start.do_glow
or data.actions.start.glow_action ~= "show"
or data.actions.start.glow_frame_type == nil
or data.actions.start.glow_type ~= "Proc"
end,
},
start_glow_lines = {
type = "range",
control = "WeakAurasSpinBox",
@@ -424,6 +458,7 @@ function OptionsPrivate.GetActionOptions(data)
or data.actions.start.glow_action ~= "show"
or not data.actions.start.glow_type
or data.actions.start.glow_type == "buttonOverlay"
or data.actions.start.glow_type == "Proc"
or data.actions.start.glow_frame_type == nil
end,
},
@@ -444,6 +479,7 @@ function OptionsPrivate.GetActionOptions(data)
or data.actions.start.glow_action ~= "show"
or not data.actions.start.glow_type
or data.actions.start.glow_type == "buttonOverlay"
or data.actions.start.glow_type == "Proc"
or data.actions.start.glow_frame_type == nil
end,
},
@@ -851,6 +887,40 @@ function OptionsPrivate.GetActionOptions(data)
end,
disabled = function() return not data.actions.finish.use_glow_color end,
},
finish_glow_startAnim = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Start Animation"],
order = 10.801,
get = function()
return data.actions.finish.glow_startAnim and true or false
end,
hidden = function()
return not data.actions.finish.do_glow
or data.actions.finish.glow_action ~= "show"
or data.actions.finish.glow_frame_type == nil
or data.actions.finish.glow_type ~= "Proc"
end,
},
finish_glow_duration = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Duration"],
order = 10.802,
softMin = 0.01,
softMax = 3,
step = 0.05,
get = function()
return data.actions.finish.glow_duration or 1
end,
hidden = function()
return not data.actions.finish.do_glow
or data.actions.finish.glow_action ~= "show"
or data.actions.finish.glow_frame_type == nil
or data.actions.finish.glow_type ~= "Proc"
end,
},
finish_glow_lines = {
type = "range",
control = "WeakAurasSpinBox",
@@ -868,6 +938,7 @@ function OptionsPrivate.GetActionOptions(data)
or data.actions.finish.glow_action ~= "show"
or not data.actions.finish.glow_type
or data.actions.finish.glow_type == "buttonOverlay"
or data.actions.start.glow_type == "Proc"
or data.actions.finish.glow_frame_type == nil
end,
},
@@ -888,6 +959,7 @@ function OptionsPrivate.GetActionOptions(data)
or data.actions.finish.glow_action ~= "show"
or not data.actions.finish.glow_type
or data.actions.finish.glow_type == "buttonOverlay"
or data.actions.start.glow_type == "Proc"
or data.actions.finish.glow_frame_type == nil
end,
},
+41 -4
View File
@@ -1276,6 +1276,9 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
local glowTypesExcepButtonOverlay = CopyTable(OptionsPrivate.Private.glow_types)
glowTypesExcepButtonOverlay["buttonOverlay"] = nil
local glowTypesExcepButtonOverlayAndProc = CopyTable(OptionsPrivate.Private.glow_types)
glowTypesExcepButtonOverlayAndProc["buttonOverlay"] = nil
glowTypesExcepButtonOverlayAndProc["Proc"] = nil
args["condition" .. i .. "value" .. j .. "glow_action"] = {
type = "select",
@@ -1386,6 +1389,40 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
disabled = function() return not anyGlowExternal("use_glow_color", true) end
}
order = order + 1
args["condition" .. i .. "value" .. j .. "glow_startAnim"] = {
type = "toggle",
width = WeakAuras.normalWidth,
name = blueIfNoValue2(data, conditions[i].changes[j], "value", "glow_startAnim", L["Start Animation"], L["Start Animation"]),
desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_startAnim", propertyType),
order = order,
get = function()
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.glow_startAnim;
end,
set = setValueComplex("glow_startAnim"),
hidden = function()
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", "Proc"))
end
}
order = order + 1
args["condition" .. i .. "value" .. j .. "glow_duration"] = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = blueIfNoValue2(data, conditions[i].changes[j], "value", "glow_duration", L["Duration"], L["Duration"]),
desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_duration", propertyType),
order = order,
softMin = 0.01,
softMax = 3,
step = 0.05,
get = function()
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.glow_duration or 1;
end,
set = setValueComplex("glow_duration"),
hidden = function()
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", "Proc"))
end,
}
order = order + 1
args["condition" .. i .. "value" .. j .. "glow_lines"] = {
type = "range",
control = "WeakAurasSpinBox",
@@ -1401,7 +1438,7 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
end,
set = setValueComplex("glow_lines"),
hidden = function()
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", glowTypesExcepButtonOverlay))
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", glowTypesExcepButtonOverlayAndProc))
end,
}
order = order + 1
@@ -1420,7 +1457,7 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
end,
set = setValueComplex("glow_frequency"),
hidden = function()
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", glowTypesExcepButtonOverlay))
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", glowTypesExcepButtonOverlayAndProc))
end,
}
order = order + 1
@@ -1496,7 +1533,7 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
end,
set = setValueComplex("glow_YOffset"),
hidden = function()
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", "Pixel"))
return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", glowTypesExcepButtonOverlay))
end,
}
order = order + 1
@@ -2830,7 +2867,7 @@ local function SubPropertiesForChange(change)
"glow_action", "glow_frame_type", "glow_type",
"glow_frame", "choose_glow_frame",
"use_glow_color", "glow_color",
"glow_lines", "glow_frequency", "glow_length", "glow_thickness", "glow_XOffset", "glow_YOffset",
"glow_startAnim", "glow_duration", "glow_lines", "glow_frequency", "glow_length", "glow_thickness", "glow_XOffset", "glow_YOffset",
"glow_scale", "glow_border"
}
elseif change.property == "chat" then
+29 -3
View File
@@ -3,7 +3,6 @@ local AddonName = ...
local OptionsPrivate = select(2, ...)
local L = WeakAuras.L;
local indentWidth = 0.15
local function createOptions(parentData, data, index, subIndex)
@@ -35,6 +34,7 @@ local function createOptions(parentData, data, index, subIndex)
anchor_area = {
type = "select",
width = WeakAuras.normalWidth,
control = "WeakAurasTwoColumnDropdown",
name = L["Glow Anchor"],
order = 3,
values = areaAnchors,
@@ -82,6 +82,14 @@ local function createOptions(parentData, data, index, subIndex)
if data.glowBorder then
line = L["%s, Border"]:format(line)
end
elseif data.glowType == "Proc" then
line = ("%s %s, Duration: %d"):format(line, color, data.glowDuration)
if data.glowStartAnim then
line = L["%s, Start Animation"]:format(line)
end
if data.glowXOffset ~= 0 or data.glowYOffset ~= 0 then
line = L["%s, offset: %0.2f;%0.2f"]:format(line, data.glowXOffset, data.glowYOffset)
end
end
return line
end,
@@ -132,6 +140,13 @@ local function createOptions(parentData, data, index, subIndex)
order = 8,
hidden = hiddenGlowExtra,
},
glowStartAnim = {
type = "toggle",
width = WeakAuras.normalWidth - indentWidth,
name = L["Start Animation"],
order = 8.5,
hidden = function() return hiddenGlowExtra() or data.glowType ~= "Proc" end
},
glowLines = {
type = "range",
control = "WeakAurasSpinBox",
@@ -141,7 +156,7 @@ local function createOptions(parentData, data, index, subIndex)
min = 1,
softMax = 30,
step = 1,
hidden = function() return hiddenGlowExtra() or data.glowType == "buttonOverlay" end,
hidden = function() return hiddenGlowExtra() or data.glowType == "buttonOverlay" or data.glowType == "Proc" end,
},
glowFrequency = {
type = "range",
@@ -152,7 +167,18 @@ local function createOptions(parentData, data, index, subIndex)
softMin = -2,
softMax = 2,
step = 0.05,
hidden = function() return hiddenGlowExtra() or data.glowType == "buttonOverlay" end,
hidden = function() return hiddenGlowExtra() or data.glowType == "buttonOverlay" or data.glowType == "Proc" end,
},
glowDuration = {
type = "range",
control = "WeakAurasSpinBox",
width = WeakAuras.normalWidth,
name = L["Duration"],
order = 10,
softMin = 0.01,
softMax = 3,
step = 0.05,
hidden = function() return hiddenGlowExtra() or data.glowType ~= "Proc" end,
},
glow_space3 = {
type = "description",