Mercurial > wow > buffalo2
comparison Veneer.lua @ 48:9837069e366a
move BuffFrame-specific things out of Veneer.lua
straighten out table hierarchy for BuffFrame module
author | Nenue |
---|---|
date | Thu, 28 Apr 2016 06:58:13 -0400 |
parents | 1a322b92dbfa |
children | 16465f3fd919 |
comparison
equal
deleted
inserted
replaced
47:1a322b92dbfa | 48:9837069e366a |
---|---|
129 return B[key] | 129 return B[key] |
130 end | 130 end |
131 | 131 |
132 | 132 |
133 --- localize for speed | 133 --- localize for speed |
134 local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays | |
135 | 134 |
136 local ModulesCall = function(func, flag) | 135 local ModulesCall = function(func, flag) |
137 | 136 |
138 local n = 0 | 137 local n = 0 |
139 for i = 1, #moduleStack do | 138 for i = 1, #moduleStack do |
167 --- The things that happen repeatedly | 166 --- The things that happen repeatedly |
168 local Init = function () | 167 local Init = function () |
169 end | 168 end |
170 | 169 |
171 | 170 |
171 local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays | |
172 --- Things that happen immediately upon entering world | 172 --- Things that happen immediately upon entering world |
173 local InitOnce = function() | 173 local InitOnce = function() |
174 print('entering world first time') | 174 print('entering world first time') |
175 local defaults = B.ConfDefaults | 175 local defaults = {} |
176 print('|cFFFFFF00Veneer|r') | 176 print('|cFFFFFF00Veneer|r') |
177 if not VeneerData then | 177 if not VeneerData then |
178 VeneerData = {} | 178 VeneerData = {} |
179 for k,v in pairs(defaults) do | 179 for k,v in pairs(defaults) do |
180 | |
181 | |
182 VeneerData[k] = v | 180 VeneerData[k] = v |
183 end | 181 end |
184 print('Veneer defaults being used.') | 182 print('Veneer defaults being used.') |
185 end | 183 end |
186 | |
187 B.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end}) | 184 B.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end}) |
188 | |
189 | |
190 | |
191 -- suffix tables | |
192 for name, display in pairs(displays) do | |
193 display.conf = setmetatable({}, { | |
194 __index = function(_, k) | |
195 --print('config check '.. name .. k) | |
196 return B.Conf[name .. k] or B.Conf['BuffButton' .. k] | |
197 end, | |
198 __newindex = function(_, k , v) | |
199 B.Conf[name..k] = v | |
200 end, | |
201 }) | |
202 end | |
203 | 185 |
204 -- To ensure that modules are run in controlled order, walk the dependency list; if the dep shows up | 186 -- To ensure that modules are run in controlled order, walk the dependency list; if the dep shows up |
205 -- in the loaded manifest, remove the value. If the dep list isn't empty, move that module to the next | 187 -- in the loaded manifest, remove the value. If the dep list isn't empty, move that module to the next |
206 -- layer. | 188 -- layer. |
207 local loaded = {} | 189 local loaded = {} |
249 loaded[name] = true | 231 loaded[name] = true |
250 end | 232 end |
251 end | 233 end |
252 i = i + 1 | 234 i = i + 1 |
253 until i > stackLevels | 235 until i > stackLevels |
254 | |
255 | 236 |
256 for level, batch in ipairs(moduleStack) do | 237 for level, batch in ipairs(moduleStack) do |
257 print('config level', level) | 238 print('config level', level) |
258 for name, module in pairs(batch) do | 239 for name, module in pairs(batch) do |
259 if not VeneerData[name] then | 240 if not VeneerData[name] then |
280 end | 261 end |
281 | 262 |
282 end | 263 end |
283 end | 264 end |
284 | 265 |
285 | 266 --- Pull in any XML templates |
286 if #checkForConfig >= 1 then | 267 if #checkForConfig >= 1 then |
287 local queuedFrame = tremove(checkForConfig) | 268 local queuedFrame = tremove(checkForConfig) |
288 while queuedFrame do | 269 while queuedFrame do |
289 B.SetConfigLayers(queuedFrame) | 270 B.SetConfigLayers(queuedFrame) |
290 B.UpdateXMLFrame(queuedFrame) | 271 B.UpdateXMLFrame(queuedFrame) |
291 queuedFrame = tremove(checkForConfig) | 272 queuedFrame = tremove(checkForConfig) |
292 end | 273 end |
293 end | 274 end |
294 -- remove from existing | |
295 end | 275 end |
296 | 276 |
297 --- Fires an update to all modules | 277 --- Fires an update to all modules |
298 local lastUpdate | 278 local lastUpdate |
299 function B.UpdateAll(...) | 279 function B.UpdateAll(...) |
391 refs[subframe] = nil | 371 refs[subframe] = nil |
392 end | 372 end |
393 end | 373 end |
394 end | 374 end |
395 | 375 |
396 B.UpdateConfigLayers = function() | 376 B.ToggleGuideLayers = function() |
397 local print = B.fprint() | 377 local print = B.fprint() |
398 local func = B.Conf.GuidesMode and 'Show' or 'Hide' | 378 local func = B.Conf.GuidesMode and 'Show' or 'Hide' |
399 local numAnchors = 0 | 379 local numAnchors = 0 |
400 for name, display in pairs(displays) do | 380 |
401 numAnchors = numAnchors + 1 | |
402 display.anchor:EnableMouse(B.Conf.GuidesMode) | |
403 if B.Conf.GuidesMode then | |
404 display.anchor:SetScript('OnUpdate', display.anchor.OnUpdate) | |
405 else | |
406 display.anchor:SetScript('OnUpdate', nil) | |
407 | |
408 for i, anchorButton in ipairs(display.anchor.anchorButton) do | |
409 anchorButton:Hide() | |
410 end | |
411 | |
412 end | |
413 --print(B.Conf.ConfigMode) | |
414 display.anchor:EnableMouse(B.Conf.ConfigMode) | |
415 end | |
416 for id, region in pairs(layers) do | 381 for id, region in pairs(layers) do |
417 --print(id, region:GetName(), func) | 382 --print(id, region:GetName(), func) |
418 region[func](region) | 383 region[func](region) |
419 end | 384 end |
420 | 385 |
421 --print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') | 386 --print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') |
387 end | |
388 B.UpdateConfigLayers = function() | |
389 print('|cFFFF0000', debugstack()) | |
390 B.ToggleGuideLayers() | |
422 end | 391 end |
423 | 392 |
424 local XMLFrame_Enable = function(self, value) | 393 local XMLFrame_Enable = function(self, value) |
425 local name = self:GetName() | 394 local name = self:GetName() |
426 local print = B.print('XML') | 395 local print = B.print('XML') |