WoWInterface SVN oUF_AutoShot

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 8 to Rev 9
    Reverse comparison

Rev 8 → Rev 9

trunk/oUF_AutoShot/oUF_AutoShot.toc
2,7 → 2,7
## Author: p3lim
## Version: 30000.wowi:revision
## Title: oUF AutoShot
## Notes: AutoShot timer support for oUF
## Notes: AutoShot timer plug-in for oUF
## RequiredDeps: oUF
 
oUF_AutoShot.lua
\ No newline at end of file
trunk/oUF_AutoShot/oUF_AutoShot.lua
5,45 → 5,42
.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)
51,12 → 48,11
if(autoshot) then
self:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED', Update)
 
autoshot:SetAlpha(0)
if(not autoshot:GetStatusBarTexture()) then
autoshot:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=])
autobar:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=])
end
 
autoshot:SetAlpha(0)
 
return true
end
end