Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (98 sloc) 4.09 KB
NRunCast = CreateFrame("Frame",nil,UIParent)
NRunCast:RegisterEvent("PLAYER_LOGIN")
local TimerOnUpdate = function(self,time)
local beforeEnd = self.endTime - GetTime()
local val
if self.inverted then val = self.startTime + beforeEnd
else val = self.endTime - beforeEnd end
self.bar:SetValue(val)
self.timeText:SetFormattedText("%.1f",beforeEnd)
end
local colors = NugRunningConfig.colors
-- function NRunCast.Fill_coloredSpells(self)
-- local _,class = UnitClass("player")
-- if class == "WARLOCK" then
-- NRunCast.coloredSpells = {
-- --[GetSpellInfo(686) ] = colors.CURSE, -- Shadow Bolt
-- [GetSpellInfo(29722)] = colors.FIRE, -- Incinerate
-- [GetSpellInfo(348) ] = colors.FIRE, -- Immo
-- [GetSpellInfo(30108)] = colors.WOOO, -- Unstable Affliction
-- }
-- end
-- if not NRunCast.coloredSpells then NRunCast.coloredSpells = {} end
-- end
NRunCast:SetScript("OnEvent",function(self,event)
local f = NugRunning:CreateTimer()
table.remove(NugRunning.timers)
f.stacktext:Hide()
f:SetScript("OnUpdate",TimerOnUpdate)
f.unit = "player"
f.dstGUID = UnitGUID("player")
f.srcGUID = UnitGUID("player")
f.dontfree = true
f.priority = 9001
f.opts = {}
-- NRunCast:Fill_coloredSpells()
f:RegisterEvent("UNIT_SPELLCAST_START")
f:RegisterEvent("UNIT_SPELLCAST_DELAYED")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("UNIT_SPELLCAST_STOP")
f:RegisterEvent("UNIT_SPELLCAST_FAILED")
f:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
f:SetScript("OnEvent", function(self, event, ...)
return NRunCast[event](self, event, ...)
end)
f.UpdateCastingInfo = function(self,name,texture,startTime,endTime,castID)
self.castID = castID
self.startTime = startTime / 1000
self.endTime = endTime / 1000
self.bar:SetMinMaxValues(self.startTime,self.endTime)
self.icon:SetTexture(texture)
self.spellText:SetText(name)
-- local color = NRunCast.coloredSpells[name] or { 0.6, 0, 1 }
local color = { 0.6, 0, 1 }
self.bar:SetStatusBarColor(unpack(color))
self.bar.bg:SetVertexColor(color[1]*.5,color[2]*.5,color[3]*.5)
self:Show()
end
--~ local point = (NRunDB.growth == "up") and "TOP" or "BOTTOM"
--~ f:SetPoint(point.."LEFT",NugRunning.anchor,"TOPRIGHT",0,0)
end)
function NRunCast.UNIT_SPELLCAST_START(self,event,unit,spell)
if unit ~= self.unit then return end
local name, subText, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit)
self.inverted = false
self:UpdateCastingInfo(name,texture,startTime,endTime,castID)
NugRunning.active[self] = true
NugRunning:ArrangeTimers()
end
NRunCast.UNIT_SPELLCAST_DELAYED = NRunCast.UNIT_SPELLCAST_START
function NRunCast.UNIT_SPELLCAST_CHANNEL_START(self,event,unit,spell)
if unit ~= self.unit then return end
local name, subText, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitChannelInfo(unit)
self.inverted = true
self:UpdateCastingInfo(name,texture,startTime,endTime,castID)
NugRunning.active[self] = true
NugRunning:ArrangeTimers()
end
NRunCast.UNIT_SPELLCAST_CHANNEL_UPDATE = NRunCast.UNIT_SPELLCAST_CHANNEL_START
function NRunCast.UNIT_SPELLCAST_STOP(self, event, unit, spell)
if unit ~= self.unit then return end
self:Hide()
NugRunning.active[self] = nil
NugRunning:ArrangeTimers()
end
function NRunCast.UNIT_SPELLCAST_FAILED(self, event, unit, spell, _,castID)
if unit ~= self.unit then return end
if self.castID == castID then NRunCast.UNIT_SPELLCAST_STOP(self, event, unit, spell) end
end
NRunCast.UNIT_SPELLCAST_INTERRUPTED = NRunCast.UNIT_SPELLCAST_STOP
NRunCast.UNIT_SPELLCAST_CHANNEL_STOP = NRunCast.UNIT_SPELLCAST_STOP
function NRunCast.PLAYER_TARGET_CHANGED(self)
local newguid = UnitGUID("target") or UnitGUID("player")
self.dstGUID = newguid
NugRunning:ArrangeTimers()
end