Mercurial > wow > turok
view Turok/Init.lua @ 9:9400a0ff8540
Ugh
Timer:
- container update directionality
- talent update iterates over a non-volatile table to carry out updates
- index management steps organized
- talentRow status implemented, returns the spell associated with the talent chosen from that row
CombatLog:
- sort out font controls and unbork arguments
author | Nenue |
---|---|
date | Sun, 21 Feb 2016 13:08:30 -0500 |
parents | a9b8b0866ece |
children |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 12/28/2015 6:40 AM --- Core load sequence goes here. --@debug@ local ADDON, TurokEnv = ... local _G = _G --@end-debug@ --GLOBALS: Turok, LibStub, GetAddOnMetadata local setmetatable, rawset, rawget, pairs, type, unpack, tostring, tinsert = setmetatable, rawset, rawget, pairs, type, unpack, tostring, table.insert Turok = LibStub("AceAddon-3.0"):NewAddon('Turok', 'AceEvent-3.0', 'AceTimer-3.0', 'AceConsole-3.0') Turok:SetDefaultModuleState(true) TurokEnv.Addon = Turok TurokEnv.LSM = LibStub("LibSharedMedia-3.0") TurokEnv.LGIST = LibStub("LibGroupInSpecT-1.1") local T = Turok --@debug@ local print = function(...) if _G.Devian and _G.DevianDB.workspace ~= 1 then _G.print('DB', ...) end end local cTypes = { ['function'] = 'FF9922', ['table'] = '00FFAA', ['number'] = '77FF00', ['string'] = '00AAFF', ['hl'] = 'FF0088', ['field'] = '00FFFF', ['boolean'] = 'CC88FF', ['false'] = 'FF7700', ['true'] = '44FF66', ['nil'] = 'FFFF00',} local Debuggers = { cType = function(s) return '|cFF' .. tostring(cTypes[type(s)]) .. tostring(s) .. '|r' end, cText = function(s) return '|cFF'..cTypes.string..tostring(s)..'|r' end, cNum = function(n) return '|cFF'..cTypes.number .. tostring(n) .. '|r' end, cWord = function(w) return '|cFF'..cTypes.table .. tostring(w) .. '|r' end, cKey = function(k) return '|cFF'..cTypes.field .. tostring(k) .. '|r' end, cPink = function(s) return '|cFF'..cTypes.hl .. tostring(s) .. '|r' end, cBool = function(s) return '|cFF'..cTypes[tostring((not not s))] .. tostring(s) .. '|r' end, } for fname, func in pairs(Debuggers) do _G[fname] = func end local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool --@end-debug@ T.db = {} T.versionString = GetAddOnMetadata("Turok", "Version") function T:OnModuleCreated(mod) if mod.events then print('Module', unpack(mod.events)) end end --- RegisterEvent embedded to module tables function T:RegisterCallback(event, func, ...) if not T.dispatchQueue[event] then T.dispatchQueue[event] = {} end if not T.dispatchQueue[event][T.ID] then T.dispatchQueue[event][T.ID] = T:GetName() end if (type(func) == 'function') then if type(T[event]) == 'function' then local oldfunc = T[event] T[event] = function(...) oldfunc(...) return func(...) end else T[event] = func end end --@debug@ print(cText('Adding listener for'), cKey(self:GetName()), cText('on'), cKey(event))--@end-debug@ end --- Default settings base T.defaults = { char = {}, lefttext = { parent = 2, -- in an overlay frame anchor = 'LEFT', anchorTo = 'LEFT', size = 18, x = 5, y = 0, justifyH = 'LEFT', justifyV = 'MIDDLE', }, righttext = { parent = 2, -- in an overlay frame anchor = 'RIGHT', anchorTo = 'RIGHT', x = -5, y = 0, size = 18, justifyH = 'RIGHT', justifyV = 'MIDDLE', }, alpha = 1, alpha_ooc = 1, alpha_fade_in = 0.2, alpha_fade_out = 0.2, border_color = {0,0,0,1}, background_color = {0,.0,0,1}, background_blend = 'BLEND', foreground_texture = [[Interface\Addons\Turok\Media\statusbar\Minimalist.tga]], foreground_color = {0,.475,.95,1}, foreground_blend = 'BLEND', foreground_inset = 0, padding = 2, spacing = 0, fill_direction = 'RIGHT', anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', x = 0, y = 0, inset = -3, width = 250, height = 100, strata = 'LOW', font = "Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf", size = 14, text_color = {1, 1, 1, 1}, justifyH = 'LEFT', outline = 'OUTLINE', combatFade = true, battle_noise_start = [[Interface\Addons\Turok\Media\sound\Low_Beep-Public_D-136_hifi.mp3]], battle_noise_end = [[Interface\Addons\Turok\Media\sound\Electro_-S_Bainbr-7955_hifi.mp3]], } T.events = { 'PLAY_MOVIE', 'PLAYER_TARGET_CHANGED', 'PLAYER_FOCUS_CHANGED', 'PLAYER_EQUIPMENT_CHANGED', 'PLAYER_REGEN_DISABLED', 'PLAYER_REGEN_ENABLED', 'SPELL_UDPATE_COOLDOWN', 'SPELL_UPDATE_USABLE', 'UNIT_AURA', 'UNIT_PET', 'UNIT_POWER_FREQUENT', 'UNIT_SPELL_HASTE', 'UNIT_SPELLCAST_SENT', 'UNIT_SPELLCAST_START', 'UNIT_SPELLCAST_DELAYED', 'UNIT_SPELLCAST_STOP', 'UNIT_SPELLCAST_CHANNEL_START', 'UNIT_SPELLCAST_CHANNEL_UPDATE', 'UNIT_SPELLCAST_CHANNEL_STOP', 'UNIT_SPELLCAST_FAILED', 'UNIT_SPELLCAST_INTERRUPTED', 'UNIT_SPELLCAST_INTERRUPTIBLE', 'UNIT_SPELLCAST_SUCCEEDED', 'UNIT_SPELLCAST_UNINTERRUPTIBLE', } T.previousSpec = {} T.talents = { {}, {}} T.changedTalents = {{}, {} } T.talentInfo = {} T.auras = {} T.spells = {} T.spellevent = {} T.channeling = {} T.casting = {} T.sent = {} T.prototype = {} T.spellBook = {} T.equipped = {} --- player-restricted unit info and text representations T.player = {} T.playertext = {} T.pet = {} --- holds non-restricted unit information T.unit = { player = {}, target = {}, focus = {}, pet = {}, } -- index of frames with conditional visual properties T.control_regions = {} -- index of frames generated by the lua T.frames = {} -- units T.units = {} T.unitsBySlot = {} setmetatable(T.unitsBySlot, {__mode="v"}) T.TrueVal = function (self,k) return rawget(self,k) end --- Sets an index hierarchy for db vars and propagates config dialog info T.LinkTable = function (over, under, pname, cname) local mt = { __index = function(t,k) if type(over[k]) ~= nil then --t[k] = over[k] --@debug@ --print('up-referencing '.. STACK_COLOR2 .. pname ..'|r.'.. STACK_COLOR3.. tostring(k)..'|r -> '.. STACK_COLOR3.. pname ..'.' .. cname .. '|r.'..STACK_COLORN.. tostring(k) ..'|r', over[k])--@end-debug@ end return over[k] end, __newindex = function (t, k, v) rawset(t,k,v) if type(v) == 'table' then --@debug@ --print('parenting '.. STACK_COLOR2.. pname ..'|r to created table '.. STACK_COLOR3.. cname ..'|r')--@end-debug@ T.LinkTable(under, v, pname, k) end end } --under.TrueVal = T.TrueVal setmetatable(under, mt) for k, v in pairs(under) do if type(v) == 'table' then --@debug@ --print('linking '..STACK_COLOR1.. pname ..'|r to '..STACK_COLOR2.. cname ..'|r')--@end-debug@ T.LinkTable(under, v, pname ..'.'.. cname, k) end end end --- Merges values of table B into table A, and copies over nested values of tables matching the keywords list local masked = {name = true, virtual = true} T.Config_Push = function(cvars, push , root, rkey) local results = {} root = root or cvars for k, v in pairs(push) do if not masked[k] then if type(v) == 'table' and v ~= root then cvars[k] = {} T.Config_Push(cvars[k], v, root) else print(' |cFFFF0088B|r ', tostring(rkey)..'.'..cKey(k)) cvars[k] = v tinsert(results, ' |cFFFF0088B|r '.. tostring(rkey)..'.'..cKey(k)) end end end return cvars, results end T.Config_Merge = function(cvars, merge, root, rkey) local diff = {} root = root or cvars rkey = rkey or '0' for k, v in pairs(merge) do if masked[k] or cvars[k] then tinsert(diff, ' |cFF00FF00A|r '.. tostring(rkey)..'.'..cWord(k)) print(' |cFF00FF00A|r ', tostring(rkey)..'.'..cText(k), '=', cvars[k]) --cvars[k] = cvars[k] else if type(v) == 'table' then if type(cvars[k]) == 'nil' then cvars[k] = {} end if type(cvars[k]) == 'table' then print(' |cFFFFFF00A+B|r '.. tostring(rkey)..'.'..cWord(k)) cvars[k] = T.Config_Merge(cvars[k], v, root, tostring(rkey)..'.'..tostring(k)) end elseif cvars[k] == nil then tinsert(diff, ' |cFFFF0088B|r '.. tostring(rkey)..'.'..cKey(k)) print(' |cFFFF0088B|r ', tostring(rkey)..'.'..cKey(k)) cvars[k] = v else tinsert(diff, ' |cFF00FF00A|r '.. tostring(rkey)..'.'..cWord(k)) print(' |cFF00FF00A|r ', tostring(rkey)..'.'..cWord(k)) --cvars[k] = cvars[k] end end end return cvars, diff end