Skip to content

Commit

Permalink
[Feature] Dispel Border Glow (#188)
Browse files Browse the repository at this point in the history
* add percentage param to CreateSlider

* add PostUpdate fn param to CreateDropdown

* add CreateGlowOptions for Builder

* add SetDispelGlow functions

* add GlowOpt annotations

* add glow prop to DispelsWidgetTable

* add consts

* add defaults

* add missing Util import

* add UpdateGlowStyle fn

* update glows

* update preview

* update UpdateGlowStyle

* remove unnecessary import

* add Glow menu options

* don't show glow color options for Dispel widget

* update default glow scale to 100%

* locales
  • Loading branch information
Krealle authored Dec 6, 2024
1 parent 86e4300 commit 9c426ca
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Data/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const.OPTION_KIND = {
ONLY_SHOW_INTERRUPT = "onlyShowInterrupt",
HIDE_AT_MAX_LEVEL = "hideAtMaxLevel",
HIDE_OUT_OF_COMBAT = "hideOutOfCombat",
GLOW = "glow",
}

---@enum AURA_OPTION_KIND
Expand Down Expand Up @@ -332,3 +333,12 @@ const.BlizzardFrameTypes = {
"buffFrame",
"debuffFrame",
}

---@enum GlowType
const.GlowType = {
NONE = "none",
NORMAL = "normal",
PIXEL = "pixel",
SHINE = "shine",
PROC = "proc",
}
13 changes: 13 additions & 0 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ Defaults.Options.fontWidth = {
type = "percentage",
auxValue = 3,
}
---@type GlowOpt
Defaults.Options.glow = {
type = CUF.constants.GlowType.NONE,
color = { 1, 1, 1, 1 },
lines = 9,
frequency = 0.25,
length = 8,
thickness = 2,
particles = 9,
duration = 1,
scale = 100,
}

---@alias Defaults.Colors.Types
---| "castBar"
Expand Down Expand Up @@ -518,6 +530,7 @@ Defaults.Widgets = {
offsetX = -4,
relativePoint = "BOTTOMRIGHT",
},
glow = Defaults.Options.glow
},
---@type TotemsWidgetTable
totems = {
Expand Down
4 changes: 4 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ L.useDeathColor = L["Enable Death Color"]
L.barAlpha = L["Health Bar Alpha"]
L.lossAlpha = L["Health Loss Alpha"]
L.backgroundAlpha = L["Background Alpha"]
L.none = L["None"]
L.pixel = L["Pixel"]
L.shine = L["Shine"]
L.proc = L["Proc"]

-- Tabs
L.unitFramesTab = "Unit Frames"
Expand Down
121 changes: 117 additions & 4 deletions Menu/Builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Builder.MenuOptions = {
TrueSingleSizeOptions = 33,
TotemOptions = 34,
HideAtMaxLevel = 35,
HideOutOfCombat = 36
HideOutOfCombat = 36,
Glow = 37
}

-------------------------------------------------
Expand Down Expand Up @@ -276,10 +277,11 @@ end
---@param minVal number
---@param maxVal number
---@param path string
---@param percentage boolean?
---@return CUFSlider
function Builder:CreateSlider(parent, widgetName, title, width, minVal, maxVal, path)
function Builder:CreateSlider(parent, widgetName, title, width, minVal, maxVal, path, percentage)
---@class CUFSlider: CellSlider
local slider = Cell:CreateSlider(L[title], parent, minVal, maxVal, width or 117, 1)
local slider = Cell:CreateSlider(L[title], parent, minVal, maxVal, width or 117, 1, nil, nil, percentage)
slider.id = "Slider"

slider.Set_DB = HandleWidgetOption
Expand Down Expand Up @@ -311,8 +313,9 @@ end
---@param width number? Default: 117
---@param items DropdownItem[] | string[]
---@param path string
---@param postUpdate? fun(val)
---@return CUFDropdown
function Builder:CreateDropdown(parent, widgetName, title, width, items, path)
function Builder:CreateDropdown(parent, widgetName, title, width, items, path, postUpdate)
---@class CUFDropdown: CellDropdown
local dropdown = Cell:CreateDropdown(parent, width or 117)
dropdown.optionHeight = 20
Expand All @@ -332,6 +335,9 @@ function Builder:CreateDropdown(parent, widgetName, title, width, items, path)
["value"] = value,
["onClick"] = function()
dropdown.Set_DB(widgetName, path, value)
if postUpdate then
postUpdate(value)
end
end,
})
end
Expand Down Expand Up @@ -1179,6 +1185,112 @@ function Builder:CreateTextureDropdown(parent, widgetName, path)
return textureDropdown
end

-------------------------------------------------
-- MARK: Glow
-------------------------------------------------

---@param parent Frame
---@param widgetName WIDGET_KIND
---@return GlowOptions
function Builder:CreateGlowOptions(parent, widgetName)
---@class GlowOptions: OptionsFrame
local f = CUF:CreateFrame(nil, parent, 1, 1, true, true)
f.id = "GlowOptions"
f.optionHeight = 120

local glowTypeItems = { "none", "normal", "pixel", "shine", "proc" }
local glowTypeDropdown = self:CreateDropdown(f, widgetName, L["Glow Type"], nil, glowTypeItems, "glow.type",
function(val) f.updateMenu(val) end)
glowTypeDropdown:SetPoint("TOPLEFT")

if widgetName ~= const.WIDGET_KIND.DISPELS then
local glowColor = self:CreateColorPickerOptions(f, widgetName, L["Glow Color"], "glow.color")
self:AnchorRight(glowColor, glowTypeDropdown)
end

local lines = self:CreateSlider(f, widgetName, L["Lines"], nil, 1, 30, "glow.lines")
self:AnchorBelow(lines, glowTypeDropdown)

local frequency = self:CreateSlider(f, widgetName, L["Frequency"], nil, -2, 2, "glow.frequency")
self:AnchorRight(frequency, lines)

local length = self:CreateSlider(f, widgetName, L["Length"], nil, 1, 50, "glow.length")
self:AnchorRight(length, frequency)

local thickness = self:CreateSlider(f, widgetName, L["Thickness"], nil, 1, 20, "glow.thickness")
self:AnchorBelow(thickness, lines)

local particles = self:CreateSlider(f, widgetName, L["Particles"], nil, 1, 30, "glow.particles")
self:AnchorRight(particles, thickness)

local duration = self:CreateSlider(f, widgetName, L["Duration"], nil, 0.1, 4, "glow.duration")
self:AnchorRight(duration, particles)

local scale = self:CreateSlider(f, widgetName, L["Scale"], nil, 50, 500, "glow.scale", true)
self:AnchorBelow(scale, duration)

---@param type GlowType
f.updateMenu = function(type)
lines:Hide()
frequency:Hide()
length:Hide()
length:Hide()
thickness:Hide()
particles:Hide()
duration:Hide()
scale:Hide()

lines:ClearAllPoints()
frequency:ClearAllPoints()
length:ClearAllPoints()
length:ClearAllPoints()
thickness:ClearAllPoints()
particles:ClearAllPoints()
duration:ClearAllPoints()
scale:ClearAllPoints()

if type == const.GlowType.NONE or type == const.GlowType.NORMAL then
f.wrapperFrame:SetHeight(55)
elseif type == const.GlowType.PIXEL then
lines:Show()
self:AnchorBelow(lines, glowTypeDropdown)

frequency:Show()
self:AnchorRight(frequency, lines)

length:Show()
self:AnchorBelow(length, lines)

thickness:Show()
self:AnchorRight(thickness, length)

f.wrapperFrame:SetHeight(f.optionHeight + 40)
elseif type == const.GlowType.SHINE then
particles:Show()
self:AnchorBelow(particles, glowTypeDropdown)

frequency:Show()
self:AnchorRight(frequency, particles)

scale:Show()
self:AnchorBelow(scale, particles)
f.wrapperFrame:SetHeight(f.optionHeight + 40)
elseif type == const.GlowType.PROC then
duration:Show()
self:AnchorBelow(duration, glowTypeDropdown)
f.wrapperFrame:SetHeight(110)
end
end

local function LoadPageDB()
local glow = HandleWidgetOption(widgetName, const.OPTION_KIND.GLOW) --[[@as GlowOpt]]
f.updateMenu(glow.type)
end
Handler:RegisterOption(LoadPageDB, widgetName, "GlowOptions")

return f
end

-------------------------------------------------
-- MARK: Aura Icon
-------------------------------------------------
Expand Down Expand Up @@ -2021,4 +2133,5 @@ Builder.MenuFuncs = {
[Builder.MenuOptions.TotemOptions] = Builder.CreateTotemOptions,
[Builder.MenuOptions.HideAtMaxLevel] = Builder.CreateHideAtMaxLevel,
[Builder.MenuOptions.HideOutOfCombat] = Builder.CreateHideOutOfCombat,
[Builder.MenuOptions.Glow] = Builder.CreateGlowOptions,
}
12 changes: 12 additions & 0 deletions WidgetAnnotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
---@field iconStyle "none" | "blizzard" | "rhombus"
---@field size number
---@field position PositionOpt
---@field glow GlowOpt

---@class TotemsWidgetTable
---@field enabled boolean
Expand Down Expand Up @@ -376,3 +377,14 @@
---@field offset number
---@field size number
---@field color RGBAOpt

---@class GlowOpt
---@field type GlowType
---@field color RGBAOpt
---@field lines number
---@field frequency number
---@field length number
---@field thickness number
---@field particles number
---@field duration number
---@field scale number
Loading

0 comments on commit 9c426ca

Please sign in to comment.