Mercurial > wow > buffalo2
comparison Modules/BuffFrame.lua @ 106:6fa74abd83fd
- Fixed config layer inconsistencies
author | Nenue |
---|---|
date | Sun, 29 Jan 2017 09:55:40 -0500 |
parents | 5476337198ec |
children | a41f6b74709a |
comparison
equal
deleted
inserted
replaced
105:3992b41c637e | 106:6fa74abd83fd |
---|---|
19 local BUFF_PROGRESS_SIZE = 4 | 19 local BUFF_PROGRESS_SIZE = 4 |
20 local BUFF_PROGRESS_INSET = 2 | 20 local BUFF_PROGRESS_INSET = 2 |
21 local PROGRESS_ANCHOR = 'BOTTOM' | 21 local PROGRESS_ANCHOR = 'BOTTOM' |
22 local PROGRESS_PARENT | 22 local PROGRESS_PARENT |
23 local PROGRESS_OFFSET = 1 | 23 local PROGRESS_OFFSET = 1 |
24 local BUFF_MAX_DISPLAY = 24 | |
25 local DEBUFF_MAX_DISPLAY = 12 | |
24 | 26 |
25 local BUFF_BUTTON_ZOOM = .15 | 27 local BUFF_BUTTON_ZOOM = .15 |
26 local BORDER_SIZE_L = 2 | 28 local BORDER_SIZE_L = 2 |
27 local BORDER_SIZE_R = 2 | 29 local BORDER_SIZE_R = 2 |
28 local BORDER_SIZE_U = 2 | 30 local BORDER_SIZE_U = 2 |
254 -- play nice with Blizzard's frame locking structure | 256 -- play nice with Blizzard's frame locking structure |
255 FRAMELOCK_STATES.PETBATTLES[self:GetName()] = "hidden" | 257 FRAMELOCK_STATES.PETBATTLES[self:GetName()] = "hidden" |
256 FRAMELOCK_STATES.PETBATTLES[self.underlay:GetName()] = "hidden" | 258 FRAMELOCK_STATES.PETBATTLES[self.underlay:GetName()] = "hidden" |
257 end | 259 end |
258 | 260 |
261 plugin.defaultSettings = { | |
262 width = 48, | |
263 height = 48, | |
264 } | |
265 | |
259 function plugin:AcquireConfigButton(name) | 266 function plugin:AcquireConfigButton(name) |
260 print('|cFF88FF00Creating config dummy', name,'Veneer') | 267 print('|cFF88FF00Creating config dummy', name,'Veneer') |
261 local button = self.Buttons[name] | 268 local button = self.Buttons[name] |
262 if not button then | 269 if not button then |
263 button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate') | 270 button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate') |
313 | 320 |
314 local icon = _G[name .. 'Icon'] | 321 local icon = _G[name .. 'Icon'] |
315 local border = _G[name .. 'Border'] | 322 local border = _G[name .. 'Border'] |
316 local count = _G[name .. 'Count'] | 323 local count = _G[name .. 'Count'] |
317 local duration = _G[name .. 'Duration'] | 324 local duration = _G[name .. 'Duration'] |
318 local veneer = self:Acquire(name) | 325 local facade = self:Acquire(name) |
319 local offset = BUFF_BUTTON_ZOOM/2 | 326 local offset = BUFF_BUTTON_ZOOM/2 |
320 | 327 |
321 self.DetectedFrames[frame] = frame | 328 self.DetectedFrames[frame] = frame |
322 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) | 329 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) |
323 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset) | 330 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset) |
324 | 331 |
325 | 332 |
326 DoRegionHooks(veneer, border) | 333 DoRegionHooks(facade, border) |
327 if border then | 334 if border then |
328 local color = DebuffTypeColor["none"] | 335 local color = DebuffTypeColor["none"] |
329 if aurasCache[frame] and aurasCache[frame][5] then | 336 if aurasCache[frame] and aurasCache[frame][5] then |
330 color = DebuffTypeColor[aurasCache[frame][5]] | 337 color = DebuffTypeColor[aurasCache[frame][5]] |
331 end | 338 end |
332 veneer.progress.fg:SetColorTexture(color.r,color.g,color.b) | 339 facade.progress.fg:SetColorTexture(color.r,color.g,color.b) |
333 veneer.border:SetColorTexture(0,0,0,1) | 340 facade.border:SetColorTexture(0,0,0,1) |
334 veneer.border:Show() | 341 facade.border:Show() |
335 else | 342 else |
336 veneer.border:SetColorTexture(0,0,0,1) | 343 facade.border:SetColorTexture(0,0,0,1) |
337 veneer.border:Show() | 344 facade.border:Show() |
338 end | 345 end |
339 | 346 |
340 if count then | 347 if count then |
341 count:ClearAllPoints() | 348 count:ClearAllPoints() |
342 hooksecurefunc(count, 'Show', function(self) self:Hide() end) | 349 hooksecurefunc(count, 'Show', function(self) self:Hide() end) |
343 if count:GetText() then | 350 if count:GetText() then |
344 veneer.count:SetText(count:GetText()) | 351 facade.count:SetText(count:GetText()) |
345 end | 352 end |
346 end | 353 end |
347 if duration then | 354 if duration then |
348 duration:ClearAllPoints() | 355 duration:ClearAllPoints() |
349 end | 356 end |
350 | 357 |
351 hooksecurefunc(frame, "Hide", function(frame) | 358 hooksecurefunc(frame, "Hide", function(frame) |
352 veneer:Hide() | 359 facade:Hide() |
353 end) | 360 end) |
354 | 361 |
355 hooksecurefunc(frame, 'Show', function(frame) | 362 hooksecurefunc(frame, 'Show', function(frame) |
356 veneer:Show() | 363 facade:Show() |
357 end) | 364 end) |
358 | 365 |
359 hooksecurefunc(frame, 'SetShown', function(frame, isShown) | 366 hooksecurefunc(frame, 'SetShown', function(frame, isShown) |
360 veneer:SetShown(isShown) | 367 facade:SetShown(isShown) |
361 end) | 368 end) |
362 | 369 |
363 | 370 facade.IsAcquired = true |
364 veneer:SetParent(UIParent) | 371 facade:SetParent(UIParent) |
365 veneer:SetAllPoints(frame) | 372 facade:SetAllPoints(frame) |
366 veneer:SetFrameStrata('MEDIUM') | 373 facade:SetFrameStrata('MEDIUM') |
367 end | 374 end |
368 | 375 |
369 | 376 |
370 --- Set widgets to reflect the passed parameters | 377 --- Set widgets to reflect the passed parameters |
371 function plugin:UpdateButton (name, duration, expires) | 378 function plugin:UpdateButton (name, duration, expires) |
372 local frame = _G[name] | 379 local frame = _G[name] |
373 local veneer = self:Acquire(name) | 380 local facade = self:Acquire(name) |
374 -- is it a new button? | 381 -- is it a new button? |
375 if not self.DetectedFrames[frame] then | 382 if not self.DetectedFrames[frame] then |
376 print('|cFFFF4400detected', name) | 383 print('|cFFFF4400detected', name) |
377 self:SetupButton(name) | 384 self:SetupButton(name) |
378 end | 385 end |
379 print(veneer:GetParent():GetName(), veneer:GetPoint(1)) | 386 print(facade:GetParent():GetName(), facade:GetPoint(1)) |
380 --[[ | 387 --[[ |
381 if frame.count then | 388 if frame.count then |
382 frame.count:SetText('test') | 389 frame.count:SetText('test') |
383 frame.count:Show() | 390 frame.count:Show() |
384 end | 391 end |
389 if expires and duration then | 396 if expires and duration then |
390 if duration ~= 0 then | 397 if duration ~= 0 then |
391 local startTime = (expires - duration) | 398 local startTime = (expires - duration) |
392 local endTime = expires or 0 | 399 local endTime = expires or 0 |
393 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires) | 400 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires) |
394 veneer.progress:Show() | 401 facade.progress:Show() |
395 veneer.elapsed = 0 | 402 facade.elapsed = 0 |
396 veneer.progress:SetScript('OnUpdate', function(self, elapsed) | 403 facade.progress:SetScript('OnUpdate', function(self, elapsed) |
397 veneer.elapsed = veneer.elapsed + elapsed | 404 facade.elapsed = facade.elapsed + elapsed |
398 | 405 |
399 local w = floor(veneer.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2) | 406 local w = floor(facade.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2) |
400 local t = GetTime() | 407 local t = GetTime() |
401 local progress = (t - startTime) / duration | 408 local progress = (t - startTime) / duration |
402 | 409 |
403 local nw = (w - (w * progress)) | 410 local nw = (w - (w * progress)) |
404 if veneer.elapsed >= 0.25 then | 411 if facade.elapsed >= 0.25 then |
405 | 412 |
406 --tprint(t, startTime, floor(progress*100), w * progress, nw, w) | 413 --tprint(t, startTime, floor(progress*100), w * progress, nw, w) |
407 veneer.elapsed = 0.25 - veneer.elapsed | 414 facade.elapsed = 0.25 - facade.elapsed |
408 end | 415 end |
409 if (progress >= 1) or not frame:IsVisible() then | 416 if (progress >= 1) or not frame:IsVisible() then |
410 veneer.startTime = nil | 417 facade.startTime = nil |
411 self:Hide() | 418 self:Hide() |
412 self:SetScript('OnUpdate', nil) | 419 self:SetScript('OnUpdate', nil) |
413 else | 420 else |
414 self.fg:SetWidth(nw) | 421 self.fg:SetWidth(nw) |
415 end | 422 end |
416 end) | 423 end) |
417 | 424 |
418 veneer.cooldown:Show() | 425 facade.cooldown:Show() |
419 veneer.cooldown:SetCooldown(startTime, duration) | 426 facade.cooldown:SetCooldown(startTime, duration) |
420 else | 427 else |
421 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero') | 428 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero') |
422 veneer.progress:SetScript('OnUpdate', nil) | 429 facade.progress:SetScript('OnUpdate', nil) |
423 veneer.progress:Hide() | 430 facade.progress:Hide() |
424 veneer.cooldown:Hide() | 431 facade.cooldown:Hide() |
425 end | 432 end |
426 | 433 |
427 if count and count > 1 then | 434 if count and count > 1 then |
428 veneer.count:SetText(count) | 435 facade.count:SetText(count) |
429 veneer.count:Show() | 436 facade.count:Show() |
430 frame.count:ClearAllPoints() | 437 frame.count:ClearAllPoints() |
431 else | 438 else |
432 veneer.count:Hide() | 439 facade.count:Hide() |
433 end | 440 end |
434 | 441 |
435 | 442 |
436 else | 443 else |
437 veneer.progress:Hide() | 444 facade.progress:Hide() |
438 veneer.cooldown:SetCooldown(0,0) | 445 facade.cooldown:SetCooldown(0,0) |
439 veneer.cooldown:Hide() | 446 facade.cooldown:Hide() |
440 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration') | 447 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration') |
441 end | 448 end |
442 veneer:Show() | 449 facade:Show() |
443 end | 450 end |
444 | 451 |
445 | 452 |
446 --- Provides the number of changed indices for use in deciding between partial and full veneer updates | 453 --- Provides the number of changed indices for use in deciding between partial and full veneer updates |
447 function plugin:ButtonHasChanged (frame, ...) | 454 function plugin:ButtonHasChanged (frame, ...) |
490 local maxColumn = 1 | 497 local maxColumn = 1 |
491 local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY | 498 local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY |
492 for i = 1, limit do | 499 for i = 1, limit do |
493 local name = 'BuffButton'..i | 500 local name = 'BuffButton'..i |
494 local buff = _G[name] or self.Buttons[name] | 501 local buff = _G[name] or self.Buttons[name] |
495 print(buff:GetName(), self.configMode) | 502 print(i, name, buff) |
496 if buff then | 503 if buff then |
497 numBuffs = numBuffs + 1 | 504 numBuffs = numBuffs + 1 |
498 buff:ClearAllPoints() | 505 buff:ClearAllPoints() |
499 if mod(numBuffs,BUFFS_PER_ROW) == 1 then | 506 if mod(numBuffs,BUFFS_PER_ROW) == 1 then |
500 if numBuffs == 1 then | 507 if numBuffs == 1 then |
517 end | 524 end |
518 end | 525 end |
519 | 526 |
520 numBuffs = 0 | 527 numBuffs = 0 |
521 limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY | 528 limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY |
522 for i = 1, DEBUFF_ACTUAL_DISPLAY do | 529 local lastDebuff |
530 local topDebuff = topBuff | |
531 for i = 1, limit do | |
523 local name = 'DebuffButton'..i | 532 local name = 'DebuffButton'..i |
524 local debuff = _G[name] or self.Buttons[name] | 533 local debuff = _G[name] or self.Buttons[name] |
534 print(i, name, debuff) | |
525 if debuff then | 535 if debuff then |
526 numBuffs = numBuffs + 1 | 536 numBuffs = numBuffs + 1 |
527 if mod(numBuffs, BUFFS_PER_ROW) == 1 then | 537 if mod(numBuffs, BUFFS_PER_ROW) == 1 then |
528 | 538 |
529 if topBuff then | 539 if topDebuff then |
530 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) | 540 debuff:SetPoint('TOPRIGHT', topDebuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) |
531 else | 541 else |
532 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y) | 542 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y) |
533 end | 543 end |
534 topBuff = debuff | 544 topDebuff = debuff |
535 | 545 |
536 else | 546 else |
537 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) | 547 debuff:SetPoint('TOPRIGHT', lastDebuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) |
538 end | 548 end |
539 lastBuff = debuff | 549 lastDebuff = debuff |
540 | 550 |
541 end | 551 end |
542 end | 552 end |
543 | 553 |
544 if lastBuff then | 554 if lastBuff then |
554 self:SetShown(configMode) | 564 self:SetShown(configMode) |
555 self.configMode = configMode | 565 self.configMode = configMode |
556 for i = 1, BUFF_MAX_DISPLAY do | 566 for i = 1, BUFF_MAX_DISPLAY do |
557 local name = 'BuffButton' .. i | 567 local name = 'BuffButton' .. i |
558 local button = self:AcquireConfigButton(name) | 568 local button = self:AcquireConfigButton(name) |
569 if not button.IsAcquired then | |
570 button.underlay.bg:SetColorTexture(0,1,0,0.5) | |
571 end | |
559 end | 572 end |
560 for i = 1, DEBUFF_MAX_DISPLAY do | 573 for i = 1, DEBUFF_MAX_DISPLAY do |
561 local name = 'DebuffButton' .. i | 574 local name = 'DebuffButton' .. i |
562 local button = self:AcquireConfigButton(name) | 575 local button = self:AcquireConfigButton(name) |
563 end | 576 if not button.IsAcquired then |
577 button.underlay.bg:SetColorTexture(1,0,0,0.5) | |
578 end | |
579 end | |
580 self:OnUpdateAllBuffAnchors() | |
564 end | 581 end |
565 function plugin:OnUpdateDuration (frame, timeLeft) | 582 function plugin:OnUpdateDuration (frame, timeLeft) |
566 local veneer = self:Acquire(frame:GetName()) | 583 local veneer = self:Acquire(frame:GetName()) |
567 local hours = floor(timeLeft/3600) | 584 local hours = floor(timeLeft/3600) |
568 local minutes = floor(mod(timeLeft, 3600)/60) | 585 local minutes = floor(mod(timeLeft, 3600)/60) |