.AutoShot.Text [fontstring] |
|
Functions that can be overridden from within a layout: |
- :OverrideAutoShot(startTime, endTime, currentTime) |
- :OverrideText(elapsed) |
|
--]] |
|
local _, class = UnitClass('player'); if(class ~= 'HUNTER') then return end |
local OnDurationUpdate |
do |
local elapsed = 0 |
function OnDurationUpdate(self) |
elapsed = GetTime() |
if(elapsed > self.max) then |
self:SetAlpha(0) |
self:SetScript('OnUpdate', nil) |
else |
self:SetValue(self.min + (elapsed - self.min)) |
|
local start, finish, current = 0, 0, 0 |
local GetTime, GetSpellInfo = |
GetTime, GetSpellInfo |
|
|
local function UpdateDuration(self, elapsed) |
current = GetTime() |
if(current > finish) then |
self:SetAlpha(0) |
self:SetScript('OnUpdate', nil) |
else |
self:SetValue(start + (current - start)) |
|
if(self.Text) then |
if(self.OverrideAutoShot) then |
self:OverrideAutoShot(start, finish, current) |
else |
self.Text:SetFormattedText('%.1f', finish - current) |
if(self.Text) then |
if(self.OverrideText) then |
self:OverrideText(elapsed) |
else |
self.Text:SetFormattedText('%.1f', self.max - elapsed) |
end |
end |
end |
end |
end |
|
local function Update(self, event, unit, spell, rank) |
if(unit ~= 'player' or spell ~= GetSpellInfo(75)) then return end |
local autoshot = self.AutoShot |
|
start = GetTime() |
finish = start + UnitRangedDamage('player') |
local function Update(self, event, unit, spellName) |
if(unit ~= 'player' or spellName ~= GetSpellInfo(75)) then return end |
|
autoshot:SetScript('OnUpdate', UpdateDuration) |
autoshot:SetAlpha(1) |
autoshot:SetMinMaxValues(start, finish) |
local bar = self.AutoShot |
bar.min = GetTime() |
bar.max = bar.min + UnitRangedDamage(unit) |
|
bar:SetAlpha(1) |
bar:SetMinMaxValues(bar.min, bar.max) |
bar:SetScript('OnUpdate', OnDurationUpdate) |
end |
|
local function Enable(self) |