Mercurial > wow > turok
view Turok/Modules/Timer/Timer.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 7:40 AM -- local _, Tk = ... local T = Tk.Addon local mod = T:NewModule("TimerControl", "AceTimer-3.0") local pairs, ipairs, rawset, getmetatable, setmetatable, type, tostring, tinsert = pairs, ipairs, rawset, getmetatable, setmetatable, type, tostring, tinsert local cWord, cNum, cText, cKey = cWord, cNum, cText, cKey local print = function(...) if not DEBUG then return end if _G.Devian and _G.DevianDB.workspace ~= 1 then _G.print('Timer', ...) end end local index_mt = { __newindex = function(t,k,v) rawset(t,k,v) if type(v) == 'table' then print('new table', cKey(k)) setmetatable(v, getmetatable(t)) else print('new index', cText(k)) end end } mod.index = {} mod.index.name = setmetatable({}, index_mt) mod.index.global = setmetatable({}, index_mt) mod.index.preset = {} -- dummies mod.prototype = { status = { spellID = {}, spellName = {}, talentID = {}, talentRow = {}, talentOffset = {}, itemID = {}, inventoryID = {}, specPage = {}, specID = {}, unit = {}, }, trigger = { aura = {}, cooldown = {}, complex = {}, }, display = { icon = {}, progressbar = {}, }, } Turok.defaults.spirit = { global = { alpha = 1, alpha_ooc = 0.5, sound_active = '[[Interface\Addons\Turok\Media\sound\link.ogg]]', sound_passive = [[Interface\Addons\Turok\Media\sound\Heart.ogg]], sound_hidden = [[Interface\Addons\Turok\Media\sound\Electro_-S_Bainbr-7955_hifi.mp3]], strata = 'LOW', anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', width = 100, height = 100, x = 0, y = 100, alpha = 1, alpha_ooc = 0.3, inverse = false, persist = false, desaturated = false, icon = {}, passive = { icon = {} }, active = { inco = {} }, }, font = [[Interface\Addons\Turok\Media\font\ArchivoNarrow-Regular.ttf]], lefttext = { size = 14, inset = -2, point = 'LEFT', outline = 'OUTLINE', format = '%n %pd', text_color = {1, 1, 1, 1}, }, containers = { }, timers = {}, } local tdb = Turok.defaults.spirit.timers mod.GetInherited = function(dvars, merge, inherited) if not inherited then inherited = {} end inherited[merge] = merge T.Config_Merge(dvars, merge) if merge.inherits then local t = mod.index.name[merge.inherits] if t and not inherited[t] then mod.GetInherited(dvars, t, inherited) end end end local GetClassInfo, GetNumClasses, GetNumSpecializationsForClassID, GetSpecializationInfoForClassID = GetClassInfo, GetNumClasses, GetNumSpecializationsForClassID, GetSpecializationInfoForClassID mod.GetIndex = function() print(cWord('**** Index Init')) local index = mod.index local globalIndex = index.global local nameIndex = index.name local tdb = TurokData.spirit.timers local classID = {} local className = {} local classSpecID = {} local specIDClass = {} for id=1, GetNumClasses() do local _, name = GetClassInfo(id) classID[name] = id className[id] = name index[name] = setmetatable({}, index_mt) classSpecID[id] = {} for h=1, GetNumSpecializationsForClassID(id) do local specID, specName = GetSpecializationInfoForClassID(id, h) classSpecID[id][h] = specID specIDClass[specID] = id end end if not tdb then print('Missing config table.') return end --- Setup virtuals for setID, entry in ipairs(tdb) do if entry.virtual then print('loading virtual set:', entry.name) globalIndex[setID] = entry nameIndex[entry.name or ('noname'.. setID)] = entry end end --- Starting readin' for setID, entry in ipairs(tdb) do if not entry.virtual then print('* .index.global['.. setID..'] =', entry.name) local dvars = T.Config_Push({}, entry, nil, cKey('['..setID..']')..'.'..cWord('dvars')) dvars.name = entry.name globalIndex[setID] = dvars local name = dvars.name or ('noname'..setID) nameIndex[name] = entry print('* .timersByName['..name..'] =', setID, entry.setID) --- Combine with any inherited templates if dvars.inherits and nameIndex[dvars.inherits] then print('* Adding heritable data from', cText(dvars.inherits)) mod.GetInherited(dvars, nameIndex[dvars.inherits], {[dvars] = dvars}) --T.Config_Merge(dvars, nameIndex[dvars.inherits], dvars, cKey('['..setID..']')..'.'..cWord('dvars')) end -- class index if not (dvars.playerClass or dvars.specID) then for id, class in pairs(className) do index[class][setID] = dvars end print('* indexed globally') else if dvars.playerClass then if type(dvars.playerClass) ~= 'table' then dvars.playerClass = {dvars.playerClass } end for i, playerClass in ipairs(dvars.playerClass) do index[playerClass][setID] = dvars print('* applying playerClass entry '..cNum(i)..': '..cWord(playerClass)) end end if dvars.specID then if type(dvars.specID) ~= 'table' then dvars.specID = {dvars.specID } end for i, specID in ipairs(dvars.specID) do print('* applying globalSpecID entry '..cNum(i)..': '..cNum(specID)..' -> '..cWord(className[specIDClass[dvars.specID]])) index[className[specIDClass[specID]]][setID] = dvars end end end end end end