4 local CreateFrame, IsResting = CreateFrame, IsResting;
5 local UnitXP, UnitXPMax, GetXPExhaustion = UnitXP, UnitXPMax, GetXPExhaustion;
6 local CTimerAfter = C_Timer.After;
7 local ExhaustionToolTipText = ExhaustionToolTipText;
8 local GameTooltip = nil;
11 local running = false;
13 local ActionBars = CreateFrame("Frame", "OmaActionBars");
15 local function expBar(parent)
16 local frame = CreateFrame("Frame", "OmaExpBar", parent);
17 frame:SetPoint("BOTTOM");
18 frame:SetWidth(width);
20 frame.base = frame:CreateTexture(nil, "BACKGROUND");
21 frame.base:SetAllPoints();
22 frame.base:SetColorTexture(0, 0, 0, 0.5);
23 frame.bar = frame:CreateTexture(nil, "BORDER");
24 frame.bar:SetPoint("TOPLEFT", frame.base, "TOPLEFT");
25 frame.bar:SetPoint("BOTTOMLEFT", frame.base, "BOTTOMLEFT");
26 frame.bar:SetColorTexture(1, 1, 1);
27 frame.rest = frame:CreateTexture(nil, "BORDER");
28 frame.rest:SetPoint("TOPLEFT", frame.bar, "TOPRIGHT");
29 frame.rest:SetPoint("BOTTOMLEFT", frame.bar, "BOTTOMRIGHT");
30 frame.rest:SetColorTexture(0, 0.3, 1, 0.7);
31 frame.text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
32 frame.text:SetPoint("BOTTOM");
35 local function updateXP()
36 local xp, xpmax = UnitXP("player"), UnitXPMax("player");
37 local rested = GetXPExhaustion();
38 local current = xp/xpmax*width;
39 local space = width - current;
40 frame.bar:SetWidth(current);
42 local restw = rested/xpmax*width;
43 frame.rest:SetWidth(min(space, restw));
45 frame.text:SetFormattedText("%d / %d (+%d)", xp, xpmax, rested/2);
46 frame.bar:SetVertexColor(0, 0.5, 1, 0.9);
49 frame.text:SetFormattedText("%d / %d", xp, xpmax);
50 frame.bar:SetVertexColor(0.6, 0.2, 1, 0.9);
53 local function updater()
55 if running then CTimerAfter(10, updater) end
59 frame:SetScript("OnEvent", function(self, event)
60 if event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" then
62 elseif event == "PLAYER_UPDATE_RESTING" then
65 CTimerAfter(6, updater);
71 frame:RegisterEvent("PLAYER_XP_UPDATE");
72 frame:RegisterEvent("PLAYER_LEVEL_UP");
73 frame:RegisterEvent("PLAYER_UPDATE_RESTING");
74 -- from FrameXML/MainMenuBar.lua
75 frame:SetScript("OnEnter", function(frame) frame.text:Show(); ExhaustionToolTipText(); end);
76 frame:SetScript("OnLeave", function(frame) frame.text:Hide(); GameTooltip:Hide(); end);
79 local function initialize()
80 -- let other addons hook this to anchor tooltip elsewhere
81 GameTooltip = _G["GameTooltip"];
82 if UnitLevel("player") < 110 and not IsXPUserDisabled() then
87 ActionBars:RegisterEvent("PLAYER_LOGIN");
88 ActionBars:SetScript("OnEvent", function(self, event)
89 if event == "PLAYER_LOGIN" then