From 30e6aeabe058577cbb89201660c77430c40edadc Mon Sep 17 00:00:00 2001 From: Vollmer Date: Mon, 9 Sep 2024 18:03:08 +0200 Subject: [PATCH] [Feature] Shield Bar texture option (#62) * add default color/texture for shieldBar * Fire "UpdateWidget" event for shieldBar * set style for shieldBar * locale --- Data/Defaults.lua | 9 +++++++++ Locales/enUS.lua | 1 + Menu/ColorTab.lua | 2 +- Widgets/Bars/ShieldBar.lua | 13 +++++++------ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Data/Defaults.lua b/Data/Defaults.lua index 7b59a55..bfe9fac 100644 --- a/Data/Defaults.lua +++ b/Data/Defaults.lua @@ -113,6 +113,7 @@ Defaults.Options.fontWidth = { ---| "comboPoints" ---| "chi" ---| "runes" +---| "shieldBar" ---@class Defaults.Colors Defaults.Colors = { @@ -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 }, } } @@ -227,6 +232,10 @@ Defaults.ColorsMenuOrder = { { "bloodRune", "rgb" }, { "frostRune", "rgb" }, { "unholyRune", "rgb" }, + }, + shieldBar = { + { "texture", "texture" }, + { "color", "rgb" }, } } diff --git a/Locales/enUS.lua b/Locales/enUS.lua index 7958f91..79b82bc 100644 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -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" diff --git a/Menu/ColorTab.lua b/Menu/ColorTab.lua index 51a1842..c27ce6f 100644 --- a/Menu/ColorTab.lua +++ b/Menu/ColorTab.lua @@ -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" diff --git a/Widgets/Bars/ShieldBar.lua b/Widgets/Bars/ShieldBar.lua index 4b3e409..b71fabd 100644 --- a/Widgets/Bars/ShieldBar.lua +++ b/Widgets/Bars/ShieldBar.lua @@ -22,7 +22,6 @@ local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs ------------------------------------------------- menu:AddWidget(const.WIDGET_KIND.SHIELD_BAR, - Builder.MenuOptions.ColorPicker, Builder.MenuOptions.FullAnchor, Builder.MenuOptions.FrameLevel) @@ -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 @@ -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