79feebe - Add boss frames
[wowui.git] / kehys / updater.lua
index 3690953..8e1fcc6 100644 (file)
@@ -83,7 +83,7 @@ function addon.FrameUpdate(frame)
             if not frame.text:IsShown() then frame.text:Show() end
         else
             frame.text.status = false;
-            if (frame.raid or frame.unit ~= "target") and frame.text:IsShown() then
+            if frame.raid and frame.text:IsShown() then
                 frame.text:Hide();
             end
         end
@@ -101,17 +101,28 @@ function addon.FrameUpdate(frame)
         -- health
         local current, hmax = UnitHealth(unit), UnitHealthMax(unit);
         if frame.prev.health ~= current or frame.prev.hmax ~= hmax then
-            if not frame.raid and frame.unit == "target" and not frame.text.status
-               and frame.prev.htext ~= current then
+            if not frame.raid and not frame.text.status and frame.prev.htext ~= current then
                 frame.prev.htext = current;
-                if current > 1000000000 then -- 1.0B
-                    frame.text:SetFormattedText("%.2fB", current / 1000000000);
-                elseif current > 1000000 then -- 1.0M
-                    frame.text:SetFormattedText("%.2fM", current / 1000000);
-                elseif current > 1000 then -- 1.0K
-                    frame.text:SetFormattedText("%.1fK", current / 1000);
+                if frame.boss then
+                    if hmax < current or hmax <= 1 then
+                        frame.text:SetText("100");
+                        if not frame.text:IsShown() then frame.text:Show() end
+                    elseif current <= 0 then
+                        if frame.text:IsShown() then frame.text:Hide() end
+                    else
+                        frame.text:SetFormattedText("%.1f", current/hmax*100);
+                        if not frame.text:IsShown() then frame.text:Show() end
+                    end
+                else
+                    if current > 1000000000 then -- 1.0B
+                        frame.text:SetFormattedText("%.2fB", current / 1000000000);
+                    elseif current > 1000000 then -- 1.0M
+                        frame.text:SetFormattedText("%.2fM", current / 1000000);
+                    elseif current > 1000 then -- 1.0K
+                        frame.text:SetFormattedText("%.1fK", current / 1000);
+                    end
+                    if not frame.text:IsShown() then frame.text:Show() end
                 end
-                if not frame.text:IsShown() then frame.text:Show() end
             end
             frame.prev.health = current;
             frame.prev.hmax = hmax;