Mercurial > wow > turok
changeset 4:8ace773d6bfc
suppress castbar latency logic on non-player units
author | Nenue |
---|---|
date | Tue, 15 Dec 2015 10:09:20 -0500 |
parents | 9de4a810fda7 |
children | 8a9a6637f082 |
files | Tek.lua |
diffstat | 1 files changed, 66 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/Tek.lua Tue Dec 15 10:09:11 2015 -0500 +++ b/Tek.lua Tue Dec 15 10:09:20 2015 -0500 @@ -2,6 +2,7 @@ -- User: Krakyn -- Created: 12/4/2015 11:17 PM local T = LibStub("AceAddon-3.0"):GetAddon("Turok") +local db = T.db local TL = 'Tek' local mod = T:NewModule("Tek") local print = function(...) @@ -14,7 +15,8 @@ local TRACKED_EVENTS = {'UNIT_SPELLCAST_START', 'UNIT_SPELLCAST_DELAYED', 'UNIT_SPELLCAST_STOP', 'UNIT_SPELLCAST_FAILED', 'UNIT_SPELLCAST_FAILED_QUIET', 'UNIT_SPELLCAST_INTERRUPTED', 'UNIT_SPELLCAST_SUCCEEDED', 'UNIT_SPELLCAST_CHANNEL_START', 'UNIT_SPELLCAST_CHANNEL_STOP', 'UNIT_SPELLCAST_CHANNEL_UPDATE' } -local FADE_OUT_TIME, FADE_IN_TIME = 1000, 200 -- animation timings +-- animations are a little different here +local FADE_OUT_TIME, FADE_IN_TIME = 1000, 200 -- values MUST be in chronological order local CHANNEL_START, CAST_START, CAST_INTERRUPTED, CAST_SUCCEEDED, CAST_STOPPED, CAST_FAILED, CHANNEL_STOPPED = 1, 2, 3, 4, 5, 6, 7 @@ -27,6 +29,50 @@ [CAST_FAILED] = '_failed', [CHANNEL_STOPPED] = '' } + +-- defaults +db.castbar = { + --T.defaults.castbar = { + width = 300, height = 24, + anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', + posX = 0, posY = 0, + foreground_casting = {0.80784313725, 0.87843137254, 0.0156862745, 1}, + background_casting = {0,0,0,0.4}, + background_interrupted = {1,0,0,1}, + background_failed = {0.60784313725, 0.87843137254, 0.0156862745, 1}, + foreground_interrupted = {1, 0.5, 0, 1}, + foreground_failed = {0,0,0,1}, + foreground_finished = {0.60784313725, 0.87843137254, 0.0156862745, 1}, + background_finished = {0.60784313725, 0.87843137254, 0.0156862745, 1}, + foreground_inset = -1, + fill_direction = 'RIGHT', + fill_inverse = false, + glow_texture = "Tooltip-BigBorder", + glow_size = 2, + spark_texture = "Tooltip-BigBorder", + spark_size = 2, + ['player'] = { + width = 400, height = 36, + anchor = 'TOP', parent = 'TkFocusBar', anchorTo = 'BOTTOM', + posX = 0, posY = 2, + }, + ['target'] = { + width = 400, height = 36, + anchor = 'BOTTOMLEFT', parent = 'TkplayerCastBar', anchorTo = 'TOPRIGHT', + posX = -30, posY = 4, + }, + ['focus'] = { + width = 200, height = 36, + anchor = 'TOPLEFT', parent = 'TkplayerCastBar', anchorTo='BOTTOMRIGHT', + posX = 2, posY = -2 + }, + ['pet'] = { + width = 300, height = 24, + anchor = 'TOPRIGHT', parent = 'TkFocusBar', anchorTo='TOPLEFT', + posX = -2, posY = 0 + }, +} + local inv = T.anchor_inverse local d = T.direction_coord local a = T.anchor_direction @@ -42,44 +88,6 @@ function mod:OnEnable() local db = T.db - db.castbar = { - --T.defaults.castbar = { - width = 300, height = 24, - anchor = 'TOP', parent = 'TkFocusBar', anchorTo = 'BOTTOM', - posX = 0, posY = -2, - foreground_casting = {0.80784313725, 0.87843137254, 0.0156862745, 1}, - background_casting = {0,0,0,0.4}, - background_interrupted = {1,0,0,1}, - background_failed = {0.60784313725, 0.87843137254, 0.0156862745, 1}, - foreground_interrupted = {1, 0.5, 0, 1}, - foreground_failed = {0,0,0,1}, - foreground_finished = {0.60784313725, 0.87843137254, 0.0156862745, 1}, - background_finished = {0.60784313725, 0.87843137254, 0.0156862745, 1}, - foreground_inset = -1, - fill_direction = 'RIGHT', - fill_inverse = false, - glow_texture = "Tooltip-BigBorder", - glow_size = 2, - spark_texture = "Tooltip-BigBorder", - spark_size = 2, - ['player'] = {}, - ['target'] = { - width = 300, height = 24, - anchor = 'BOTTOMLEFT', parent = 'TkplayerCastBar', anchorTo = 'TOPRIGHT', - posX = 4, posY = 4, - }, - ['focus'] = { - width = 300, height = 24, - anchor = 'TOPLEFT', parent = 'TkplayerCastBar', anchorTo='BOTTOMRIGHT', - posX = 2, posY = -2 - }, - ['pet'] = { - width = 300, height = 24, - anchor = 'TOPRIGHT', parent = 'TkFocusBar', anchorTo='TOPLEFT', - posX = -2, posY = 0 - }, - } - self.casting = c self.castbar = {} @@ -101,13 +109,19 @@ T:AddLabel(pc, cdb, 'spelltext') local casttime = T:AddLabel(pc, cdb, 'casttime') - local latency = T:AddLabel(pc, cdb, 'latency') pc.foreground:SetWidth(0) casttime:SetPoint('RIGHT', pc, 'RIGHT') casttime:SetJustifyH('RIGHT') - latency:SetPoint('TOPRIGHT', pc.casttime, 'BOTTOMRIGHT') - latency:SetJustifyH('RIGHT') + + if unit == 'player' then + local lb = pc:CreateTexture('latency', 'OVERLAY') + local lt = T:AddLabel(pc, cdb, 'latency') + lt:SetPoint('TOPRIGHT', pc.casttime, 'BOTTOMRIGHT') + lt:SetJustifyH('RIGHT') + pc.latency = lb + lb.text = lt + end pc.transpt = a[cdb.fill_direction] pc.xtrans = function() return math.min((cdb.width + cdb.foreground_inset) * pc.percent * d[pc.transpt][1], cdb.width) end @@ -131,10 +145,6 @@ pc.unit = unit T:Bar_SetUpdateHandler(pc, self.TekUpdate) - - - - --print('created', fn) end -- Casting table events @@ -147,6 +157,8 @@ self:RegisterEvent('PLAYER_TARGET_CHANGED') self:RegisterEvent('PLAYER_FOCUS_CHANGED') + -- kill default casting bar + -- T.cbscripts = {CastingBarFrame:GetScript('OnUpdate'), CastingBarFrame:GetScript('OnEvent')} CastingBarFrame:SetScript('OnUpdate', nil) CastingBarFrame:SetScript('OnEvent', nil) CastingBarFrame:Hide() @@ -176,6 +188,10 @@ print('|cFFDD77DD'..u..'|r init_cast (spell='..s.displayName..', startTime='..s.startTime..', endTime='..s.endTime..', channel=',s.channel,')') print(self:GetName(), self:IsVisible(), self:IsShown()) + if u == 'player' then + self.latency.text:SetText(s.latency) + end + -- update translation point if s.casting == CHANNEL_START and not cdb.fill_inverse then self.transpt = inv[a[cdb.fill_direction]] @@ -189,7 +205,6 @@ self.icon:SetTexture(s.texture) spelltext:SetText(s.displayName) - latency:SetText(s.latency) self.duration = s.endTime - s.startTime self.fadeIn = s.startTime + (1-alpha) * FADE_IN_TIME self.fadeOut = s.endTime + FADE_OUT_TIME -- needs to exist for target changes @@ -232,9 +247,11 @@ self:SetAlpha(alpha) self.casttime:SetText(nil) self.spelltext:SetText(nil) - self.latency:SetText(nil) self.debugged = false self.percent = 0 + if u == 'player' then + self.latency.text:SetText(nil) + end mod.casting[self.unit] = nil print('|cFFDD77DD'..u..'|r work complete, hiding...') end @@ -330,7 +347,7 @@ function mod:UNIT_SPELLCAST_SUCCEEDED(e, unit, spellname, rank, castID, target) -- Server says: they stopped because they're done - if c[unit].castID == castID and c[unit].casting ~= CHANNEL_START then + if c[unit].castID == castID and c[unit].casting ~= CHANNEL_START then c[unit].casting = CAST_SUCCEEDED c[unit].fade = true end