Skip to content

Commit

Permalink
[Feature] Health Bar Orientation Option (#72)
Browse files Browse the repository at this point in the history
* defaults

* add dropdown

* use own orientation
  • Loading branch information
Krealle authored Sep 14, 2024
1 parent 3299023 commit 6e4a46e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ Defaults.Widgets = {
---@field parent Unit?
---@field anchorToParent boolean?
---@field anchorPosition ParentAnchor?
---@field barOrientation string

---@alias UnitLayoutTable table<Unit, UnitLayout>
---@type UnitLayoutTable
Expand All @@ -619,6 +620,7 @@ Defaults.Layouts = {
widgets = Defaults.Widgets,
hideBlizzardCastBar = false,
clickCast = false,
barOrientation = "horizontal",
},
target = {
enabled = false,
Expand All @@ -643,6 +645,7 @@ Defaults.Layouts = {
sameSizeAsPlayer = false,
clickCast = false,
mirrorPlayer = false,
barOrientation = "horizontal",
},
focus = {
enabled = false,
Expand All @@ -666,6 +669,7 @@ Defaults.Layouts = {
},
sameSizeAsPlayer = false,
clickCast = false,
barOrientation = "horizontal",
},
targettarget = {
enabled = false,
Expand All @@ -689,6 +693,7 @@ Defaults.Layouts = {
offsetX = 2,
offsetY = 0
},
barOrientation = "horizontal",
},
pet = {
enabled = false,
Expand Down Expand Up @@ -716,5 +721,6 @@ Defaults.Layouts = {
offsetX = 0,
offsetY = -5
},
barOrientation = "horizontal",
},
}
33 changes: 33 additions & 0 deletions UnitFrames/MenuOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ local function AddLoadPageDB(unitPage)
end
end

unitPage.barOrientationDropdown:SetSelectedValue(pageDB.barOrientation)

unitPage.enabledCB:SetChecked(pageDB.enabled)
end
CUF:RegisterCallback("LoadPageDB", "Units_" .. unitPage.id .. "_LoadPageDB", LoadPageDB)
Expand Down Expand Up @@ -156,6 +158,37 @@ local function AddUnitsToMenu()
CUF:SetTooltips(unitPage.copyFromDropdown, "ANCHOR_TOPLEFT", 0, 3, L.CopyWidgetsFrom,
L.CopyWidgetsFromTooltip)

---@type CellDropdown
unitPage.barOrientationDropdown = Cell:CreateDropdown(unitPage.frame, 117)
unitPage.barOrientationDropdown:SetPoint("TOPLEFT", unitPage.copyFromDropdown, "TOPRIGHT", 40, 0)
unitPage.barOrientationDropdown:SetLabel(L["Bar Orientation"])
unitPage.barOrientationDropdown:SetItems({
{
["text"] = L["Horizontal"],
["value"] = "horizontal",
["onClick"] = function()
CUF.DB.SelectedLayoutTable()[unit].barOrientation = "horizontal"
CUF:Fire("UpdateLayout", CUF.vars.selectedLayout, "barOrientation", unit)
end,
},
{
["text"] = L["Vertical"] .. " A",
["value"] = "vertical",
["onClick"] = function()
CUF.DB.SelectedLayoutTable()[unit].barOrientation = "vertical"
CUF:Fire("UpdateLayout", CUF.vars.selectedLayout, "barOrientation", unit)
end,
},
{
["text"] = L["Vertical"] .. " B",
["value"] = "vertical_health",
["onClick"] = function()
CUF.DB.SelectedLayoutTable()[unit].barOrientation = "vertical_health"
CUF:Fire("UpdateLayout", CUF.vars.selectedLayout, "barOrientation", unit)
end,
},
})

-- Third row

---@type CellSlider
Expand Down
3 changes: 1 addition & 2 deletions UnitFrames/UnitButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function U:UpdateUnitButtonLayout(unit, kind, button)

-- NOTE: SetOrientation BEFORE SetPowerSize
if not kind or kind == "barOrientation" then
U:SetOrientation(button, Cell.vars.currentLayoutTable.barOrientation[1],
Cell.vars.currentLayoutTable.barOrientation[2])
U:SetOrientation(button, layout[unit].barOrientation, false)
end

if not kind or strfind(kind, "power$") or kind == "barOrientation" then
Expand Down

0 comments on commit 6e4a46e

Please sign in to comment.