Mercurial > wow > worldplan
comparison WorldQuests.lua @ 96:8591401ec278
- Fixed quest markers for other maps becoming visible due to ambiguous interpretations of pin.used.
- Removed some redundant filter checking calls on pins obtained through Acquire()
author | Nenue |
---|---|
date | Sun, 14 May 2017 23:45:08 -0400 |
parents | b29b35cb8539 |
children | 5d90d09cb7b7 |
comparison
equal
deleted
inserted
replaced
95:b29b35cb8539 | 96:8591401ec278 |
---|---|
26 local GetQuestLogRewardInfo = GetQuestLogRewardInfo | 26 local GetQuestLogRewardInfo = GetQuestLogRewardInfo |
27 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID | 27 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID |
28 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete | 28 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete |
29 local HaveQuestRewardData = HaveQuestRewardData | 29 local HaveQuestRewardData = HaveQuestRewardData |
30 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation | 30 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation |
31 local InCombatLockdown, hooksecurefunc = InCombatLockdown, hooksecurefunc | |
31 | 32 |
32 local ToggleButton = {} | 33 local ToggleButton = {} |
33 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 | 34 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 |
34 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", | 35 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", |
35 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } | 36 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } |
47 | 48 |
48 local continentScanned | 49 local continentScanned |
49 local layoutDirty = true | 50 local layoutDirty = true |
50 local bountiesDirty = true | 51 local bountiesDirty = true |
51 local artifactPowerDirty = true | 52 local artifactPowerDirty = true |
53 local hooksDirty = true | |
52 local currentScale = WorldMapDetailFrame:GetScale() | 54 local currentScale = WorldMapDetailFrame:GetScale() |
53 local canTargetQuests | 55 local canTargetQuests |
54 local isDataLoaded = true | 56 local isDataLoaded = true |
55 local artifactKnowledgeLevel | 57 local artifactKnowledgeLevel |
56 local superTrackedQuestID | 58 local superTrackedQuestID |
209 callbacks[ActionButton] = {} | 211 callbacks[ActionButton] = {} |
210 callbacks[ActionButton].UpdateCastingState = function(WorldQuests) | 212 callbacks[ActionButton].UpdateCastingState = function(WorldQuests) |
211 WorldQuests:Refresh('CASTING_STATE_CHANGED') | 213 WorldQuests:Refresh('CASTING_STATE_CHANGED') |
212 end | 214 end |
213 | 215 |
214 function Module:Setup() | 216 callbacks.UseWorldMapActionButtonSpellOnQuest = function(questID) |
215 --print('|cFFFF4400'..self:GetName()..':Setup()') | 217 if db.QuestsByID[questID] then |
216 for mapID, mapName in pairs(WORLD_QUEST_MAPS) do | 218 db.QuestsByID[questID].isStale = true |
217 db.QuestsByZone[mapID] = {} | 219 end |
218 end | 220 end |
221 | |
222 function Module:SetupCallbacks() | |
223 if InCombatLockdown() then | |
224 return nil | |
225 end | |
226 print('SetupCallbacks()') | |
219 for target, arg in pairs(callbacks) do | 227 for target, arg in pairs(callbacks) do |
220 --print(type(target)) | 228 --print(type(target)) |
221 if type(target) == 'table' then | 229 if type(target) == 'table' then |
222 local callerName = target:GetName() or tostring(target) | 230 local callerName = target:GetName() or tostring(target) |
223 for name, method in pairs(arg) do | 231 for name, method in pairs(arg) do |
231 self:OnSecureHook(target, arg, ...) | 239 self:OnSecureHook(target, arg, ...) |
232 end) | 240 end) |
233 end | 241 end |
234 end | 242 end |
235 | 243 |
244 | |
245 end | |
246 | |
247 function Module:Setup() | |
248 --print('|cFFFF4400'..self:GetName()..':Setup()') | |
249 for mapID, mapName in pairs(WORLD_QUEST_MAPS) do | |
250 db.QuestsByZone[mapID] = {} | |
251 end | |
252 | |
253 hooksDirty = self:SetupCallbacks() | |
236 | 254 |
237 self:SetAllPoints(WorldMapFrame.UIElementsFrame) | 255 self:SetAllPoints(WorldMapFrame.UIElementsFrame) |
238 self:UpdateArtifactPower() | 256 self:UpdateArtifactPower() |
239 self:UpdateBounties('SETUP') | 257 self:UpdateBounties('SETUP') |
240 self:Show() | 258 self:Show() |
288 end | 306 end |
289 -- re-anchors and scales pins that have had either of these changed due to data loading delays | 307 -- re-anchors and scales pins that have had either of these changed due to data loading delays |
290 function Module:UpdateNext() | 308 function Module:UpdateNext() |
291 --print('|cFF00FF88UpdateNext()') | 309 --print('|cFF00FF88UpdateNext()') |
292 local pin = tremove(db.UpdatedPins) | 310 local pin = tremove(db.UpdatedPins) |
293 | |
294 -- criteria state is asserted independently | |
295 pin:CheckFilterRules() | 311 pin:CheckFilterRules() |
312 | |
296 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] | 313 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] |
297 --print(pin.title, pin.dataLoaded and not pin.filtered, scaleFactor) | 314 --print(pin.title, pin.dataLoaded and not pin.filtered, scaleFactor) |
298 if pin.used then | 315 if pin.used then |
316 pin:SetShown(true) | |
299 pin:SetAnchor(nil, pin.x, pin.y, self.hostWidth, self.hostHeight, scaleFactor) | 317 pin:SetAnchor(nil, pin.x, pin.y, self.hostWidth, self.hostHeight, scaleFactor) |
300 if pin:IsVisible() then | 318 pin:Refresh() |
301 pin:Refresh() | 319 else |
302 else | 320 print('|cFFFF4400flagging queued pin that got hidden:', pin.title) |
303 pin.isStale = true | 321 pin.isStale = true |
304 end | |
305 end | 322 end |
306 end | 323 end |
307 | 324 |
308 function Module:UpdateBounties(...) | 325 function Module:UpdateBounties(...) |
309 print('|cFF00FF88BountyInfo()|r', ...) | 326 print('|cFF00FF88BountyInfo()|r', ...) |
366 artifactPowerDirty = nil | 383 artifactPowerDirty = nil |
367 end | 384 end |
368 | 385 |
369 local msg = '|cFF00FF88WorldQuests:Refresh()|r|cFF00FFFF' | 386 local msg = '|cFF00FF88WorldQuests:Refresh()|r|cFF00FFFF' |
370 function Module:Refresh(...) | 387 function Module:Refresh(...) |
388 | |
389 if hooksDirty then | |
390 hooksDirty = self:SetupCallbacks() | |
391 end | |
392 | |
393 | |
371 if not self:IsVisible() then | 394 if not self:IsVisible() then |
372 print('|cFFFF4400Refresh()|r', ...) | 395 print('|cFFFF4400Refresh()|r', ...) |
373 --layoutDirty = true | |
374 return | 396 return |
375 else | 397 else |
376 -- | |
377 if lastRefresh == GetTime() then | 398 if lastRefresh == GetTime() then |
378 print('|cFFFF4400multiple refreshes tried') | 399 print('|cFFFF4400multiple refreshes tried') |
379 end | 400 end |
380 lastRefresh = GetTime() | 401 lastRefresh = GetTime() |
381 --rprint(msg, ...) | |
382 print(msg, lastRefresh, ...) | 402 print(msg, lastRefresh, ...) |
383 end | 403 end |
384 | 404 |
385 if not db.Config.EnablePins then | 405 if not db.Config.EnablePins then |
386 numShown = 0 | 406 numShown = 0 |
387 self.refreshBenchMark = GetTime() | 407 self.refreshBenchMark = GetTime() |
388 self.refreshBenchMarkTicker = 2 | 408 self.refreshBenchMarkTicker = 2 |
389 print('starting bench', self.refreshBenchMark) | 409 print('starting bench', self.refreshBenchMark) |
390 return | 410 return |
391 end | 411 end |
392 --wprint(' '..msg) | |
393 | 412 |
394 scaleConstant = db.isContinentMap and 2 or 3 | 413 scaleConstant = db.isContinentMap and 2 or 3 |
395 canTargetQuests = SpellCanTargetQuest() | 414 canTargetQuests = SpellCanTargetQuest() |
396 | 415 |
397 for index, pin in pairs(db.QuestsByID) do | 416 for index, pin in pairs(db.QuestsByID) do |
398 pin.used = nil | 417 pin.used = nil |
399 end | 418 end |
400 | 419 |
401 self:UpdateAnchors(...) | 420 self:UpdateAnchors(...) |
402 --[[ | |
403 if bountiesDirty then | |
404 --print(' bounties dirty, pushing that') | |
405 self:UpdateBounties() | |
406 end | |
407 --]] | |
408 | 421 |
409 if artifactPowerDirty and not InCombatLockdown() then | 422 if artifactPowerDirty and not InCombatLockdown() then |
410 self:UpdateArtifactPower() | 423 self:UpdateArtifactPower() |
411 end | 424 end |
412 -- calculate quests shown | 425 -- calculate quests shown |
413 numShown = 0 | 426 numShown = 0 |
414 numLoaded = 0 | 427 numLoaded = 0 |
415 for questID, pin in pairs(db.QuestsByID) do | 428 for questID, pin in pairs(db.QuestsByID) do |
416 local oV = pin:IsShown() | 429 local oV = pin:IsShown() |
417 if pin.used then | 430 if pin.used then |
431 print('show', pin.title) | |
418 pin.throttle = 1 | 432 pin.throttle = 1 |
419 --[[ | |
420 if oV == false then | |
421 --rprint('|cFF00FF00cleanup +|r', questID, pin.title) | |
422 end | |
423 --]] | |
424 pin:SetShown(true) | 433 pin:SetShown(true) |
425 numShown = numShown + 1 | 434 numShown = numShown + 1 |
426 if pin.dataLoaded then | 435 if pin.dataLoaded then |
427 numLoaded = numLoaded + 1 | 436 numLoaded = numLoaded + 1 |
428 end | 437 end |
429 | 438 |
430 else | 439 else |
431 --[[ | 440 if pin:IsShown() then |
432 if oV == true then | 441 print('|cFFFF4400need to remove', pin.title) |
433 rprint('|cFFFF4400 -|r', questID, pin.title) | 442 |
434 end | 443 end |
435 --]] | 444 |
436 pin.hideReason = "Not used in map area " .. (db.currentMapID) | 445 pin.hideReason = "Not used in map area " .. (db.currentMapID) |
437 pin:SetShown(false) | 446 pin:SetShown(false) |
438 end | 447 end |
439 | 448 |
440 end | 449 end |
441 --print('flags ', layoutDirty, self.isStale) | |
442 --print(' ', numShown, 'shown,', numLoaded, 'with data') | |
443 | 450 |
444 | 451 |
445 -- | 452 -- |
446 self.refreshBenchMark = GetTime() | 453 self.refreshBenchMark = GetTime() |
447 self.refreshBenchMarkTicker = 2 | 454 self.refreshBenchMarkTicker = 2 |
481 print('|cFF00FFFFRefreshIfChanged()|r', refreshReason) | 488 print('|cFF00FFFFRefreshIfChanged()|r', refreshReason) |
482 self.isStale = true | 489 self.isStale = true |
483 end | 490 end |
484 end | 491 end |
485 | 492 |
486 -- marks a pin set for passive update | |
487 function Module:MarkAllPins(pins) | |
488 --print(' |cFFFFFF00'..self:GetName()..':MarkAllPins()|r', pins) | |
489 pins = pins or db.QuestsByID | |
490 for questID, pin in pairs(pins) do | |
491 pin.isStale = true | |
492 --rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used) | |
493 end | |
494 end | |
495 | |
496 -- Walks the current map tree and fires updates as needed | 493 -- Walks the current map tree and fires updates as needed |
497 function Module:UpdateAnchors (event) | 494 function Module:UpdateAnchors (event) |
498 wipe(self.UsedPositions) | 495 wipe(self.UsedPositions) |
499 local hostWidth, hostHeight = WorldMapPOIFrame:GetSize() | 496 local hostWidth, hostHeight = WorldMapPOIFrame:GetSize() |
500 | 497 |
527 end | 524 end |
528 end | 525 end |
529 end | 526 end |
530 end | 527 end |
531 | 528 |
532 -- Applies map association to the pins corresponding with each TaskInfo item | 529 -- Attempt to display the pins for quests in taskInfo |
533 function Module:UpdateQuestsForMap(taskInfo, mapID) | 530 function Module:UpdateQuestsForMap(taskInfo, mapID) |
534 print('|cFF00FF00UpdateQuestsForMap()|r', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID), layoutDirty) | 531 print('|cFF00FF00UpdateQuestsForMap()|r', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID), layoutDirty) |
535 if db.QuestsByZone[mapID] then | 532 if db.QuestsByZone[mapID] then |
536 wipe(db.QuestsByZone[mapID]) | 533 wipe(db.QuestsByZone[mapID]) |
537 elseif db.isBrokenIsle then | 534 elseif db.isBrokenIsle then |
538 continentScanned = true | 535 continentScanned = true |
539 end | 536 end |
537 print('layoutDirty =',layoutDirty) | |
540 | 538 |
541 for index, info in pairs(taskInfo) do | 539 for index, info in pairs(taskInfo) do |
542 local questID, x, y = info.questId, info.x, info.y | 540 local questID, x, y = info.questId, info.x, info.y |
543 local pin = self:AcquirePin(info) | 541 local pin = self:AcquirePin(info) |
544 | 542 |
545 if pin then | 543 if pin.canShow then |
546 pin.used = true | 544 pin.used = true |
547 print(pin.title, pin.isStale, layoutDirty, (pin.owningFrame ~= WorldMapFrame)) | 545 print('using', pin.title, (pin.owningFrame ~= WorldMapFrame)) |
548 if pin:IsShown() and (layoutDirty or pin.isStale or (pin.owningFrame ~= WorldMapFrame)) then | 546 if layoutDirty or (pin.owningFrame ~= WorldMapFrame) then |
549 local scaleFactor = SCALE_FACTORS[(not pin.filtered and scaleConstant) or 1] | 547 local scaleFactor = SCALE_FACTORS[(not pin.filtered and scaleConstant) or 1] |
550 pin.owningFrame = WorldMapFrame | 548 pin.owningFrame = WorldMapFrame |
551 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) | 549 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) |
552 if pin.isStale then | 550 if pin.isStale then |
553 pin:Refresh('WORLDMAP_REFRESH ' .. GetTime()) | 551 pin:Refresh('WORLDMAP_REFRESH ' .. GetTime()) |
554 end | 552 end |
555 else | 553 end |
556 if layoutDirty then | 554 if db.QuestsByZone[mapID] then |
557 pin.isStale = true | |
558 end | |
559 end | |
560 | |
561 if db.QuestsByZone[mapID] and pin.used then | |
562 db.QuestsByZone[mapID][questID] = pin | 555 db.QuestsByZone[mapID][questID] = pin |
563 end | 556 end |
557 else | |
558 print('|cFFFF4400not using|r', pin.title) | |
564 end | 559 end |
565 end | 560 end |
566 end | 561 end |
567 | 562 |
568 -- locates or creates a corresponding pin frame for the provided TaskInfo data | 563 -- locates or creates a corresponding pin frame for the provided TaskInfo data |