Mercurial > wow > buffalo2
comparison Veneer.lua @ 113:2105b6e5095f
- Added Blood of Sargeras to currency list
- Fixed panel ordering issues when a module is loaded on the fly.
author | Nick@Zahhak |
---|---|
date | Sun, 26 Mar 2017 06:25:18 -0400 |
parents | 7c77fde36287 |
children | 8c94bee4fdfc |
comparison
equal
deleted
inserted
replaced
112:7c77fde36287 | 113:2105b6e5095f |
---|---|
8 local VENEER_VERSION = 703 | 8 local VENEER_VERSION = 703 |
9 local LE_FREE_FRAMES_GROUP = 1 | 9 local LE_FREE_FRAMES_GROUP = 1 |
10 local type, strrep, ipairs, tinsert, tostring, select = type, string.rep, ipairs, tinsert, tostring, select | 10 local type, strrep, ipairs, tinsert, tostring, select = type, string.rep, ipairs, tinsert, tostring, select |
11 local pairs, tremove = pairs, tremove | 11 local pairs, tremove = pairs, tremove |
12 local print = DEVIAN_WORKSPACE and function(...) _G.print('Veneer', ...) end or nop | 12 local print = DEVIAN_WORKSPACE and function(...) _G.print('Veneer', ...) end or nop |
13 local eprint = DEVIAN_WORKSPACE and function(...) _G.print('VeneerEvent', ...) end or nop | |
13 local wipe = table.wipe | 14 local wipe = table.wipe |
14 | 15 |
15 SLASH_VENEER1 = "/veneer" | 16 SLASH_VENEER1 = "/veneer" |
16 SLASH_VENEER2 = "/vn" | 17 SLASH_VENEER2 = "/vn" |
17 SlashCmdList.VENEER = function(cmd) | 18 SlashCmdList.VENEER = function(cmd) |
101 end | 102 end |
102 | 103 |
103 local select, IsAddOnLoaded, IsLoggedIn = select, IsAddOnLoaded, IsLoggedIn | 104 local select, IsAddOnLoaded, IsLoggedIn = select, IsAddOnLoaded, IsLoggedIn |
104 | 105 |
105 function Veneer:OnEvent(event, ...) | 106 function Veneer:OnEvent(event, ...) |
107 local print = eprint | |
106 print('|cFFFF0088OnEvent()|r',event, ...) | 108 print('|cFFFF0088OnEvent()|r',event, ...) |
107 if (event == 'PLAYER_LOGIN') or (event == 'ADDON_LOADED') then | 109 if (event == 'PLAYER_LOGIN') or (event == 'ADDON_LOADED') then |
108 print(IsLoggedIn(), self.initialized) | 110 print(IsLoggedIn(), self.initialized) |
109 if IsLoggedIn() and not self.intialized then | 111 if IsLoggedIn() and not self.intialized then |
110 self:Setup() | 112 self:Setup() |
203 end) | 205 end) |
204 end | 206 end |
205 | 207 |
206 | 208 |
207 function Veneer:GetClusterFromArgs (...) | 209 function Veneer:GetClusterFromArgs (...) |
208 local primaryAnchor | |
209 local insertPosition | |
210 local insertPriority | |
211 | |
212 | |
213 local clusterTable = self.FrameClusters | |
214 for i = 1, select('#', ...) do | |
215 local arg = select(i, ...) | |
216 local argType = type(arg) | |
217 if argType == 'string' then | |
218 if not primaryAnchor then | |
219 primaryAnchor = arg | |
220 end | |
221 clusterTable[arg] = clusterTable[arg] or {} | |
222 clusterTable = clusterTable[arg] | |
223 print(strrep(' ', i)..'anchor cluster', i, arg) | |
224 elseif argType == 'boolean' then | |
225 if arg == true then | |
226 print('force top position') | |
227 insertPosition = 1 | |
228 insertPriority = nil | |
229 end | |
230 elseif argType == 'number' then | |
231 insertPriority = arg | |
232 end | |
233 end | |
234 | |
235 if insertPriority then | |
236 for i = 1, #clusterTable do | |
237 if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > insertPriority) then | |
238 print('prioritized insert position:', insertPriority, insertPosition) | |
239 break | |
240 else | |
241 print('passing lower priority frame:', clusterTable[i]:GetName()) | |
242 end | |
243 insertPosition = i | |
244 end | |
245 end | |
246 | |
247 | |
248 if not primaryAnchor then | |
249 primaryAnchor = 'CENTER' | |
250 clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} | |
251 clusterTable = clusterTable[primaryAnchor] | |
252 print('using default anchor') | |
253 end | |
254 | |
255 if not insertPosition then | |
256 insertPosition = #clusterTable + 1 | |
257 print('using default position') | |
258 end | |
259 return primaryAnchor, clusterTable, insertPosition | 210 return primaryAnchor, clusterTable, insertPosition |
260 end | 211 end |
261 | 212 |
262 -- args: frame object, list of anchor groups, true for forced top, number for priority layer | 213 -- args: frame object, list of anchor groups, true for forced top, number for priority layer |
263 function Veneer:AddHandler(handler, ...) | 214 function Veneer:AddHandler(handler, ...) |
270 handler[k] = v | 221 handler[k] = v |
271 end | 222 end |
272 end | 223 end |
273 | 224 |
274 if not handler.anchorFrame then | 225 if not handler.anchorFrame then |
275 local anchorGroup, clusterTable, clusterIndex, clusterPriority = self:GetClusterFromArgs(...) | 226 |
276 if clusterIndex == 1 then | 227 local primaryAnchor |
277 for i, frame in ipairs(clusterTable) do | 228 local clusterIndex |
278 frame.clusterIndex = i + 1 | 229 local clusterPriority = handler.anchorPriority |
279 end | 230 local clusterDepth = 0 |
280 end | 231 |
232 local clusterTable = self.FrameClusters | |
233 for i = 1, select('#', ...) do | |
234 local arg = select(i, ...) | |
235 local argType = type(arg) | |
236 if argType == 'string' then | |
237 | |
238 if not primaryAnchor then | |
239 primaryAnchor = arg | |
240 end | |
241 clusterDepth = clusterDepth + 1 | |
242 clusterTable[arg] = clusterTable[arg] or {} | |
243 clusterTable = clusterTable[arg] | |
244 print('clusterGroup =', clusterDepth ..'.'.. arg) | |
245 elseif argType == 'boolean' then | |
246 if arg == true then | |
247 print('anchorFirst =', arg) | |
248 clusterPriority = nil | |
249 end | |
250 elseif argType == 'number' then | |
251 if arg ~= clusterPriority then | |
252 print('anchorPriority =', arg) | |
253 clusterPriority = arg | |
254 end | |
255 | |
256 end | |
257 end | |
258 | |
259 if clusterPriority then | |
260 for i = 1, #clusterTable do | |
261 clusterIndex = i | |
262 if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > clusterPriority) then | |
263 print('|cFF00BB00insert position:', clusterPriority, clusterIndex) | |
264 break | |
265 else | |
266 print('passing lower priority frame:', clusterTable[i]:GetName()) | |
267 end | |
268 end | |
269 else | |
270 print('|cFF00BB00inserting at front') | |
271 clusterIndex = 1 | |
272 end | |
273 | |
274 | |
275 if not primaryAnchor then | |
276 primaryAnchor = 'CENTER' | |
277 clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} | |
278 clusterTable = clusterTable[primaryAnchor] | |
279 end | |
280 | |
281 if not clusterPriority then | |
282 clusterIndex = #clusterTable + 1 | |
283 end | |
284 if not clusterIndex then | |
285 clusterIndex = #clusterTable + 1 | |
286 end | |
287 | |
288 | |
281 tinsert(clusterTable, clusterIndex, handler) | 289 tinsert(clusterTable, clusterIndex, handler) |
282 print(' cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex) | 290 print(' cluster', primaryAnchor, 'table', clusterTable, 'priority', clusterPriority, 'position', clusterIndex) |
283 | 291 |
284 handler.anchorCluster = clusterTable | 292 handler.anchorCluster = clusterTable |
285 handler.anchorIndex = clusterIndex | 293 handler.anchorIndex = clusterIndex |
286 else | 294 else |
287 local clusterTable = self.FrameClusters[LE_FREE_FRAMES_GROUP] | 295 local clusterTable = self.FrameClusters[LE_FREE_FRAMES_GROUP] |
332 -- updates anchor relations to and from the target handler | 340 -- updates anchor relations to and from the target handler |
333 function Veneer:GetAnchor(...) | 341 function Veneer:GetAnchor(...) |
334 | 342 |
335 end | 343 end |
336 | 344 |
337 -- Evaluates frames visibility and chains them accordingly | 345 -- Recursives updates frame group anchors |
338 | 346 function Veneer:EvaluateAnchors(parent) |
339 function Veneer:DynamicReanchor(parent) | |
340 parent = parent or self | 347 parent = parent or self |
348 local print = eprint | |
341 print('|cFF88FF00DynamicReanchor()') | 349 print('|cFF88FF00DynamicReanchor()') |
342 for anchorPoint, cluster in pairs(parent.FrameClusters) do | 350 for anchorPoint, cluster in pairs(parent.FrameClusters) do |
343 if anchorPoint ~= LE_FREE_FRAMES_GROUP then | 351 if anchorPoint ~= LE_FREE_FRAMES_GROUP then |
344 local lastFrame | 352 local lastFrame |
345 for index, frame in ipairs(cluster) do | 353 for index, frame in ipairs(cluster) do |
370 end | 378 end |
371 | 379 |
372 end | 380 end |
373 end | 381 end |
374 | 382 |
383 Veneer.DynamicReanchor = Veneer.EvaluateAnchors | |
384 | |
375 -- Evaluates the current visibility state and re-anchors adjacent blocks accordingly | 385 -- Evaluates the current visibility state and re-anchors adjacent blocks accordingly |
376 function Veneer:InternalReanchor(handler, printFunc) | 386 function Veneer:InternalReanchor(handler, printFunc) |
387 local print = eprint | |
377 print('|cFF00FFFFVeneer:InternalReanchor('..handler:GetName()..')') | 388 print('|cFF00FFFFVeneer:InternalReanchor('..handler:GetName()..')') |
378 if handler.anchorFrame then | 389 if handler.anchorFrame then |
379 handler:SetPoint(handler.anchorPoint, handler.anchorFrame, handler.anchorFrom, handler.anchorX, handler.anchorY) | 390 handler:SetPoint(handler.anchorPoint, handler.anchorFrame, handler.anchorFrom, handler.anchorX, handler.anchorY) |
380 return | 391 return |
381 end | 392 end |
421 printFunc('|cFF88FF00'..handler:GetName()..':SetPoint(', handler.anchorPoint, anchorParent, anchorTo) | 432 printFunc('|cFF88FF00'..handler:GetName()..':SetPoint(', handler.anchorPoint, anchorParent, anchorTo) |
422 end | 433 end |
423 end | 434 end |
424 | 435 |
425 function Veneer:SlideBlock(frame, ...) | 436 function Veneer:SlideBlock(frame, ...) |
437 local print = eprint | |
426 local aX, aY = frame:GetLeft(), frame:GetTop() | 438 local aX, aY = frame:GetLeft(), frame:GetTop() |
427 | 439 |
428 frame:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', aX, aY) | 440 frame:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', aX, aY) |
429 frame.animation = frame.animation or {} | 441 frame.animation = frame.animation or {} |
430 frame.animation.startX = aX | 442 frame.animation.startX = aX |
438 | 450 |
439 end | 451 end |
440 | 452 |
441 | 453 |
442 function Veneer:ExecuteOnClusters(layer, method) | 454 function Veneer:ExecuteOnClusters(layer, method) |
455 local print = eprint | |
443 self.parserDepth = self.parserDepth + 1 | 456 self.parserDepth = self.parserDepth + 1 |
444 if not layer then | 457 if not layer then |
445 if self.parserDepth > 1 then | 458 if self.parserDepth > 1 then |
446 tinsert(self.pendingCalls, method) | 459 tinsert(self.pendingCalls, method) |
447 print('delaying walk for', method) | 460 print('delaying walk for', method) |
478 | 491 |
479 | 492 |
480 | 493 |
481 -- Takes frame handle and assigns a block to it | 494 -- Takes frame handle and assigns a block to it |
482 function Veneer:Acquire (frame, template) | 495 function Veneer:Acquire (frame, template) |
496 local print = eprint | |
483 if not frame then | 497 if not frame then |
484 print('|cFFFF4400Unable to acquire frame...|r') | 498 print('|cFFFF4400Unable to acquire frame...|r') |
485 return | 499 return |
486 end | 500 end |
487 local veneer = self.Frames[frame] | 501 local veneer = self.Frames[frame] |