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 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()