a0d7f3a - Move away from deprecated power types, only register events once
[wowui.git] / OmaRF / FrameInit.lua
index 9fb853d..51c59e3 100644 (file)
@@ -3,7 +3,11 @@ local _;
 local unpack, pairs, rawget = unpack, pairs, rawget;
 local UnitHealthMax, UnitPowerMax = UnitHealthMax, UnitPowerMax;
 local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
-local SPELL_POWER_MANA = SPELL_POWER_MANA;
+local PowerTypeMana = Enum.PowerType.Mana;
+local PowerTypeRage = Enum.PowerType.Rage;
+local PowerTypeFocus = Enum.PowerType.Focus;
+local PowerTypeEnergy = Enum.PowerType.Energy;
+local PowerTypeRunic = Enum.PowerType.RunicPower;
 
 local M = {};
 OmaFrames = M;
@@ -24,14 +28,14 @@ M.OverlayColorDispel = {1, 0.5, 0, 0.5};
 M.OverlayColorCharm = {0.8, 0, 1, 0.5};
 M.OverlayColorAlert = {1, 0, 0, 0.5};
 M.PowerColors = {
-    [SPELL_POWER_MANA] = {0, 0.5, 1},
-    [SPELL_POWER_RAGE] = {1, 0, 0},
-    [SPELL_POWER_FOCUS] = {1, 0.5, 0},
-    [SPELL_POWER_ENERGY] = {1, 0.8, 0},
-    [SPELL_POWER_RUNIC_POWER] = {0.9, 0, 0.1},
+    [PowerTypeMana] = {0, 0.5, 1},
+    [PowerTypeRage] = {1, 0, 0},
+    [PowerTypeFocus] = {1, 0.5, 0},
+    [PowerTypeEnergy] = {1, 0.8, 0},
+    [PowerTypeRunic] = {0.9, 0, 0.1},
 };
 -- watch to not remove mana entry
-setmetatable(M.PowerColors, {__index = function(t) return rawget(t, SPELL_POWER_MANA) end});
+setmetatable(M.PowerColors, {__index = function(t) return rawget(t, PowerTypeMana) end});
 
 local positions = M.Positions;
 local width, height = M.Width, M.Height;
@@ -137,6 +141,23 @@ local function setupFrame(frame, secure, unit)
     frame.text:SetPoint("CENTER", frame.background, "CENTER", 0, -1);
     frame.text:Hide();
     setupIndicators(frame);
+    -- setup events
+    frame:RegisterEvent("PARTY_MEMBER_ENABLE");
+    frame:RegisterEvent("PARTY_MEMBER_DISABLE");
+    frame:RegisterUnitEvent("UNIT_HEALTH", unit);
+    frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", unit);
+    frame:RegisterUnitEvent("UNIT_MAXHEALTH", unit);
+    frame:RegisterUnitEvent("UNIT_POWER", unit);
+    frame:RegisterUnitEvent("UNIT_MAXPOWER", unit);
+    frame:RegisterUnitEvent("UNIT_DISPLAYPOWER", unit);
+    frame:RegisterUnitEvent("UNIT_NAME_UPDATE", unit);
+    frame:RegisterUnitEvent("UNIT_AURA", unit);
+    frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", unit);
+    frame:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit);
+    frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit);
+    frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", unit);
+    frame:RegisterUnitEvent("UNIT_CONNECTION", unit);
+    frame:RegisterUnitEvent("INCOMING_RESURRECT_CHANGED", unit);
     -- set attributes
     secure:RegisterForClicks("AnyDown");
     secure:SetAttribute("type1", "spell"); -- left click