Mercurial > wow > worldplan
diff WorldQuests.lua @ 35:26dfa661daa7
WorldPlan:
- Quest pins will appear in the flight map. They follow the filter settings applied from the world map.
- Reward filter toggle changed to clear out other reward filters. The assumption being that one is most often looking only for that particular type of quest when they go to use it.
- Fixed filter bar info falling out of sync after player-triggered world map updates.
- Code stuff:
-- Quest pin shown-state management makes better use of OnShow OnHide handlers, SetShown is toggled and it all goes from there
-- WorldQuests module re-factored outside of the top level frame script.
ClassPlan:
- Available missions are now recorded; the mission list can be toggled between in-progress and available by clicking the heading.
author | Nenue |
---|---|
date | Thu, 03 Nov 2016 17:29:15 -0400 |
parents | 0100d923d8c3 |
children | 21bcff08b0f4 |
line wrap: on
line diff
--- a/WorldQuests.lua Wed Nov 02 19:04:47 2016 -0400 +++ b/WorldQuests.lua Thu Nov 03 17:29:15 2016 -0400 @@ -3,6 +3,8 @@ -- Created: 11/2/2016 3:40 PM -- %file-revision% +WorldPlanDataProvider = {} +WorldPlanDataPinMixin = {} WorldPlanQuestsMixin = { QuestsByZone = {}, QuestsByID = {}, @@ -18,6 +20,7 @@ local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end +local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end local PinBaseIndex = 1600 @@ -178,19 +181,12 @@ -- create of update quest pins for a map and its underlying zones function WorldQuests:RefreshData (mapID) local print = wqprint - mapID = mapID or GetCurrentMapAreaID() - superTrackedID = GetSuperTrackedQuestID() + mapID = mapID or WorldPlan.currentMapID if not mapID then -- info not available yet return end - if not self:IsVisible() then - self.isStale = true - print('frame closed, do it later') - return - end - print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID()) @@ -204,7 +200,7 @@ end self.fullSearch = nil elseif self.QuestsByZone[mapID] then - local taskInfo = TQ_GetQuestsForPlayerByMapID(mapID) + local taskInfo = TQ_GetQuestsForPlayerByMapID(mapID, WorldPlan.currentMapID) local numQuests = 0 if taskInfo and #taskInfo >= 1 then print('|cFF00FFFF Zone:|r', mapID, GetMapNameByID(mapID), #taskInfo) @@ -232,7 +228,7 @@ end -function WorldQuests:Refresh() +function WorldQuests:Refresh(forced) local print = wqprint print('|cFF00FF88'..self:GetName()..':Refresh()|r') if not self:IsVisible() then @@ -288,9 +284,9 @@ for questID, pin in pairs(pins) do pin:IsShowable() if pin.used then - pin.hasUpdate = true - pin:SetFrameLevel(PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) - print('level', PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) + pin.isStale = true + pin:SetFrameLevel(PinBaseIndex+ numPins) + print('level', PinBaseIndex+ numPins) pin:SetAnchor(_G.WorldMapPOIFrame, currentMap, mapWidth, mapHeight) numPins = numPins + 1 end @@ -305,18 +301,14 @@ function WorldQuests:Cleanup () local print = wqprint local showQuestPOI = WorldPlan.db.EnablePins - WorldPlan:print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') + print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') -- continent or zone sizing numPins = 0 for questID, pin in pairs(self.QuestsByID) do - -- can we show it? pin:SetShown((showQuestPOI and pin.used)) end - print(' adding:', table.concat(debug_animate, ',' )) - print(' refresh:', table.concat(debug_show, ',' )) - print(' hiding:', table.concat(debug_hide, ',' )) self.isStale = nil end @@ -324,3 +316,103 @@ local pin = WorldQuests:GetPinByQuestID(questID) return pin:IsShowable() 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 = mprint + print('|cFFFF0088'..self.owningMap:GetName()..':RefreshAllData()|r') + + + local pinsToRemove = {}; + for questId in pairs(self.activePins) do + pinsToRemove[questId] = true; + end + + SetMapZoom(8) + + 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("WorldPlanPinContainer") + frame:SetAlphaLimits(1, 0.7, 1) + frame:SetScalingLimits(1, 3, 1.5); + frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanPinContainer")); + 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() + mprint('|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("WorldQuestPinTemplate"); +end \ No newline at end of file