Mercurial > wow > worldplan
comparison 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 |
comparison
equal
deleted
inserted
replaced
34:0100d923d8c3 | 35:26dfa661daa7 |
---|---|
1 -- WorldPlan | 1 -- WorldPlan |
2 -- WorldQuests.lua | 2 -- WorldQuests.lua |
3 -- Created: 11/2/2016 3:40 PM | 3 -- Created: 11/2/2016 3:40 PM |
4 -- %file-revision% | 4 -- %file-revision% |
5 | 5 |
6 WorldPlanDataProvider = {} | |
7 WorldPlanDataPinMixin = {} | |
6 WorldPlanQuestsMixin = { | 8 WorldPlanQuestsMixin = { |
7 QuestsByZone = {}, | 9 QuestsByZone = {}, |
8 QuestsByID = {}, | 10 QuestsByID = {}, |
9 freePins = {}, | 11 freePins = {}, |
10 } | 12 } |
16 local GetMapInfo = GetMapInfo | 18 local GetMapInfo = GetMapInfo |
17 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | 19 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end |
18 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end | 20 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end |
19 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end | 21 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end |
20 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | 22 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end |
23 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end | |
21 | 24 |
22 | 25 |
23 local PinBaseIndex = 1600 | 26 local PinBaseIndex = 1600 |
24 local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096 | 27 local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096 |
25 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", | 28 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", |
176 end | 179 end |
177 | 180 |
178 -- create of update quest pins for a map and its underlying zones | 181 -- create of update quest pins for a map and its underlying zones |
179 function WorldQuests:RefreshData (mapID) | 182 function WorldQuests:RefreshData (mapID) |
180 local print = wqprint | 183 local print = wqprint |
181 mapID = mapID or GetCurrentMapAreaID() | 184 mapID = mapID or WorldPlan.currentMapID |
182 superTrackedID = GetSuperTrackedQuestID() | |
183 if not mapID then | 185 if not mapID then |
184 -- info not available yet | 186 -- info not available yet |
185 return | |
186 end | |
187 | |
188 if not self:IsVisible() then | |
189 self.isStale = true | |
190 print('frame closed, do it later') | |
191 return | 187 return |
192 end | 188 end |
193 | 189 |
194 | 190 |
195 print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID()) | 191 print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID()) |
202 local submapID, name, depth = MC_GetZoneInfo(mapID, i) | 198 local submapID, name, depth = MC_GetZoneInfo(mapID, i) |
203 self:RefreshData(submapID) | 199 self:RefreshData(submapID) |
204 end | 200 end |
205 self.fullSearch = nil | 201 self.fullSearch = nil |
206 elseif self.QuestsByZone[mapID] then | 202 elseif self.QuestsByZone[mapID] then |
207 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapID) | 203 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapID, WorldPlan.currentMapID) |
208 local numQuests = 0 | 204 local numQuests = 0 |
209 if taskInfo and #taskInfo >= 1 then | 205 if taskInfo and #taskInfo >= 1 then |
210 print('|cFF00FFFF Zone:|r', mapID, GetMapNameByID(mapID), #taskInfo) | 206 print('|cFF00FFFF Zone:|r', mapID, GetMapNameByID(mapID), #taskInfo) |
211 wipe(self.QuestsByZone[mapID]) | 207 wipe(self.QuestsByZone[mapID]) |
212 ZoneInfo[mapID] = taskInfo | 208 ZoneInfo[mapID] = taskInfo |
230 --WorldPlan.isStale = (self.isStale or WorldPlan.isStale) | 226 --WorldPlan.isStale = (self.isStale or WorldPlan.isStale) |
231 end | 227 end |
232 | 228 |
233 end | 229 end |
234 | 230 |
235 function WorldQuests:Refresh() | 231 function WorldQuests:Refresh(forced) |
236 local print = wqprint | 232 local print = wqprint |
237 print('|cFF00FF88'..self:GetName()..':Refresh()|r') | 233 print('|cFF00FF88'..self:GetName()..':Refresh()|r') |
238 if not self:IsVisible() then | 234 if not self:IsVisible() then |
239 self.isStale = true | 235 self.isStale = true |
240 print('frame closed, do it later') | 236 print('frame closed, do it later') |
286 local hostFrame = WorldMapPOIFrame | 282 local hostFrame = WorldMapPOIFrame |
287 local mapWidth, mapHeight = hostFrame:GetSize() | 283 local mapWidth, mapHeight = hostFrame:GetSize() |
288 for questID, pin in pairs(pins) do | 284 for questID, pin in pairs(pins) do |
289 pin:IsShowable() | 285 pin:IsShowable() |
290 if pin.used then | 286 if pin.used then |
291 pin.hasUpdate = true | 287 pin.isStale = true |
292 pin:SetFrameLevel(PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) | 288 pin:SetFrameLevel(PinBaseIndex+ numPins) |
293 print('level', PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) | 289 print('level', PinBaseIndex+ numPins) |
294 pin:SetAnchor(_G.WorldMapPOIFrame, currentMap, mapWidth, mapHeight) | 290 pin:SetAnchor(_G.WorldMapPOIFrame, currentMap, mapWidth, mapHeight) |
295 numPins = numPins + 1 | 291 numPins = numPins + 1 |
296 end | 292 end |
297 end | 293 end |
298 end | 294 end |
303 local debug_animate = {} | 299 local debug_animate = {} |
304 local debug_hide = {} | 300 local debug_hide = {} |
305 function WorldQuests:Cleanup () | 301 function WorldQuests:Cleanup () |
306 local print = wqprint | 302 local print = wqprint |
307 local showQuestPOI = WorldPlan.db.EnablePins | 303 local showQuestPOI = WorldPlan.db.EnablePins |
308 WorldPlan:print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') | 304 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') |
309 -- continent or zone sizing | 305 -- continent or zone sizing |
310 | 306 |
311 | 307 |
312 numPins = 0 | 308 numPins = 0 |
313 for questID, pin in pairs(self.QuestsByID) do | 309 for questID, pin in pairs(self.QuestsByID) do |
314 -- can we show it? | |
315 pin:SetShown((showQuestPOI and pin.used)) | 310 pin:SetShown((showQuestPOI and pin.used)) |
316 end | 311 end |
317 print(' adding:', table.concat(debug_animate, ',' )) | |
318 print(' refresh:', table.concat(debug_show, ',' )) | |
319 print(' hiding:', table.concat(debug_hide, ',' )) | |
320 self.isStale = nil | 312 self.isStale = nil |
321 end | 313 end |
322 | 314 |
323 function WorldQuests:FilterCheckByID(questID) | 315 function WorldQuests:FilterCheckByID(questID) |
324 local pin = WorldQuests:GetPinByQuestID(questID) | 316 local pin = WorldQuests:GetPinByQuestID(questID) |
325 return pin:IsShowable() | 317 return pin:IsShowable() |
326 end | 318 end |
319 | |
320 | |
321 | |
322 | |
323 function WorldPlanDataProvider:OnShow() | |
324 assert(self.ticker == nil); | |
325 self.ticker = C_Timer.NewTicker(10, function() self:RefreshAllData() end); | |
326 end | |
327 function WorldPlanDataProvider:OnHide() | |
328 self.ticker:Cancel(); | |
329 self.ticker = nil; | |
330 end | |
331 | |
332 function WorldPlanDataProvider:OnAdded(mapCanvas) | |
333 self.activePins = {}; | |
334 self.owningMap = mapCanvas | |
335 end | |
336 | |
337 | |
338 | |
339 function WorldPlanDataProvider:RefreshAllData() | |
340 local print = mprint | |
341 print('|cFFFF0088'..self.owningMap:GetName()..':RefreshAllData()|r') | |
342 | |
343 | |
344 local pinsToRemove = {}; | |
345 for questId in pairs(self.activePins) do | |
346 pinsToRemove[questId] = true; | |
347 end | |
348 | |
349 SetMapZoom(8) | |
350 | |
351 local mapAreaID = self:GetMap():GetMapID(); | |
352 for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do | |
353 local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex); | |
354 print(zoneMapID, zoneName) | |
355 if zoneDepth <= 1 then -- Exclude subzones | |
356 local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID); | |
357 | |
358 if taskInfo then | |
359 for i, info in ipairs(taskInfo) do | |
360 if HaveQuestData(info.questId) then | |
361 if QuestUtils_IsQuestWorldQuest(info.questId) then | |
362 local pin = WorldPlanQuests:AcquirePin(info.questId, zoneMapID) | |
363 pin:RefreshData(info) | |
364 pin:IsShowable() | |
365 if pin.used then | |
366 print(i, pin.x, pin.y, pin.used, pin.isNew, pin.isStale, pin:IsShown(), pin:GetAlpha()) | |
367 pinsToRemove[info.questId] = nil; | |
368 | |
369 local frame = self.activePins[info.questId] | |
370 if not frame then | |
371 frame = self:GetMap():AcquirePin("WorldPlanPinContainer") | |
372 frame:SetAlphaLimits(1, 0.7, 1) | |
373 frame:SetScalingLimits(1, 3, 1.5); | |
374 frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanPinContainer")); | |
375 frame:Show() | |
376 self.activePins[info.questId] = frame | |
377 end | |
378 frame:SetPosition(info.x, info.y) | |
379 frame.pin = pin | |
380 | |
381 pin.isStale = true | |
382 pin:SetParent(frame) | |
383 pin:ClearAllPoints() | |
384 pin:SetPoint('CENTER', frame, 'CENTER') | |
385 | |
386 end | |
387 pin:SetShown(pin.used) | |
388 end | |
389 end | |
390 end | |
391 end | |
392 end | |
393 end | |
394 | |
395 for questId in pairs(pinsToRemove) do | |
396 self:GetMap():RemovePin(self.activePins[questId]); | |
397 self.activePins[questId] = nil; | |
398 end | |
399 self:GetMap():RemoveAllPinsByTemplate("WorldQuestPinTemplate"); | |
400 | |
401 end | |
402 | |
403 function WorldPlanDataPinMixin:OnShow() | |
404 mprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r') | |
405 end | |
406 | |
407 function WorldPlanDataPinMixin:OnMouseEnter () | |
408 self.pin:OnEnter() | |
409 end | |
410 | |
411 function WorldPlanDataPinMixin:OnMouseLeave () | |
412 self.pin:OnLeave() | |
413 end | |
414 | |
415 function WorldPlanDataPinMixin:RemoveAllData() | |
416 wipe(self.activePins); | |
417 self:GetMap():RemoveAllPinsByTemplate("WorldQuestPinTemplate"); | |
418 end |