comparison WorldQuests.lua @ 49:dbd81d49af02

- Solve more frame data flagging issues - Unify method for resolving filter and visibility states - Flight Map modifications respect filter settings - Solve initial draw issues with tag icon, filter state handling - Solve issues with text layer synchronization during map changes
author Nenue
date Thu, 29 Dec 2016 13:31:20 -0500
parents c0b88bd1e40b
children 6439015d74b1
comparison
equal deleted inserted replaced
48:c0b88bd1e40b 49:dbd81d49af02
57 hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end) 57 hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end)
58 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function () self:Refresh() end) 58 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function () self:Refresh() end)
59 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end) 59 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end)
60 end 60 end
61 61
62 function Module:OnConfigUpdate()
63 if db.Config.FadeWhileGrouped then
64 db.PinAlpha = 0.15
65 else
66 db.PinAlpha = 1
67 end
68 end
69
62 local InternalHideButton = function(button, index) 70 local InternalHideButton = function(button, index)
63 button:Hide() 71 button:Hide()
64 if button.questID and db.QuestsByID[button.questID] then 72 if button.questID and db.QuestsByID[button.questID] then
65 if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then 73 if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then
66 db.QuestsByID[button.questID]:SetShown(true) 74 db.QuestsByID[button.questID]:SetShown(true)
115 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL') 123 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL')
116 self:RegisterEvent('SKILL_LINES_CHANGED') 124 self:RegisterEvent('SKILL_LINES_CHANGED')
117 end 125 end
118 126
119 function Module:OnMapInfo() 127 function Module:OnMapInfo()
128 print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r visible =', self:IsVisible())
120 if self:IsVisible() then 129 if self:IsVisible() then
121 self:Refresh(true) 130 self:Refresh(true)
122 else 131 else
123 self.isStale = true 132 self.isStale = true
124 end 133 end
159 168
160 if not QuestUtils_IsQuestWorldQuest(questID) then 169 if not QuestUtils_IsQuestWorldQuest(questID) then
161 return nil 170 return nil
162 end 171 end
163 172
164 173 -- if we're grabbing a pin, the filters need to be checked
165 local pin = db.QuestsByID[questID] 174 local pin = db.QuestsByID[questID]
166 if not pin then 175 if not pin then
167 local numFree = #db.FreePins 176 local numFree = #db.FreePins
168 if numFree >= 1 then 177 if numFree >= 1 then
169 pin = tremove(db.FreePins, numFree) 178 pin = tremove(db.FreePins, numFree)
200 pin.y = info.y or pin.y 209 pin.y = info.y or pin.y
201 rprint('|cFFFF4400coords|r', info.x, info.y) 210 rprint('|cFFFF4400coords|r', info.x, info.y)
202 end 211 end
203 end 212 end
204 213
205 pin:GetData() 214 if not pin.dataLoaded then
206 C_TaskQuest.RequestPreloadRewardData(info.questId) 215 pin:GetData()
216 C_TaskQuest.RequestPreloadRewardData(info.questId)
217 end
218
219 pin:IsFiltered()
220 pin:IsShowable()
221 pin.isStale = true
222 rprint(pin:GetID(), pin.filtered, pin.used)
223
207 return pin 224 return pin
208 end 225 end
209 226
210 -- remove from index and add it to the recycling heap 227 -- remove from index and add it to the recycling heap
211 function Module:ReleasePin (pin) 228 function Module:ReleasePin (pin)
279 local scanner = _G.WorldPlanTooltip 296 local scanner = _G.WorldPlanTooltip
280 local print = qprint 297 local print = qprint
281 if not itemID then 298 if not itemID then
282 return 299 return
283 end 300 end
284 --print('GetRewardHeader', questID) 301 qprint('GetRewardHeader', questID)
285 302
286 scanner:SetOwner(WorldPlan, "ANCHOR_NONE") 303 scanner:SetOwner(WorldPlan, "ANCHOR_NONE")
287 scanner:SetItemByID(itemID) 304 scanner:SetItemByID(itemID)
288 scanner:Show() 305 scanner:Show()
289 local ttl1 = _G['WorldPlanTooltipTextLeft1'] 306 local ttl1 = _G['WorldPlanTooltipTextLeft1']
312 elseif text:match("Item Level") then 329 elseif text:match("Item Level") then
313 --print('equipment!', text) 330 --print('equipment!', text)
314 quantity = text:match("Item Level ([%d\+]+)") 331 quantity = text:match("Item Level ([%d\+]+)")
315 return REWARD_GEAR, icon, quantity, name, itemID, quality 332 return REWARD_GEAR, icon, quantity, name, itemID, quality
316 elseif text:match("Crafting Reagent") then 333 elseif text:match("Crafting Reagent") then
317 --print('|cFFFF4400it is a reagent', text) 334 qprint('|cFFFF4400it is a reagent', text)
318 return REWARD_REAGENT, icon, quantity, name, itemID, quality 335 return REWARD_REAGENT, icon, quantity, name, itemID, quality
319 end 336 end
320 end 337 end
321 end 338 end
322 339
323 if ttl3 then 340 if ttl3 then
324 local text = ttl3:GetText() 341 local text = ttl3:GetText()
325 if text and text:match("Crafting Reagent") then 342 if text and text:match("Crafting Reagent") then
326 --print('|cFFFF4400it is a reagent', text) 343 qprint('|cFFFF4400it is a reagent', text)
327 return REWARD_REAGENT, icon, quantity, name, itemID, quality 344 return REWARD_REAGENT, icon, quantity, name, itemID, quality
328 end 345 end
329 end 346 end
330 return 128, icon, quantity, name, itemID, quality 347 return 128, icon, quantity, name, itemID, quality
331 end 348 end
392 db:print(id, pin.worldQuestType, pin.rewardType, pin.title) 409 db:print(id, pin.worldQuestType, pin.rewardType, pin.title)
393 end 410 end
394 end 411 end
395 412
396 function Module:Refresh(fromUser) 413 function Module:Refresh(fromUser)
414 self.isUserTriggered = fromUser
397 self.currentMapID = GetCurrentMapAreaID() 415 self.currentMapID = GetCurrentMapAreaID()
416 rprint('|cFF00FF88'..self:GetName()..':Refresh()|r', fromUser or '|cFFFFFF00internal')
398 print('|cFF00FF88'..self:GetName()..':Refresh()|r', fromUser or '|cFFFFFF00internal') 417 print('|cFF00FF88'..self:GetName()..':Refresh()|r', fromUser or '|cFFFFFF00internal')
399 if not self:IsVisible() then 418 if not self:IsVisible() then
400 print(' not visible, flag for later') 419 print(' not visible, flag for later')
401 self.isStale = true 420 self.isStale = true
402 return 421 return
405 424
406 for index, pin in pairs(db.QuestsByID) do 425 for index, pin in pairs(db.QuestsByID) do
407 pin.used = nil 426 pin.used = nil
408 end 427 end
409 428
410 self:SetFilteredPins(db.QuestsByID)
411 self:UpdateAnchors(nil, fromUser) 429 self:UpdateAnchors(nil, fromUser)
412 self:Cleanup (fromUser) 430 self:Cleanup (fromUser)
413 self.isStale = nil 431 self.isStale = nil
432 self.isUserTriggered = nil
414 end 433 end
415 434
416 -- update visibility states of all pins 435 -- update visibility states of all pins
417 function Module:SetFilteredPins(pins) 436 function Module:SetFilteredPins(pins)
418 print(' |cFFFFFF00'..self:GetName()..':SetFilteredPins()|r', pins) 437 print(' |cFFFFFF00'..self:GetName()..':SetFilteredPins()|r', pins)
419 pins = pins or db.QuestsByID 438 pins = pins or db.QuestsByID
420 for questID, pin in pairs(pins) do 439 for questID, pin in pairs(pins) do
421 pin.filtered = pin:IsFiltered()
422 pin.isStale = true 440 pin.isStale = true
423 rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used) 441 rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used)
424 end 442 end
425 end 443 end
426 444
431 if not pin then 449 if not pin then
432 return 450 return
433 end 451 end
434 452
435 453
436 print('~ ', pin.mapID, pin.questID, pin.title) 454 --print('~ ', pin.mapID, pin.questID, pin.title)
437 rprint('|cFF00FF00update|r', x, y, pin.title) 455 rprint('|cFF00FF00update|r', x, y, pin.mapID, pin.questID, pin.title)
438 pin:IsShowable()
439 456
440 if x and y then 457 if x and y then
441
442 pin.x = x 458 pin.x = x
443 pin.y = y 459 pin.y = y
444 pin:SetFrameLevel(PinBaseIndex+numPins) 460 pin.owningFrame = self.hostFrame
445 pin:SetPoint('CENTER', self.hostFrame, 'TOPLEFT', self.hostWidth * pin.x, -self.hostHeight * pin.y)
446 pin.throttle = 1 461 pin.throttle = 1
447 pin:SetShown(pin.used) 462
463 pin:SetParent(self.hostFrame)
464 pin:SetFrameLevel(PinBaseIndex+pin:GetID())
465 pin:SetAnchor(pin.x, pin.y, self.hostWidth, self.hostHeight)
448 tinsert(self.UsedPositions, pin) 466 tinsert(self.UsedPositions, pin)
449 end 467 end
450 pin.owningFrame = self.hostFrame
451 pin:SetParent(self.hostFrame)
452 468
453 if mapID then 469 if mapID then
454 if not db.QuestsByZone[mapID] then 470 if not db.QuestsByZone[mapID] then
455 db.QuestsByZone[mapID] = {} 471 db.QuestsByZone[mapID] = {}
456 end 472 end
457 db.QuestsByZone[mapID][questID] = pin 473 db.QuestsByZone[mapID][questID] = pin
458 end 474 end
459 end 475 end
460 476
461 function Module:UpdateMap(taskInfo, mapID) 477 function Module:UpdateMap(taskInfo, mapID)
462 print('Map', GetMapNameByID(mapID), GetMapNameByID(self.currentMapID)) 478 rprint('Map', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID))
463 for index, info in pairs(taskInfo) do 479 for index, info in pairs(taskInfo) do
464 self:UpdateQuestButton(info, mapID) 480 self:UpdateQuestButton(info, mapID)
465 end 481 end
466 end 482 end
467 483
468 function Module:UpdateAnchors (fromUser) 484 function Module:UpdateAnchors (fromUser)
469
470
471 wipe(self.UsedPositions) 485 wipe(self.UsedPositions)
472 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()', fromUser) 486 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()', fromUser)
473 self.hostFrame = WorldMapPOIFrame 487 self.hostFrame = WorldMapPOIFrame
474 self.hostWidth, self.hostHeight = self.hostFrame:GetSize() 488 self.hostWidth, self.hostHeight = self.hostFrame:GetSize()
475 self.nudgeThrescholdX = 16/self.hostWidth 489 self.nudgeThrescholdX = 16/self.hostWidth
480 if isMicroDungeon then 494 if isMicroDungeon then
481 return 495 return
482 end 496 end
483 497
484 numPins = 0 498 numPins = 0
485 local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID) 499 local taskInfo = TQ_GetQuestsForPlayerByMapID(db.currentMapID)
486 if taskInfo then 500 if taskInfo then
487 self:UpdateMap(taskInfo, self.currentMapID) 501 self:UpdateMap(taskInfo, db.currentMapID)
488 end 502 end
489 local numZones = MC_GetNumZones(self.currentMapID) 503 local numZones = MC_GetNumZones(db.currentMapID)
490 if numZones then 504 if numZones then
491 for i = 1, numZones do 505 for i = 1, numZones do
492 local mapAreaID = MC_GetZoneInfo(self.currentMapID, i) 506 local mapAreaID = MC_GetZoneInfo(self.currentMapID, i)
493 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, self.currentMapID) 507 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, db.currentMapID)
494 if taskInfo then 508 if taskInfo then
495 self:UpdateMap(taskInfo, mapAreaID) 509 self:UpdateMap(taskInfo, mapAreaID)
496 end 510 end
497 end 511 end
498 end
499 if self.filtersDirty then
500 self:SetFilteredPins(db.QuestsByID)
501 end 512 end
502 end 513 end
503 514
504 -- shows, animates, or hides pins based on their current visibility flags 515 -- shows, animates, or hides pins based on their current visibility flags
505 function Module:Cleanup (fromUser) 516 function Module:Cleanup (fromUser)
509 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') 520 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
510 --local showQuestPOI = db.Config.EnablePins 521 --local showQuestPOI = db.Config.EnablePins
511 for questID, pin in pairs(db.QuestsByID) do 522 for questID, pin in pairs(db.QuestsByID) do
512 local oV = pin:IsShown() 523 local oV = pin:IsShown()
513 if pin.used then 524 if pin.used then
514
515 pin.throttle = 1 525 pin.throttle = 1
516 if oV == false then 526 if oV == false then
517 print('|cFF00FF00cleanup +|r', questID, pin.title) 527 print('|cFF00FF00cleanup +|r', questID, pin.title)
518 end 528 end
519 else 529 else
520 if oV == true then 530 if oV == true then
521 print('|cFFFF4400 -|r', questID, pin.title) 531 print('|cFFFF4400 -|r', questID, pin.title)
522 end 532 end
523 end 533 pin.isStale = true
524 pin:SetShown(pin.used or false) 534 pin:SetShown(false)
525 535 end
526 if pin.worldQuest and (not C_TaskQuest.IsActive(pin.questID)) then 536 end
527 self:ReleasePin(pin) 537 end
528 end 538
529 pin.isStale = true
530 end
531 end
532