comparison WorldPlan.lua @ 27:4a7e89bffbcb r27-beta

- Order Hall resource rewards now show numerals in quest pins. - Fixed an occasional lua error that occurs when opening the quest map for the first time. - Fixed another source of textures losing their masks.
author Nenue
date Thu, 27 Oct 2016 06:18:16 -0400
parents 08b03bcdfeac
children c1612c2c1840
comparison
equal deleted inserted replaced
26:99f6e6ffb2d1 27:4a7e89bffbcb
84 local POI_DEFAULT_TYPE = { 84 local POI_DEFAULT_TYPE = {
85 a = 1, 85 a = 1,
86 r = 1, g = 1, b = 1, 86 r = 1, g = 1, b = 1,
87 x = 0, y = 0, 87 x = 0, y = 0,
88 desaturated = true, 88 desaturated = true,
89 mask = POI_BORDER_MASK, 89 pinMask = POI_BORDER_MASK,
90 rewardMask = POI_BORDER_MASK,
90 texture = POI_BORDER_FILL, 91 texture = POI_BORDER_FILL,
91 continent = { 92 continent = {
92 PinSize = 18, 93 PinSize = 18,
93 Border = 3, 94 Border = 3,
94 TrackingBorder = 2, 95 TrackingBorder = 2,
95 TagSize = 6, 96 TagSize = 6,
96 TimeleftStage = 3, 97 TimeleftStage = 3,
98 showNumber = true,
97 }, 99 },
98 zone = { 100 zone = {
99 PinSize = 22, 101 PinSize = 22,
100 Border = 3, 102 Border = 3,
101 TrackingBorder = 2, 103 TrackingBorder = 2,
102 TagSize = 12, 104 TagSize = 12,
103 TimeleftStage = 3, 105 TimeleftStage = 3,
106 showNumber = true,
104 }, 107 },
105 minimized = { 108 minimized = {
106 PinSize = 4, 109 PinSize = 4,
107 Border = 1, 110 Border = 1,
108 TrackingBorder = 2, 111 TrackingBorder = 2,
109 NoIcon = true, 112 NoIcon = true,
110 TimeleftStage = 1, 113 TimeleftStage = 1,
114 showNumber = false,
111 } 115 }
112 } 116 }
113 local POI_REWARD_TYPE = setmetatable({}, { 117 local POI_REWARD_TYPE = setmetatable({}, {
114 __newindex = function(t, k, v) 118 __newindex = function(t, k, v)
115 if type(v) == 'table' then 119 if type(v) == 'table' then
136 POI_REWARD_TYPE[REWARD_REAGENT] = { 140 POI_REWARD_TYPE[REWARD_REAGENT] = {
137 r = 0, g = 1, b = 1, 141 r = 0, g = 1, b = 1,
138 } 142 }
139 POI_REWARD_TYPE[REWARD_ARTIFACT_POWER] = { 143 POI_REWARD_TYPE[REWARD_ARTIFACT_POWER] = {
140 r = 1, g = .25, b = .5, 144 r = 1, g = .25, b = .5,
141 showNumber = true, 145 hasNumeric = true,
146 numberRGB = {1, 1, 1},
142 } 147 }
143 POI_REWARD_TYPE[REWARD_GEAR] = { 148 POI_REWARD_TYPE[REWARD_GEAR] = {
144 r = .1, g = .2, b = 1, 149 r = .1, g = .2, b = 1,
145 } 150 }
146 POI_REWARD_TYPE[REWARD_CURRENCY] = { 151 POI_REWARD_TYPE[REWARD_CURRENCY] = {
147 r = 1, g = 1, b = 0, 152 r = 1, g = 1, b = 0,
153 hasNumeric = true,
154 numberRGB = {1, 1, 1},
148 } 155 }
149 POI_REWARD_TYPE[REWARD_CASH] = { 156 POI_REWARD_TYPE[REWARD_CASH] = {
150 r = 0, g = 0, b = 0, 157 r = 0, g = 0, b = 0,
151 --x = 0, y = -1, 158 --x = 0, y = -1,
152 --mask = ICON_MONEY, 159 --mask = ICON_MONEY,
158 165
159 local defaults = { 166 local defaults = {
160 defaultPinStyle = POI_DEFAULT_TYPE, 167 defaultPinStyle = POI_DEFAULT_TYPE,
161 rewardStyle = POI_REWARD_TYPE, 168 rewardStyle = POI_REWARD_TYPE,
162 filterStyle = POI_FILTER_STYLE, 169 filterStyle = POI_FILTER_STYLE,
163 ShowAllProfessionQuests = true, 170 ShowAllProfessionQuests = false,
164 DisplayContinentSummary = true, 171 DisplayContinentSummary = true,
165 DisplayContinentPins = true, 172 DisplayContinentPins = true,
166 NotifyWhenNewQuests = true, 173 NotifyWhenNewQuests = true,
167 EnablePins = true, 174 EnablePins = true,
168 FadeWhileGrouped = true, 175 FadeWhileGrouped = true,
227 if #tasksQueue == 0 then 234 if #tasksQueue == 0 then
228 _G.WorldPlan:SetScript('OnUpdate', nil) 235 _G.WorldPlan:SetScript('OnUpdate', nil)
229 end 236 end
230 end) 237 end)
231 end 238 end
239 print('inserting task #', #tasksQueue+1, func)
232 tinsert(tasksQueue, func) 240 tinsert(tasksQueue, func)
233 end 241 end
234 242
235 -- combines templates 243 -- combines templates
236 local function DoMixins(frame,...) 244 local function DoMixins(frame,...)
335 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL") 343 self:RegisterEvent("WORLD_QUEST_COMPLETED_BY_SPELL")
336 self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED") 344 self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED")
337 self:RegisterEvent("SKILL_LINES_CHANGED") 345 self:RegisterEvent("SKILL_LINES_CHANGED")
338 self:RegisterEvent("ARTIFACT_XP_UPDATE") 346 self:RegisterEvent("ARTIFACT_XP_UPDATE")
339 self:RegisterEvent("ADDON_LOADED") 347 self:RegisterEvent("ADDON_LOADED")
348 self:SetParent(WorldMapFrame)
340 349
341 WorldPlan.modules = { 350 WorldPlan.modules = {
342 WorldQuests, FilterBar, WorldPlanFlightMapMixin, 351 WorldQuests, FilterBar, WorldPlanFlightMapMixin,
343 } 352 }
344 end 353 end
345 354
355 function WorldPlan:OnShow()
356 print(self:GetName()..':OnShow()')
357 if self.isStale then
358 self:RefreshAll()
359 end
360
361 end
362
346 function WorldPlan:OnEvent (event, ...) 363 function WorldPlan:OnEvent (event, ...)
347 print() 364 print()
348 print(event, ...) 365 print(event, self.initialized)
349 if event == 'ADDON_LOADED' then 366 if event == 'ADDON_LOADED' then
350 local addon = ... 367 local addon = ...
351 if addon == "Blizzard_FlightMap" then 368 if addon == "Blizzard_FlightMap" then
352 print('do mixin junk') 369 print('do mixin junk')
353 self.OnFlightMapLoaded() 370 self.OnFlightMapLoaded()
357 self:Setup() 374 self:Setup()
358 end 375 end
359 elseif event == 'WORLD_MAP_UPDATE' then 376 elseif event == 'WORLD_MAP_UPDATE' then
360 self.currentMapID = GetCurrentMapAreaID() 377 self.currentMapID = GetCurrentMapAreaID()
361 self:RefreshAll() 378 self:RefreshAll()
362 end 379 else
363 for i, module in ipairs(self.modules) do 380 for i, module in ipairs(self.modules) do
364 if module.OnEvent then 381 if module.OnEvent then
365 print('forwarding to', tostring(module)) 382 print('forwarding to', tostring(module))
366 module:OnEvent(event, ...) 383 module:OnEvent(event, ...)
384 end
367 end 385 end
368 end 386 end
369 end 387 end
370 388
371 389
524 end) 542 end)
525 543
526 end 544 end
527 545
528 function WorldQuests:OnEvent (event, ...) 546 function WorldQuests:OnEvent (event, ...)
529 print('|cFFFFFF00'..tostring(self)..':OnEvent()'..event..'|r', ...) 547 print('|cFFFFFF00'..tostring(self)..':OnEvent()'..event..'|r', GetTime(), ...)
530 if event == 'QUEST_LOG_UPDATE' then 548 if event == 'QUEST_LOG_UPDATE' then
531 local questID, added = ... 549 local questID, added = ...
532 if questID and added then 550 if questID and added then
533 self:GetPinByQuestID(questID) 551 self:GetPinByQuestID(questID)
534 else 552 else
535 self:GetPinsForMap() 553 self:GetPinsForMap()
536 end 554 end
555 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'doRefresh:', hasNewQuestPins)
556 if WorldMapFrame:IsVisible() and hasNewQuestPins then
557 self:Refresh(true)
558 end
559
537 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then 560 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
538 local questID = ... 561 local questID = ...
539 if questID and QuestsByID[questID] then 562 if questID and QuestsByID[questID] then
540 self:ReleasePin(QuestsByID[questID]) 563 self:ReleasePin(QuestsByID[questID])
541 end 564 end
643 QuestsByZone[mapID][questID] = self:GetPinByQuestID(questID, info) 666 QuestsByZone[mapID][questID] = self:GetPinByQuestID(questID, info)
644 numQuests = numQuests + 1 667 numQuests = numQuests + 1
645 end 668 end
646 end 669 end
647 end 670 end
648 if hasNewQuestPins and not self.fullSearch then
649 print('|cFF00FF00NEW PINS DO ANCHOR THINGS')
650 self:Refresh (true)
651 hasNewQuestPins = nil
652 end
653 end 671 end
654 672
655 -- create or update the pin using the given questID and C_TaskQuest results 673 -- create or update the pin using the given questID and C_TaskQuest results
656 function WorldQuests:GetPinByQuestID (questID, taskInfo) 674 function WorldQuests:GetPinByQuestID (questID, taskInfo)
657 if (QuestMapFrame_IsQuestWorldQuest (questID)) then 675
658 local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _ 676 local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _
659 local pin = self:AcquirePin(questID, taskInfo) 677 local pin = self:AcquirePin(questID, taskInfo)
660 678
661 if pin.isNew then 679 if pin.isNew then
662 if not hasNewQuestPins then 680 if not hasNewQuestPins then
699 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID) 717 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
700 if factionID then 718 if factionID then
701 QuestsByFaction[factionID] = QuestsByFaction[factionID] or {} 719 QuestsByFaction[factionID] = QuestsByFaction[factionID] or {}
702 QuestsByFaction[factionID][questID] = pin 720 QuestsByFaction[factionID][questID] = pin
703 end 721 end
704 pin.title = questTitle or "|cFFFF0000Retrieving..."
705 pin.factionID = factionID 722 pin.factionID = factionID
706 pin.capped = capped 723 pin.capped = capped
707 724
708 -- set tag details 725 -- set tag details
709 local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(questID); 726 local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(questID);
726 pin.worldQuestType = worldQuestType 743 pin.worldQuestType = worldQuestType
727 pin.isElite = isElite 744 pin.isElite = isElite
728 pin.tradeskillLineIndex = tradeskillLineIndex 745 pin.tradeskillLineIndex = tradeskillLineIndex
729 pin.rarity = rarity 746 pin.rarity = rarity
730 pin.tagAtlas = tagAtlas 747 pin.tagAtlas = tagAtlas
731 end
732 748
733 -- flag unresolved info 749 -- flag unresolved info
734 if not (rewardIcon and rewardName) then 750 if not (rewardIcon and rewardName) then
735 if not pin.isPending then 751 if not pin.isPending then
736 pin.isPending = true 752 pin.isPending = true
749 --WorldPlan:print('|cFF00FF00'..tostring(pin.title)..'|r has info', rewardIcon, rewardName) 765 --WorldPlan:print('|cFF00FF00'..tostring(pin.title)..'|r has info', rewardIcon, rewardName)
750 pin.hasUpdate = true 766 pin.hasUpdate = true
751 end 767 end
752 pin.isPending = nil 768 pin.isPending = nil
753 end 769 end
770
771 pin.title = questTitle or "|cFFFF0000Retrieving..."
754 pin.itemTexture = rewardIcon or pin.itemTexture 772 pin.itemTexture = rewardIcon or pin.itemTexture
755 pin.itemName = rewardName or pin.itemName 773 pin.itemName = rewardName or pin.itemName
756 774
757 qprint(' |cFF00FFFF'..questID..'|r:->', (HaveQuestData(questID) and "|cFF00FF00HaveQuestData" or "-"), (C_TaskQuest.IsActive(questID) and "|cFF88FF00IsActive|r" or "")) 775 qprint(' |cFF00FFFF'..questID..'|r:->', (HaveQuestData(questID) and "|cFF00FF00HaveQuestData" or "-"), (C_TaskQuest.IsActive(questID) and "|cFF88FF00IsActive|r" or ""))
758 qprint(' ', pin.title, pin.itemTexture, 'rewardType:', pin.rewardType, 'tag:', pin.tagID, 'style', pin.style ) 776 qprint(' ', pin.title, pin.itemTexture, 'rewardType:', pin.rewardType, 'tag:', pin.tagID, 'style', pin.style )
848 866
849 numPins = 0 867 numPins = 0
850 for questID, pin in pairs(QuestsByID) do 868 for questID, pin in pairs(QuestsByID) do
851 -- can we show it? 869 -- can we show it?
852 if showQuestPOI and (pin.used) then 870 if showQuestPOI and (pin.used) then
853 pin:Refresh()
854 871
855 if fadeGrouped then 872 if fadeGrouped then
856 pin:SetAlpha(0.25) 873 pin:SetAlpha(0.25)
857 else 874 else
858 pin:SetAlpha(1) 875 pin:SetAlpha(1)
860 -- is it a new quest? 877 -- is it a new quest?
861 if pin.isNew then 878 if pin.isNew then
862 if not pin.isAnimating then 879 if not pin.isAnimating then
863 pin.isAnimating = true 880 pin.isAnimating = true
864 OnNext(function() 881 OnNext(function()
865 pin.isNew = nil 882 pin:ShowNew()
866 pin:Show()
867 pin.FadeIn:Play()
868 end) 883 end)
869 if not notifyPlayed then 884 if not notifyPlayed then
870 for k,v in pairs(NotificationTypes) do 885 for k,v in pairs(NotificationTypes) do
871 if v[pin[k]] then 886 if v[pin[k]] then
872 notifyPlayed = true 887 notifyPlayed = true
881 end 896 end
882 -- trap new but animating pins here 897 -- trap new but animating pins here
883 else 898 else
884 -- hard show existing pin 899 -- hard show existing pin
885 print('refresh #', questID, 'filtered:', pin.filtered) 900 print('refresh #', questID, 'filtered:', pin.filtered)
886 pin:Show() 901 pin.hasUpdate = true
902 pin:Show(true)
887 tinsert(debug_show,questID) 903 tinsert(debug_show,questID)
888 end 904 end
889 else 905 else
890 if pin:IsShown() then 906 if pin:IsShown() then
891 tinsert(debug_hide,questID) 907 tinsert(debug_hide,questID)
994 end 1010 end
995 1011
996 --- Fixes icons upon size update 1012 --- Fixes icons upon size update
997 function QuestPOI:UpdateSize (style, subStyle) 1013 function QuestPOI:UpdateSize (style, subStyle)
998 self.style = self.style or POI_DEFAULT_TYPE 1014 self.style = self.style or POI_DEFAULT_TYPE
999 self.subStyle = self.subStyle or 'continent'
1000
1001 style = style or self.style 1015 style = style or self.style
1002 subStyle = style[subStyle or self.subStyle] 1016 subStyle = subStyle or self.subStyle
1003 1017
1018 qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
1004 1019
1005 self.currentWidth = subStyle.PinSize 1020 self.currentWidth = subStyle.PinSize
1006 self.borderSize = subStyle.Border 1021 self.borderSize = subStyle.Border
1007 self.trackingBorderSize = subStyle.TrackingBorder 1022 self.trackingBorderSize = subStyle.TrackingBorder
1008 self.tagSize = subStyle.TagSize 1023 self.tagSize = subStyle.TagSize
1009 self.TimeleftStage = subStyle.TimeleftStage 1024 self.TimeleftStage = subStyle.TimeleftStage
1010 self.NoIcon = subStyle.NoIcon 1025 self.NoIcon = subStyle.NoIcon
1011 1026
1027
1012 self:SetSize(self.currentWidth, self.currentWidth) 1028 self:SetSize(self.currentWidth, self.currentWidth)
1013 1029
1030 local icon = self.icon
1014 local iconBorder = self.iconBorder 1031 local iconBorder = self.iconBorder
1015 local trackingBorder = self.supertrackBorder 1032 local trackingBorder = self.supertrackBorder
1016 local tag = self.tagIcon 1033 local tag = self.tagIcon
1017 local style = self.style or POI_DEFAULT_TYPE 1034 local pinMask = style.pinMask
1018 local mask = style.mask or POI_BORDER_FILL 1035 local rewardMask = style.rewardMask
1019 1036
1020 self.icon:SetMask(nil) 1037 if self.NoIcon then
1021 self.iconBorder:SetMask(nil) 1038 self.icon:Hide()
1022 self.supertrackBorder:SetMask(nil) 1039 else
1040 self.icon:Show()
1041 icon:SetMask(nil)
1042 icon:SetMask(rewardMask)
1043 icon:SetTexture(self.icon:GetTexture())
1044 end
1045 iconBorder:SetMask(nil)
1046 trackingBorder:SetMask(nil)
1023 1047
1024 1048
1025 local borderWidth = self.borderSize 1049 local borderWidth = self.borderSize
1026 local trackingWidth = self.trackingBorderSize 1050 local trackingWidth = self.trackingBorderSize
1027 1051
1040 else 1064 else
1041 tag:Hide() 1065 tag:Hide()
1042 end 1066 end
1043 1067
1044 --qprint('using mask:', mask, self.name ) 1068 --qprint('using mask:', mask, self.name )
1045 self.icon:SetMask(mask) 1069 iconBorder:SetMask(pinMask)
1046 self.icon:SetTexture(self.icon:GetTexture()) 1070 trackingBorder:SetMask(pinMask)
1047 self.iconBorder:SetMask(mask) 1071
1048 self.supertrackBorder:SetMask(mask)
1049
1050 if self.NoIcon then
1051 self.icon:Hide()
1052 else
1053 self.icon:Show()
1054 end
1055 1072
1056 end 1073 end
1057 1074
1058 1075
1059 function FilterBar:OnEvent(event) 1076 function FilterBar:OnEvent(event)
1234 function FilterPin:OnLoad() 1251 function FilterPin:OnLoad()
1235 self:RegisterForClicks('AnyUp') 1252 self:RegisterForClicks('AnyUp')
1236 self:SetFrameStrata('HIGH') 1253 self:SetFrameStrata('HIGH')
1237 self:SetFrameLevel(151) 1254 self:SetFrameLevel(151)
1238 self:SetScript('OnUpdate', nil) 1255 self:SetScript('OnUpdate', nil)
1256 self.style = db.filterStyle
1257 self.subStyle = db.defaultPinStyle.continent
1239 end 1258 end
1240 1259
1241 function FilterPin:OnUpdate () 1260 function FilterPin:OnUpdate ()
1242 1261
1243 end 1262 end