Nenue@6
|
1 --- ${PACKAGE_NAME}
|
Nenue@6
|
2 -- @file-author@
|
Nenue@6
|
3 -- @project-revision@ @project-hash@
|
Nenue@6
|
4 -- @file-revision@ @file-hash@
|
Nenue@6
|
5 -- Created: 12/28/2015 6:40 AM
|
Nenue@6
|
6 --- Core load sequence goes here.
|
Nenue@6
|
7 --@debug@
|
Nenue@6
|
8 local ADDON, TurokEnv = ...
|
Nenue@6
|
9 local _G = _G
|
Nenue@6
|
10 --@end-debug@
|
Nenue@6
|
11 --GLOBALS: Turok, LibStub, GetAddOnMetadata
|
Nenue@6
|
12 local setmetatable, rawset, rawget, pairs, type, unpack, tostring, tinsert = setmetatable, rawset, rawget, pairs, type, unpack, tostring, table.insert
|
Nenue@6
|
13 Turok = LibStub("AceAddon-3.0"):NewAddon('Turok', 'AceEvent-3.0', 'AceTimer-3.0', 'AceConsole-3.0')
|
Nenue@6
|
14 Turok:SetDefaultModuleState(true)
|
Nenue@6
|
15 TurokEnv.Addon = Turok
|
Nenue@6
|
16 TurokEnv.LSM = LibStub("LibSharedMedia-3.0")
|
Nenue@6
|
17 TurokEnv.LGIST = LibStub("LibGroupInSpecT-1.1")
|
Nenue@6
|
18 local T = Turok
|
Nenue@6
|
19 --@debug@
|
Nenue@6
|
20 local print = function(...)
|
Nenue@6
|
21 if _G.Devian and _G.DevianDB.workspace ~= 1 then
|
Nenue@6
|
22 _G.print('DB', ...)
|
Nenue@6
|
23 end
|
Nenue@6
|
24 end
|
Nenue@6
|
25 local cTypes = { ['function'] = 'FF9922', ['table'] = '00FFAA', ['number'] = '77FF00', ['string'] = '00AAFF', ['hl'] = 'FF0088', ['field'] = '00FFFF',
|
Nenue@6
|
26 ['boolean'] = 'CC88FF', ['false'] = 'FF7700', ['true'] = '44FF66', ['nil'] = 'FFFF00',}
|
Nenue@6
|
27
|
Nenue@6
|
28 local Debuggers = {
|
Nenue@6
|
29 cType = function(s) return '|cFF' .. tostring(cTypes[type(s)]) .. tostring(s) .. '|r' end,
|
Nenue@6
|
30 cText = function(s) return '|cFF'..cTypes.string..tostring(s)..'|r' end,
|
Nenue@6
|
31 cNum = function(n) return '|cFF'..cTypes.number .. tostring(n) .. '|r' end,
|
Nenue@6
|
32 cWord = function(w) return '|cFF'..cTypes.table .. tostring(w) .. '|r' end,
|
Nenue@6
|
33 cKey = function(k) return '|cFF'..cTypes.field .. tostring(k) .. '|r' end,
|
Nenue@6
|
34 cPink = function(s) return '|cFF'..cTypes.hl .. tostring(s) .. '|r' end,
|
Nenue@6
|
35 cBool = function(s) return '|cFF'..cTypes[tostring((not not s))] .. tostring(s) .. '|r' end,
|
Nenue@6
|
36 }
|
Nenue@6
|
37 for fname, func in pairs(Debuggers) do
|
Nenue@6
|
38 _G[fname] = func
|
Nenue@6
|
39 end
|
Nenue@6
|
40 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool
|
Nenue@6
|
41 --@end-debug@
|
Nenue@6
|
42
|
Nenue@6
|
43 T.db = {}
|
Nenue@6
|
44 T.versionString = GetAddOnMetadata("Turok", "Version")
|
Nenue@6
|
45
|
Nenue@6
|
46 function T:OnModuleCreated(mod)
|
Nenue@6
|
47 if mod.events then
|
Nenue@6
|
48 print('Module', unpack(mod.events))
|
Nenue@6
|
49 end
|
Nenue@6
|
50 end
|
Nenue@6
|
51 --- RegisterEvent embedded to module tables
|
Nenue@6
|
52 function T:RegisterCallback(event, func, ...)
|
Nenue@6
|
53 if not T.dispatchQueue[event] then
|
Nenue@6
|
54 T.dispatchQueue[event] = {}
|
Nenue@6
|
55 end
|
Nenue@6
|
56
|
Nenue@6
|
57 if not T.dispatchQueue[event][T.ID] then
|
Nenue@6
|
58 T.dispatchQueue[event][T.ID] = T:GetName()
|
Nenue@6
|
59 end
|
Nenue@6
|
60
|
Nenue@6
|
61 if (type(func) == 'function') then
|
Nenue@6
|
62 if type(T[event]) == 'function' then
|
Nenue@6
|
63 local oldfunc = T[event]
|
Nenue@6
|
64 T[event] = function(...)
|
Nenue@6
|
65 oldfunc(...)
|
Nenue@6
|
66 return func(...)
|
Nenue@6
|
67 end
|
Nenue@6
|
68 else
|
Nenue@6
|
69 T[event] = func
|
Nenue@6
|
70 end
|
Nenue@6
|
71 end
|
Nenue@6
|
72 --@debug@
|
Nenue@6
|
73 print(cText('Adding listener for'), cKey(self:GetName()), cText('on'), cKey(event))--@end-debug@
|
Nenue@6
|
74 end
|
Nenue@6
|
75
|
Nenue@6
|
76 --- Default settings base
|
Nenue@6
|
77 T.defaults = {
|
Nenue@6
|
78 char = {},
|
Nenue@6
|
79
|
Nenue@6
|
80 lefttext = {
|
Nenue@6
|
81 parent = 2, -- in an overlay frame
|
Nenue@6
|
82 anchor = 'LEFT',
|
Nenue@6
|
83 anchorTo = 'LEFT',
|
Nenue@6
|
84 size = 18,
|
Nenue@6
|
85 x = 5, y = 0,
|
Nenue@6
|
86 justifyH = 'LEFT',
|
Nenue@6
|
87 justifyV = 'MIDDLE',
|
Nenue@6
|
88 },
|
Nenue@6
|
89
|
Nenue@6
|
90 righttext = {
|
Nenue@6
|
91 parent = 2, -- in an overlay frame
|
Nenue@6
|
92 anchor = 'RIGHT',
|
Nenue@6
|
93 anchorTo = 'RIGHT',
|
Nenue@6
|
94 x = -5,
|
Nenue@6
|
95 y = 0,
|
Nenue@6
|
96 size = 18,
|
Nenue@6
|
97 justifyH = 'RIGHT',
|
Nenue@6
|
98 justifyV = 'MIDDLE',
|
Nenue@6
|
99 },
|
Nenue@6
|
100
|
Nenue@6
|
101 alpha = 1,
|
Nenue@6
|
102 alpha_ooc = 1,
|
Nenue@6
|
103 alpha_fade_in = 0.2,
|
Nenue@6
|
104 alpha_fade_out = 0.2,
|
Nenue@6
|
105 border_color = {0,0,0,1},
|
Nenue@6
|
106
|
Nenue@6
|
107 background_color = {0,.0,0,1},
|
Nenue@6
|
108 background_blend = 'BLEND',
|
Nenue@6
|
109
|
Nenue@6
|
110 foreground_texture = [[Interface\Addons\Turok\Media\statusbar\Minimalist.tga]],
|
Nenue@6
|
111 foreground_color = {0,.475,.95,1},
|
Nenue@6
|
112 foreground_blend = 'BLEND',
|
Nenue@6
|
113
|
Nenue@6
|
114 foreground_inset = 0,
|
Nenue@6
|
115 padding = 2,
|
Nenue@6
|
116 spacing = 0,
|
Nenue@6
|
117 fill_direction = 'RIGHT',
|
Nenue@6
|
118
|
Nenue@6
|
119 anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER',
|
Nenue@6
|
120 x = 0, y = 0,
|
Nenue@6
|
121 inset = -3,
|
Nenue@6
|
122 width = 250,
|
Nenue@6
|
123 height = 100,
|
Nenue@6
|
124 strata = 'LOW',
|
Nenue@6
|
125 font = "Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf",
|
Nenue@6
|
126 size = 14,
|
Nenue@6
|
127 text_color = {1, 1, 1, 1},
|
Nenue@6
|
128 justifyH = 'LEFT',
|
Nenue@6
|
129 outline = 'OUTLINE',
|
Nenue@6
|
130 combatFade = true,
|
Nenue@6
|
131
|
Nenue@6
|
132 battle_noise_start = [[Interface\Addons\Turok\Media\sound\Low_Beep-Public_D-136_hifi.mp3]],
|
Nenue@6
|
133 battle_noise_end = [[Interface\Addons\Turok\Media\sound\Electro_-S_Bainbr-7955_hifi.mp3]],
|
Nenue@6
|
134 }
|
Nenue@6
|
135
|
Nenue@6
|
136
|
Nenue@6
|
137 T.events = {
|
Nenue@6
|
138 'PLAY_MOVIE',
|
Nenue@6
|
139 'PLAYER_TARGET_CHANGED',
|
Nenue@6
|
140 'PLAYER_FOCUS_CHANGED',
|
Nenue@6
|
141 'PLAYER_EQUIPMENT_CHANGED',
|
Nenue@6
|
142 'PLAYER_REGEN_DISABLED',
|
Nenue@6
|
143 'PLAYER_REGEN_ENABLED',
|
Nenue@6
|
144 'SPELL_UDPATE_COOLDOWN',
|
Nenue@6
|
145 'SPELL_UPDATE_USABLE',
|
Nenue@6
|
146 'UNIT_AURA',
|
Nenue@6
|
147 'UNIT_PET',
|
Nenue@6
|
148 'UNIT_POWER_FREQUENT',
|
Nenue@6
|
149 'UNIT_SPELL_HASTE',
|
Nenue@6
|
150 'UNIT_SPELLCAST_SENT',
|
Nenue@6
|
151 'UNIT_SPELLCAST_START',
|
Nenue@6
|
152 'UNIT_SPELLCAST_DELAYED',
|
Nenue@6
|
153 'UNIT_SPELLCAST_STOP',
|
Nenue@6
|
154 'UNIT_SPELLCAST_CHANNEL_START',
|
Nenue@6
|
155 'UNIT_SPELLCAST_CHANNEL_UPDATE',
|
Nenue@6
|
156 'UNIT_SPELLCAST_CHANNEL_STOP',
|
Nenue@6
|
157 'UNIT_SPELLCAST_FAILED',
|
Nenue@6
|
158 'UNIT_SPELLCAST_INTERRUPTED',
|
Nenue@6
|
159 'UNIT_SPELLCAST_INTERRUPTIBLE',
|
Nenue@6
|
160 'UNIT_SPELLCAST_SUCCEEDED',
|
Nenue@6
|
161 'UNIT_SPELLCAST_UNINTERRUPTIBLE',
|
Nenue@6
|
162 }
|
Nenue@6
|
163 T.previousSpec = {}
|
Nenue@6
|
164 T.talents = { {}, {}}
|
Nenue@6
|
165 T.changedTalents = {{}, {} }
|
Nenue@6
|
166 T.talentInfo = {}
|
Nenue@6
|
167 T.auras = {}
|
Nenue@6
|
168 T.spells = {}
|
Nenue@6
|
169 T.spellevent = {}
|
Nenue@6
|
170 T.channeling = {}
|
Nenue@6
|
171 T.casting = {}
|
Nenue@6
|
172 T.sent = {}
|
Nenue@6
|
173 T.prototype = {}
|
Nenue@6
|
174 T.spellBook = {}
|
Nenue@6
|
175 T.equipped = {}
|
Nenue@6
|
176
|
Nenue@6
|
177 --- player-restricted unit info and text representations
|
Nenue@6
|
178 T.player = {}
|
Nenue@6
|
179 T.playertext = {}
|
Nenue@6
|
180 T.pet = {}
|
Nenue@6
|
181
|
Nenue@6
|
182 --- holds non-restricted unit information
|
Nenue@6
|
183 T.unit = {
|
Nenue@6
|
184 player = {},
|
Nenue@6
|
185 target = {},
|
Nenue@6
|
186 focus = {},
|
Nenue@6
|
187 pet = {},
|
Nenue@6
|
188 }
|
Nenue@6
|
189
|
Nenue@6
|
190 -- index of frames with conditional visual properties
|
Nenue@6
|
191 T.control_regions = {}
|
Nenue@6
|
192
|
Nenue@6
|
193 -- index of frames generated by the lua
|
Nenue@6
|
194 T.frames = {}
|
Nenue@6
|
195
|
Nenue@6
|
196 -- units
|
Nenue@6
|
197 T.units = {}
|
Nenue@6
|
198 T.unitsBySlot = {}
|
Nenue@6
|
199 setmetatable(T.unitsBySlot, {__mode="v"})
|
Nenue@6
|
200
|
Nenue@6
|
201
|
Nenue@6
|
202
|
Nenue@6
|
203 T.TrueVal = function (self,k)
|
Nenue@6
|
204 return rawget(self,k)
|
Nenue@6
|
205 end
|
Nenue@6
|
206 --- Sets an index hierarchy for db vars and propagates config dialog info
|
Nenue@6
|
207 T.LinkTable = function (over, under, pname, cname)
|
Nenue@6
|
208 local mt = {
|
Nenue@6
|
209 __index = function(t,k)
|
Nenue@6
|
210 if type(over[k]) ~= nil then
|
Nenue@6
|
211 --t[k] = over[k]
|
Nenue@6
|
212 --@debug@
|
Nenue@6
|
213 --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@
|
Nenue@6
|
214 end
|
Nenue@6
|
215 return over[k]
|
Nenue@6
|
216 end,
|
Nenue@6
|
217 __newindex = function (t, k, v)
|
Nenue@6
|
218 rawset(t,k,v)
|
Nenue@6
|
219 if type(v) == 'table' then
|
Nenue@6
|
220 --@debug@
|
Nenue@6
|
221 --print('parenting '.. STACK_COLOR2.. pname ..'|r to created table '.. STACK_COLOR3.. cname ..'|r')--@end-debug@
|
Nenue@6
|
222 T.LinkTable(under, v, pname, k)
|
Nenue@6
|
223 end
|
Nenue@6
|
224 end
|
Nenue@6
|
225 }
|
Nenue@6
|
226 --under.TrueVal = T.TrueVal
|
Nenue@6
|
227 setmetatable(under, mt)
|
Nenue@6
|
228 for k, v in pairs(under) do
|
Nenue@6
|
229 if type(v) == 'table' then
|
Nenue@6
|
230 --@debug@
|
Nenue@6
|
231 --print('linking '..STACK_COLOR1.. pname ..'|r to '..STACK_COLOR2.. cname ..'|r')--@end-debug@
|
Nenue@6
|
232 T.LinkTable(under, v, pname ..'.'.. cname, k)
|
Nenue@6
|
233 end
|
Nenue@6
|
234 end
|
Nenue@6
|
235 end
|
Nenue@6
|
236
|
Nenue@6
|
237
|
Nenue@6
|
238 --- Merges values of table B into table A, and copies over nested values of tables matching the keywords list
|
Nenue@6
|
239 local masked = {name = true, virtual = true}
|
Nenue@6
|
240 T.Config_Push = function(cvars, push , root, rkey)
|
Nenue@6
|
241 local results = {}
|
Nenue@6
|
242 root = root or cvars
|
Nenue@6
|
243 for k, v in pairs(push) do
|
Nenue@6
|
244 if not masked[k] then
|
Nenue@6
|
245 if type(v) == 'table' and v ~= root then
|
Nenue@6
|
246 cvars[k] = {}
|
Nenue@6
|
247 T.Config_Push(cvars[k], v, root)
|
Nenue@6
|
248 else
|
Nenue@6
|
249 print(' |cFFFF0088B|r ', tostring(rkey)..'.'..cKey(k))
|
Nenue@6
|
250 cvars[k] = v
|
Nenue@6
|
251 tinsert(results, ' |cFFFF0088B|r '.. tostring(rkey)..'.'..cKey(k))
|
Nenue@6
|
252 end
|
Nenue@6
|
253 end
|
Nenue@6
|
254 end
|
Nenue@6
|
255 return cvars, results
|
Nenue@6
|
256 end
|
Nenue@6
|
257 T.Config_Merge = function(cvars, merge, root, rkey)
|
Nenue@6
|
258 local diff = {}
|
Nenue@6
|
259 root = root or cvars
|
Nenue@6
|
260 rkey = rkey or '0'
|
Nenue@6
|
261 for k, v in pairs(merge) do
|
Nenue@6
|
262 if masked[k] or cvars[k] then
|
Nenue@6
|
263 tinsert(diff, ' |cFF00FF00A|r '.. tostring(rkey)..'.'..cWord(k))
|
Nenue@6
|
264 print(' |cFF00FF00A|r ', tostring(rkey)..'.'..cText(k), '=', cvars[k])
|
Nenue@6
|
265 --cvars[k] = cvars[k]
|
Nenue@6
|
266 else
|
Nenue@6
|
267 if type(v) == 'table' then
|
Nenue@6
|
268 if type(cvars[k]) == 'nil' then
|
Nenue@6
|
269 cvars[k] = {}
|
Nenue@6
|
270 end
|
Nenue@6
|
271 if type(cvars[k]) == 'table' then
|
Nenue@6
|
272 print(' |cFFFFFF00A+B|r '.. tostring(rkey)..'.'..cWord(k))
|
Nenue@6
|
273 cvars[k] = T.Config_Merge(cvars[k], v, root, tostring(rkey)..'.'..tostring(k))
|
Nenue@6
|
274 end
|
Nenue@6
|
275 elseif cvars[k] == nil then
|
Nenue@6
|
276 tinsert(diff, ' |cFFFF0088B|r '.. tostring(rkey)..'.'..cKey(k))
|
Nenue@6
|
277 print(' |cFFFF0088B|r ', tostring(rkey)..'.'..cKey(k))
|
Nenue@6
|
278 cvars[k] = v
|
Nenue@6
|
279 else
|
Nenue@6
|
280 tinsert(diff, ' |cFF00FF00A|r '.. tostring(rkey)..'.'..cWord(k))
|
Nenue@6
|
281 print(' |cFF00FF00A|r ', tostring(rkey)..'.'..cWord(k))
|
Nenue@6
|
282 --cvars[k] = cvars[k]
|
Nenue@6
|
283 end
|
Nenue@6
|
284 end
|
Nenue@6
|
285 end
|
Nenue@6
|
286 return cvars, diff
|
Nenue@6
|
287 end |