From 3d8547df6c696ca477e36b0c49c0723ddfc563a9 Mon Sep 17 00:00:00 2001 From: Vollmer Date: Fri, 30 Aug 2024 00:06:48 +0200 Subject: [PATCH 1/2] add hideIfEmptyOrFull toggle --- Menu/Builder.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Menu/Builder.lua b/Menu/Builder.lua index 108817d..2f0e863 100644 --- a/Menu/Builder.lua +++ b/Menu/Builder.lua @@ -893,7 +893,7 @@ function Builder:CreatePowerFormatOptions(parent, widgetName) ---@class PowerFormatOptions: OptionsFrame local f = CUF:CreateFrame(nil, parent, 1, 1, true, true) - f.optionHeight = 70 + f.optionHeight = 100 f.id = "PowerFormatOptions" f.formatDropdown = self:CreateDropdown(parent, widgetName, "Format", 200, @@ -917,6 +917,10 @@ function Builder:CreatePowerFormatOptions(parent, widgetName) SetEnabled(text == L["Custom"]) end) + f.hideIfEmptyOrFull = self:CreateCheckBox(f, widgetName, L["hideIfEmptyOrFull"], + const.OPTION_KIND.HIDE_IF_EMPTY_OR_FULL) + self:AnchorBelow(f.hideIfEmptyOrFull, f.formatEditBox, 35) + local function LoadPageDB() SetEnabled(HandleWidgetOption(widgetName, const.OPTION_KIND.FORMAT) == const.PowerTextFormat.CUSTOM) end From dde37be6c1051cc883a23ee1d98da3243d67da06 Mon Sep 17 00:00:00 2001 From: Vollmer Date: Fri, 30 Aug 2024 00:06:54 +0200 Subject: [PATCH 2/2] impl hideIfEmptyOrFull logic --- Widgets/Texts/PowerText.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Widgets/Texts/PowerText.lua b/Widgets/Texts/PowerText.lua index 7e5a7d2..a68f7ab 100644 --- a/Widgets/Texts/PowerText.lua +++ b/Widgets/Texts/PowerText.lua @@ -45,6 +45,9 @@ function W.UpdatePowerTextWidget(button, unit, setting, subSetting) widget:SetTextFormat(styleTable.textFormat) widget:SetFormat(styleTable.format) end + if not setting or setting == const.OPTION_KIND.HIDE_IF_EMPTY_OR_FULL then + widget.hideIfEmptyOrFull = styleTable.hideIfEmptyOrFull + end if widget.enabled and button:IsVisible() then widget.Update(button) @@ -167,6 +170,7 @@ function W:CreatePowerText(button) button.widgets.powerText = powerText powerText.textFormat = "" + powerText.hideIfEmptyOrFull = false powerText.SetFormat = PowerText_SetFormat powerText.SetTextFormat = PowerText_SetTextFormat @@ -176,6 +180,11 @@ function W:CreatePowerText(button) local powerMax = UnitPowerMax(button.states.unit) local power = UnitPower(button.states.unit) + if self.hideIfEmptyOrFull and (power == 0 or power == powerMax) then + self:Hide() + return + end + if powerMax > 0 and power then button.widgets.powerText:SetValue(power, powerMax) button.widgets.powerText:Show()