From 970f9377d0344b60ab9b77796135726bfecfdd20 Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Thu, 1 Feb 2018 15:05:25 +0200 Subject: [PATCH] Make exp bar contained on its own --- OmaAB/{ActionBars.lua => ExpBar.lua} | 28 +++++++++++----------------- OmaAB/OmaAB.toc | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) rename OmaAB/{ActionBars.lua => ExpBar.lua} (82%) diff --git a/OmaAB/ActionBars.lua b/OmaAB/ExpBar.lua similarity index 82% rename from OmaAB/ActionBars.lua rename to OmaAB/ExpBar.lua index facac67..021ac76 100644 --- a/OmaAB/ActionBars.lua +++ b/OmaAB/ExpBar.lua @@ -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); diff --git a/OmaAB/OmaAB.toc b/OmaAB/OmaAB.toc index 0af84fa..e24adfd 100644 --- a/OmaAB/OmaAB.toc +++ b/OmaAB/OmaAB.toc @@ -4,4 +4,4 @@ ## Author: schyrio ## Notes: My action bars -ActionBars.lua +ExpBar.lua -- 2.39.5