Skip to content

Commit

Permalink
[Feature] Shield Bar texture option (#62)
Browse files Browse the repository at this point in the history
* add default color/texture for shieldBar

* Fire "UpdateWidget" event for shieldBar

* set style for shieldBar

* locale
  • Loading branch information
Krealle authored Sep 9, 2024
1 parent 1bc1d54 commit 30e6aea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Defaults.Options.fontWidth = {
---| "comboPoints"
---| "chi"
---| "runes"
---| "shieldBar"

---@class Defaults.Colors
Defaults.Colors = {
Expand Down Expand Up @@ -169,6 +170,10 @@ Defaults.Colors = {
bloodRune = { 1.0, 0.24, 0.24, 1 },
frostRune = { 0.24, 1.0, 1.0, 1 },
unholyRune = { 0.24, 1.0, 0.24, 1 },
},
shieldBar = {
texture = "Interface\\Buttons\\WHITE8X8",
color = { 1, 1, 0, 0.25 },
}
}

Expand Down Expand Up @@ -227,6 +232,10 @@ Defaults.ColorsMenuOrder = {
{ "bloodRune", "rgb" },
{ "frostRune", "rgb" },
{ "unholyRune", "rgb" },
},
shieldBar = {
{ "texture", "texture" },
{ "color", "rgb" },
}
}

Expand Down
1 change: 1 addition & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ L["def:per"] = "Displays the deficit as a percentage."
L["def:per-short"] = "Displays the deficit as a percentage without decimals."

-- Colors
L.color = "Color"
L.stageZero = "Stage 0"
L.stageOne = "Stage 1"
L.stageTwo = "Stage 2"
Expand Down
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" then
if which == "castBar" or which == "shieldBar" then
CUF:Fire("UpdateWidget", DB.GetMasterLayout(), nil, which, const.OPTION_KIND.COLOR)
elseif which == "essence"
or which == "classResources"
Expand Down
13 changes: 7 additions & 6 deletions Widgets/Bars/ShieldBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs
-------------------------------------------------

menu:AddWidget(const.WIDGET_KIND.SHIELD_BAR,
Builder.MenuOptions.ColorPicker,
Builder.MenuOptions.FullAnchor,
Builder.MenuOptions.FrameLevel)

Expand All @@ -32,10 +31,10 @@ menu:AddWidget(const.WIDGET_KIND.SHIELD_BAR,
---@param subSetting string
function W.UpdateShieldBarWidget(button, unit, setting, subSetting, ...)
local widget = button.widgets.shieldBar
local styleTable = DB.GetCurrentWidgetTable(const.WIDGET_KIND.SHIELD_BAR, unit) --[[@as ShieldBarWidgetTable]]
--local styleTable = DB.GetCurrentWidgetTable(const.WIDGET_KIND.SHIELD_BAR, unit) --[[@as ShieldBarWidgetTable]]

if not setting or setting == const.OPTION_KIND.RGBA then
widget:SetColor(unpack(styleTable.rgba))
if not setting or setting == const.OPTION_KIND.COLOR then
widget:UpdateStyle()
end

if widget.enabled and button:IsVisible() then
Expand Down Expand Up @@ -134,8 +133,10 @@ function W:CreateShieldBar(button)
local tex = shieldBar:CreateTexture(nil, "BORDER", nil, -7)
tex:SetAllPoints()

function shieldBar:SetColor(r, g, b, a)
tex:SetColorTexture(r, g, b, a)
function shieldBar:UpdateStyle()
local colors = DB.GetColors().shieldBar
tex:SetTexture(colors.texture)
tex:SetVertexColor(unpack(colors.color))
end

---@param styleTable ShieldBarWidgetTable
Expand Down

0 comments on commit 30e6aea

Please sign in to comment.