comparison WorldQuests.lua @ 65:02f1d3bce558

Update for Legion Patch 7.2 - Massively improved performance footprint via 7.2 API changes and some major optimization of POI update triggers - Removed AP token caching until reliable mechanisms for detecting AK shifts can be resolved.
author Nenue
date Wed, 29 Mar 2017 13:45:41 -0400
parents 876c3f0bfd0e
children e43e10c5576b
comparison
equal deleted inserted replaced
64:876c3f0bfd0e 65:02f1d3bce558
33 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER 33 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER
34 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT 34 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT
35 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES 35 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
36 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS 36 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
37 37
38 38 local numShown = 0
39 local numLoaded = 0
40 local isDataLoaded
39 local numPins = 0 41 local numPins = 0
40 local NumPinFrames = 1 42 local NumPinFrames = 1
41 Module.TasksByID = {} 43 Module.TasksByID = {}
42 44
43 --%debug% 45 --%debug%
70 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", InternalDoRefresh) 72 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", InternalDoRefresh)
71 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end) 73 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end)
72 hooksecurefunc("WorldMapFrame_UpdateMap", InternalDoRefresh) 74 hooksecurefunc("WorldMapFrame_UpdateMap", InternalDoRefresh)
73 WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(InternalDoRefresh); 75 WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(InternalDoRefresh);
74 WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(InternalDoRefresh); 76 WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(InternalDoRefresh);
77
78 self.Status = CreateFrame('Frame', nil, self)
79 self.Status:SetPoint('TOPLEFT', WorldMapPOIFrame, 'TOPLEFT', 0, 0)
80 self.Status:SetPoint('BOTTOMRIGHT', WorldMapPOIFrame, 'TOPRIGHT', 0, -4)
81 self.Status.t = self.Status:CreateTexture(nil, 'OVERLAY')
82 self.Status.b = self.Status:CreateTexture(nil, 'BACKGROUND')
83 self.Status.b:SetColorTexture(0,0,0,.25)
84 self.Status.b:SetAllPoints(self.Status)
85 self.Status.t:SetColorTexture(1,1,1,.5)
86 self.Status.t:SetPoint('TOP')
87 self.Status.t:SetPoint('BOTTOM')
88 self.Status.t:SetPoint('LEFT')
89 local translationEnd, translationStart
90 self.Status:SetScript('OnUpdate', function(status)
91 local translateTo
92 if numLoaded < numShown then
93 translateTo = numLoaded/numShown * status:GetWidth()
94 status.t:SetWidth(translateTo)
95 else
96 translateTo = numShown * status:GetWidth()
97 status.t:SetWidth(translateTo)
98 end
99
100
101 end)
75 end 102 end
76 103
77 function Module:OnConfigUpdate() 104 function Module:OnConfigUpdate()
78 if db.Config.FadeWhileGrouped then 105 if db.Config.FadeWhileGrouped then
79 db.PinAlpha = 0.15 106 db.PinAlpha = 0.15
158 self:Refresh(true) 185 self:Refresh(true)
159 else 186 else
160 self.isStale = true 187 self.isStale = true
161 end 188 end
162 end 189 end
163 190 local superTrackedQuestID
164 function Module:OnEvent (event, ...) 191 function Module:OnEvent (event, ...)
165 192
166 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) 193 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
167 if (event == 'QUEST_LOG_UPDATE') or (event == 'SUPER_TRACKED_QUEST_CHANGED') then 194 if (event == 'QUEST_LOG_UPDATE') or (event == 'SUPER_TRACKED_QUEST_CHANGED') then
168 local questID, added = ... 195 local questID, added = ...
179 local questID = ... 206 local questID = ...
180 if questID and db.QuestsByID[questID] then 207 if questID and db.QuestsByID[questID] then
181 self:ReleasePin(db.QuestsByID[questID]) 208 self:ReleasePin(db.QuestsByID[questID])
182 rprint('|cFFFF4400release|r', questID) 209 rprint('|cFFFF4400release|r', questID)
183 end 210 end
184 elseif event == 'SKILL_LINES_CHANGED' then 211 elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then
185 self:Refresh()
186 elseif event == 'CURRENT_SPELL_CAST_CHANGED' then
187
188 self:Refresh() 212 self:Refresh()
189 elseif event == 'ARTIFACT_UPDATE' then 213 elseif event == 'ARTIFACT_UPDATE' then
190 local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier() 214 local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier()
191 if ak and (ak ~= self.akLevel) then 215 if ak and (ak ~= self.akLevel) then
192 print('push artifact knowledge update', self.akLevel, 'to', ak) 216 print('push artifact knowledge update', self.akLevel, 'to', ak)
193 self.akLevel = ak 217 self.akLevel = ak
194 for index, pin in pairs( db.QuestsByID) do 218 for index, pin in pairs( db.QuestsByID) do
195 pin.dataLoaded = nil 219 pin.dataLoaded = nil
196 end 220 end
197 self:Refresh() 221 self:Refresh()
222 end
223 elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then
224 if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then
225 db.QuestsByID[superTrackedQuestID].isStale = true
226 end
227 local newID = GetSuperTrackedQuestID()
228 if newID and db.QuestsByID[newID] then
229 db.QuestsByID[newID].isStale = true
198 end 230 end
199 end 231 end
200 end 232 end
201 233
202 local totalPins = 0 234 local totalPins = 0
251 rprint('|cFFFF4400coords|r', info.x, info.y) 283 rprint('|cFFFF4400coords|r', info.x, info.y)
252 end 284 end
253 end 285 end
254 286
255 if (not pin.dataLoaded) then 287 if (not pin.dataLoaded) then
256 pin:GetData() 288 local dataLoaded = pin:GetData()
289 isDataLoaded = (isDataLoaded and dataLoaded)
257 WorldPlan.dataFlush = true 290 WorldPlan.dataFlush = true
258 end 291 end
259 292
260 pin.isActive = TQ_IsActive(questID) 293 pin.isActive = TQ_IsActive(questID)
261 294
262 pin:CheckFilterRules() 295 pin:CheckFilterRules()
263 pin.isStale = true
264 rprint(pin:GetID(), pin.filtered, pin.used) 296 rprint(pin:GetID(), pin.filtered, pin.used)
265 297
266 return pin 298 return pin
267 end 299 end
268 300
473 end 505 end
474 506
475 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') 507 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
476 rprint('|cFFFFFF00'..self:GetName()..':Cleanup()|r') 508 rprint('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
477 --local showQuestPOI = db.Config.EnablePins 509 --local showQuestPOI = db.Config.EnablePins
510 numShown = 0
511 numLoaded = 0
478 for questID, pin in pairs(db.QuestsByID) do 512 for questID, pin in pairs(db.QuestsByID) do
479 local oV = pin:IsShown() 513 local oV = pin:IsShown()
480 if pin.used then 514 if pin.used then
481 pin.throttle = 1 515 pin.throttle = 1
482 if oV == false then 516 if oV == false then
483 print('|cFF00FF00cleanup +|r', questID, pin.title) 517 print('|cFF00FF00cleanup +|r', questID, pin.title)
484 end 518 end
485 pin:SetShown(true) 519 pin:SetShown(true)
520 numShown = numShown + 1
521 if pin.dataLoaded then
522 numLoaded = numLoaded + 1
523 end
524
486 else 525 else
487 if oV == true then 526 if oV == true then
488 print('|cFFFF4400 -|r', questID, pin.title) 527 print('|cFFFF4400 -|r', questID, pin.title)
489 end 528 end
490 pin:HideFrames() 529 pin:HideFrames()
491 end 530 end
492 end 531 end
532
533 if numShown > numLoaded then
534 self.Status:Show()
535 end
536
493 537
494 self.isStale = nil 538 self.isStale = nil
495 self.sizesDirty = nil 539 self.sizesDirty = nil
496 end 540 end
497 541
515 559
516 print('~ ', pin.mapID, pin.questID, pin.title) 560 print('~ ', pin.mapID, pin.questID, pin.title)
517 rprint('|cFF00FF00update|r', pin.questID, pin.title) 561 rprint('|cFF00FF00update|r', pin.questID, pin.title)
518 562
519 if x and y then 563 if x and y then
520 pin.x = x
521 pin.y = y
522 pin:SetFrameLevel(PinBaseIndex+pin:GetID()) 564 pin:SetFrameLevel(PinBaseIndex+pin:GetID())
523 pin.owningFrame = WorldMapFrame 565 pin.owningFrame = WorldMapFrame
524 pin:SetAnchor(WorldMapPOIFrame, pin.x, pin.y, self.hostWidth, self.hostHeight) 566 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight)
525 --tinsert(self.UsedPositions, pin) 567 --tinsert(self.UsedPositions, pin)
526 end 568 end
527 if self:IsVisible() then 569 if self:IsVisible() and pin.isStale then
528 pin:Refresh() 570 pin:Refresh()
529 else
530 pin.isStale = true
531 end 571 end
532 if mapID then 572 if mapID then
533 if not db.QuestsByZone[mapID] then 573 if not db.QuestsByZone[mapID] then
534 db.QuestsByZone[mapID] = {} 574 db.QuestsByZone[mapID] = {}
535 end 575 end
543 self:UpdateQuestButton(info, mapID) 583 self:UpdateQuestButton(info, mapID)
544 end 584 end
545 end 585 end
546 586
547 function Module:UpdateAnchors () 587 function Module:UpdateAnchors ()
588
548 wipe(self.UsedPositions) 589 wipe(self.UsedPositions)
549 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()') 590 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()')
550 self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize() 591 self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize()
551 self.nudgeThrescholdX = 16/self.hostWidth 592 self.nudgeThrescholdX = 16/self.hostWidth
552 self.nudgeThrescholdY = 16/self.hostHeight 593 self.nudgeThrescholdY = 16/self.hostHeight
554 print('|cFF00FF00'..self:GetName()..':UpdateAnchors()') 595 print('|cFF00FF00'..self:GetName()..':UpdateAnchors()')
555 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo() 596 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo()
556 if isMicroDungeon then 597 if isMicroDungeon then
557 return 598 return
558 end 599 end
559 600 -- starts as true
601 isDataLoaded = true
560 602
561 numPins = 0 603 numPins = 0
562 local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID) 604 local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID)
563 if taskInfo then 605 if taskInfo then
564 self:UpdateMap(taskInfo, self.currentMapID) 606 self:UpdateMap(taskInfo, self.currentMapID)
573 end 615 end
574 end 616 end
575 end 617 end
576 end 618 end
577 619
578