Mercurial > wow > worldplan
comparison QuestPOI.lua @ 67:96183f981acb
Update for Legion Patch 7.2
- Pins for quests detected from the flight map should properly update as needed.
- Fixed dropdown menu configurations not getting applied.
- Added a toggle button to the world map display that performs the same function as the 'Enable' option in the dropdown menu.
- Rewrote the majority of display update handlers for a significant performance improvements while interacting with the world map.
- AP token info should now reflect artifact knowledge changes.
author | Nenue |
---|---|
date | Sat, 01 Apr 2017 08:17:30 -0400 |
parents | e43e10c5576b |
children | 31de7e9e7849 |
comparison
equal
deleted
inserted
replaced
66:e43e10c5576b | 67:96183f981acb |
---|---|
29 local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select | 29 local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select |
30 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID | 30 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID |
31 local GameTooltip = GameTooltip | 31 local GameTooltip = GameTooltip |
32 local GetItemIcon = GetItemIcon | 32 local GetItemIcon = GetItemIcon |
33 | 33 |
34 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end | 34 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop |
35 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end | 35 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop |
36 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | 36 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or nop |
37 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end | 37 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or nop |
38 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end | 38 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or nop |
39 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end | 39 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or nop |
40 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or function() end | 40 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop |
41 local QuestPOI = WorldPlanPOIMixin | 41 local QuestPOI = WorldPlanPOIMixin |
42 | 42 |
43 local pinBaseIndex = 1300 | 43 local pinBaseIndex = 1300 |
44 local overlayBaseIndex = 1350 | 44 local overlayBaseIndex = 1350 |
45 local previousHighlight | 45 local previousHighlight |
46 | 46 |
47 local DATA_DEBUG = false | |
47 local PIN_REFRESH_DELAY = .5 | 48 local PIN_REFRESH_DELAY = .5 |
48 local PIN_REQUEST_DELAY = .1 | 49 local PIN_REQUEST_DELAY = .1 |
49 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" | 50 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" |
50 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" | 51 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" |
51 | 52 |
88 numberFontObject = 'WorldPlanFont' | 89 numberFontObject = 'WorldPlanFont' |
89 } | 90 } |
90 local MINIMIZED_STYLE = { | 91 local MINIMIZED_STYLE = { |
91 hideNumber = true, | 92 hideNumber = true, |
92 hideIcon = true, | 93 hideIcon = true, |
94 iconWidth = 3, | |
93 } | 95 } |
94 local REWARD_TYPE_STYLES = { | 96 local REWARD_TYPE_STYLES = { |
95 [REWARD_CASH] = { | 97 [REWARD_CASH] = { |
96 border = {1,1,0}, | 98 border = {1,1,0}, |
97 hideNumber = true, | 99 hideNumber = true, |
374 self.dataLoaded = true | 376 self.dataLoaded = true |
375 self.isStale = true | 377 self.isStale = true |
376 end | 378 end |
377 end | 379 end |
378 | 380 |
379 self.isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(questID) | |
380 | 381 |
381 return self.dataLoaded | 382 return self.dataLoaded |
382 end | 383 end |
383 | 384 |
384 --- Returns true if data has changed (either from loading in or qualifications changed) | 385 --- Returns true if data has changed (either from loading in or qualifications changed) |
509 | 510 |
510 qprint(' '..self.questID..':|cFFFFFF00SetRewardInfo():', numQuestRewards, rewardType) | 511 qprint(' '..self.questID..':|cFFFFFF00SetRewardInfo():', numQuestRewards, rewardType) |
511 qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName)) | 512 qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName)) |
512 | 513 |
513 if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then | 514 if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then |
515 if DATA_DEBUG and (self.debugTimer <= 0) then | |
516 return false | |
517 end | |
518 | |
514 return true, rewardType, rewardName, rewardIcon, rewardCount, quality | 519 return true, rewardType, rewardName, rewardIcon, rewardCount, quality |
520 | |
515 else | 521 else |
516 return false | 522 return false |
517 end | 523 end |
518 end | 524 end |
519 | 525 |
563 if self.isStale then | 569 if self.isStale then |
564 qprint('|cFF0088FFflagged for refresh') | 570 qprint('|cFF0088FFflagged for refresh') |
565 self:Refresh() | 571 self:Refresh() |
566 end | 572 end |
567 | 573 |
568 if self.isNew or (not self.Overlay:IsShown()) then | 574 if self.isNew then |
569 --qprint('|cFFFFFF00popping new pin handler') | 575 qprint('|cFFFFFF00popping new pin handler') |
570 self:StartFade() | 576 self:StartFade() |
571 end | 577 end |
572 | 578 |
573 if not self.isAnimating then | 579 if not self.isAnimating then |
574 self:SetAlpha(db.PinAlpha) -- fix stuck alpha | 580 self:SetAlpha(db.PinAlpha) -- fix stuck alpha |
583 -- reset flags | 589 -- reset flags |
584 self:SetAlpha(db.PinAlpha) | 590 self:SetAlpha(db.PinAlpha) |
585 self.isAnimating = nil | 591 self.isAnimating = nil |
586 end | 592 end |
587 | 593 |
588 -- Places the pin and triggers display | 594 -- Applies position and sizing parameters to the pin data |
589 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor) | 595 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor) |
590 wqprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used) | 596 dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used) |
591 if not self.used then | 597 if not self.used then |
592 self:HideFrames() | 598 self:HideFrames() |
593 return | 599 return |
594 end | 600 end |
595 | 601 |
596 self:SetScale(scaleFactor) | 602 if owner then |
597 self:SetParent(owner) | 603 local prevOwner = self:GetParent() |
604 if prevOwner ~= owner then | |
605 self.isStale = true | |
606 end | |
607 self:SetParent(owner) | |
608 self.Overlay:SetParent(owner) | |
609 else | |
610 owner = self:GetParent() | |
611 end | |
612 | |
598 self:ClearAllPoints() | 613 self:ClearAllPoints() |
599 self:SetFrameLevel(pinBaseIndex + self:GetID()) | 614 self:SetFrameLevel(pinBaseIndex + self:GetID()) |
600 self.Overlay:SetParent(owner) | |
601 self.Overlay:SetScale(scaleFactor) | |
602 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID()) | 615 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID()) |
616 | |
617 local scaleChanged | |
618 if scaleFactor and (self.scaleFactor ~= scaleFactor) then | |
619 print('scaleFactor') | |
620 self:SetScale(scaleFactor) | |
621 self.Overlay:SetScale(scaleFactor) | |
622 self.scaleFactor = scaleFactor | |
623 scaleChanged = true | |
624 end | |
625 | |
603 if (dX and dY) then | 626 if (dX and dY) then |
604 if not (mapHeight and mapWidth) then | 627 if not (mapHeight and mapWidth) then |
605 mapWidth, mapHeight = owner:GetSize() | 628 mapWidth, mapHeight = owner:GetSize() |
606 end | 629 end |
607 if (self.x ~= dY) or (self.y ~= dY) or (self.scaleFactor ~= scaleFactor) then | 630 |
631 if (self.x ~= dY) or (self.y ~= dY) or scaleChanged then | |
608 self.x = dX | 632 self.x = dX |
609 self.y = dY | 633 self.y = dY |
610 self.scaleFactor = scaleFactor | |
611 local pX = (dX * mapWidth) * (1 / scaleFactor) | 634 local pX = (dX * mapWidth) * (1 / scaleFactor) |
612 local pY = (-dY * mapHeight) * (1 / scaleFactor) | 635 local pY = (-dY * mapHeight) * (1 / scaleFactor) |
613 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY) | 636 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY) |
614 end | 637 end |
615 else | 638 end |
616 if self.x or self.y then | 639 |
617 self.x = nil | |
618 self.y = nil | |
619 self:SetPoint('CENTER') | |
620 end | |
621 end | |
622 | |
623 self:ShowFrames() | |
624 end | 640 end |
625 | 641 |
626 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked | 642 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked |
627 function QuestPOI:ShowFrames() | 643 function QuestPOI:ShowFrames() |
628 if not self:IsShown() then | 644 if not self:IsShown() then |
648 self.used = nil | 664 self.used = nil |
649 end | 665 end |
650 | 666 |
651 function QuestPOI:OnLoad() | 667 function QuestPOI:OnLoad() |
652 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config) | 668 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config) |
653 | 669 self.debugTimer = 4 |
654 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r' | 670 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r' |
655 self.isPending = true | 671 self.isPending = true |
656 self.count = self.Overlay.count | 672 self.count = self.Overlay.count |
657 self.timeLabel = self.Overlay.timeLabel | 673 self.timeLabel = self.Overlay.timeLabel |
658 self.Description = self.Overlay.Description | 674 self.Description = self.Overlay.Description |
672 end | 688 end |
673 | 689 |
674 | 690 |
675 function QuestPOI:OnUpdate (sinceLast) | 691 function QuestPOI:OnUpdate (sinceLast) |
676 -- control update check intervals | 692 -- control update check intervals |
693 | |
694 | |
677 self.throttle = (self.throttle or self.updateRate) + sinceLast | 695 self.throttle = (self.throttle or self.updateRate) + sinceLast |
678 if self.throttle >= self.updateRate then | 696 if self.throttle >= self.updateRate then |
679 -- factor overtime into the throttle timer | 697 -- factor overtime into the throttle timer |
680 self.throttle = self.throttle - self.updateRate | 698 self.throttle = self.throttle - self.updateRate |
681 else | 699 else |
682 return | 700 return |
683 end | 701 end |
684 if self.isNew then | 702 --@debug@ |
685 --print('|cFFFFFF00push new poi stuff') | 703 if DATA_DEBUG then |
686 self:OnNew() | 704 self.debugTimer = self.debugTimer - sinceLast |
687 elseif self.isStale then | 705 if self.debugTimer >= 0 then |
688 --wprint('|cFFFFFF00push poi update') | 706 print(self.debugTimer) |
689 self:Refresh() | 707 end |
690 return | 708 end |
691 end | 709 --@end-debug@ |
692 | 710 |
693 -- query for reward data if it wasn't found in the original scan | 711 -- query for reward data if it wasn't found in the original scan |
694 local questID = self.questID | 712 local questID = self.questID |
695 if not self.dataLoaded then | 713 if not self.dataLoaded then |
696 --print('|cFFFF4400'..self:GetID()..':|r polling reward info') | 714 print('|cFFFF4400'..self:GetID()..':|r polling reward info') |
697 if not (self.isAnimating) then | 715 if not (self.isAnimating) then |
698 self.PendingFade:Play() | 716 self.PendingFade:Play() |
699 end | 717 end |
700 local dataLoaded = self:GetData() | 718 local dataLoaded = self:GetData() |
701 if dataLoaded then | 719 if dataLoaded and not tContains(db.UpdatedPins, self) then |
702 WorldPlanQuests.isZoomDirty = true | 720 |
721 print('|cFF00FF88'..self:GetID()..':|r reward info loaded! queue it up') | |
722 | |
723 tinsert(db.UpdatedPins, self) | |
703 end | 724 end |
704 return | 725 return |
705 else | 726 else |
706 if self.PendingFade:IsPlaying() then | 727 if self.PendingFade:IsPlaying() then |
728 print('|cFFFF4400'..self:GetID()..':|r cancel fader') | |
707 self.PendingFade:Stop() | 729 self.PendingFade:Stop() |
730 end | |
731 | |
732 if self.isStale then | |
733 print(self.questID, '|cFFFFFF00flagged for update') | |
734 self:CheckFilterRules() | |
735 self:Refresh() | |
736 return | |
708 end | 737 end |
709 end | 738 end |
710 | 739 |
711 self:UpdateStatus() | 740 self:UpdateStatus() |
712 end | 741 end |