comparison Veneer.lua @ 54:ed74c5cabe98

Core - updated comment notes Objectives - force hide blocks when their tracker is hidden Clock - convert clock into its own module - display zone coordinates alongside time
author Nenue
date Wed, 01 Jun 2016 20:48:14 -0400
parents 16465f3fd919
children dd9b5f59632c
comparison
equal deleted inserted replaced
53:5cedcb683eda 54:ed74c5cabe98
1 --- Modulizer framework 1 --------------------------------------------
2 -- Veneer
3 -- Core
4 -- author: Krakyn
5 -- @project-revision@ @project-hash@
6 -- @file-revision@ @file-hash@
7 -- Created: 4/27/2016 1:02 AM
8 --------------------------------------------
9 --- Implemented methods
2 -- OnInitialize 10 -- OnInitialize
3 -- OnUpdate 11 -- OnUpdate
4 -- OnEnable -- run when GetSpecialization() returns true 12 -- OnEnable -- runs as soon as GetSpecialization() returns valid data
5 13
6 local ADDON, A = ... 14 local ADDON, A = ...
7 Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent)
8 local B = Veneer
9 local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove 15 local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove
10 local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G 16 local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G
11 local type, tostring, format = type, tostring, string.format 17 local type, tostring, format = type, tostring, string.format
12 A.frame = B 18
13 19 --- Establish presence
14 --- Cache tables 20 Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent)
15 local initOnced 21 local V = Veneer
16 local modules = {} 22 A.frame = V
17 local queuedModules = {} 23
18 local checkForConfig = {} 24 --- Work variables
19 local moduleStack = { 25 local modules = {} -- module collector
20 } 26 local queuedModules = {} -- indicates modules that were encountered out of dependency order
27 local checkForConfig = {} -- indicates frames created from XML that use their own namespace for position control
28 local moduleStack = {} -- dictates the order in which module methods are fired
29 local initOnced -- internal check for doing bottom-up SV retrieval
21 30
22 --- Utilities 31 --- Utilities
23 B.wipeall = function (...) 32 V.wipeall = function (...)
24 for i = 1, select('#', ...) do 33 for i = 1, select('#', ...) do
25 wipe(select(i, ...)) 34 wipe(select(i, ...))
26 end 35 end
27 end 36 end
28 37
29 --- Various region categories 38 --- Various region categories
30 B.displays = {} 39 V.displays = {}
31 B.configLayers = {} 40 V.configLayers = {}
32 B.configLayersRef = {} 41 V.configLayersRef = {}
33 42
34 43
35 --@debug@ 44 --- Returns a debug hook for adding generic module information to each message
36 --- Generates a print handler pointing to a static channel signature 45 -- @usage func = V.print(sig)
37 -- @usage func = B.print(sig)
38 -- @param sig channel name or number 46 -- @param sig channel name or number
47 local debugstack = _G.debugstack
48 local Devian = _G.Devian
39 local printfuncs = {} 49 local printfuncs = {}
40 B.print = function(pref, ...) 50 V.print = function(pref, ...)
41 if Devian and Devian.InWorkspace() then 51 if Devian and Devian.InWorkspace() then
42 printfuncs[pref] = printfuncs[pref] or function(...) print(pref, ...) end 52 printfuncs[pref] = printfuncs[pref] or function(...) print(pref, ...) end
43 53
44 return printfuncs[pref] 54 return printfuncs[pref]
45 else 55 else
46 return function () end 56 return function () end
47 end 57 end
48 end 58 end
49 59
60 --@debug@
50 local rgb = {} 61 local rgb = {}
51 local getcolor = function() 62 local getcolor = function()
52 local n, p = 0, 4 63 local n, p = 0, 4
53 for i = 1, 3 do 64 for i = 1, 3 do
54 rgb[i] = min(random(n,p) * 64, 255) 65 rgb[i] = min(random(n,p) * 64, 255)
61 return unpack(rgb) 72 return unpack(rgb)
62 end 73 end
63 74
64 local color = {} 75 local color = {}
65 local fprints = {} 76 local fprints = {}
66 B.fprint = function() 77 --- Attempts to generate a debug printer based on the local scope. Results vary by where the originator was invoked.
78 V.fprint = function()
67 if not (Devian and Devian.InWorkspace()) then 79 if not (Devian and Devian.InWorkspace()) then
68 return function() end 80 return function() end
69 end 81 end
70
71 82
72 local sig = debugstack(2,1) 83 local sig = debugstack(2,1)
73 if fprints[sig] then 84 if fprints[sig] then
74 return fprints[sig] 85 return fprints[sig]
75 end 86 end
86 97
87 local r, g, b = getcolor() 98 local r, g, b = getcolor()
88 color[sig] = color[sig] or format('|cFF%02X%02X%02X%s|r', r, g, b, func) 99 color[sig] = color[sig] or format('|cFF%02X%02X%02X%s|r', r, g, b, func)
89 100
90 --print(color[func] .. ' ( ' .. table.concat(args, ', ')..' )' ) 101 --print(color[func] .. ' ( ' .. table.concat(args, ', ')..' )' )
91 func = B.print(func) 102 func = V.print(func)
92 fprints[sig] = func 103 fprints[sig] = func
93 return func 104 return func
94 end 105 end
95 106
96 --@end-debug@ 107 --@end-debug@
97 --[=[@non-debug@ 108 --[=[@non-debug@
98 B.print = function() end 109 V.print = function() end
99 --@end-non-debug@]=] 110 --@end-non-debug@]=]
100 111
101 -- for the Mikk script 112 -- for the Mikk script
102 -- GLOBALS: NUM_LE_RAID_BUFF_TYPES 113 -- GLOBALS: NUM_LE_RAID_BUFF_TYPES
103 -- GLOBALS: BUFF_FLASH_TIME_ON, BUFF_FLASH_TIME_OFF, BUFF_MIN_ALPHA, BUFF_WARNING_TIME, BUFF_DURATION_WARNING_TIME 114 -- GLOBALS: BUFF_FLASH_TIME_ON, BUFF_FLASH_TIME_OFF, BUFF_MIN_ALPHA, BUFF_WARNING_TIME, BUFF_DURATION_WARNING_TIME
104 -- GLOBALS: BUFFS_PER_ROW, BUFF_MAX_DISPLAY, BUFF_ACTUAL_DISPLAY, DEBUFF_MAX_DISPLAY, DEBUFF_ACTUAL_DISPLAY, BUFF_ROW_SPACING 115 -- GLOBALS: BUFFS_PER_ROW, BUFF_MAX_DISPLAY, BUFF_ACTUAL_DISPLAY, DEBUFF_MAX_DISPLAY, DEBUFF_ACTUAL_DISPLAY, BUFF_ROW_SPACING
105 -- GLOBALS: CONSOLIDATED_BUFFS_PER_ROW, CONSOLIDATED_BUFF_ROW_HEIGHT, NUM_TEMP_ENCHANT_FRAMES 116 -- GLOBALS: CONSOLIDATED_BUFFS_PER_ROW, CONSOLIDATED_BUFF_ROW_HEIGHT, NUM_TEMP_ENCHANT_FRAMES
106 -- GLOBALS: BUFF_BUTTON_HEIGHT, BUFF_FRAME_BASE_EXTENT, BUFF_HORIZ_SPACING 117 -- GLOBALS: BUFF_BUTTON_HEIGHT, BUFF_FRAME_BASE_EXTENT, BUFF_HORIZ_SPACING
107 118
108 local print = B.print('Bfl') 119 local print = V.print('Bfl')
109 120
110 --- Template for making perpendicular traversals of the displays structure; also makes sure the table is there 121 --- Template for making perpendicular traversals of the displays structure; also makes sure the table is there
111 B.Abstract = function(dest, key, table) 122 local setmetatable = setmetatable
123 V.Abstract = function(dest, key, table)
112 if table then 124 if table then
113 for _, v in pairs(dest) do 125 for _, v in pairs(dest) do
114 v[key] = {} 126 v[key] = {}
115 end 127 end
116 end 128 end
117 B[key] = setmetatable({}, { 129 V[key] = setmetatable({}, {
118 __index = function(t, k) 130 __index = function(t, k)
119 return dest[k][key] 131 return dest[k][key]
120 end, 132 end,
121 __newindex = function(_, k, v) 133 __newindex = function(_, k, v)
122 print('abstract write ('..key..'):', k) 134 print('abstract write ('..key..'):', k)
124 end, 136 end,
125 __tostring = function() return 'Abstract:'..key..'' end 137 __tostring = function() return 'Abstract:'..key..'' end
126 }) 138 })
127 139
128 140
129 return B[key] 141 return V[key]
130 end 142 end
131 143
132 144
133 --- localize for speed 145 --- internal
134
135 local ModulesCall = function(func, flag) 146 local ModulesCall = function(func, flag)
136
137 local n = 0 147 local n = 0
138 for i = 1, #moduleStack do 148 for i = 1, #moduleStack do
139 print('calling level '..i) 149 print('calling level '..i)
140 local stackset = moduleStack[i] 150 local stackset = moduleStack[i]
141
142 for name, module in pairs(stackset) do 151 for name, module in pairs(stackset) do
143 n = n + 1 152 n = n + 1
144
145
146 if module[func] then 153 if module[func] then
147 -- nil = pass 154 -- nil = pass
148 if not flag or module.Conf[flag] then 155 if not flag or (module.Conf and module.Conf[flag]) then
149 if (flag) then 156 if (flag) then
150 print(' check', flag, '=', module.Conf[flag]) 157 print(' check', flag, '=', module.Conf[flag])
151 end 158 end
152 159
153 print(' ',n..' '..name..'.'..func..'()') 160 print(' ',n..' '..name..'.'..func..'()')
154 module[func](module, module.Conf) 161 module[func](module, module.Conf)
155 end 162 end
156
157 end 163 end
158 end 164 end
159 end 165 end
160 end 166 end
161 167
166 --- The things that happen repeatedly 172 --- The things that happen repeatedly
167 local Init = function () 173 local Init = function ()
168 end 174 end
169 175
170 176
171 local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays 177 local layers, refs, displays = V.configLayers, V.configLayersRef, V.displays
172 --- Things that happen immediately upon entering world 178 --- Things that happen immediately upon entering world
173 local InitOnce = function() 179 local InitOnce = function()
174 print('entering world first time') 180 print('entering world first time')
175 local defaults = {} 181 local defaults = {}
176 print('|cFFFFFF00Veneer|r') 182 print('|cFFFFFF00Veneer|r')
179 for k,v in pairs(defaults) do 185 for k,v in pairs(defaults) do
180 VeneerData[k] = v 186 VeneerData[k] = v
181 end 187 end
182 print('Veneer defaults being used.') 188 print('Veneer defaults being used.')
183 end 189 end
184 B.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end}) 190 V.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end})
185 191
186 -- To ensure that modules are run in controlled order, walk the dependency list; if the dep shows up 192 -- To ensure that modules are run in controlled order, walk the dependency list; if the dep shows up
187 -- in the loaded manifest, remove the value. If the dep list isn't empty, move that module to the next 193 -- in the loaded manifest, remove the value. If the dep list isn't empty, move that module to the next
188 -- layer. 194 -- layer.
189 local loaded = {} 195 local loaded = {}
265 271
266 --- Pull in any XML templates 272 --- Pull in any XML templates
267 if #checkForConfig >= 1 then 273 if #checkForConfig >= 1 then
268 local queuedFrame = tremove(checkForConfig) 274 local queuedFrame = tremove(checkForConfig)
269 while queuedFrame do 275 while queuedFrame do
270 B.SetConfigLayers(queuedFrame) 276 V.SetConfigLayers(queuedFrame)
271 B.UpdateXMLFrame(queuedFrame) 277 V.UpdateXMLFrame(queuedFrame)
272 queuedFrame = tremove(checkForConfig) 278 queuedFrame = tremove(checkForConfig)
273 end 279 end
274 end 280 end
275 end 281 end
276 282
277 --- Fires an update to all modules 283 --- Fires an update to all modules
278 local lastUpdate 284 local lastUpdate
279 function B.UpdateAll(...) 285 function V.UpdateAll(...)
280 lastUpdate = GetTime() 286 lastUpdate = GetTime()
281 ModulesCall('OnUpdate') 287 ModulesCall('OnUpdate')
282 end 288 end
283 289
284 B:RegisterEvent('PLAYER_ENTERING_WORLD') 290 V:RegisterEvent('PLAYER_ENTERING_WORLD')
285 B:SetScript('OnEvent', function(self, event) 291 V:SetScript('OnEvent', function(self, event)
286 if event == 'PLAYER_ENTERING_WORLD' then 292 if event == 'PLAYER_ENTERING_WORLD' then
287 if not initOnced then 293 if not initOnced then
288 InitOnce() 294 InitOnce()
289 ModulesCall('OnInitialize') 295 ModulesCall('OnInitialize')
290 initOnced = true 296 initOnced = true
291 C_Timer.After(1, function() 297 C_Timer.After(1, function()
292 if GetSpecialization() then 298 if GetSpecialization() then
293 print(GetSpecialization(), 'enabling') 299 print(GetSpecialization(), 'enabling')
294 300
295 ModulesCall('OnEnable', 'enabled') 301 ModulesCall('OnEnable', 'enabled')
296 B:SetScript('OnUpdate', nil) 302 V:SetScript('OnUpdate', nil)
297 end 303 end
298 end) 304 end)
299 end 305 end
300 end 306 end
301 307
302 B.UpdateAll() 308 V.UpdateAll()
303 309
304 if event == 'PLAYER_ENTERING_WORLD' then 310 if event == 'PLAYER_ENTERING_WORLD' then
305 B.UpdateConfigLayers() 311 V.UpdateConfigLayers()
306 end 312 end
307 313
308 end) 314 end)
309 315
310 --- Modulizer method 316 --- Modulizer method
311 -- 317 --
312 function B:RegisterModule (name, module, ...) 318 function V:RegisterModule (name, module, ...)
313 if modules[name] then 319 if modules[name] then
314 print('pulling modules[|cFFFF8800'.. tostring(name) ..'|r]') 320 print('pulling modules[|cFFFF8800'.. tostring(name) ..'|r]')
315 return modules[name] 321 return modules[name]
316 end 322 end
317 323
319 if module then 325 if module then
320 if modules[name] then 326 if modules[name] then
321 error("Module table for '"..tostring(name).."' already exists.") 327 error("Module table for '"..tostring(name).."' already exists.")
322 end 328 end
323 else 329 else
324 module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate') 330 module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', V, 'VeneerHandlerTemplate')
325 end 331 end
326 modules[name] = module 332 modules[name] = module
327 B[name] = module 333 V[name] = module
328 if select('#', ...) >= 1 then 334 if select('#', ...) >= 1 then
329 local numDeps = select('#', ...) 335 local numDeps = select('#', ...)
330 print(' '..numDeps..' deps detected') 336 print(' '..numDeps..' deps detected')
331 for i = 1, numDeps do 337 for i = 1, numDeps do
332 local dep = select(i, ...) 338 local dep = select(i, ...)
338 end 344 end
339 return module 345 return module
340 end 346 end
341 347
342 348
343 B.SetConfigLayers = function(frame) 349 V.SetConfigLayers = function(frame)
344 local print = B.fprint() 350 local print = V.fprint()
345 if not frame.config then 351 if not frame.config then
346 --print(frame:GetName(), 'has no config layers') 352 --print(frame:GetName(), 'has no config layers')
347 return 353 return
348 end 354 end
349 --print('Registering config layers from', frame:GetName()) 355 --print('Registering config layers from', frame:GetName())
357 end 363 end
358 --print(' ', i, subframe:GetName()) 364 --print(' ', i, subframe:GetName())
359 end 365 end
360 end 366 end
361 367
362 B.RemoveConfigLayers = function(frame) 368 V.RemoveConfigLayers = function(frame)
363 369
364 local print = B.fprint() 370 local print = V.fprint()
365 print('|cFFFF0000RemoveConfigLayers', frame:GetName()) 371 print('|cFFFF0000RemoveConfigLayers', frame:GetName())
366 for i, subframe in pairs(layers) do 372 for i, subframe in pairs(layers) do
367 if subframe:GetParent() == frame then 373 if subframe:GetParent() == frame then
368 print('|cFFFF8800 ', subframe:GetParent():GetName(), '|cFFFFFF00', subframe:GetName()) 374 print('|cFFFF8800 ', subframe:GetParent():GetName(), '|cFFFFFF00', subframe:GetName())
369 layers[i]:Hide() 375 layers[i]:Hide()
371 refs[subframe] = nil 377 refs[subframe] = nil
372 end 378 end
373 end 379 end
374 end 380 end
375 381
376 B.ToggleGuideLayers = function() 382 V.ToggleGuideLayers = function()
377 local print = B.fprint() 383 local print = V.fprint()
378 local func = B.Conf.GuidesMode and 'Show' or 'Hide' 384 local func = V.Conf.GuidesMode and 'Show' or 'Hide'
379 local numAnchors = 0 385 local numAnchors = 0
380 386
381 for id, region in pairs(layers) do 387 for id, region in pairs(layers) do
382 --print(id, region:GetName(), func) 388 --print(id, region:GetName(), func)
383 region[func](region) 389 region[func](region)
384 end 390 end
385 391
386 --print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') 392 --print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames')
387 end 393 end
388 B.UpdateConfigLayers = function() 394 V.UpdateConfigLayers = function()
389 print('|cFFFF0000', debugstack()) 395 print('|cFFFF0000', debugstack())
390 B.ToggleGuideLayers() 396 V.ToggleGuideLayers()
391 end 397 end
392 398
393 local XMLFrame_Enable = function(self, value) 399 local XMLFrame_Enable = function(self, value)
394 local name = self:GetName() 400 local name = self:GetName()
395 local print = B.print('XML') 401 local print = V.print('XML')
396 402
397 if not B.Conf[name] then 403 if not V.Conf[name] then
398 B.Conf[name] = { 404 V.Conf[name] = {
399 enabled = true 405 enabled = true
400 } 406 }
401 end 407 end
402 408
403 print() 409 print()
404 local enabled 410 local enabled
405 if value == nil then 411 if value == nil then
406 if B.Conf[name].enabled == nil then 412 if V.Conf[name].enabled == nil then
407 print('toggle based on visibility') 413 print('toggle based on visibility')
408 enabled = (not self:IsVisible()) and true or false 414 enabled = (not self:IsVisible()) and true or false
409 else 415 else
410 print('toggle a config value =', B.Conf[name].enabled) 416 print('toggle a config value =', V.Conf[name].enabled)
411 enabled = B.Conf[name].enabled 417 enabled = V.Conf[name].enabled
412 end 418 end
413 419
414 enabled = (enabled ~= true) and true or false 420 enabled = (enabled ~= true) and true or false
415 else 421 else
416 print('use argument value', value) 422 print('use argument value', value)
417 enabled = value 423 enabled = value
418 end 424 end
419 425
420 print('arg =', value, 'conf =', B.Conf[name].enabled, 'result=', enabled) 426 print('arg =', value, 'conf =', V.Conf[name].enabled, 'result=', enabled)
421 427
422 B.Conf[name].enabled = enabled 428 V.Conf[name].enabled = enabled
423 429
424 local stateFunc = enabled and 'Show' or 'Hide' 430 local stateFunc = enabled and 'Show' or 'Hide'
425 local eventFunc = enabled and 'OnToggle' or 'OnToggle' 431 local eventFunc = enabled and 'OnToggle' or 'OnToggle'
426 --- taggled layers 432 --- taggled layers
427 if self.toggled then 433 if self.toggled then
429 region[stateFunc](region) 435 region[stateFunc](region)
430 end 436 end
431 end 437 end
432 --- toggle action 438 --- toggle action
433 if self.OnToggle then 439 if self.OnToggle then
434 self:OnToggle(B.Conf[name].enabled) 440 self:OnToggle(V.Conf[name].enabled)
435 end 441 end
436 --- do enable 442 --- do enable
437 if B.Conf[name].enabled then 443 if V.Conf[name].enabled then
438 if self.OnEnable then 444 if self.OnEnable then
439 self:OnEnable() 445 self:OnEnable()
440 end 446 end
441 else 447 else
442 if self.OnDisable then 448 if self.OnDisable then
443 self:OnDisable() 449 self:OnDisable()
444 end 450 end
445 end 451 end
446 end 452 end
447 --- Generic handlers for keeping track of XML-defined frames 453 --- Generic handlers for keeping track of XML-defined frames
448 local print = B.print('XML') 454 local print = V.print('XML')
449 B.prototypes = {} 455 local prototypes = {}
450 B.prototypes.OnDragStart = function(self) 456 prototypes.OnDragStart = function(self)
451 local print = B.print('XML')
452 self.xA = self:GetLeft() 457 self.xA = self:GetLeft()
453 self.yA = self:GetBottom() 458 self.yA = self:GetBottom()
454 self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1) 459 self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1)
455 print('acquire anchor', self:GetPoint(1)) 460 print('acquire anchor', self:GetPoint(1))
456 print(self:GetName(), 'start moving ('..self.x..', '..self.y..')') 461 print(self:GetName(), 'start moving ('..self.x..', '..self.y..')')
457 self:StartMoving() 462 self:StartMoving()
458 end 463 end
459 464
460 B.prototypes.OnDragStop = function(self) 465 prototypes.OnDragStop = function(self)
461 local print = B.print('XML')
462 local name = self:GetName() 466 local name = self:GetName()
463 print(name, 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') 467 print(name, 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')')
464 local xB = self:GetLeft() - self.xA 468 local xB = self:GetLeft() - self.xA
465 local yB = self:GetBottom() - self.yA 469 local yB = self:GetBottom() - self.yA
466 print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) 470 print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB)
467
468 self:StopMovingOrSizing() 471 self:StopMovingOrSizing()
469 B.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} 472 V.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB}
470 B.UpdateXMLFrame(self) 473 V.UpdateXMLFrame(self)
471 end 474 end
472 475
473 476
474 B.RegisterModuleFrame = function(self, moduleName) 477 V.RegisterModuleFrame = function(self, moduleName)
475 local print = B.print('XML')
476 local name = self:GetName() 478 local name = self:GetName()
477 tinsert(checkForConfig, self) 479 tinsert(checkForConfig, self)
478 self.Enable = XMLFrame_Enable 480 self.Enable = XMLFrame_Enable
479 self.moduleName = moduleName 481 self.moduleName = moduleName
480 print('|cFF00FF00XML stuff related to '.. tostring(moduleName) .. ':', self:GetName()) 482 print('|cFF00FF00XML stuff related to '.. tostring(moduleName) .. ':', self:GetName())
481 ------------------------------------------------------------------------------------------ 483 ------------------------------------------------------------------------------------------
482 if not B[name] then 484 if not V[name] then
483 return 485 return
484 end 486 end
485 487
486 local scriptTypes = {'OnUpdate', 'OnEvent', 'OnDragStart', 'OnDragStop'} 488 local scriptTypes = {'OnUpdate', 'OnEvent', 'OnDragStart', 'OnDragStop'}
487 for script in next(scriptTypes) do 489 for script in next(scriptTypes) do
488 if B[name][script] then 490 if V[name][script] then
489 self:SetScript(script, B[name][script]) 491 self:SetScript(script, V[name][script])
490 end 492 end
491 end 493 end
492 494
493 end 495 end
494 local XMLFrame_OnDragStart = function() end 496 local XMLFrame_OnDragStart = function() end
495 local XMLFrame_OnDragStop = function() end 497 local XMLFrame_OnDragStop = function() end
496 498
497 B.UpdateXMLFrame = function(self) 499 V.UpdateXMLFrame = function(self)
498 local print = B.print('XML') 500 local print = V.print('XML')
499 501
500 local name = self:GetName() 502 local name = self:GetName()
501 503
502 504
503 if self.drag then 505 if self.drag then
504 self:RegisterForDrag('LeftButton') 506 self:RegisterForDrag('LeftButton')
505 self:SetScript('OnDragStart', XMLFrame_OnDragStart) 507 self:SetScript('OnDragStart', prototypes.OnDragStart)
506 if self.OnDragStop then 508 if self.OnDragStop then
507 self:SetScript('OnDragStop', function(self, ...) 509 self:SetScript('OnDragStop', function(self, ...)
508 print('|cFFFF0088end of dragging') 510 print('|cFFFF0088end of dragging')
509 self:OnDragStop(self, ...) 511 self:OnDragStop(self, ...)
510 XMLFrame_OnDragStop(self, ...) 512 prototypes.OnDragStop(self, ...)
511 end) 513 end)
512 else 514 else
513 self:SetScript('OnDragStop', XMLFrame_OnDragStop) 515 self:SetScript('OnDragStop', prototypes.OnDragStop)
514 end 516 end
515 else 517 else
516 self:EnableMouse(false) 518 self:EnableMouse(false)
517 end 519 end
518 520
519 if not B.Conf[name] then 521 if not V.Conf[name] then
520 B.Conf[name] = { 522 V.Conf[name] = {
521 enabled = self.enabled, 523 enabled = self.enabled,
522 } 524 }
523 end 525 end
524 local c = B.Conf[name] 526 local c = V.Conf[name]
525 527
526 if not c.position then 528 if not c.position then
527 local anchor, _, point, x, y = self:GetPoint(1) 529 local anchor, _, point, x, y = self:GetPoint(1)
528 print('seeding default position', anchor, point, x, y) 530 print('seeding default position', anchor, point, x, y)
529 c.position = {anchor, point, x, y} 531 c.position = {anchor, point, x, y}