Skip to content

Commit

Permalink
[Feature] Frame Highlighting (#196)
Browse files Browse the repository at this point in the history
* annotations

* widget kind const

* defaults

* add menu options

* add color options

* Implement Widget

* add widget to all units

* locale
  • Loading branch information
Krealle authored Dec 20, 2024
1 parent 9d1fd25 commit 142066f
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cell_UnitFrames.toc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Widgets/Auras/Dispels.lua
Widgets/Auras/Totems.lua

Widgets/Misc/Fader.lua
Widgets/Misc/Highlight.lua

UnitFrames/UnitButton.xml
UnitFrames/UnitButton.lua
Expand Down
5 changes: 4 additions & 1 deletion Data/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ const.WIDGET_KIND = {
HEAL_ABSORB = "healAbsorb",
DISPELS = "dispels",
TOTEMS = "totems",
FADER = "fader"
FADER = "fader",
HIGHLIGHT = "highlight",
}

---@enum OPTION_KIND
Expand Down Expand Up @@ -181,6 +182,8 @@ const.OPTION_KIND = {
TIME_TO_HOLD = "timeToHold",
INTERRUPTED_LABEL = "interruptedLabel",
ICON_TEXTURE = "iconTexture",
TARGET = "target",
HOVER = "hover",
}

---@enum AURA_OPTION_KIND
Expand Down
33 changes: 27 additions & 6 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Defaults.Options.glow = {
---| "healAbsorb"
---| "unitFrames"
---| "classBar"
---| "highlight"

---@class Defaults.Colors
Defaults.Colors = {
Expand Down Expand Up @@ -220,6 +221,10 @@ Defaults.Colors = {
},
classBar = {
texture = "Interface\\Buttons\\WHITE8X8",
},
highlight = {
target = { 1, 0.3, 0.3, 1 },
hover = { 1, 1, 1, 1 }
}
}

Expand Down Expand Up @@ -309,6 +314,10 @@ Defaults.ColorsMenuOrder = {
},
classBar = {
{ "texture", "texture" },
},
highlight = {
{ "target", "rgb" },
{ "hover", "rgb" },
}
}

Expand Down Expand Up @@ -772,7 +781,14 @@ Defaults.Widgets = {
fadeDuration = 0.25,
maxAlpha = 1,
minAlpha = 0.35,
}
},
---@type HighlightWidgetTable
highlight = {
enabled = false,
hover = true,
target = true,
size = 1,
},
}

-- Boss Widgets
Expand Down Expand Up @@ -903,7 +919,8 @@ Defaults.Layouts = {
castBar = Defaults.Widgets.castBar,
healAbsorb = Defaults.Widgets.healAbsorb,
dispels = Defaults.Widgets.dispels,
fader = Defaults.Widgets.fader
fader = Defaults.Widgets.fader,
highlight = Defaults.Widgets.highlight,
},
sameSizeAsPlayer = false,
clickCast = false,
Expand Down Expand Up @@ -936,7 +953,8 @@ Defaults.Layouts = {
castBar = Defaults.Widgets.castBar,
healAbsorb = Defaults.Widgets.healAbsorb,
dispels = Defaults.Widgets.dispels,
fader = Defaults.Widgets.fader
fader = Defaults.Widgets.fader,
highlight = Defaults.Widgets.highlight,
},
anchorToParent = false,
parent = CUF.constants.UNIT.PLAYER,
Expand Down Expand Up @@ -965,7 +983,8 @@ Defaults.Layouts = {
powerText = Defaults.Widgets.powerText,
levelText = Defaults.Widgets.levelText,
raidIcon = Defaults.Widgets.raidIcon,
fader = Defaults.Widgets.fader
fader = Defaults.Widgets.fader,
highlight = Defaults.Widgets.highlight,
},
sameSizeAsPlayer = false,
clickCast = false,
Expand Down Expand Up @@ -1002,7 +1021,8 @@ Defaults.Layouts = {
castBar = Defaults.Widgets.castBar,
healAbsorb = Defaults.Widgets.healAbsorb,
dispels = Defaults.Widgets.dispels,
fader = Defaults.Widgets.fader
fader = Defaults.Widgets.fader,
highlight = Defaults.Widgets.highlight,
},
sameSizeAsPlayer = false,
clickCast = false,
Expand Down Expand Up @@ -1041,7 +1061,8 @@ Defaults.Layouts = {
buffs = Defaults.Widgets_Boss.buffs,
debuffs = Defaults.Widgets_Boss.debuffs,
castBar = Defaults.Widgets_Boss.castBar,
fader = Defaults.Widgets.fader
fader = Defaults.Widgets.fader,
highlight = Defaults.Widgets.highlight,
},
healthBarColorType = CUF.constants.UnitButtonColorType.CELL,
healthLossColorType = CUF.constants.UnitButtonColorType.CUSTOM,
Expand Down
2 changes: 2 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ L.classBar = "Class Bar"
L.healthBar = "Health Bar"
L.healAbsorb = "Heal Absorb"
L.totems = "Totems"
L.highlight = "Highlight"

-- Misc
L.Frame = "Frame"
Expand Down Expand Up @@ -391,3 +392,4 @@ L.HelpTip_BlizzardFramesToggle = "Click here to toggle Blizzard Frames"
-- Aliases
-- !!DO NOT ADD TO CURSEFORGE!!
L.unitFrames = L.UnitFrames
L.hover = L.Hover
27 changes: 27 additions & 0 deletions Menu/Builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Builder.MenuOptions = {
HideOutOfCombat = 36,
Glow = 37,
IconTexture = 38,
Highlight = 39,
}

local FAILED = FAILED or "Failed"
Expand Down Expand Up @@ -2143,6 +2144,31 @@ function Builder:CreateTotemOptions(parent, widgetName)
return f
end

-------------------------------------------------
-- MARK: Highlight
-------------------------------------------------

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

local targetCB = self:CreateCheckBox(f, widgetName, L.target, const.OPTION_KIND.TARGET)
targetCB:SetPoint("TOPLEFT", 0, 10)
local hoverCB = self:CreateCheckBox(f, widgetName, L.Hover, const.OPTION_KIND.HOVER)
self:AnchorRightOfCB(hoverCB, targetCB)

local sizeSlider = self:CreateSlider(f, widgetName, L["Highlight Size"], nil, -5, 5,
const.OPTION_KIND.SIZE)
self:AnchorBelow(sizeSlider, targetCB)

return f
end

-------------------------------------------------
-- MARK: MenuBuilder.MenuFuncs
-- Down here because of annotations
Expand Down Expand Up @@ -2187,4 +2213,5 @@ Builder.MenuFuncs = {
[Builder.MenuOptions.HideOutOfCombat] = Builder.CreateHideOutOfCombat,
[Builder.MenuOptions.Glow] = Builder.CreateGlowOptions,
[Builder.MenuOptions.IconTexture] = Builder.CreateIconTextureOptions,
[Builder.MenuOptions.Highlight] = Builder.CreateHighlightOptions,
}
2 changes: 1 addition & 1 deletion Menu/ColorTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ local function CreateColorPicker(which, colorName, colorTable, parent)
cp:SetColor(colorTable[colorName])
cp.onChange = function(r, g, b, a)
DB.SetColor(which, colorName, { r, g, b, a })
if which == "castBar" or which == "shieldBar" or which == "healAbsorb" then
if which == "castBar" or which == "shieldBar" or which == "healAbsorb" or which == "highlight" then
CUF:Fire("UpdateWidget", DB.GetMasterLayout(), nil, which, const.OPTION_KIND.COLOR)
elseif which == "essence"
or which == "classResources"
Expand Down
9 changes: 9 additions & 0 deletions WidgetAnnotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
---| DispelsWidgetTable
---| TotemsWidgetTable
---| FaderWidgetTable
---| HighlightWidgetTable

---@alias Widget
---| NameTextWidget
Expand All @@ -41,6 +42,7 @@
---| DispelsWidget
---| TotemsWidget
---| FaderWidget
---| HighlightWidget

---@class CUFUnitButton.Widgets
---@field healthBar HealthBarWidget
Expand Down Expand Up @@ -70,6 +72,7 @@
---@field dispels DispelsWidget
---@field totems TotemsWidget
---@field fader FaderWidget
---@field highlight HighlightWidget

---@class BaseWidget
---@field enabled boolean
Expand Down Expand Up @@ -324,6 +327,12 @@
---@field maxAlpha number
---@field minAlpha number

---@class HighlightWidgetTable
---@field enabled boolean
---@field hover boolean
---@field target boolean
---@field size number

-------------------------------------------------
-- MARK: Generic Options
-------------------------------------------------
Expand Down
Loading

0 comments on commit 142066f

Please sign in to comment.