git
/
wowui.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c711b1a
)
43716fe - Fix rested xp errors, update rested bonus when resting
author
Aleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sun, 28 Jan 2018 15:16:25 +0000
committer
Aleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sun, 28 Jan 2018 15:16:25 +0000
OmaAB/ActionBars.lua
patch
|
blob
|
history
diff --git
a/OmaAB/ActionBars.lua
b/OmaAB/ActionBars.lua
index
f61b9c7
..
facac67
100644
(file)
--- a/
OmaAB/ActionBars.lua
+++ b/
OmaAB/ActionBars.lua
@@
-1,12
+1,14
@@
-- ActionBars.lua
local _;
local min = math.min;
-- ActionBars.lua
local _;
local min = math.min;
-local CreateFrame
= CreateFrame
;
+local CreateFrame
, IsResting = CreateFrame, IsResting
;
local UnitXP, UnitXPMax, GetXPExhaustion = UnitXP, UnitXPMax, GetXPExhaustion;
local UnitXP, UnitXPMax, GetXPExhaustion = UnitXP, UnitXPMax, GetXPExhaustion;
+local CTimerAfter = C_Timer.After;
local ExhaustionToolTipText = ExhaustionToolTipText;
local GameTooltip = nil;
local width = 300;
local ExhaustionToolTipText = ExhaustionToolTipText;
local GameTooltip = nil;
local width = 300;
+local running = false;
local ActionBars = CreateFrame("Frame", "OmaActionBars");
local ActionBars = CreateFrame("Frame", "OmaActionBars");
@@
-33,10
+35,11
@@
local function expBar(parent)
local function updateXP()
local xp, xpmax = UnitXP("player"), UnitXPMax("player");
local rested = GetXPExhaustion();
local function updateXP()
local xp, xpmax = UnitXP("player"), UnitXPMax("player");
local rested = GetXPExhaustion();
- local current
, restw = xp/xpmax*width, rested
/xpmax*width;
+ local current
= xp
/xpmax*width;
local space = width - current;
frame.bar:SetWidth(current);
if rested then
local space = width - current;
frame.bar:SetWidth(current);
if rested then
+ local restw = rested/xpmax*width;
frame.rest:SetWidth(min(space, restw));
frame.rest:Show();
frame.text:SetFormattedText("%d / %d (+%d)", xp, xpmax, rested/2);
frame.rest:SetWidth(min(space, restw));
frame.rest:Show();
frame.text:SetFormattedText("%d / %d (+%d)", xp, xpmax, rested/2);
@@
-47,15
+50,27
@@
local function expBar(parent)
frame.bar:SetVertexColor(0.6, 0.2, 1, 0.9);
end
end
frame.bar:SetVertexColor(0.6, 0.2, 1, 0.9);
end
end
+ local function updater()
+ updateXP();
+ if running then CTimerAfter(10, updater) end
+ end
updateXP();
frame:SetScript("OnEvent", function(self, event)
if event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" then
updateXP();
updateXP();
frame:SetScript("OnEvent", function(self, event)
if event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" then
updateXP();
+ elseif event == "PLAYER_UPDATE_RESTING" then
+ if IsResting() then
+ running = true;
+ CTimerAfter(6, updater);
+ else
+ running = false;
+ end
end
end);
frame:RegisterEvent("PLAYER_XP_UPDATE");
frame:RegisterEvent("PLAYER_LEVEL_UP");
end
end);
frame:RegisterEvent("PLAYER_XP_UPDATE");
frame:RegisterEvent("PLAYER_LEVEL_UP");
+ frame:RegisterEvent("PLAYER_UPDATE_RESTING");
-- from FrameXML/MainMenuBar.lua
frame:SetScript("OnEnter", function(frame) frame.text:Show(); ExhaustionToolTipText(); end);
frame:SetScript("OnLeave", function(frame) frame.text:Hide(); GameTooltip:Hide(); end);
-- from FrameXML/MainMenuBar.lua
frame:SetScript("OnEnter", function(frame) frame.text:Show(); ExhaustionToolTipText(); end);
frame:SetScript("OnLeave", function(frame) frame.text:Hide(); GameTooltip:Hide(); end);