From f8b2534f94ce1a82750cc5bef535a5f18cb91e25 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 12 Nov 2022 15:03:29 +0100 Subject: [PATCH] ui-widgets: properly display statusbar zero values Set point to zero if value and max-value are both zero. Previously, if both value and max-value were zero, it displayed the statusbar as 100% due to a division by zero. --- api/ui-widgets.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index 89506fd0..ed1fc405 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -41,6 +41,9 @@ do -- statusbars point = math.min(height, point) point = math.max(0, point) + -- set point to zero if value and max is zero + if val == 0 then point = 0 end + -- set status bar position/size self.bar:SetPoint("TOPLEFT", self, "TOPLEFT", 0, - height + point) self.bar:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, 0) @@ -57,6 +60,9 @@ do -- statusbars point = math.min(width, point) point = math.max(0, point) + -- set point to zero if value and max is zero + if val == 0 then point = 0 end + -- set status bar position/size self.bar:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 0) self.bar:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", - width + point, 0)