79feebe - Add boss frames
[wowui.git] / kehys / player.lua
index 08ea8fe..ca0bd8b 100644 (file)
@@ -96,7 +96,7 @@ local function initPlayer(parent, width, height, update, event)
     f.healabsorb:Hide();
     f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
     f.text:SetPoint("RIGHT", f, "RIGHT", -2, 8);
-    f.text:SetFont(STANDARD_TEXT_FONT, 13);
+    f.text:SetFont(STANDARD_TEXT_FONT, 15);
     f.text:Hide();
     f.targeticon = f:CreateTexture(nil, "OVERLAY");
     f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1);
@@ -144,17 +144,28 @@ local function initPet(parent, width, height, update, event)
     f.prev = {};
 
     petUpdate = function()
-        CTimerAfter(0.1, petUpdate);
-        update(f);
+        if f.updating then
+            CTimerAfter(0.1, petUpdate);
+            return update(f);
+        end
     end
     f:SetScript("OnEvent", event);
+    f:SetScript("OnHide", function()
+        f:UnregisterAllEvents();
+        f.updating = false;
+        f.prev = {};
+    end);
+    f:SetScript("OnShow", function()
+        addon.RegisterEvents(f);
+        addon.RegisterUnitEvents(f);
+        event(f, "UPDATE_ALL_BARS");
+        f.updating = true;
+        petUpdate();
+    end);
     f:RegisterForClicks("AnyDown");
     f:SetAttribute("*type1", "target");
     f:SetAttribute("*type2", "togglemenu");
     f:SetAttribute("toggleForVehicle", true);
-    RegisterUnitWatch(f);
-    RegisterStateDriver(f, "vehicleui", "[vehicleui] vehicle; no");
-    f:SetAttribute("_onstate-vehicleui", vehicletoggle);
 
     -- create visuals
     f.base = f:CreateTexture(nil, "BACKGROUND");
@@ -193,8 +204,8 @@ local function initPet(parent, width, height, update, event)
     f.name = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
     f.name:SetPoint("LEFT", f, "LEFT", 5, 0);
     f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
-    f.text:SetPoint("RIGHT", f, "RIGHT", -5, 0);
-    f.text:SetFont(STANDARD_TEXT_FONT, 13);
+    f.text:SetPoint("RIGHT", f, "RIGHT", -3, -1);
+    f.text:SetFont(STANDARD_TEXT_FONT, 10);
     f.text:Hide();
     f.targeticon = f:CreateTexture(nil, "OVERLAY");
     f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1);
@@ -203,11 +214,9 @@ local function initPet(parent, width, height, update, event)
     f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
     f.targeticon:Hide();
 
-    addon.RegisterEvents(f);
-    addon.RegisterUnitEvents(f);
-    event(f, "UPDATE_ALL_BARS");
-    petUpdate();
-    f:Show();
+    RegisterUnitWatch(f);
+    RegisterStateDriver(f, "vehicleui", "[vehicleui] vehicle; no");
+    f:SetAttribute("_onstate-vehicleui", vehicletoggle);
 end
 
 CFrame:SetScript("OnEvent", function(self)