castbar: prefer unitstrings over names

This commit is contained in:
shagu
2019-08-30 19:57:45 +02:00
parent 191ee8fed2
commit 89fec7abdc
2 changed files with 10 additions and 6 deletions
+6
View File
@@ -51,6 +51,9 @@ local libcast = CreateFrame("Frame", "pfEnemyCast")
local player = UnitName("player")
UnitChannelInfo = _G.UnitChannelInfo or function(unit)
-- convert to name if unitstring was given
unit = pfValidUnits[unit] and UnitName(unit) or unit
local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill
local db = libcast.db[unit]
@@ -77,6 +80,9 @@ UnitChannelInfo = _G.UnitChannelInfo or function(unit)
end
UnitCastingInfo = _G.UnitCastingInfo or function(unit)
-- convert to name if unitstring was given
unit = pfValidUnits[unit] and UnitName(unit) or unit
local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill
local db = libcast.db[unit]
+4 -6
View File
@@ -92,10 +92,10 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function ()
local name = this.unitstr and UnitName(this.unitstr) or this.unitname
if not name then return end
local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(name)
local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(this.unitstr or this.unitname)
if not cast then
-- scan for channel spells if no cast was found
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(name)
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(this.unitstr or this.unitname)
end
if cast then
@@ -167,13 +167,11 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function ()
if this.unitstr and not UnitIsUnit(this.unitstr, "player") then return end
if event == CASTBAR_EVENT_CAST_DELAY then
local name = this.unitstr and UnitName(this.unitstr) or this.unitname
local isCast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(name)
local isCast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(this.unitstr or this.unitname)
if not isCast then return end
this.delay = this.delay + (endTime - this.endTime) / 1000
elseif event == CASTBAR_EVENT_CHANNEL_DELAY then
local name = this.unitstr and UnitName(this.unitstr) or this.unitname
local isChannel, _, _, _, startTime, endTime = UnitChannelInfo(name)
local isChannel, _, _, _, startTime, endTime = UnitChannelInfo(this.unitstr or this.unitname)
if not isChannel then return end
this.delay = ( this.delay or 0 ) + this.bar:GetValue() - (endTime/1000 - GetTime())
end