Nenue@6: --- Turok Nenue@6: -- @file-author@ Nenue@6: -- @project-revision@ @project-hash@ Nenue@6: -- @file-revision@ @file-hash@ Nenue@6: --- Defines the mechanisms for the storage and dispatch of events data. Nenue@6: --@debug@ Nenue@6: --@end-debug@ Nenue@6: -- GLOBALS: LibStub, Turok, TurokData, ReloadUI Nenue@6: local ADDON, Tk = ... Nenue@6: local db, L Nenue@6: local MAJOR, MINOR = "Turok", "@project-revision@" Nenue@6: local T, LGIST, _G = Tk.Addon, Tk.LGIST, _G Nenue@6: Nenue@6: Nenue@6: local pcall, type, ipairs, pairs, format, tinsert, match, strpad, error = pcall, type, ipairs, pairs, string.format, table.insert, string.match, string.rep, error Nenue@6: local PlaySoundFile, LoadAddOn, IsAddOnLoaded, UnitName, UnitGUID, UnitPowerMax = PlaySoundFile, LoadAddOn, IsAddOnLoaded, UnitName, UnitGUID, UnitPowerMax Nenue@6: local GetSpecializationInfo, GetSpecialization, UnitSpellHaste, GetActiveSpecGroup = GetSpecializationInfo, GetSpecialization, UnitSpellHaste, GetActiveSpecGroup Nenue@6: local UnitInfo, UnitCastingInfo, UnitChannelInfo = UnitInfo, UnitCastingInfo, UnitChannelInfo Nenue@6: local rawset, unpack, tostring, setmetatable, xpcall, unpack = rawset, unpack, tostring, setmetatable, xpcall, unpack Nenue@6: Nenue@6: --@debug@ Nenue@6: local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool Nenue@6: local print = function(...) Nenue@6: if _G.Devian and _G.DevianDB.workspace ~= 1 then Nenue@6: _G.print('Turok', ...) Nenue@6: end Nenue@6: end Nenue@6: local GetPrint = function(trace) Nenue@6: return trace and print or function() end Nenue@6: end Nenue@6: --@end-debug@ Nenue@6: Nenue@6: Nenue@6: Nenue@6: --- Pull saved variables and make them sane Nenue@6: function T.OnInitialize(T) Nenue@6: Nenue@6: --@debug@ Nenue@6: local tmpidx Nenue@6: if TurokData and TurokData.spirit and TurokData.spirit.timerindex then Nenue@6: tmpidx = TurokData.spirit.timerindex Nenue@6: end Nenue@6: TurokData = Turok.defaults Nenue@6: if tmpidx then Nenue@6: TurokData.spirit.timerindex = tmpidx Nenue@6: end Nenue@6: --@end-debug@ Nenue@6: T.db = _G.TurokData Nenue@6: LibStub("LibFog-1.0"):Embed(T) Nenue@6: if T.db.queue_for_wipe then Nenue@6: T:Print("db reset flag received") Nenue@6: local index = _G.TurokData.spirit.timerindex Nenue@6: _G.TurokData = T.defaults Nenue@6: T.db = _G.TurokData Nenue@6: T.db.spirit.timerindex = index Nenue@6: end Nenue@6: Nenue@6: T:RegisterChatCommand("tkr", function() Nenue@6: T.db.queue_for_wipe = true Nenue@6: ReloadUI() Nenue@6: end) Nenue@6: Nenue@6: -- db hierarchy Nenue@6: for k, v in pairs(T.db) do Nenue@6: if type(v) == 'table' then Nenue@6: --@debug@ Nenue@6: --print('|cFF44FF88loading stored db|r: db.|cFF44AAFF'.. k ..'|r')--@end-debug@ Nenue@6: T.LinkTable(T.db, v, 'db', k) Nenue@6: end Nenue@6: end Nenue@6: setmetatable(T.db, Nenue@6: {__newindex = function (t, k, v) Nenue@6: rawset(t,k,v) Nenue@6: if type(v) == 'table' then Nenue@6: --@debug@ Nenue@6: --print('|cFF44FF88creating new db|r: db.|cFF44AAFF'.. k ..'|r')--@end-debug@ Nenue@6: T.LinkTable(T.db, v, 'db', k) Nenue@6: end Nenue@6: end}) Nenue@6: T.L = setmetatable({}, {__call = function(t, s) return t[s] or s end}) Nenue@6: end Nenue@6: Nenue@6: --- Get everything rolling Nenue@6: function T:OnEnable() Nenue@6: db = TurokData Nenue@6: L = T.L Nenue@6: Nenue@6: self.dispatchQueue = {} Nenue@6: self.sharedTables = {} Nenue@6: local skip = {modules = true, db = true, defaultModuleLibraries = true, orderedModules = true, prototype = true, events = true} -- local data that exists before init Nenue@6: for id, mod in pairs(self.orderedModules) do Nenue@6: mod.ID = id Nenue@6: mod.RegisterCallback = self.RegisterCallback Nenue@6: print('load', mod:GetName()) Nenue@6: for k, v in pairs(mod) do Nenue@6: if not skip[k] then Nenue@6: if match(k, '^[%u_]+$') then Nenue@6: if not self.dispatchQueue[k] then Nenue@6: self.dispatchQueue[k] = {} Nenue@6: end Nenue@6: self:RegisterEvent(k, 'Dispatch') Nenue@6: self.dispatchQueue[k][id] = mod:GetName() Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: print('events') Nenue@6: for k, v in pairs(self.dispatchQueue) do Nenue@6: print(' ',k,'->', unpack(v)) Nenue@6: end Nenue@6: Nenue@6: print('shared') Nenue@6: for k, v in pairs(self.sharedTables) do Nenue@6: print(' ',k) Nenue@6: end Nenue@6: --@debug@ Nenue@6: self:Print(MAJOR, MINOR, 'enabled.')--@end-debug@ Nenue@6: self:RegisterChatCommand("tkl", function() Nenue@6: PlaySoundFile([[Interface\Addons\Turok\Media\sound\wilhelm.ogg]]) Nenue@6: if not IsAddOnLoaded("Turok_Config") then Nenue@6: local loaded, message = LoadAddOn("Turok_Config") Nenue@6: if not loaded then Nenue@6: return T:Print("|cFFFF0000Load-on-Demand failed!|r Reason: " .. message) Nenue@6: end Nenue@6: --self.config = LibStub('AceConfigDialog-3.0'):AddToBlizOptions(MAJOR) Nenue@6: end Nenue@6: InterfaceOptionsFrame_OpenToCategory(MAJOR) Nenue@6: InterfaceOptionsFrame_OpenToCategory(MAJOR) Nenue@6: end) Nenue@6: Nenue@6: self:RegisterChatCommand("unlock", function() Nenue@6: T.unlocked = (not T.unlocked) and true or nil Nenue@6: if T.unlocked then Nenue@6: self:Print('frames unlocked') Nenue@6: else Nenue@6: self:Print('frames locked') Nenue@6: end Nenue@6: for k, v in pairs(self.orderedModules) do Nenue@6: if v.UpdateLocked then Nenue@6: v:UpdateLocked() Nenue@6: end Nenue@6: end Nenue@6: end) Nenue@6: Nenue@6: self:RegisterChatCommand("lsm", function(input) Nenue@6: local a1, n = self:GetArgs(input, 1,0) Nenue@6: local a2 = self:GetArgs(input, 1, n) Nenue@6: self:Print(self.LSM:Fetch(a1, a2)) Nenue@6: end) Nenue@6: Nenue@6: local name, realm = UnitFullName('player') Nenue@6: LGIST.RegisterCallback(self, "GroupInSpecT_InspectReady", 'GIST_InspectReady') Nenue@6: LGIST.RegisterCallback(self, "GroupInSpecT_Update", 'GIST_Update') Nenue@6: self:RegisterCharacterInfo(name, realm) Nenue@6: Nenue@6: if InCombatLockdown() then Nenue@6: T.inCombat = true Nenue@6: end Nenue@6: Nenue@6: T:PLAYER_SPECIALIZATION_CHANGED('PLAYER_SPECIALIZATION_CHANGED','player') Nenue@6: for order, event in ipairs(self.events) do Nenue@6: self:RegisterEvent(event, 'Dispatch') Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: do Nenue@6: local bucket_events = {['PLAYER_SPECIALIZATION_CHANGED'] = {}, ['PLAYER_TALENT_UPDATE'] = {}} Nenue@6: local bucket_start = {} Nenue@6: local event_queue = {} Nenue@6: local wipe, debugstack = table.wipe, debugstack Nenue@6: Nenue@6: --- Passes event data to the appropriate handlers, and runs any callback returned Nenue@6: -- @param e event name Nenue@6: -- @param ... event arguments as given by WoW Lua Nenue@6: -- @return callback1 runs after its corresponding method has been dispatched to Nenue@6: -- @return callback2 runs after all dispatching has completed, in the order that dispatches occurred Nenue@6: function T:Dispatch(event, ...) Nenue@6: if not (self[event] or self.dispatchQueue[event]) then Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: Nenue@6: if bucket_events[event] then Nenue@6: local unit = ... Nenue@6: if unit and unit ~= 'player' then Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: print(cText('*** Bucket Event:'), cWord(event)) Nenue@6: if not bucket_start[event] then Nenue@6: self['TKBATCH_'..event] = {} Nenue@6: bucket_start[event] = GetTime() Nenue@6: T:ScheduleTimer( function() Nenue@6: print('*** Firing bucketed event ('..#bucket_events[event]..'):', event, unpack(bucket_events[event][#bucket_events[event]])) Nenue@6: T:Dispatch('TKBATCH_'..event, unpack(bucket_events[event][#bucket_events[event]])) Nenue@6: bucket_start[event] = nil Nenue@6: Nenue@6: self['TKBATCH_'..event] = nil Nenue@6: end,0.1) Nenue@6: end Nenue@6: tinsert(bucket_events[event], {...}) Nenue@6: return Nenue@6: else Nenue@6: event = event:gsub('^TKBATCH_', '') Nenue@6: end Nenue@6: Nenue@6: Nenue@6: if event ~= 'COMBAT_LOG_EVENT_UNFILTERED' then print('|cFFFF0088received|r', event, ...) end Nenue@6: local args = {event, ...} Nenue@6: Nenue@6: -- if addon is listening directly Nenue@6: if self[event] then Nenue@6: print(cWord(event)) Nenue@6: local reg = function() print(unpack(args)) self[event](self, unpack(args)) end Nenue@6: tinsert(event_queue, {self, event, reg}) Nenue@6: Nenue@6: Nenue@6: -- if modules want this event directly Nenue@6: end Nenue@6: if self.dispatchQueue[event] then Nenue@6: for id, name in pairs(self.dispatchQueue[event]) do Nenue@6: local mod = self.orderedModules[id] Nenue@6: local reg = function() print(unpack(args)) mod[event](mod, unpack(args)) end Nenue@6: tinsert(event_queue, {mod, event, reg}) Nenue@6: end Nenue@6: else Nenue@6: print("Received", event, "but nothing is listening to it.") Nenue@6: end Nenue@6: Nenue@6: for i, entry in ipairs(event_queue) do Nenue@6: local handler, event, func = unpack(entry) Nenue@6: print('->', cWord(handler:GetName()), cBool(result), cText(message)) Nenue@6: local result, message = xpcall(func, function(m) print(m, debugstack()) return debugstack() end) Nenue@6: Nenue@6: if bucket_events[event] then Nenue@6: wipe(bucket_events[event]) Nenue@6: bucket_events[event].history = {} Nenue@6: end Nenue@6: end Nenue@6: wipe(event_queue) Nenue@6: end Nenue@6: end Nenue@6: --- Store character data to speed up spec-specific load time Nenue@6: function T:RegisterCharacterInfo(name,realm) Nenue@6: local classLocalized, classEnglish, classID = UnitClass('player') Nenue@6: Nenue@6: -- set savedvars Nenue@6: self.playerName = name Nenue@6: self.playerRealm = realm Nenue@6: self.playerClass = classEnglish Nenue@6: self.playerClassLocalized = classLocalized Nenue@6: self.playerClassID = classID Nenue@6: self.GUID = UnitGUID('player') Nenue@6: local namerealm = name..'-'..realm Nenue@6: if not db.char[namerealm] then Nenue@6: db.char[namerealm] = { Nenue@6: spellBook = {} Nenue@6: } Nenue@6: end Nenue@6: T.spellBook = db.char[namerealm].spellBook Nenue@6: Nenue@6: -- push combat ratings calc Nenue@6: self:COMBAT_RATING_UPDATE() Nenue@6: end Nenue@6: Nenue@6: --- Polls for specialization info until it's available Nenue@6: function T:RegisterSpecEvents() Nenue@6: local specPage = GetSpecialization() Nenue@6: if specPage then Nenue@6: Nenue@6: local specID, specName, specDesc, specTexture = GetSpecializationInfo(specPage) Nenue@6: local specGroup = GetActiveSpecGroup() Nenue@6: print('Turok', cText('* Spec Info:'), GetSpecializationInfo(GetSpecialization())) Nenue@6: if T.specID and specID ~= T.specID then Nenue@6: print('pushing out old spec data') Nenue@6: T.previousSpec = { Nenue@6: specPage = T.specPage, Nenue@6: specGroup = T.specGroup, Nenue@6: specID = T.specID, Nenue@6: specName = T.specName, Nenue@6: specTexture = T.specTexture Nenue@6: } Nenue@6: elseif not T.previousSpec then Nenue@6: print('first run probably') Nenue@6: T.previousSpec = {} Nenue@6: end Nenue@6: Nenue@6: Nenue@6: T.specUpdate = (specID ~= T.specID) Nenue@6: T.talentsChanged = (T.specGroup ~= specGroup) Nenue@6: T.specPage = specPage Nenue@6: T.specGroup = specGroup Nenue@6: T.specID = specID Nenue@6: T.specName = specName Nenue@6: T.specTexture = specTexture Nenue@6: else Nenue@6: print('Turok', cText('* No Spec Info yet, start polling')) Nenue@6: -- repeat until we get something to update with Nenue@6: T:ScheduleTimer('RegisterSpecEvents', 1) Nenue@6: end Nenue@6: Nenue@6: if T.specID and not T.__specevents then Nenue@6: T.__specevents = true Nenue@6: T:PLAYER_SPECIALIZATION_CHANGED('PLAYER_SPECIALIZATION_CHANGED','player') Nenue@6: T:RegisterEvent('PLAYER_TALENT_UPDATE', 'Dispatch') Nenue@6: T:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', 'Dispatch') Nenue@6: T:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED', 'Dispatch') Nenue@6: T:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', 'Dispatch') Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: --- Event handler wrapper for the Specialization getter used at load time Nenue@6: local GetSpecializationSpells, GetSpellInfo = GetSpecializationSpells, GetSpellInfo Nenue@6: function T:PLAYER_SPECIALIZATION_CHANGED(event, unit) Nenue@6: -- make sure this was fired for player Nenue@6: if (unit ~= 'player') then Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: Nenue@6: print('Turok', '|cFF00FF00'.. event) Nenue@6: -- Set current spec values and fill out previousSpec table Nenue@6: T:RegisterSpecEvents() Nenue@6: local ot = T.previousSpec Nenue@6: Nenue@6: -- Is the new spec different? Nenue@6: if T.specUpdate then Nenue@6: print(cText('Spec changed from'), cWord(ot.specName), cText('to'), cKey(T.specName)) Nenue@6: Nenue@6: if ot.specPage and not T.spellBook[ot.specPage] then Nenue@6: T.spellBook[ot.specPage] = {} Nenue@6: end Nenue@6: Nenue@6: local spellBook = {GetSpecializationSpells(T.specPage)} Nenue@6: if not T.spellBook[T.specPage] then Nenue@6: T.spellBook[T.specPage] = {} Nenue@6: for i = 1, #spellBook, 2 do Nenue@6: T.spellBook[T.specPage][spellBook[i]] = GetSpellInfo(spellBook[i]) Nenue@6: if (not ot.specPage) or (T.spellBook[ot.specPage] and not T.spellBook[ot.specPage][spellBook[i]]) then Nenue@6: print(cText('activating for spell'), T.spellBook[T.specPage][spellBook[i]]) Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: Nenue@6: Nenue@6: -- list changed spells for use by spell posession checks Nenue@6: local diff = { Nenue@6: gained = {}, Nenue@6: lost = {} Nenue@6: } Nenue@6: Nenue@6: --- Check against current for removed spells Nenue@6: if T.spellBook[ot.specPage] then Nenue@6: for id, spellInfo in pairs(T.spellBook[ot.specPage]) do Nenue@6: if not T.spellBook[ot.specPage] then Nenue@6: tinsert(diff.lost, spellInfo) Nenue@6: print('lost', spellInfo.spellName) Nenue@6: else Nenue@6: print('keep', spellInfo.spellName) Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: T.spellBook.change = diff Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: local GetInventoryItemID, GetItemSpell, GetSpellInfo, GetItemInfo = GetInventoryItemID, GetItemSpell, GetSpellInfo, GetItemInfo Nenue@6: function T:PLAYER_EQUIPMENT_CHANGED(event, slot, hasItem) Nenue@6: print('Equip slot #', slot, ' has?', hasItem) Nenue@6: if hasItem then Nenue@6: local itemID = GetInventoryItemID('player', slot) Nenue@6: print('itemID?', itemID) Nenue@6: local spellName = GetItemSpell(itemID) Nenue@6: print('spell?', spellName) Nenue@6: local _, spellID Nenue@6: if spellName then Nenue@6: _, _, _, _, _, _, spellID = GetSpellInfo(spellName) Nenue@6: end Nenue@6: Nenue@6: local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID) Nenue@6: T.equipped[slot] = { Nenue@6: itemID = itemID, Nenue@6: spellName = spellName, Nenue@6: spellID = spellID, Nenue@6: name = name, Nenue@6: link = link, Nenue@6: equipSlot = equipSlot, Nenue@6: texture = texture, Nenue@6: } Nenue@6: print('equipped', name) Nenue@6: Nenue@6: else Nenue@6: self.equipped[slot] = nil Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: local GetPowerRegen, UnitPowerType = GetPowerRegen, UnitPowerType Nenue@6: function T:COMBAT_RATING_UPDATE(t,e) Nenue@6: --@debug@ Nenue@6: print('|cFF00FFFFCOMBAT_RATING_UPDATE')--@end-debug@ Nenue@6: self.haste = UnitSpellHaste('player') Nenue@6: self.powerRegen = GetPowerRegen() Nenue@6: self.powerType = UnitPowerType('player') Nenue@6: self.castTimeMod = 1+ self.haste/100 Nenue@6: self.GCD = 1.5 * self.castTimeMod Nenue@6: Nenue@6: L.haste = format('%.2f', self.haste) Nenue@6: L.focusregen = format('%.2f', self.powerRegen) Nenue@6: L.castingmod = format('%.2f', self.castTimeMod) Nenue@6: end Nenue@6: Nenue@6: function T:UNIT_SPELLCAST_INTERRUPTED(e, unit, spellName, rank, target, castID) Nenue@6: if not T.isEventUnit[unit] then Nenue@6: return Nenue@6: end Nenue@6: T.spellevent[unit] = {unit, spellName, rank, target, castID, nil } Nenue@6: end Nenue@6: Nenue@6: function T:UNIT_SPELLCAST_SENT(e,unit, spellName, rank, target, castID) Nenue@6: if not T.isEventUnit[unit] then Nenue@6: return Nenue@6: end Nenue@6: T.unit[unit].spellEventString = e Nenue@6: T.unit[unit].spellevent = {unit, spellName, rank, target, castID} Nenue@6: end Nenue@6: Nenue@6: function T:UNIT_SPELLCAST (e, unit, spellName, rank, castID, spellID) Nenue@6: if not T.isEventUnit[unit] then Nenue@6: return Nenue@6: end Nenue@6: --name, subText, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible Nenue@6: local q = {UnitCastingInfo(unit)} Nenue@6: T.unit[unit].casting = q[1] and q or false Nenue@6: T.unit[unit].spellEventString = e Nenue@6: T.unit[unit].spellevent = {unit, spellName, rank, nil,castID, spellID } Nenue@6: print(e, unit) Nenue@6: end Nenue@6: Nenue@6: function T:UNIT_CHANNEL(e, unit, spellName, rank, castID, spellID) Nenue@6: if not T.isEventUnit[unit] then Nenue@6: return Nenue@6: end Nenue@6: --name, subText, text, texture, startTime, endTime, isTradeSkill, notInterruptible Nenue@6: local q = {UnitChannelInfo(unit) } Nenue@6: T.unit[unit].channeling = q[1] and q or false Nenue@6: T.unit[unit].spellEventString = e Nenue@6: T.unit[unit].spellevent = {unit, spellName, rank, nil, castID, spellID } Nenue@6: print(e, unit) Nenue@6: end Nenue@6: Nenue@6: T.UNIT_SPELLCAST_START = T.UNIT_SPELLCAST Nenue@6: T.UNIT_SPELLCAST_STOP = T.UNIT_SPELLCAST Nenue@6: T.UNIT_SPELLCAST_DELAYED = T.UNIT_SPELLCAST Nenue@6: T.UNIT_SPELLCAST_INTERRUPTED = T.UNIT_SPELLCAST Nenue@6: T.UNIT_SPELLCAST_FAILED = T.UNIT_SPELLCAST Nenue@6: T.UNIT_SPELLCAST_SUCCEEDED = T.UNIT_SPELLCAST Nenue@6: T.UNIT_SPELLCAST_CHANNEL_START = T.UNIT_CHANNEL Nenue@6: T.UNIT_SPELLCAST_CHANNEL_UPDATE= T.UNIT_CHANNEL Nenue@6: T.UNIT_SPELLCAST_CHANNEL_STOP= T.UNIT_CHANNEL Nenue@6: Nenue@6: local UnitExists, GetRealmName, UnitClassification, UnitClass, UnitIsFriend, UnitIsEnemy, UnitIsFeignDeath Nenue@6: = UnitExists, GetRealmName, UnitClassification, UnitClass, UnitIsFriend, UnitIsEnemy, UnitIsFeignDeath Nenue@6: function T:UnitChanged(e, unit) Nenue@6: local u = T.unit[unit] Nenue@6: local exists = UnitExists(unit) Nenue@6: local realm Nenue@6: _G.print('Update', cText(' '..unit..' change:'), cText(unit), cText(exists and UnitName(unit))) Nenue@6: Nenue@6: u.exists = exists Nenue@6: u.name, realm = UnitName(unit) Nenue@6: u.realm = realm or GetRealmName() Nenue@6: u.classification = UnitClassification(unit) Nenue@6: u.class = UnitClass(unit) Nenue@6: u.isFriendly = UnitIsFriend('player', unit) Nenue@6: u.isEnemy = UnitIsEnemy('player', unit) Nenue@6: u.isFeign = UnitIsFeignDeath(unit) Nenue@6: u.isNeutral = not(u.isHostile or u.isFriendly) Nenue@6: Nenue@6: local castinfo, channelinfo = {UnitCastingInfo(unit)}, {UnitChannelInfo(unit)} Nenue@6: u.casting = (u.exists and castinfo[1]) and castinfo or false Nenue@6: u.channeling = (u.exists and channelinfo[1]) and channelinfo or false Nenue@6: u.isCasting = (u.casting or u.channeling) and true or false Nenue@6: Nenue@6: Nenue@6: for k,v in pairs(T.unit[unit]) do Nenue@6: _G.print('Update', cText(' -'), cText(k),'->', cText(v)) Nenue@6: end Nenue@6: end Nenue@6: function T:PLAYER_TARGET_CHANGED(e) Nenue@6: T:UnitChanged(e, 'target') Nenue@6: end Nenue@6: function T:PLAYER_FOCUS_CHANGED(e) Nenue@6: T:UnitChanged(e, 'focus') Nenue@6: end Nenue@6: function T:UNIT_PET(e, unit,...) Nenue@6: if unit == 'player' then Nenue@6: print(e, unit, ...) Nenue@6: T:UnitChanged(e, 'pet') Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: local Turok_OnCombat = function(inCombat) Nenue@6: print(cText('* CombatToggle:'), cBool(inCombat)) Nenue@6: PlaySoundFile(db['battle_noise'.. (inCombat and '_start' or '_end')]) Nenue@6: Nenue@6: for _, region in pairs(Tk.LibFog.animate_regions) do Nenue@6: if region.combatFade then Nenue@6: print(' |cFFFFFF00+|r', region:GetName()) Nenue@6: region:UpdateAlpha(inCombat) Nenue@6: else Nenue@6: print(' |cFFFF4400-|r', region:GetName()) Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: --- InCombatLockdown() isn't updated immediately, so we have to assume Nenue@6: function T:PLAYER_REGEN_DISABLED(e,...) Nenue@6: T.inCombat = true Nenue@6: Turok_OnCombat(true) Nenue@6: end Nenue@6: function T:PLAYER_REGEN_ENABLED(e,...) Nenue@6: T.inCombat = nil Nenue@6: Turok_OnCombat(false) Nenue@6: end Nenue@6: Nenue@6: -- GIST datas Nenue@6: function T:GIST_InspectReady (event, guid, unit) Nenue@6: print('GIST barf', guid, unit) Nenue@6: end Nenue@6: Nenue@6: function T:GIST_Update(event, guid, unit, info) Nenue@6: Nenue@6: if info.class_id and info.global_spec_id and info.guid and info.lku then Nenue@6: --_G.print('GIST', 'Update', unit) Nenue@6: --_G.print('GIST',' class:', info.class_id, 'specid:', info.global_spec_id, 'guid:', info.guid) Nenue@6: Nenue@6: self.units[info.guid] = info Nenue@6: self.unitsBySlot[info.lku] = info Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: -- todo: re-locate these Nenue@6: Nenue@6: T.PLAY_MOVIE = function (e, id) Nenue@6: MovieFrame:Hide() Nenue@6: T:Print('skipped a shitty movie', e, id) Nenue@6: end Nenue@6: T.CINEMATIC_START = function(...) Nenue@6: CinematicFrame_CancelCinematic() Nenue@6: T:Print('skipped a shitty cinematic', ...) Nenue@6: end