79feebe - Add boss frames
[wowui.git] / kehys / updater.lua
index 9a673ae..8e1fcc6 100644 (file)
@@ -27,9 +27,14 @@ local ignoredAuras = {
 local powerColors = {
     [Enum.PowerType.Mana] = {0.1, 0.5, 0.9},
     [Enum.PowerType.Rage] = {1, 0, 0},
 local powerColors = {
     [Enum.PowerType.Mana] = {0.1, 0.5, 0.9},
     [Enum.PowerType.Rage] = {1, 0, 0},
+    [Enum.PowerType.Pain] = {1, 0, 0},
     [Enum.PowerType.Focus] = {1, 0.5, 0},
     [Enum.PowerType.Energy] = {1, 0.8, 0},
     [Enum.PowerType.Focus] = {1, 0.5, 0},
     [Enum.PowerType.Energy] = {1, 0.8, 0},
+    [Enum.PowerType.Fury] = {0.8, 0.3, 0.9},
     [Enum.PowerType.RunicPower] = {0.8, 0, 0.2},
     [Enum.PowerType.RunicPower] = {0.8, 0, 0.2},
+    [Enum.PowerType.LunarPower] = {0.3, 0.5, 0.9},
+    [Enum.PowerType.Maelstrom] = {0, 0.5, 1},
+    [Enum.PowerType.Insanity] = {0.4, 0, 0.8},
 };
 
 function addon.FrameUpdate(frame)
 };
 
 function addon.FrameUpdate(frame)
@@ -78,11 +83,11 @@ function addon.FrameUpdate(frame)
             if not frame.text:IsShown() then frame.text:Show() end
         else
             frame.text.status = false;
             if not frame.text:IsShown() then frame.text:Show() end
         else
             frame.text.status = false;
-            if not (frame.nonraid and frame.unit == "target") and frame.text:IsShown() then
+            if frame.raid and frame.text:IsShown() then
                 frame.text:Hide();
             end
         end
                 frame.text:Hide();
             end
         end
-        if frame.nonraid and frame.unit == "player" then
+        if not frame.raid and frame.unit == "player" then
             if InCombatLockdown() then
                 frame.status:SetTexCoord(0.5, 1, 0, 0.484375);
                 frame.status:Show();
             if InCombatLockdown() then
                 frame.status:SetTexCoord(0.5, 1, 0, 0.484375);
                 frame.status:Show();
@@ -93,20 +98,31 @@ function addon.FrameUpdate(frame)
                 frame.status:Hide();
             end
         end
                 frame.status:Hide();
             end
         end
-        -- TODO incoming res, maybe just with events?
         -- health
         local current, hmax = UnitHealth(unit), UnitHealthMax(unit);
         if frame.prev.health ~= current or frame.prev.hmax ~= hmax then
         -- health
         local current, hmax = UnitHealth(unit), UnitHealthMax(unit);
         if frame.prev.health ~= current or frame.prev.hmax ~= hmax then
-            if frame.nonraid and frame.unit == "target" 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;
                 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
                 end
-                if not frame.text:IsShown() then frame.text:Show() end
             end
             frame.prev.health = current;
             frame.prev.hmax = hmax;
             end
             frame.prev.health = current;
             frame.prev.hmax = hmax;
@@ -205,7 +221,7 @@ function addon.FrameUpdate(frame)
                 frame.rounds = 0;
             end
         end
                 frame.rounds = 0;
             end
         end
-        if not frame.nonraid then
+        if frame.raid then
             -- tank CD marker
             if next(frame.tankcd) then
                 if not frame.defensive:IsShown() then frame.defensive:Show() end
             -- tank CD marker
             if next(frame.tankcd) then
                 if not frame.defensive:IsShown() then frame.defensive:Show() end