Mercurial > wow > worldplan
comparison QuestPOI.lua @ 74:2ba11b25aa7f
flight map data handler adjustments
author | Nenue |
---|---|
date | Sat, 08 Apr 2017 17:07:58 -0400 |
parents | 25f7dbc20a72 |
children | 78d78dc77822 |
comparison
equal
deleted
inserted
replaced
73:25f7dbc20a72 | 74:2ba11b25aa7f |
---|---|
101 hideIcon = true, | 101 hideIcon = true, |
102 iconWidth = 3, | 102 iconWidth = 3, |
103 } | 103 } |
104 local REWARD_TYPE_STYLES = { | 104 local REWARD_TYPE_STYLES = { |
105 [REWARD_CASH] = { | 105 [REWARD_CASH] = { |
106 border = {1,1,0}, | |
107 hideNumber = true, | 106 hideNumber = true, |
108 }, | 107 }, |
109 [REWARD_ARTIFACT_POWER] = {}, | 108 [REWARD_ARTIFACT_POWER] = {}, |
110 [REWARD_GEAR] = { | 109 [REWARD_GEAR] = { |
111 | |
112 hideNumber = true, | 110 hideNumber = true, |
113 }, | 111 }, |
114 [REWARD_CURRENCY] = { | 112 [REWARD_CURRENCY] = { |
115 textColor = {1,1,0,.5} | 113 textColor = {1,1,0,.5} |
116 }, | 114 }, |
117 [REWARD_REAGENT] = { | 115 [REWARD_REAGENT] = { |
118 | 116 |
119 hideNumber = true, | 117 hideNumber = true, |
120 }, | 118 }, |
121 } | 119 } |
120 local BORDER_SELECTED_BOUNTY = {1, 1, 0, 1 } | |
121 local BORDER_CRITERIA = {.25, .5, 1, 1} | |
122 | 122 |
123 local LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS = LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS | 123 local LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS = LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS |
124 | 124 |
125 | 125 |
126 local STYLE_TYPE_PENDING = 768 | 126 local STYLE_TYPE_PENDING = 768 |
489 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') | 489 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') |
490 WorldPlanTooltip:SetHyperlink(itemLink) | 490 WorldPlanTooltip:SetHyperlink(itemLink) |
491 for i = 1, WorldPlanTooltip:NumLines() do | 491 for i = 1, WorldPlanTooltip:NumLines() do |
492 local line = _G['WorldPlanTooltipTextLeft' .. i] | 492 local line = _G['WorldPlanTooltipTextLeft' .. i] |
493 local text = line and line:GetText() | 493 local text = line and line:GetText() |
494 local ap = text and text:gsub(',', ''):match('(%d+) '..ARTIFACT_POWER) | 494 local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('(%d+) '..ARTIFACT_POWER) |
495 if ap then | 495 if ap then |
496 rewardCount = tonumber(ap) | 496 rewardCount = tonumber(ap) |
497 print(ap) | 497 print(ap) |
498 end | 498 end |
499 | 499 |
574 function QuestPOI:StartFade() | 574 function QuestPOI:StartFade() |
575 if not self.isAnimating then | 575 if not self.isAnimating then |
576 qprint('|cFFFFFF00clearing new status') | 576 qprint('|cFFFFFF00clearing new status') |
577 self:SetAlpha(0) | 577 self:SetAlpha(0) |
578 if self.dataLoaded then | 578 if self.dataLoaded then |
579 self:Refresh() | 579 self:Refresh('POI_ISNEW') |
580 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha) | 580 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha) |
581 self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha) | 581 self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha) |
582 self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha) | 582 self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha) |
583 | 583 |
584 self.isAnimating = true | 584 self.isAnimating = true |
603 print('|cFF00FF00Alpha correction') | 603 print('|cFF00FF00Alpha correction') |
604 self:SetAlpha(db.PinAlpha) -- fix stuck alpha | 604 self:SetAlpha(db.PinAlpha) -- fix stuck alpha |
605 end | 605 end |
606 if self.isStale then | 606 if self.isStale then |
607 print('|cFF00FF00refresh on show') | 607 print('|cFF00FF00refresh on show') |
608 self:Refresh() | 608 self:Refresh('POI_SCRIPT') |
609 end | 609 end |
610 end | 610 end |
611 self:ShowFrames() | 611 self:ShowFrames() |
612 end | 612 end |
613 | 613 |
631 self:HideFrames() | 631 self:HideFrames() |
632 return | 632 return |
633 end | 633 end |
634 | 634 |
635 if owner then | 635 if owner then |
636 local prevOwner = self:GetParent() | |
637 if prevOwner ~= owner then | |
638 self.isStale = true | |
639 end | |
640 self:SetParent(owner) | 636 self:SetParent(owner) |
641 self.Overlay:SetParent(owner) | 637 self.Overlay:SetParent(owner) |
638 self.isStale = true | |
642 else | 639 else |
643 owner = self:GetParent() | 640 owner = self:GetParent() |
644 end | 641 end |
645 | 642 |
646 self:ClearAllPoints() | |
647 self:SetFrameLevel(pinBaseIndex + self:GetID()) | 643 self:SetFrameLevel(pinBaseIndex + self:GetID()) |
648 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID()) | 644 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID()) |
649 | 645 |
650 local scaleChanged | 646 |
651 if scaleFactor and (self.scaleFactor ~= scaleFactor) then | 647 if scaleFactor then |
652 --print('scaleFactor') | 648 --print('scaleFactor') |
653 self:SetScale(scaleFactor) | 649 self:SetScale(scaleFactor) |
654 self.Overlay:SetScale(scaleFactor) | 650 self.Overlay:SetScale(scaleFactor) |
655 self.scaleFactor = scaleFactor | 651 self.scaleFactor = scaleFactor |
656 scaleChanged = true | 652 end |
657 end | 653 |
658 | 654 mapWidth = mapWidth or owner:GetWidth() |
659 if (dX and dY) then | 655 mapHeight = mapHeight or owner:GetHeight() |
660 if not (mapHeight and mapWidth) then | 656 dX = dX or self.x |
661 mapWidth, mapHeight = owner:GetSize() | 657 dY = dY or self.y |
662 end | 658 --print(owner:GetName() or tostring(owner), self:GetName(), owner:GetScale(), scaleFactor) |
663 | 659 if (self.x ~= dX) or (self.y ~= dY) or scaleFactor then |
664 if (self.x ~= dY) or (self.y ~= dY) or scaleChanged then | 660 |
665 self.x = dX | 661 self.x = dX |
666 self.y = dY | 662 self.y = dY |
667 local pX = (dX * mapWidth) * (1 / scaleFactor) | 663 local pX = (dX * mapWidth) * (1 / scaleFactor) |
668 local pY = (-dY * mapHeight) * (1 / scaleFactor) | 664 local pY = (-dY * mapHeight) * (1 / scaleFactor) |
669 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY) | 665 --print('to', pX, pY, self:GetScale()) |
670 end | 666 self:ClearAllPoints() |
667 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY) | |
671 end | 668 end |
672 | 669 |
673 end | 670 end |
674 | 671 |
675 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked | 672 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked |
746 if not self.dataLoaded then | 743 if not self.dataLoaded then |
747 print('|cFFFF4400'..self:GetID()..':|r polling reward info') | 744 print('|cFFFF4400'..self:GetID()..':|r polling reward info') |
748 | 745 |
749 local dataLoaded = self:GetData() | 746 local dataLoaded = self:GetData() |
750 if dataLoaded and not tContains(db.UpdatedPins, self) then | 747 if dataLoaded and not tContains(db.UpdatedPins, self) then |
751 | |
752 print('|cFF00FF88'..self:GetID()..':|r delayed reward info, queueing for update') | |
753 self.PendingFade:Stop() | 748 self.PendingFade:Stop() |
749 -- scale info from the parent module is needed, so deal with it there | |
754 tinsert(db.UpdatedPins, self) | 750 tinsert(db.UpdatedPins, self) |
755 end | 751 end |
756 return | 752 return |
757 end | 753 end |
758 | 754 |
759 if self.maxAlertLevel then | 755 if self.maxAlertLevel then |
760 self:UpdateStatus() | 756 self:UpdateStatus() |
757 end | |
758 | |
759 end | |
760 | |
761 function QuestPOI:GetCriteriaState() | |
762 local isCriteria, isBounty, isSpellTarget | |
763 if self.factionID then | |
764 | |
765 local bounties = db.BountiesByFactionID | |
766 if bounties then | |
767 for factionID, bounty in pairs(bounties) do | |
768 | |
769 if IsQuestCriteriaForBounty(self.questID, bounty.questID) then | |
770 isCriteria = true | |
771 if db.selectedBounty == bounty then | |
772 isBounty = true | |
773 end | |
774 print('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty) | |
775 end | |
776 end | |
777 | |
778 | |
779 print('|cFFFF4400Criteria:|r', self.questID, self.isCriteria, self.isBounty) | |
780 | |
781 end | |
782 end | |
783 isSpellTarget = IsQuestIDValidSpellTarget(self.questID) | |
784 | |
785 if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then | |
786 | |
787 self.isBounty = isBounty | |
788 self.isCriteria = isCriteria | |
789 self.isSpellTarget = isSpellTarget | |
790 return true | |
761 end | 791 end |
762 | 792 |
763 end | 793 end |
764 | 794 |
765 -- Called at static intervals and with Refresh | 795 -- Called at static intervals and with Refresh |
777 tl = timeState | 807 tl = timeState |
778 self.timeLabel:SetText(text) | 808 self.timeLabel:SetText(text) |
779 end | 809 end |
780 end | 810 end |
781 | 811 |
812 local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder | |
813 | |
782 if tl and (timeLeft < 120) then | 814 if tl and (timeLeft < 120) then |
783 self.HighlightBorder:SetVertexColor(1,0,0,0.7) | 815 border:SetVertexColor(1,0,0,0.7) |
784 elseif self.isBounty then | |
785 self.HighlightBorder:SetVertexColor(1,1,0,1) | |
786 elseif self.isCriteria then | |
787 self.HighlightBorder:SetVertexColor(.25,.5,1,1) | |
788 else | 816 else |
789 self.HighlightBorder:SetVertexColor(0,0,0,0.7) | 817 border:SetVertexColor(0,0,0,0.7) |
790 end | 818 end |
791 self.alertLevel = tl | 819 self.alertLevel = tl |
792 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) | 820 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) |
793 else | 821 else |
794 self.hideReason = "No longer active." | 822 self.hideReason = "No longer active." |
796 | 824 |
797 end | 825 end |
798 end | 826 end |
799 | 827 |
800 | 828 |
801 function QuestPOI:Refresh () | 829 function QuestPOI:Refresh (event) |
802 | 830 |
803 rprint('|cFF00FF88'..self:GetID()..'|r:Refresh() type =', self.rewardType, 'title =', self.title) | 831 print('|cFF00FF88'..self:GetID()..'|r:Refresh()', event) |
804 | 832 |
805 local style = DEFAULT_STYLE | 833 local style = DEFAULT_STYLE |
806 if self.dataLoaded and not self.filtered then | 834 if self.dataLoaded and not self.filtered then |
807 style = REWARD_TYPE_STYLES[self.rewardType] | 835 style = REWARD_TYPE_STYLES[self.rewardType] |
808 else | 836 else |
826 local count = self.count | 854 local count = self.count |
827 local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber | 855 local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber |
828 | 856 |
829 local tagIcon = self.tagIcon | 857 local tagIcon = self.tagIcon |
830 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel | 858 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel |
859 | |
831 | 860 |
832 if self.itemName then | 861 if self.itemName then |
833 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then | 862 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then |
834 local numberString = self.itemNumber | 863 local numberString = self.itemNumber |
835 if self.itemNumber >= 1000000 then | 864 if self.itemNumber >= 1000000 then |
881 icon:SetTexture(PENDING_ICON) | 910 icon:SetTexture(PENDING_ICON) |
882 icon:SetDesaturated(true) | 911 icon:SetDesaturated(true) |
883 icon:SetVertexColor(unpack(borderColor)) | 912 icon:SetVertexColor(unpack(borderColor)) |
884 end | 913 end |
885 local borderMask = style.borderMask or DEFAULT_STYLE.borderMask | 914 local borderMask = style.borderMask or DEFAULT_STYLE.borderMask |
886 local borderSize = currentWidth + (borderWidth * 2) | 915 local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0) |
887 | 916 |
888 | 917 |
889 iconBorder:SetSize(borderSize, borderSize) | 918 iconBorder:SetSize(borderSize, borderSize) |
890 iconBorder:SetMask(borderMask) | 919 iconBorder:SetMask(borderMask) |
891 iconBorder:SetTexture(PENDING_BORDER) | 920 iconBorder:SetTexture(PENDING_BORDER) |
892 iconBorder:SetVertexColor(unpack(borderColor)) | 921 |
893 iconBorder:SetDesaturated(true) | 922 iconBorder:SetDesaturated(true) |
894 | 923 |
895 local highlightSize = borderSize + (highlightWidth * 2) | 924 local highlightSize = borderSize + (highlightWidth * 2) |
896 trackingBorder:SetSize(highlightSize, highlightSize) | 925 trackingBorder:SetSize(highlightSize, highlightSize) |
897 trackingBorder:SetMask(borderMask) | 926 trackingBorder:SetMask(borderMask) |
910 | 939 |
911 self:UpdateSize() | 940 self:UpdateSize() |
912 self:UpdateStatus() | 941 self:UpdateStatus() |
913 self.isStale = nil | 942 self.isStale = nil |
914 | 943 |
944 if self.isBounty then | |
945 print('is bounty') | |
946 iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) | |
947 trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY)) | |
948 elseif self.isCriteria then | |
949 print('is criteria of a bounty') | |
950 iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) | |
951 trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA)) | |
952 else | |
953 | |
954 iconBorder:SetVertexColor(unpack(borderColor)) | |
955 trackingBorder:SetVertexColor(1,1,1,1) | |
956 end | |
915 | 957 |
916 if SpellCanTargetQuest() then | 958 if SpellCanTargetQuest() then |
917 if IsQuestIDValidSpellTarget(self.questID) then | 959 if IsQuestIDValidSpellTarget(self.questID) then |
918 icon:SetVertexColor(1,1,1) | 960 icon:SetVertexColor(1,1,1) |
919 else | 961 else |