Mercurial > wow > worldplan
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FlightMap.lua Fri Nov 04 01:40:39 2016 -0400 @@ -0,0 +1,132 @@ + +local print = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end +local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end +local wipe, pairs, ipairs = wipe, pairs, ipairs +local HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest = HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest + +WorldPlanFlightMapHandler = { + TaskQueue = {} +} +WorldPlanDataProvider = {} +WorldPlanDataPinMixin = {} + +function WorldPlanFlightMapHandler:OnLoad() + print('MapCanvas Module') + self:RegisterEvent('ADDON_LOADED') +end +function WorldPlanFlightMapHandler:OnEvent(event, arg) + if arg == "Blizzard_FlightMap" then + print('sending data provider') + local dataProvider = Mixin(MapCanvasDataProviderMixin, WorldPlanDataProvider) + WorldPlanDataPinMixin = Mixin(MapCanvasPinMixin, WorldPlanDataPinMixin) + WorldPlanDataPinMixin.OnNext = function(...) self:OnNext(...) end + FlightMapFrame:AddDataProvider(dataProvider) + end +end + +function WorldPlanFlightMapHandler:OnNext(func) + tinsert(self.TaskQueue, func) +end + +function WorldPlanFlightMapHandler:OnUpdate() + if #self.TaskQueue >= 1 then + print('firing scheduled task ('.. tostring(#self.TaskQueue) ..' remaining)') + local func = tremove(self.TaskQueue, 1) + func() + end +end + +function WorldPlanDataProvider:OnShow() + assert(self.ticker == nil); + self.ticker = C_Timer.NewTicker(10, function() self:RefreshAllData() end); +end +function WorldPlanDataProvider:OnHide() + self.ticker:Cancel(); + self.ticker = nil; +end + +function WorldPlanDataProvider:OnAdded(mapCanvas) + self.activePins = {}; + self.owningMap = mapCanvas +end + + +function WorldPlanDataProvider:RefreshAllData() + local print = print + print('|cFFFF0088'..self.owningMap:GetName()..':RefreshAllData()|r') + + + local pinsToRemove = {}; + for questId in pairs(self.activePins) do + pinsToRemove[questId] = true; + end + + + local mapAreaID = self:GetMap():GetMapID(); + for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do + local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex); + print(zoneMapID, zoneName) + if zoneDepth <= 1 then -- Exclude subzones + local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID); + + if taskInfo then + for i, info in ipairs(taskInfo) do + if HaveQuestData(info.questId) then + if QuestUtils_IsQuestWorldQuest(info.questId) then + local pin = WorldPlanQuests:AcquirePin(info.questId, zoneMapID) + pin:RefreshData(info) + pin:IsShowable() + if pin.used then + print(i, pin.x, pin.y, pin.used, pin.isNew, pin.isStale, pin:IsShown(), pin:GetAlpha()) + pinsToRemove[info.questId] = nil; + + local frame = self.activePins[info.questId] + if not frame then + frame = self:GetMap():AcquirePin("WorldPlanFlightPin") + frame:SetAlphaLimits(1, 0.7, 1) + frame:SetScalingLimits(1, 3, 1.5); + frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanFlightPin")); + frame:Show() + self.activePins[info.questId] = frame + end + frame:SetPosition(info.x, info.y) + frame.pin = pin + + pin.isStale = true + pin:SetParent(frame) + pin:ClearAllPoints() + pin:SetPoint('CENTER', frame, 'CENTER') + + end + pin:SetShown(pin.used) + end + end + end + end + end + end + + for questId in pairs(pinsToRemove) do + self:GetMap():RemovePin(self.activePins[questId]); + self.activePins[questId] = nil; + end + --self:GetMap():RemoveAllPinsByTemplate("WorldQuestPinTemplate"); + +end + +function WorldPlanDataPinMixin:OnShow() + print('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r') +end + +function WorldPlanDataPinMixin:OnMouseEnter () + self.pin:OnEnter() +end + +function WorldPlanDataPinMixin:OnMouseLeave () + self.pin:OnLeave() +end + +function WorldPlanDataPinMixin:RemoveAllData() + wipe(self.activePins); + self:GetMap():RemoveAllPinsByTemplate("WorldPlanFlightPin"); +end \ No newline at end of file