Skip to content

Commit

Permalink
add builder options
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Sep 5, 2024
1 parent 60b9545 commit 04702d5
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Data/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ const.OPTION_KIND = {
ZOOM = "zoom",
SPELL_WIDTH = "spellWidth",
HIDE_IF_EMPTY_OR_FULL = "hideIfEmptyOrFull",
SPACING = "spacing",
VERTICAL_FILL = "verticalFill",
SAME_SIZE_AS_HEALTH_BAR = "sameSizeAsHealthBar",
}

---@enum AURA_OPTION_KIND
Expand Down
13 changes: 13 additions & 0 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,20 @@ Defaults.Widgets = {
---@type ClassBarWidgetTable
classBar = {
enabled = true,
spacing = 5,
frameLevel = 10,
verticalFill = false,
sameSizeAsHealthBar = true,
size = {
width = 200,
height = 8,
},
position = {
point = "BOTTOMLEFT",
offsetY = 0,
offsetX = 0,
relativePoint = "TOPLEFT",
},
}
}

Expand Down
3 changes: 3 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ L.levelText = "Level Text"
L.readyCheckIcon = "Ready Check Icon"
L.restingIcon = "Resting Icon"
L.castBar = "Cast Bar"
L.classBar = "Class Bar"

-- Misc
L.Frame = "Frame"
Expand All @@ -147,6 +148,8 @@ L.HideDefaultCastBar = "Hide Default Cast Bar"
L.HideDefaultCastBarTooltip = [[Hides the default cast bar.
Reload to show it again after disabling this option.]]
L.texture = "Texture"
L.VerticalFill = "Vertical Fill"
L.SameSizeAsHealthBar = "Same Size As Health Bar"

-- Custom Formats
L.ValidTags = "Valid Tags"
Expand Down
38 changes: 38 additions & 0 deletions Menu/Builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Builder.MenuOptions = {
FullAnchor = 19,
ColorPicker = 20,
CastBarGeneral = 21,
ClassBarOptions = 22,
CastBarTimer = 23,
CastBarSpell = 24,
CastBarSpark = 25,
Expand Down Expand Up @@ -1513,6 +1514,42 @@ function Builder:CreateCastBarIconOptions(parent, widgetName)
return f
end

-------------------------------------------------
-- MARK: Class Bar
-------------------------------------------------

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

-- First Row
f.anchorOptions = self:CreateAnchorOptions(f, widgetName, nil, -1000, 1000)
f.anchorOptions:SetPoint("TOPLEFT", 0, -5)

-- Second Row
f.sizeOptions = self:CreateSizeOptions(f, widgetName, 0, 500)
self:AnchorBelow(f.sizeOptions, f.anchorOptions.anchorDropdown)

f.spacing = self:CreateSlider(f, widgetName, L["Spacing"], nil, 0, 50,
const.OPTION_KIND.SPACING)
self:AnchorRight(f.spacing, f.sizeOptions.sizeHeightSlider)

-- Third Row
f.verticalFill = self:CreateCheckBox(f, widgetName, L.VerticalFill, const.OPTION_KIND.VERTICAL_FILL)
self:AnchorBelow(f.verticalFill, f.sizeOptions.sizeWidthSlider)

f.sameSizeAsHealthBar = self:CreateCheckBox(f, widgetName, L.SameSizeAsHealthBar,
const.OPTION_KIND.SAME_SIZE_AS_HEALTH_BAR)
self:AnchorRightOfCB(f.sameSizeAsHealthBar, f.verticalFill)

return f
end

-------------------------------------------------
-- MARK: MenuBuilder.MenuFuncs
-- Down here because of annotations
Expand Down Expand Up @@ -1547,4 +1584,5 @@ Builder.MenuFuncs = {
[Builder.MenuOptions.CastBarEmpower] = Builder.CreateCastBarEmpowerOptions,
[Builder.MenuOptions.CastBarBorder] = Builder.CreatCastBarBorderOptions,
[Builder.MenuOptions.CastBarIcon] = Builder.CreateCastBarIconOptions,
[Builder.MenuOptions.ClassBarOptions] = Builder.CreateClassBarOptions,
}
11 changes: 5 additions & 6 deletions WidgetAnnotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,11 @@
---@class ClassBarWidgetTable
---@field enabled boolean
---@field frameLevel number
--[[ ---@field position PositionOpt
---@field size SizeOpt ]]
--[[ ---@field colors ClassBarColorsOpt
---@class ClassBarColorsOpt
---@field ]]
---@field position PositionOpt
---@field size SizeOpt
---@field spacing number
---@field verticalFill boolean
---@field sameSizeAsHealthBar boolean

-------------------------------------------------
-- MARK: Generic Options
Expand Down
1 change: 1 addition & 0 deletions Widgets/Bars/ClassBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ local TIMER_TICK_INTERVAL = 0.1
-------------------------------------------------

menu:AddWidget(const.WIDGET_KIND.CLASS_BAR,
Builder.MenuOptions.ClassBarOptions,
Builder.MenuOptions.FrameLevel)

---@param button CUFUnitButton
Expand Down

0 comments on commit 04702d5

Please sign in to comment.