annotate FlightMap.lua @ 113:03e4a8b93012 v7.3.0-2

7.3 Updates - Added some map frame adjustments to keep the filter bar from obstructing edge of zone clicks KNOWN ISSUES: - Argus quests can only be filtered when viewing Argus maps - Main Argus map in the WorldMapFrame has misaligned pins; this is due to it using a different map texture from what is used in the teleporter map, so all the POI coordinates are based on that map in the client info
author Nenue
date Tue, 05 Sep 2017 03:14:34 -0400
parents e8b6c5433128
children bf4a36378bb9
rev   line source
Nenue@40 1 local _, db = ...
Nenue@36 2 local print = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end
Nenue@36 3 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@36 4 local wipe, pairs, ipairs = wipe, pairs, ipairs
Nenue@36 5 local HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest = HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest
Nenue@36 6
Nenue@36 7 WorldPlanFlightMapHandler = {
Nenue@36 8 TaskQueue = {}
Nenue@36 9 }
Nenue@36 10 WorldPlanDataProvider = {}
Nenue@36 11 WorldPlanDataPinMixin = {}
Nenue@36 12
Nenue@36 13 function WorldPlanFlightMapHandler:OnLoad()
Nenue@36 14 print('MapCanvas Module')
Nenue@36 15 self:RegisterEvent('ADDON_LOADED')
Nenue@36 16 end
Nenue@36 17 function WorldPlanFlightMapHandler:OnEvent(event, arg)
Nenue@36 18 if arg == "Blizzard_FlightMap" then
Nenue@36 19 print('sending data provider')
Nenue@36 20 local dataProvider = Mixin(MapCanvasDataProviderMixin, WorldPlanDataProvider)
Nenue@36 21 WorldPlanDataPinMixin = Mixin(MapCanvasPinMixin, WorldPlanDataPinMixin)
Nenue@36 22 WorldPlanDataPinMixin.OnNext = function(...) self:OnNext(...) end
Nenue@36 23 FlightMapFrame:AddDataProvider(dataProvider)
Nenue@36 24 end
Nenue@36 25 end
Nenue@36 26
Nenue@36 27 function WorldPlanFlightMapHandler:OnNext(func)
Nenue@36 28 tinsert(self.TaskQueue, func)
Nenue@36 29 end
Nenue@36 30
Nenue@36 31 function WorldPlanFlightMapHandler:OnUpdate()
Nenue@36 32 if #self.TaskQueue >= 1 then
Nenue@36 33 print('firing scheduled task ('.. tostring(#self.TaskQueue) ..' remaining)')
Nenue@36 34 local func = tremove(self.TaskQueue, 1)
Nenue@36 35 func()
Nenue@36 36 end
Nenue@36 37 end
Nenue@36 38
Nenue@40 39 function WorldPlanDataProvider:OnLoad()
Nenue@40 40
Nenue@40 41 self:SetNudgeTargetFactor(0.015);
Nenue@53 42 self:SetNudgeZoomedOutFactor(0.5);
Nenue@53 43 self:SetNudgeZoomedInFactor(0.15);
Nenue@40 44 end
Nenue@40 45
Nenue@36 46 function WorldPlanDataProvider:OnShow()
Nenue@36 47 assert(self.ticker == nil);
Nenue@36 48 self.ticker = C_Timer.NewTicker(10, function() self:RefreshAllData() end);
Nenue@36 49 end
Nenue@36 50 function WorldPlanDataProvider:OnHide()
Nenue@36 51 self.ticker:Cancel();
Nenue@36 52 self.ticker = nil;
Nenue@36 53 end
Nenue@36 54
Nenue@74 55
Nenue@36 56 function WorldPlanDataProvider:OnAdded(mapCanvas)
Nenue@36 57 self.activePins = {};
Nenue@36 58 self.owningMap = mapCanvas
Nenue@37 59 self:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@37 60
Nenue@38 61 -- get rid of blizzard's widgery-joob
Nenue@37 62 for frame in pairs(FlightMapFrame.dataProviders) do
Nenue@37 63 if frame.OnAdded == WorldQuestDataProviderMixin.OnAdded then
Nenue@37 64 FlightMapFrame:RemoveDataProvider(frame)
Nenue@37 65 break
Nenue@37 66 end
Nenue@37 67 end
Nenue@36 68 end
Nenue@36 69
Nenue@36 70
Nenue@36 71 function WorldPlanDataProvider:RefreshAllData()
Nenue@36 72 local print = print
Nenue@36 73 print('|cFFFF0088'..self.owningMap:GetName()..':RefreshAllData()|r')
Nenue@109 74 db.PinStrata = 'HIGH'
Nenue@36 75
Nenue@36 76 local pinsToRemove = {};
Nenue@36 77 for questId in pairs(self.activePins) do
Nenue@36 78 pinsToRemove[questId] = true;
Nenue@36 79 end
Nenue@40 80 print(unpack(db.Config.FlightMapAlphaLimits))
Nenue@40 81 local alpha1, alpha2, alpha3 = unpack(db.Config.FlightMapAlphaLimits)
Nenue@40 82 local scale1, scale2, scale3 = unpack(db.Config.FlightMapScalingLimits)
Nenue@36 83
Nenue@36 84 local mapAreaID = self:GetMap():GetMapID();
Nenue@111 85 print(mapAreaID)
Nenue@86 86 WorldPlanQuests.isStale = true
Nenue@36 87 for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do
Nenue@36 88 local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex);
Nenue@111 89 print(zoneMapID, zoneName, self:GetTransformFlags())
Nenue@36 90 if zoneDepth <= 1 then -- Exclude subzones
Nenue@111 91 local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID, self:GetTransformFlags());
Nenue@36 92
Nenue@36 93 if taskInfo then
Nenue@36 94 for i, info in ipairs(taskInfo) do
Nenue@36 95 if HaveQuestData(info.questId) then
Nenue@36 96 if QuestUtils_IsQuestWorldQuest(info.questId) then
Nenue@49 97 local pin = WorldPlanQuests:AcquirePin(info, zoneMapID)
Nenue@49 98 if pin then
Nenue@49 99
Nenue@111 100 --print(pin:GetID(), pin.used, pin.filtered)
Nenue@49 101
Nenue@96 102 if pin.canShow then
Nenue@49 103 pinsToRemove[info.questId] = nil;
Nenue@49 104
Nenue@96 105 pin.used = true
Nenue@49 106 local frame = self.activePins[info.questId]
Nenue@49 107 if not frame then
Nenue@49 108 frame = self:GetMap():AcquirePin("WorldPlanFlightPin")
Nenue@49 109 frame:SetAlphaLimits(alpha1, alpha2, alpha3)
Nenue@49 110 frame:SetScalingLimits(scale1, scale2, scale3);
Nenue@49 111 frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanFlightPin"));
Nenue@49 112 frame:Show()
Nenue@49 113 self.activePins[info.questId] = frame
Nenue@49 114 end
Nenue@49 115 frame:SetPosition(info.x, info.y)
Nenue@49 116 frame.pin = pin
Nenue@49 117
Nenue@74 118 -- fix the scale
Nenue@86 119 pin.owningFrame = frame:GetMap()
Nenue@74 120 pin:SetAnchor(frame, nil, nil, nil, nil, 1)
Nenue@49 121 pin.throttle = 1
Nenue@67 122 pin:ClearAllPoints()
Nenue@67 123 pin:SetPoint('CENTER', frame, 'CENTER')
Nenue@96 124 pin:SetShown(true)
Nenue@93 125 frame:SetSize(pin:GetSize())
Nenue@52 126 --print(pin.Overlay:IsShown(), pin.Overlay:GetPoint(1))
Nenue@49 127 end
Nenue@40 128 end
Nenue@40 129
Nenue@36 130 end
Nenue@36 131 end
Nenue@36 132 end
Nenue@36 133 end
Nenue@36 134 end
Nenue@36 135 end
Nenue@36 136
Nenue@36 137 for questId in pairs(pinsToRemove) do
Nenue@36 138 self:GetMap():RemovePin(self.activePins[questId]);
Nenue@36 139 self.activePins[questId] = nil;
Nenue@36 140 end
Nenue@36 141 --self:GetMap():RemoveAllPinsByTemplate("WorldQuestPinTemplate");
Nenue@37 142 for pin in self:GetMap():EnumeratePinsByTemplate("WorldQuestPinTemplate") do
Nenue@37 143 pin:Hide()
Nenue@37 144 end
Nenue@36 145
Nenue@36 146 end
Nenue@49 147
Nenue@49 148
Nenue@49 149
Nenue@37 150 function WorldPlanDataProvider:OnEvent()
Nenue@37 151 end
Nenue@36 152
Nenue@49 153 function WorldPlanDataPinMixin:OnLoad()
Nenue@49 154 self.UpdateTooltip = self.OnMouseEnter;
Nenue@49 155
Nenue@49 156 -- Flight points can nudge world quests.
Nenue@49 157 self:SetNudgeTargetFactor(0.015);
Nenue@49 158 self:SetNudgeZoomedOutFactor(1.0);
Nenue@49 159 self:SetNudgeZoomedInFactor(0.25);
Nenue@49 160 end
Nenue@49 161
Nenue@74 162 function WorldPlanDataPinMixin:OnUpdate()
Nenue@74 163 local pin = self.pin
Nenue@74 164 if pin and pin.isStale then
Nenue@74 165 print(pin.questID, 'is stale')
Nenue@74 166 pin:SetAnchor(nil, nil, nil, nil, nil, pin.filtered and 0.5 or 1)
Nenue@74 167 if pin.isNew then
Nenue@74 168 pin:OnShow()
Nenue@74 169 end
Nenue@74 170 end
Nenue@74 171 end
Nenue@74 172
Nenue@74 173
Nenue@36 174 function WorldPlanDataPinMixin:OnShow()
Nenue@36 175 end
Nenue@36 176
Nenue@36 177 function WorldPlanDataPinMixin:OnMouseEnter ()
Nenue@52 178 WorldMap_HijackTooltip(self:GetMap())
Nenue@36 179 end
Nenue@36 180
Nenue@36 181 function WorldPlanDataPinMixin:OnMouseLeave ()
Nenue@73 182 WorldMap_RestoreTooltip()
Nenue@73 183 WorldMapTooltip:Hide()
Nenue@36 184 end
Nenue@36 185
Nenue@36 186 function WorldPlanDataPinMixin:RemoveAllData()
Nenue@36 187 wipe(self.activePins);
Nenue@36 188 self:GetMap():RemoveAllPinsByTemplate("WorldPlanFlightPin");
Nenue@36 189 end