Mercurial > wow > buffalo2
comparison Modules/BuffFrame.lua @ 121:1f68c46bc4de
BuffFrame:
- Added interface framework for selectively hiding certain buff's auxiliary values.
| author | Nenue |
|---|---|
| date | Mon, 17 Jul 2017 11:51:31 -0400 |
| parents | 8c94bee4fdfc |
| children | ea2c616a3b4f |
comparison
equal
deleted
inserted
replaced
| 120:5f1ba488c395 | 121:1f68c46bc4de |
|---|---|
| 45 anchorX = BUFF_FRAMES_X, | 45 anchorX = BUFF_FRAMES_X, |
| 46 anchorY = BUFF_FRAMES_Y, | 46 anchorY = BUFF_FRAMES_Y, |
| 47 | 47 |
| 48 Buttons = {}, | 48 Buttons = {}, |
| 49 DetectedFrames = {}, | 49 DetectedFrames = {}, |
| 50 AuraCache = {} | 50 AuraCache = {}, |
| 51 ValueMasks = {} | |
| 51 } | 52 } |
| 52 VeneerBuffFrameButtonMixin = {} | 53 VeneerBuffFrameButtonMixin = {} |
| 53 local Facade = VeneerBuffFrameButtonMixin | 54 local Facade = VeneerBuffFrameButtonMixin |
| 54 local plugin = VeneerBuffFrameMixin | 55 local plugin = VeneerBuffFrameMixin |
| 55 | 56 |
| 68 local pendingFrames = {} | 69 local pendingFrames = {} |
| 69 local veneers = {} | 70 local veneers = {} |
| 70 local expirationCache = {} | 71 local expirationCache = {} |
| 71 local visibility = {} | 72 local visibility = {} |
| 72 local isHooked = {} | 73 local isHooked = {} |
| 74 local valueMasks | |
| 73 | 75 |
| 74 plugin.options = { | 76 plugin.options = { |
| 75 nameString = 'Buff Frames', | 77 nameString = 'Buff Frames', |
| 76 { | 78 { |
| 77 name = 'BuffButtonZoom', | 79 name = 'BuffButtonZoom', |
| 301 hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end) | 303 hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end) |
| 302 for i = 1, 3 do | 304 for i = 1, 3 do |
| 303 self:SetupButton('TempEnchant'..i) | 305 self:SetupButton('TempEnchant'..i) |
| 304 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1) | 306 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1) |
| 305 end | 307 end |
| 308 | |
| 309 VeneerData.BuffFrame = VeneerData.BuffFrame or {} | |
| 310 VeneerData.BuffFrame.ValueMasks = VeneerData.BuffFrame.ValueMasks or {} | |
| 311 valueMasks = VeneerData.BuffFrame.ValueMasks | |
| 306 end | 312 end |
| 307 | 313 |
| 308 function plugin:SetHidden(region) | 314 function plugin:SetHidden(region) |
| 309 if not self.hiddenRegions[region] then | 315 if not self.hiddenRegions[region] then |
| 310 self.hiddenRegions[region] = true | 316 self.hiddenRegions[region] = true |
| 311 region:SetShown(false) | 317 region:SetShown(false) |
| 312 hooksecurefunc(region) | 318 |
| 319 end | |
| 320 end | |
| 321 | |
| 322 local lastAuditName = '' | |
| 323 local lastAuditIndex = '' | |
| 324 local Audit_OnClick = function(self) | |
| 325 | |
| 326 local facade = self:GetParent() | |
| 327 local index = self.index | |
| 328 local name = facade.buffName | |
| 329 if name then | |
| 330 DEFAULT_CHAT_FRAME:AddMessage('|cFF00FFFFVeneer|r: Hiding |cFF00FF88'..name..' value'..index..'|r, type /vn buffs reset to undo.') | |
| 331 valueMasks[name] = valueMasks[name] or {} | |
| 332 valueMasks[name][index] = false | |
| 333 print('AuditClick', name, index, false) | |
| 313 end | 334 end |
| 314 end | 335 end |
| 315 | 336 |
| 316 function plugin:SetupButton (name) | 337 function plugin:SetupButton (name) |
| 317 local frame = _G[name] | 338 local frame = _G[name] |
| 364 | 385 |
| 365 hooksecurefunc(frame, 'SetShown', function(frame, isShown) | 386 hooksecurefunc(frame, 'SetShown', function(frame, isShown) |
| 366 facade:SetShown(isShown) | 387 facade:SetShown(isShown) |
| 367 end) | 388 end) |
| 368 | 389 |
| 390 facade.Audit = facade.Audit or {} | |
| 391 for i = 1, 3 do | |
| 392 local button = CreateFrame('Button', nil, facade, 'VeneerBuffAuditTemplate') | |
| 393 button.index = i | |
| 394 button:RegisterForClicks('AnyUp') | |
| 395 button:SetScript('OnClick', Audit_OnClick) | |
| 396 button:SetPoint('TOPLEFT', 0, (i-1) * 16 * -1) | |
| 397 facade.Audit[i] = button | |
| 398 end | |
| 399 | |
| 369 facade.IsAcquired = true | 400 facade.IsAcquired = true |
| 370 facade:SetParent(UIParent) | 401 facade:SetParent(UIParent) |
| 371 facade:SetAllPoints(frame) | 402 facade:SetAllPoints(frame) |
| 372 facade:SetFrameStrata('MEDIUM') | 403 facade:SetFrameStrata('MEDIUM') |
| 373 end | 404 end |
| 374 | 405 |
| 375 | 406 |
| 376 --- Set widgets to reflect the passed parameters | 407 --- Set widgets to reflect the passed parameters |
| 408 local values = {} | |
| 377 function plugin:UpdateButton (name, duration, expires) | 409 function plugin:UpdateButton (name, duration, expires) |
| 378 local frame = _G[name] | 410 local frame = _G[name] |
| 379 local facade = self:Acquire(name) | 411 local facade = self:Acquire(name) |
| 380 -- is it a new button? | 412 -- is it a new button? |
| 381 if not self.DetectedFrames[frame] then | 413 if not self.DetectedFrames[frame] then |
| 382 print('|cFFFF4400detected', name) | 414 print('|cFFFF4400detected', name) |
| 383 self:SetupButton(name) | 415 self:SetupButton(name) |
| 384 end | 416 end |
| 385 print(facade:GetParent():GetName(), facade:GetPoint(1)) | |
| 386 --[[ | 417 --[[ |
| 387 if frame.count then | 418 if frame.count then |
| 388 frame.count:SetText('test') | 419 frame.count:SetText('test') |
| 389 frame.count:Show() | 420 frame.count:Show() |
| 390 end | 421 end |
| 391 --]] | 422 --]] |
| 392 | 423 |
| 393 local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, nameplateShowPersonal, spellID, canApplyAura, isBossDebuff, _, nameplateShowAll, timeMod, value1, value2, value3 = UnitAura(frame.unit, frame:GetID(), frame.filter) | 424 local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, nameplateShowPersonal, spellID, canApplyAura, isBossDebuff, _, nameplateShowAll, timeMod, value1, value2, value3 = UnitAura(frame.unit, frame:GetID(), frame.filter) |
| 394 | 425 values[1] = value1 |
| 395 | 426 values[2] = value2 |
| 427 values[3] = value3 | |
| 428 | |
| 429 facade.buffName = name | |
| 396 | 430 |
| 397 if expires and duration then | 431 if expires and duration then |
| 398 if duration ~= 0 then | 432 if duration ~= 0 then |
| 399 local startTime = (expires - duration) | 433 local startTime = (expires - duration) |
| 400 local endTime = expires or 0 | 434 local endTime = expires or 0 |
| 423 end | 457 end |
| 424 | 458 |
| 425 | 459 |
| 426 end) | 460 end) |
| 427 | 461 |
| 428 facade.cooldown:Show() | 462 --facade.cooldown:Show() |
| 429 facade.cooldown:SetCooldown(startTime, duration) | 463 --facade.cooldown:SetCooldown(startTime, duration) |
| 430 else | 464 else |
| 431 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero') | 465 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero') |
| 432 facade.progress:SetScript('OnUpdate', nil) | 466 facade.progress:SetScript('OnUpdate', nil) |
| 433 facade.progress:Hide() | 467 facade.progress:Hide() |
| 434 facade.cooldown:Hide() | 468 --facade.cooldown:Hide() |
| 435 end | 469 end |
| 436 | 470 |
| 437 if count and count > 1 then | 471 if count and count > 1 then |
| 438 facade.count:SetText(count) | 472 facade.count:SetText(count) |
| 439 facade.count:Show() | 473 facade.count:Show() |
| 440 frame.count:ClearAllPoints() | 474 frame.count:ClearAllPoints() |
| 441 else | 475 else |
| 442 facade.count:Hide() | 476 facade.count:Hide() |
| 443 end | 477 end |
| 444 | 478 |
| 445 | 479 for i, button in ipairs(facade.Audit) do |
| 446 facade.overlay.Value1:SetText(value1) | 480 local isShown = (values[i] and true) |
| 447 facade.overlay.Value2:SetText(value2) | 481 if valueMasks[name] and valueMasks[name][i] ~= nil then |
| 448 facade.overlay.Value3:SetText(value3) | 482 print(':: use value mask', name, i) |
| 483 isShown = (values[i] == 1) and true or false | |
| 484 end | |
| 485 | |
| 486 facade.Audit[i]:SetShown(isShown) | |
| 487 facade.Audit[i].Value:SetText(values[i]) | |
| 488 end | |
| 489 | |
| 449 | 490 |
| 450 else | 491 else |
| 451 facade.progress:Hide() | 492 facade.progress:Hide() |
| 452 facade.cooldown:SetCooldown(0,0) | 493 --facade.cooldown:SetCooldown(0,0) |
| 453 facade.cooldown:Hide() | 494 --facade.cooldown:Hide() |
| 454 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration') | 495 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration') |
| 455 end | 496 end |
| 456 facade:Show() | 497 facade:Show() |
| 457 end | 498 end |
| 458 | 499 |
