Mercurial > wow > worldplan
view FlightMap.lua @ 38:a93cae445d3f v1.0-rc9
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 02:53:57 -0400 |
parents | 78cf1f19856a |
children | 589c444d4837 |
line wrap: on
line source
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 self:RegisterEvent('QUEST_LOG_UPDATE') -- get rid of blizzard's widgery-joob for frame in pairs(FlightMapFrame.dataProviders) do if frame.OnAdded == WorldQuestDataProviderMixin.OnAdded then FlightMapFrame:RemoveDataProvider(frame) break end end 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.owningFrame = self:GetMap() 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"); for pin in self:GetMap():EnumeratePinsByTemplate("WorldQuestPinTemplate") do pin:Hide() end end function WorldPlanDataProvider:OnEvent() for pin in self:GetMap():EnumeratePinsByTemplate("WorldQuestPinTemplate") do pin:Hide() end end function WorldPlanDataPinMixin:OnShow() print('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r') end function WorldPlanDataPinMixin:OnMouseEnter () end function WorldPlanDataPinMixin:OnMouseLeave () end function WorldPlanDataPinMixin:RemoveAllData() wipe(self.activePins); self:GetMap():RemoveAllPinsByTemplate("WorldPlanFlightPin"); end