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.
This commit is contained in:
shagu
2022-11-12 15:03:29 +01:00
parent 83afabf3c0
commit f8b2534f94
+6
View File
@@ -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)