Mercurial > wow > buffalo2
comparison BuffFrame/BuffButton.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 | d7655c4e6e06 |
comparison
equal
deleted
inserted
replaced
47:1a322b92dbfa | 48:9837069e366a |
---|---|
2 -- @file-author@ | 2 -- @file-author@ |
3 -- @project-revision@ @project-hash@ | 3 -- @project-revision@ @project-hash@ |
4 -- @file-revision@ @file-hash@ | 4 -- @file-revision@ @file-hash@ |
5 -- Created: 3/12/2016 12:47 AM | 5 -- Created: 3/12/2016 12:47 AM |
6 local MODULE = 'BuffFrame' | 6 local MODULE = 'BuffFrame' |
7 local _, A = ... | 7 |
8 local B, _G = A.frame, _G | 8 local _ |
9 local B, _G = select(2,...).frame, _G | |
9 local type, unpack, select, pairs, ipairs = _G.type, _G.unpack, _G.select, _G.pairs, _G.ipairs | 10 local type, unpack, select, pairs, ipairs = _G.type, _G.unpack, _G.select, _G.pairs, _G.ipairs |
10 local min, ceil, mod, tonumber, tostring = _G.min, _G.ceil, _G.mod, _G.tonumber, _G.tostring | 11 local min, ceil, mod, tonumber, tostring = _G.min, _G.ceil, _G.mod, _G.tonumber, _G.tostring |
11 local floor, wipe, max = _G.math.floor, _G.table.wipe, _G.math.max | 12 local floor, wipe, max = _G.math.floor, _G.table.wipe, _G.math.max |
12 local CreateFrame, IsInGroup, GetCVarBool = _G.CreateFrame, _G.IsInGroup, _G.GetCVarBool | 13 local CreateFrame, IsInGroup, GetCVarBool = _G.CreateFrame, _G.IsInGroup, _G.GetCVarBool |
13 local BuffFrame, ConsolidatedBuffs = _G.BuffFrame, _G.ConsolidatedBuffs | 14 local BuffFrame, ConsolidatedBuffs = _G.BuffFrame, _G.ConsolidatedBuffs |
15 local UnitAura, UnitName, RegisterStateDriver = _G.UnitAura, _G.UnitName, _G.RegisterStateDriver | |
16 | |
17 local M = B:RegisterModule(MODULE) | |
18 local displays = M.displays | |
14 local print, gprint, aprint, fprint = B.print('Buff'), B.print('SetGuides'), B.print('SetAnchors'), B.fprint | 19 local print, gprint, aprint, fprint = B.print('Buff'), B.print('SetGuides'), B.print('SetAnchors'), B.fprint |
15 local displays, anchors, guides, decors, positioned, drawn, zoom = B.displays, {}, {}, {}, {}, {}, {} | |
16 local UnitAura, UnitName, RegisterStateDriver = _G.UnitAura, _G.UnitName, _G.RegisterStateDriver | |
17 | |
18 local M = B:RegisterModule(MODULE) | |
19 | 20 |
20 M.GetBuffZoom = function(buffName) | 21 M.GetBuffZoom = function(buffName) |
21 local zoom = tonumber(B.displays[buffName].conf['Zoom']) / 100 / 2 | 22 local zoom = tonumber(M.displays[buffName].conf['Zoom']) / 100 / 2 |
22 local zoomL, zoomU, zoomR, zoomD = zoom, zoom, 1-zoom, 1-zoom | 23 local zoomL, zoomU, zoomR, zoomD = zoom, zoom, 1-zoom, 1-zoom |
23 print(buffName, zoom) | 24 print(buffName, zoom) |
24 return function(self, ...) | 25 return function(self, ...) |
25 if select('#',...) == 4 then | 26 if select('#',...) == 4 then |
26 zoomL, zoomR, zoomU, zoomD = ... | 27 zoomL, zoomR, zoomU, zoomD = ... |
48 --- Called infrequently to align stencil frames | 49 --- Called infrequently to align stencil frames |
49 local refreshCount = 0 | 50 local refreshCount = 0 |
50 M.UpdateGuideFrames = function(buffName) | 51 M.UpdateGuideFrames = function(buffName) |
51 refreshCount = refreshCount + 1 | 52 refreshCount = refreshCount + 1 |
52 local print = fprint() | 53 local print = fprint() |
53 | 54 print(buffName) |
55 local displays, anchors = M.displays, M.anchors | |
56 local guides, decors = M.guides, M.decors | |
54 | 57 |
55 local anchor = anchors[buffName] | 58 local anchor = anchors[buffName] |
56 local c, g, d = displays[buffName].conf, guides[buffName], decors[buffName] | 59 local c, g, d = displays[buffName].conf, guides[buffName], decors[buffName] |
57 local perRow = c['PerRow'] | 60 local perRow = c['PerRow'] |
58 local buffSpacing, buffSize, buffBorder, buffDurationSize, buffCountSize, relativeX, relativeY = c['Spacing'], c['Size'], c['Border'], c['DurationSize'], c['CountSize'], c['RelativeX'], c['RelativeY'] | 61 local buffSpacing, buffSize, buffBorder, buffDurationSize, buffCountSize, relativeX, relativeY = c['Spacing'], c['Size'], c['Border'], c['DurationSize'], c['CountSize'], c['RelativeX'], c['RelativeY'] |
196 local print = fprint() | 199 local print = fprint() |
197 local c = auraType.conf | 200 local c = auraType.conf |
198 local numBuffs = 0 | 201 local numBuffs = 0 |
199 local actualIcons = auraType.actualIcons() | 202 local actualIcons = auraType.actualIcons() |
200 local maxIcons = auraType.maxIcons | 203 local maxIcons = auraType.maxIcons |
204 local guides, decors, anchors, drawn = M.guides, M.decors, M.anchors, M.drawn | |
205 | |
201 local anchor = anchors[buffName] | 206 local anchor = anchors[buffName] |
202 local buffMax = c['Max'] | 207 local buffMax = c['Max'] |
203 local consolidated = (anchor.contains and IsInGroup()) | 208 local consolidated = (anchor.contains and IsInGroup()) |
204 local consolidatedPosition = (consolidated and anchor.containPosition or 0) | 209 local consolidatedPosition = (consolidated and anchor.containPosition or 0) |
205 | 210 |
369 | 374 |
370 end | 375 end |
371 | 376 |
372 M.PostBuffAnchors = function() | 377 M.PostBuffAnchors = function() |
373 local print = fprint() | 378 local print = fprint() |
379 local anchors = M.anchors | |
374 if M.ShowConsolidatedBuffs then | 380 if M.ShowConsolidatedBuffs then |
375 M.UpdateRaidBuffs() | 381 M.UpdateRaidBuffs() |
376 end | 382 end |
377 for buttonName, auraType in pairs(displays) do | 383 for buttonName, auraType in pairs(displays) do |
378 print('sending', buttonName, auraType) | 384 print('sending', buttonName, auraType) |
389 M.UpdateButtonPositions(buttonName, auraType) | 395 M.UpdateButtonPositions(buttonName, auraType) |
390 end | 396 end |
391 end | 397 end |
392 | 398 |
393 M.UpdateBuffs = function(buttonName, forced) | 399 M.UpdateBuffs = function(buttonName, forced) |
400 local displays, drawn = M.displays, M.drawn | |
394 local print = B.fprint(buttonName) | 401 local print = B.fprint(buttonName) |
395 local c = displays[buttonName].conf | 402 local c = displays[buttonName].conf |
396 if drawn[buttonName] then | 403 if drawn[buttonName] then |
397 wipe(drawn[buttonName]) | 404 wipe(drawn[buttonName]) |
398 else | 405 else |
404 M.UpdateButtonPositions(buttonName, displays[buttonName]) | 411 M.UpdateButtonPositions(buttonName, displays[buttonName]) |
405 end | 412 end |
406 | 413 |
407 --- should only be called from user input | 414 --- should only be called from user input |
408 print('init def') | 415 print('init def') |
409 function M:OnInitialize () | |
410 drawn = B.Abstract(B.displays, 'drawn') | |
411 -- Lesser extent of guide frames that have been positioned | |
412 positioned = B.Abstract(B.displays, 'positioned', positioned) | |
413 -- Backdrop style frame | |
414 decors = B.Abstract(B.displays, 'decorator', decors) | |
415 -- Static positioning frames | |
416 guides = B.Abstract(B.displays, 'guides', guides) | |
417 -- Anchor points for guides | |
418 anchors = B.Abstract(B.displays, 'anchor') | |
419 -- Stored functions for doing icon texture adjustments | |
420 zoom = B.Abstract(B.displays, 'zoom', zoom) | |
421 | |
422 B:RegisterUnitEvent("UNIT_AURA", "player", "vehicle") | |
423 B:RegisterEvent("GROUP_ROSTER_UPDATE") | |
424 B:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED") | |
425 hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", M.PostBuffAnchors) | |
426 hooksecurefunc("RaidBuffTray_Update", M.UpdateRaidBuffs) | |
427 end | |
428 print('update def') | |
429 function M:OnUpdate () | |
430 M.ShowConsolidated = (IsInGroup() and GetCVarBool("consolidateBuffs")) | |
431 M.ShowMissingBuffs = (IsInGroup() and B.Conf.RaidShowMissing) | |
432 | |
433 for name, auraType in pairs(displays) do | |
434 print(name, auraType) | |
435 M.UpdateBuffs(auraType.buffName, true) | |
436 end | |
437 | |
438 M.UpdateAnchorAnchors() | |
439 M.UpdateRaidBuffs() | |
440 M.UpdateBuffsTodo() | |
441 end |