Mercurial > wow > worldplan
comparison FlightMap.lua @ 36:21bcff08b0f4
WorldPlan:
- Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map.
- Filter controls polish:
- First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click.
- Adheres to the Blizzard CVars added in patch 7.1
- Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction.
ClassPlan:
- The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading.
- Information filtering by character and realm.
| author | Nenue |
|---|---|
| date | Fri, 04 Nov 2016 01:40:39 -0400 |
| parents | |
| children | 78cf1f19856a |
comparison
equal
deleted
inserted
replaced
| 35:26dfa661daa7 | 36:21bcff08b0f4 |
|---|---|
| 1 | |
| 2 local print = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end | |
| 3 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | |
| 4 local wipe, pairs, ipairs = wipe, pairs, ipairs | |
| 5 local HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest = HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest | |
| 6 | |
| 7 WorldPlanFlightMapHandler = { | |
| 8 TaskQueue = {} | |
| 9 } | |
| 10 WorldPlanDataProvider = {} | |
| 11 WorldPlanDataPinMixin = {} | |
| 12 | |
| 13 function WorldPlanFlightMapHandler:OnLoad() | |
| 14 print('MapCanvas Module') | |
| 15 self:RegisterEvent('ADDON_LOADED') | |
| 16 end | |
| 17 function WorldPlanFlightMapHandler:OnEvent(event, arg) | |
| 18 if arg == "Blizzard_FlightMap" then | |
| 19 print('sending data provider') | |
| 20 local dataProvider = Mixin(MapCanvasDataProviderMixin, WorldPlanDataProvider) | |
| 21 WorldPlanDataPinMixin = Mixin(MapCanvasPinMixin, WorldPlanDataPinMixin) | |
| 22 WorldPlanDataPinMixin.OnNext = function(...) self:OnNext(...) end | |
| 23 FlightMapFrame:AddDataProvider(dataProvider) | |
| 24 end | |
| 25 end | |
| 26 | |
| 27 function WorldPlanFlightMapHandler:OnNext(func) | |
| 28 tinsert(self.TaskQueue, func) | |
| 29 end | |
| 30 | |
| 31 function WorldPlanFlightMapHandler:OnUpdate() | |
| 32 if #self.TaskQueue >= 1 then | |
| 33 print('firing scheduled task ('.. tostring(#self.TaskQueue) ..' remaining)') | |
| 34 local func = tremove(self.TaskQueue, 1) | |
| 35 func() | |
| 36 end | |
| 37 end | |
| 38 | |
| 39 function WorldPlanDataProvider:OnShow() | |
| 40 assert(self.ticker == nil); | |
| 41 self.ticker = C_Timer.NewTicker(10, function() self:RefreshAllData() end); | |
| 42 end | |
| 43 function WorldPlanDataProvider:OnHide() | |
| 44 self.ticker:Cancel(); | |
| 45 self.ticker = nil; | |
| 46 end | |
| 47 | |
| 48 function WorldPlanDataProvider:OnAdded(mapCanvas) | |
| 49 self.activePins = {}; | |
| 50 self.owningMap = mapCanvas | |
| 51 end | |
| 52 | |
| 53 | |
| 54 function WorldPlanDataProvider:RefreshAllData() | |
| 55 local print = print | |
| 56 print('|cFFFF0088'..self.owningMap:GetName()..':RefreshAllData()|r') | |
| 57 | |
| 58 | |
| 59 local pinsToRemove = {}; | |
| 60 for questId in pairs(self.activePins) do | |
| 61 pinsToRemove[questId] = true; | |
| 62 end | |
| 63 | |
| 64 | |
| 65 local mapAreaID = self:GetMap():GetMapID(); | |
| 66 for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do | |
| 67 local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex); | |
| 68 print(zoneMapID, zoneName) | |
| 69 if zoneDepth <= 1 then -- Exclude subzones | |
| 70 local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID); | |
| 71 | |
| 72 if taskInfo then | |
| 73 for i, info in ipairs(taskInfo) do | |
| 74 if HaveQuestData(info.questId) then | |
| 75 if QuestUtils_IsQuestWorldQuest(info.questId) then | |
| 76 local pin = WorldPlanQuests:AcquirePin(info.questId, zoneMapID) | |
| 77 pin:RefreshData(info) | |
| 78 pin:IsShowable() | |
| 79 if pin.used then | |
| 80 print(i, pin.x, pin.y, pin.used, pin.isNew, pin.isStale, pin:IsShown(), pin:GetAlpha()) | |
| 81 pinsToRemove[info.questId] = nil; | |
| 82 | |
| 83 local frame = self.activePins[info.questId] | |
| 84 if not frame then | |
| 85 frame = self:GetMap():AcquirePin("WorldPlanFlightPin") | |
| 86 frame:SetAlphaLimits(1, 0.7, 1) | |
| 87 frame:SetScalingLimits(1, 3, 1.5); | |
| 88 frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanFlightPin")); | |
| 89 frame:Show() | |
| 90 self.activePins[info.questId] = frame | |
| 91 end | |
| 92 frame:SetPosition(info.x, info.y) | |
| 93 frame.pin = pin | |
| 94 | |
| 95 pin.isStale = true | |
| 96 pin:SetParent(frame) | |
| 97 pin:ClearAllPoints() | |
| 98 pin:SetPoint('CENTER', frame, 'CENTER') | |
| 99 | |
| 100 end | |
| 101 pin:SetShown(pin.used) | |
| 102 end | |
| 103 end | |
| 104 end | |
| 105 end | |
| 106 end | |
| 107 end | |
| 108 | |
| 109 for questId in pairs(pinsToRemove) do | |
| 110 self:GetMap():RemovePin(self.activePins[questId]); | |
| 111 self.activePins[questId] = nil; | |
| 112 end | |
| 113 --self:GetMap():RemoveAllPinsByTemplate("WorldQuestPinTemplate"); | |
| 114 | |
| 115 end | |
| 116 | |
| 117 function WorldPlanDataPinMixin:OnShow() | |
| 118 print('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r') | |
| 119 end | |
| 120 | |
| 121 function WorldPlanDataPinMixin:OnMouseEnter () | |
| 122 self.pin:OnEnter() | |
| 123 end | |
| 124 | |
| 125 function WorldPlanDataPinMixin:OnMouseLeave () | |
| 126 self.pin:OnLeave() | |
| 127 end | |
| 128 | |
| 129 function WorldPlanDataPinMixin:RemoveAllData() | |
| 130 wipe(self.activePins); | |
| 131 self:GetMap():RemoveAllPinsByTemplate("WorldPlanFlightPin"); | |
| 132 end |
