From fa297de5bb051aa6613c223a948f59bef89699c5 Mon Sep 17 00:00:00 2001 From: Vollmer Date: Thu, 29 Aug 2024 23:58:32 +0200 Subject: [PATCH] impl hideIfEmptyOrFull logic --- Widgets/Texts/HealthText.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Widgets/Texts/HealthText.lua b/Widgets/Texts/HealthText.lua index d25cd56..b601fcc 100644 --- a/Widgets/Texts/HealthText.lua +++ b/Widgets/Texts/HealthText.lua @@ -45,6 +45,9 @@ function W.UpdateHealthTextWidget(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) @@ -343,6 +346,7 @@ function W:CreateHealthText(button) healthText.textFormat = "" healthText._showingAbsorbs = false + healthText.hideIfEmptyOrFull = false healthText.SetFormat = HealthText_SetFormat healthText.SetTextFormat = HealthText_SetTextFormat @@ -351,7 +355,12 @@ function W:CreateHealthText(button) function healthText:UpdateValue() local health, healthMax, totalAbsorbs = GetHealthInfo(self._owner.states.displayedUnit, self._showingAbsorbs) if self.enabled and healthMax ~= 0 then - self:SetValue(health, healthMax, totalAbsorbs) + if self.hideIfEmptyOrFull and (health == 0 or health == healthMax) then + self:Hide() + else + self:SetValue(health, healthMax, totalAbsorbs) + self:Show() + end end end