Fix the start time of an action displayed in the icon.
Johnny C. Lam [11-15-13 - 19:58]
Fix the start time of an action displayed in the icon.
This had assumed that the current time was in the first interval of the
time-span, which is not always true. Implement a new method for
OvaleTimeSpan to determine the next time given a starting point, and use
that method instead of making the assumption.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1177 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index 68585f0..2fc6ec8 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -22,6 +22,7 @@ do
local OvaleGUID = Ovale.OvaleGUID
local OvaleOptions = Ovale.OvaleOptions
local OvaleState = Ovale.OvaleState
+ local OvaleTimeSpan = Ovale.OvaleTimeSpan
local Type = "OvaleFrame"
local Version = 7
@@ -34,6 +35,7 @@ do
local API_GetSpellTexture = GetSpellTexture
local API_GetTime = GetTime
local API_RegisterStateDriver = RegisterStateDriver
+ local NextTime = OvaleTimeSpan.NextTime
--</private-static-properties>
--<public-methods>
@@ -186,7 +188,7 @@ do
Ovale:Logf("****Master Node %d", k)
OvaleBestAction:StartNewAction()
local timeSpan, _, element = OvaleBestAction:Compute(node)
- local start = timeSpan[1]
+ local start = NextTime(timeSpan, state.currentTime)
if start then
Ovale:Logf("Compute start = %f", start)
end
@@ -278,7 +280,7 @@ do
end
OvaleState:ApplySpell(spellId, start, start + castTime, nextCast, false, OvaleGUID:GetGUID(spellTarget))
timeSpan, _, element = OvaleBestAction:Compute(node)
- start = timeSpan[1]
+ start = NextTime(timeSpan, state.currentTime)
icons[2]:Update(element, start, OvaleBestAction:GetActionInfo(element))
else
icons[2]:Update(element, nil)
diff --git a/OvaleTimeSpan.lua b/OvaleTimeSpan.lua
index 1f098b9..88d6b1b 100644
--- a/OvaleTimeSpan.lua
+++ b/OvaleTimeSpan.lua
@@ -147,6 +147,18 @@ function OvaleTimeSpan:HasTime(atTime)
return false
end
+function OvaleTimeSpan:NextTime(atTime)
+ local A = self
+ local countA = A and #A or 0
+ for i = 1, countA, 2 do
+ if atTime < A[i] then
+ return A[i]
+ elseif A[i] <= atTime and atTime <= A[i+1] then
+ return atTime
+ end
+ end
+end
+
function OvaleTimeSpan:Measure()
local A = self
local countA = A and #A or 0
diff --git a/compiler.pl b/compiler.pl
index 0aad2b8..bf8b2f5 100644
--- a/compiler.pl
+++ b/compiler.pl
@@ -115,6 +115,7 @@ $sp{OvaleTimeSpan}{HasTime} = true;
$sp{OvaleTimeSpan}{Intersect} = true;
$sp{OvaleTimeSpan}{IntersectInterval} = true;
$sp{OvaleTimeSpan}{Measure} = true;
+$sp{OvaleTimeSpan}{NextTime} = true;
$sp{OvaleTimeSpan}{Union} = true;
sub ParseDirectory