Nenue@1: Nenue@1: -- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList Nenue@1: local T = LibStub("AceAddon-3.0"):NewAddon("Turok", "AceConsole-3.0", "AceEvent-3.0") Nenue@1: local _G = _G Nenue@1: local rawset = _G.rawset Nenue@1: local time = GetTime() Nenue@1: _G.Turok = T Nenue@1: local print = function(...) Nenue@1: --_G.print('Core', ...) Nenue@1: end Nenue@1: Nenue@1: Nenue@1: T.mods = {} Nenue@1: T:SetDefaultModuleState(true) Nenue@1: T:SetDefaultModuleLibraries("AceEvent-3.0") Nenue@1: T:SetDefaultModulePrototype({OnInitialize = function(mod) Nenue@1: print('CORE', mod:GetName().. ' found') Nenue@1: end}) Nenue@1: Nenue@1: -- propagates parameter data around Nenue@1: function T:LinkTable(parent, child, pname, cname) Nenue@1: local mt = { Nenue@1: __index = function(t,k) Nenue@1: if parent[k] then Nenue@1: t[k] = parent[k] Nenue@1: end Nenue@1: print('|cFFFF8800'.. pname ..'.' .. cname .. '|r.|cFFFFFF00'.. k ..'|r inheriting value at |cFFFF8800' .. pname ..'|r.|cFFFFFF00'.. k..'|r') Nenue@1: return parent[k] Nenue@1: end, Nenue@1: __newindex = function (t, k, v) Nenue@1: rawset(t,k,v) Nenue@1: if type(v) == 'table' then Nenue@1: T:LinkTable(child, v, pname, k) Nenue@1: print('|cFFFF8800'.. pname ..'.' .. cname .. '|r.|cFFFFFF00'.. k ..'|r sub-table created') Nenue@1: end Nenue@1: end Nenue@1: } Nenue@1: print('|cFFFF8800'.. pname ..'.|cFFFFFF00'.. cname ..'|r sub-tables will be retconned') Nenue@1: setmetatable(child, mt) Nenue@1: for k, v in pairs(child) do Nenue@1: if type(v) == 'table' then Nenue@1: T:LinkTable(child, v, cname, k) Nenue@1: end Nenue@1: end Nenue@1: end Nenue@1: Nenue@1: function T:OnInitialize() Nenue@1: Nenue@1: local defaults = { Nenue@1: background_color = {0,0,0,0}, Nenue@1: background_blend = 'BLEND', Nenue@1: foreground_color = {1,1,1,0.5}, Nenue@1: foreground_blend = 'BLEND', Nenue@1: foreground_inset = -1, Nenue@1: width = 250, Nenue@1: height = 100, Nenue@1: alpha = 1, Nenue@1: alpha_ooc = 0.1, Nenue@1: strata = 'LOW', Nenue@1: label_strata = 'HIGH', Nenue@1: label_justifyH = 'LEFT', Nenue@1: label_color = {1, 1, 1, 1}, Nenue@1: label_font = 'turok', Nenue@1: label_size = 14, Nenue@1: label_inset = -2, Nenue@1: label_point = 'LEFT', Nenue@1: label_outline = 'OUTLINE', Nenue@1: anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', Nenue@1: focusbar = { Nenue@1: foreground_color = {1, 1, 1, 0.7}, Nenue@1: background_color = {0,0,0,0.8}, Nenue@1: width = 300, height = 24, Nenue@1: posX = 0, posY = -150, Nenue@1: }, Nenue@1: } Nenue@1: _G.TurokData = defaults Nenue@1: if not _G.TurokData then Nenue@1: _G.TurokData = defaults Nenue@1: end Nenue@1: Nenue@1: T.db = _G.TurokData Nenue@1: local db = T.db Nenue@1: for k, v in pairs(db) do Nenue@1: if type(v) == 'table' then Nenue@1: T:LinkTable(db, v, 'db', k) Nenue@1: end Nenue@1: end Nenue@1: setmetatable(db, Nenue@1: {__newindex = function (t, k, v) Nenue@1: rawset(t,k,v) Nenue@1: if type(v) == 'table' then Nenue@1: T:LinkTable(db, v, 'db', k) Nenue@1: print('CFG', '|cFFFF0000db|r.|cFF00FFFF' .. k ..'|r created at bottom level') Nenue@1: end Nenue@1: end}) Nenue@1: Nenue@1: options = { Nenue@1: type = 'group', Nenue@1: name = 'Turok', Nenue@1: handler = T, Nenue@1: set = function(info,value) Nenue@1: local k = db[info[1]] Nenue@1: for i = 2, #info-1 do Nenue@1: if type(k[i]) ~= 'table' then Nenue@1: print('fart') Nenue@1: end Nenue@1: Nenue@1: k = k[i] Nenue@1: end Nenue@1: k[info[#info]] = value Nenue@1: end, Nenue@1: get = function(info) Nenue@1: local k = db[info[1]] Nenue@1: for i = 2, #info-1 do Nenue@1: if type(k[i]) ~= 'table' then Nenue@1: print('fart') Nenue@1: end Nenue@1: Nenue@1: k = k[i] Nenue@1: end Nenue@1: return k[info[#info]] Nenue@1: end, Nenue@1: desc = '"Dinosaur" Hunter', Nenue@1: args = { Nenue@1: background_color = { Nenue@1: type = 'color', Nenue@1: name = 'Background Color', Nenue@1: hasAlpha = true, Nenue@1: } Nenue@1: } Nenue@1: } Nenue@1: LibStub("AceConfig-3.0"):RegisterOptionsTable('Turok', options, {"tk"}) Nenue@1: Nenue@1: end Nenue@1: Nenue@1: Nenue@1: function T:OnEnable() Nenue@1: local db = _G.TurokData Nenue@1: Nenue@1: print('I... am Turok') Nenue@1: Nenue@1: self.stats = {} Nenue@1: Nenue@1: Nenue@1: T.focusbar = T:CreateBar('TkFocusBar', db.focusbar) Nenue@1: local fb = T.focusbar Nenue@1: T:AddLabel(fb, db.focusbar) Nenue@1: fb:Update(UnitPower("player"), 0, UnitPowerMax("player")) Nenue@1: T:Bar_SetUpdateHandler(fb, function(self) Nenue@1: T.Bar_Update(fb, UnitPower("player")) Nenue@1: end) Nenue@1: end