Skip to content

Commit

Permalink
[Feature] Add Over Shield texture (#76)
Browse files Browse the repository at this point in the history
* add overShield color

* add overShield prop

* add toggle for overShield

* add overShield texture
  • Loading branch information
Krealle authored Sep 15, 2024
1 parent 9cde948 commit 8fed8e1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions Data/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const.OPTION_KIND = {
VERTICAL_FILL = "verticalFill",
SAME_SIZE_AS_HEALTH_BAR = "sameSizeAsHealthBar",
REVERSE_FILL = "reverseFill",
OVER_SHIELD = "overShield",
}

---@enum AURA_OPTION_KIND
Expand Down
7 changes: 5 additions & 2 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Defaults.Colors = {
shieldBar = {
texture = "Interface\\Buttons\\WHITE8X8",
color = { 1, 1, 0, 0.25 },
overShield = { 1, 1, 1, 1 },
}
}

Expand Down Expand Up @@ -236,8 +237,9 @@ Defaults.ColorsMenuOrder = {
{ "unholyRune", "rgb" },
},
shieldBar = {
{ "texture", "texture" },
{ "color", "rgb" },
{ "texture", "texture" },
{ "color", "rgb" },
{ "overShield", "rgb" },
}
}

Expand Down Expand Up @@ -493,6 +495,7 @@ Defaults.Widgets = {
frameLevel = 10,
point = "RIGHT",
reverseFill = false,
overShield = false,
},
---@type CastBarWidgetTable
castBar = {
Expand Down
5 changes: 5 additions & 0 deletions Menu/Builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1579,9 +1579,14 @@ function Builder:CreateShieldBarOptions(parent, widgetName)
const.OPTION_KIND.REVERSE_FILL)
self:AnchorRight(f.reverseFill, f.anchorOptions)

f.overShield = self:CreateCheckBox(f, widgetName, L["Over Shield"],
const.OPTION_KIND.OVER_SHIELD)
self:AnchorRightOfCB(f.overShield, f.reverseFill)

-- Dirty hook, should be made generic really
hooksecurefunc(f.anchorOptions.text, "SetText", function(_, text)
f.reverseFill:SetEnabled(text == L.healthBar)
f.overShield:SetEnabled(text == L.healthBar)
end)

return f
Expand Down
1 change: 1 addition & 0 deletions WidgetAnnotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
---@field frameLevel number
---@field point "RIGHT"|"LEFT"|"healthBar"
---@field reverseFill boolean
---@field overShield boolean

---@class CastBarWidgetTable
---@field enabled boolean
Expand Down
21 changes: 21 additions & 0 deletions Widgets/Bars/ShieldBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function W.UpdateShieldBarWidget(button, unit, setting, subSetting, ...)
widget.reverseFill = styleTable.reverseFill
widget:Repoint()
end
if not setting or setting == const.OPTION_KIND.OVER_SHIELD then
widget.showOverShield = styleTable.overShield
end

if widget.enabled and button:IsVisible() then
widget.Update(button)
Expand All @@ -65,6 +68,9 @@ local function Update(button)
shieldBar:Hide()
return
end
if not shieldBar.showOverShield or shieldBar.currentPoint ~= "healthBar" then
shieldBar.overShieldGlow:Hide()
end

-- Preview
if shieldBar._isSelected then
Expand Down Expand Up @@ -125,6 +131,10 @@ local function ShieldBar_SetValue(bar, percent)
elseif bar.reverseFill then
bar:Repoint()
end

if bar.showOverShield and maxLossWidth == 0 then
bar.overShieldGlow:Show()
end
end

bar:SetWidth(barWidth)
Expand All @@ -151,6 +161,10 @@ local function Repoint(bar, anchorPoint)
bar:SetPoint("TOP", bar.parentHealthBarLoss, "TOP", 0, 0)
bar:SetPoint("BOTTOM", bar.parentHealthBarLoss, "BOTTOM", 0, 0)
bar:SetPoint("LEFT", bar.parentHealthBarLoss, "LEFT", 0, 0)

bar.overShieldGlow:SetPoint("TOPRIGHT")
bar.overShieldGlow:SetPoint("BOTTOMRIGHT")
bar.overShieldGlow:SetWidth(4)
end
end

Expand All @@ -174,6 +188,7 @@ function W:CreateShieldBar(button)
shieldBar.reverseFill = false
shieldBar.currentPoint = "RIGHT"
shieldBar.currentAnchorPoint = ""
shieldBar.showOverShield = false

shieldBar:Hide()
shieldBar:SetBackdrop({ edgeFile = Cell.vars.whiteTexture, edgeSize = 0.1 })
Expand All @@ -182,10 +197,16 @@ function W:CreateShieldBar(button)
local tex = shieldBar:CreateTexture(nil, "BORDER", nil, -7)
tex:SetAllPoints()

local overShieldGlow = shieldBar:CreateTexture(nil, "ARTWORK", nil, -4)
overShieldGlow:SetTexture("Interface\\AddOns\\Cell\\Media\\overshield")
overShieldGlow:Hide()
shieldBar.overShieldGlow = overShieldGlow

function shieldBar:UpdateStyle()
local colors = DB.GetColors().shieldBar
tex:SetTexture(colors.texture)
tex:SetVertexColor(unpack(colors.color))
overShieldGlow:SetVertexColor(unpack(colors.overShield))
end

---@param styleTable ShieldBarWidgetTable
Expand Down

0 comments on commit 8fed8e1

Please sign in to comment.