4 local CreateFrame = CreateFrame;
5 local UnitXP, UnitXPMax, GetXPExhaustion = UnitXP, UnitXPMax, GetXPExhaustion;
6 local ExhaustionToolTipText = ExhaustionToolTipText;
7 local GameTooltip = nil;
11 local ActionBars = CreateFrame("Frame", "OmaActionBars");
13 local function expBar(parent)
14 local frame = CreateFrame("Frame", "OmaExpBar", parent);
15 frame:SetPoint("BOTTOM");
16 frame:SetWidth(width);
18 frame.base = frame:CreateTexture(nil, "BACKGROUND");
19 frame.base:SetAllPoints();
20 frame.base:SetColorTexture(0, 0, 0, 0.5);
21 frame.bar = frame:CreateTexture(nil, "BORDER");
22 frame.bar:SetPoint("TOPLEFT", frame.base, "TOPLEFT");
23 frame.bar:SetPoint("BOTTOMLEFT", frame.base, "BOTTOMLEFT");
24 frame.bar:SetColorTexture(1, 1, 1);
25 frame.rest = frame:CreateTexture(nil, "BORDER");
26 frame.rest:SetPoint("TOPLEFT", frame.bar, "TOPRIGHT");
27 frame.rest:SetPoint("BOTTOMLEFT", frame.bar, "BOTTOMRIGHT");
28 frame.rest:SetColorTexture(0, 0.3, 1, 0.7);
29 frame.text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
30 frame.text:SetPoint("BOTTOM");
33 local function updateXP()
34 local xp, xpmax = UnitXP("player"), UnitXPMax("player");
35 local rested = GetXPExhaustion();
36 local current, restw = xp/xpmax*width, rested/xpmax*width;
37 local space = width - current;
38 frame.bar:SetWidth(current);
40 frame.rest:SetWidth(min(space, restw));
42 frame.text:SetFormattedText("%d / %d (+%d)", xp, xpmax, rested/2);
43 frame.bar:SetVertexColor(0, 0.5, 1, 0.9);
46 frame.text:SetFormattedText("%d / %d", xp, xpmax);
47 frame.bar:SetVertexColor(0.6, 0.2, 1, 0.9);
52 frame:SetScript("OnEvent", function(self, event)
53 if event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" then
57 frame:RegisterEvent("PLAYER_XP_UPDATE");
58 frame:RegisterEvent("PLAYER_LEVEL_UP");
59 -- from FrameXML/MainMenuBar.lua
60 frame:SetScript("OnEnter", function(frame) frame.text:Show(); ExhaustionToolTipText(); end);
61 frame:SetScript("OnLeave", function(frame) frame.text:Hide(); GameTooltip:Hide(); end);
64 local function initialize()
65 -- let other addons hook this to anchor tooltip elsewhere
66 GameTooltip = _G["GameTooltip"];
67 if UnitLevel("player") < 110 and not IsXPUserDisabled() then
72 ActionBars:RegisterEvent("PLAYER_LOGIN");
73 ActionBars:SetScript("OnEvent", function(self, event)
74 if event == "PLAYER_LOGIN" then