970f937 - Make exp bar contained on its own
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Thu, 1 Feb 2018 13:05:25 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Thu, 1 Feb 2018 13:05:25 +0000
OmaAB/ExpBar.lua [moved from OmaAB/ActionBars.lua with 82% similarity]
OmaAB/OmaAB.toc

similarity index 82%
rename from OmaAB/ActionBars.lua
rename to OmaAB/ExpBar.lua
index facac67..021ac76 100644 (file)
@@ -1,7 +1,7 @@
--- ActionBars.lua
+-- ExpBar.lua
 local _;
 local min = math.min;
-local CreateFrame, IsResting = CreateFrame, IsResting;
+local IsResting = IsResting;
 local UnitXP, UnitXPMax, GetXPExhaustion = UnitXP, UnitXPMax, GetXPExhaustion;
 local CTimerAfter = C_Timer.After;
 local ExhaustionToolTipText = ExhaustionToolTipText;
@@ -9,11 +9,9 @@ local GameTooltip = nil;
 
 local width = 300;
 local running = false;
+local frame = CreateFrame("Frame", "OmaExpBar", UIParent);
 
-local ActionBars = CreateFrame("Frame", "OmaActionBars");
-
-local function expBar(parent)
-    local frame = CreateFrame("Frame", "OmaExpBar", parent);
+local function expBar()
     frame:SetPoint("BOTTOM");
     frame:SetWidth(width);
     frame:SetHeight(10);
@@ -68,6 +66,7 @@ local function expBar(parent)
             end
         end
     end);
+    frame:UnregisterAllEvents();
     frame:RegisterEvent("PLAYER_XP_UPDATE");
     frame:RegisterEvent("PLAYER_LEVEL_UP");
     frame:RegisterEvent("PLAYER_UPDATE_RESTING");
@@ -76,17 +75,12 @@ local function expBar(parent)
     frame:SetScript("OnLeave", function(frame) frame.text:Hide(); GameTooltip:Hide(); end);
 end
 
-local function initialize()
-    -- let other addons hook this to anchor tooltip elsewhere
-    GameTooltip = _G["GameTooltip"];
-    if UnitLevel("player") < 110 and not IsXPUserDisabled() then
-        expBar(UIParent);
-    end
-end
-
-ActionBars:RegisterEvent("PLAYER_LOGIN");
-ActionBars:SetScript("OnEvent", function(self, event)
+frame:RegisterEvent("PLAYER_LOGIN");
+frame:SetScript("OnEvent", function(self, event)
     if event == "PLAYER_LOGIN" then
-        initialize();
+        GameTooltip = _G["GameTooltip"];
+        if UnitLevel("player") < 110 and not IsXPUserDisabled() then
+            return expBar();
+        end
     end
 end);
index 0af84fa..e24adfd 100644 (file)
@@ -4,4 +4,4 @@
 ## Author: schyrio
 ## Notes: My action bars
 
-ActionBars.lua
+ExpBar.lua