annotate WorldQuests.lua @ 66:e43e10c5576b

Update for Legion Patch 7.2 - Massive performance improvements through largely re-written update routines. - Removed AP token caching until reliable mechanisms for detecting AK shifts can be resolved.
author Nenue
date Thu, 30 Mar 2017 02:32:44 -0400
parents 02f1d3bce558
children 96183f981acb
rev   line source
Nenue@33 1 -- WorldPlan
Nenue@33 2 -- WorldQuests.lua
Nenue@33 3 -- Created: 11/2/2016 3:40 PM
Nenue@33 4 -- %file-revision%
Nenue@40 5 local _, db = ...
Nenue@45 6 local Module = WorldPlanQuestsMixin
Nenue@33 7
Nick@64 8 local _G = _G
Nenue@33 9 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo
Nenue@33 10 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented
Nenue@33 11 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID
Nick@64 12 local TQ_IsActive = C_TaskQuest.IsActive
Nick@64 13 local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe
Nick@64 14 local GetTaskInfo, GetTasksTable, HaveQuestData = GetTaskInfo, GetTasksTable, HaveQuestData
Nick@64 15 local GetTime = GetTime
Nick@64 16 local SpellCanTargetQuest = SpellCanTargetQuest
Nick@64 17 local tonumber, abs = tonumber, math.abs
Nick@64 18 local GetQuestLogRewardInfo = GetQuestLogRewardInfo
Nick@64 19 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID
Nick@64 20
Nenue@40 21 local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
Nenue@40 22 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end
Nenue@33 23 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@33 24 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@35 25 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end
Nenue@33 26
Nenue@40 27 local PinBaseIndex = 1200
Nenue@33 28 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
Nenue@33 29 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah",
Nenue@33 30 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', }
Nenue@33 31
Nenue@33 32 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD
Nenue@33 33 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER
Nenue@33 34 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT
Nenue@33 35 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
Nenue@33 36 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
Nenue@66 37 local SCALE_FACTORS = {
Nenue@66 38 0.25, 0.7, 1
Nenue@66 39 }
Nenue@33 40
Nenue@65 41 local numShown = 0
Nenue@65 42 local numLoaded = 0
Nenue@65 43 local isDataLoaded
Nenue@33 44 local numPins = 0
Nenue@33 45 local NumPinFrames = 1
Nenue@66 46 local scaleConstant = 1
Nenue@45 47 Module.TasksByID = {}
Nenue@33 48
Nenue@33 49 --%debug%
Nenue@33 50 local SetTimedCallbackForAllPins = function(seconds, callback)
Nenue@33 51 C_Timer.After(seconds, function()
Nenue@33 52 for id, pin in pairs(WorldPlanQuests.QuestsByID) do
Nenue@33 53 callback(pin)
Nenue@33 54 end
Nenue@33 55 end)
Nenue@33 56 end
Nenue@33 57
Nenue@45 58 function Module:OnUpdate(sinceLast)
Nenue@66 59 if self.filtersDirty or self.isStale or self.isZoomDirty then
Nenue@40 60 self:Refresh()
Nenue@40 61 end
Nenue@40 62 end
Nenue@40 63
Nenue@52 64 local InternalDoRefresh = function (self)
Nick@60 65 WorldPlanQuests:Refresh()
Nenue@52 66 end
Nenue@52 67
Nenue@45 68 function Module:Setup()
Nenue@40 69 print('|cFFFF4400'..self:GetName()..':Setup()')
Nenue@33 70
Nenue@33 71 for mapID, mapName in pairs(WORLD_QUEST_MAPS) do
Nenue@40 72 db.QuestsByZone[mapID] = {}
Nenue@33 73 end
Nenue@33 74
Nenue@45 75 hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end)
Nenue@56 76 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", InternalDoRefresh)
Nenue@45 77 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end)
Nenue@56 78 hooksecurefunc("WorldMapFrame_UpdateMap", InternalDoRefresh)
Nenue@52 79 WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(InternalDoRefresh);
Nenue@52 80 WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(InternalDoRefresh);
Nenue@65 81
Nenue@65 82 self.Status = CreateFrame('Frame', nil, self)
Nenue@65 83 self.Status:SetPoint('TOPLEFT', WorldMapPOIFrame, 'TOPLEFT', 0, 0)
Nenue@65 84 self.Status:SetPoint('BOTTOMRIGHT', WorldMapPOIFrame, 'TOPRIGHT', 0, -4)
Nenue@65 85 self.Status.t = self.Status:CreateTexture(nil, 'OVERLAY')
Nenue@65 86 self.Status.b = self.Status:CreateTexture(nil, 'BACKGROUND')
Nenue@65 87 self.Status.b:SetColorTexture(0,0,0,.25)
Nenue@65 88 self.Status.b:SetAllPoints(self.Status)
Nenue@65 89 self.Status.t:SetColorTexture(1,1,1,.5)
Nenue@65 90 self.Status.t:SetPoint('TOP')
Nenue@65 91 self.Status.t:SetPoint('BOTTOM')
Nenue@65 92 self.Status.t:SetPoint('LEFT')
Nenue@65 93 local translationEnd, translationStart
Nenue@65 94 self.Status:SetScript('OnUpdate', function(status)
Nenue@65 95 local translateTo
Nenue@65 96 if numLoaded < numShown then
Nenue@65 97 translateTo = numLoaded/numShown * status:GetWidth()
Nenue@65 98 status.t:SetWidth(translateTo)
Nenue@65 99 else
Nenue@65 100 translateTo = numShown * status:GetWidth()
Nenue@65 101 status.t:SetWidth(translateTo)
Nenue@65 102 end
Nenue@65 103
Nenue@65 104
Nenue@65 105 end)
Nenue@45 106 end
Nenue@33 107
Nenue@49 108 function Module:OnConfigUpdate()
Nenue@49 109 if db.Config.FadeWhileGrouped then
Nenue@49 110 db.PinAlpha = 0.15
Nenue@49 111 else
Nenue@49 112 db.PinAlpha = 1
Nenue@49 113 end
Nenue@49 114 end
Nenue@49 115
Nenue@45 116 local InternalHideButton = function(button, index)
Nenue@45 117 button:Hide()
Nenue@45 118 if button.questID and db.QuestsByID[button.questID] then
Nenue@45 119 if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then
Nenue@45 120 db.QuestsByID[button.questID]:SetShown(true)
Nenue@45 121 end
Nenue@45 122 end
Nenue@45 123 end
Nenue@45 124 local InternalShowButton = function(button, index)
Nenue@45 125 button:Show()
Nenue@45 126 if button.questID and db.QuestsByID[button.questID] then
Nenue@45 127 db.QuestsByID[button.questID]:SetShown(false)
Nenue@45 128 end
Nenue@45 129 end
Nenue@33 130
Nick@62 131 function Module:UpdateBlizzButtons()
Nick@62 132
Nenue@45 133 local func = SpellCanTargetQuest() and InternalShowButton or InternalHideButton
Nenue@45 134 for i = 1, NUM_WORLDMAP_TASK_POIS do
Nenue@45 135 local button = _G['WorldMapFrameTaskPOI'..i]
Nenue@45 136 if button and button.worldQuest then
Nenue@45 137 func(button, i)
Nenue@45 138 end
Nenue@45 139 end
Nenue@45 140 end
Nenue@40 141
Nick@62 142 function Module:OnUpdateQuestBonusObjectives()
Nick@62 143 print('|cFFFF4400WorldMap_UpdateQuestBonusObjectives')
Nick@62 144 self:UpdateBlizzButtons()
Nick@62 145 end
Nick@62 146
Nenue@45 147 function Module:OnClickWorldMapActionButton()
Nick@62 148 self:UpdateBlizzButtons()
Nenue@45 149 end
Nenue@40 150
Nenue@33 151 local defaults = {}
Nenue@40 152 local REWARD_UNKNOWN = 768
Nenue@45 153 function Module:OnLoad()
Nenue@40 154 print('|cFFFF4400'..self:GetName()..':OnLoad()')
Nenue@33 155
Nenue@48 156 self:SetParent(WorldMapPOIFrame)
Nenue@33 157 WorldPlan:AddHandler(self, defaults)
Nenue@33 158
Nenue@33 159 for areaID, fileName in pairs(WORLD_QUEST_MAPS) do
Nenue@40 160 db.QuestsByZone[areaID] = {}
Nenue@33 161 end
Nenue@33 162
Nenue@41 163 -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level
Nenue@33 164 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL')
Nenue@55 165 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@33 166 self:RegisterEvent('SKILL_LINES_CHANGED')
Nick@62 167 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED')
Nenue@33 168 end
Nenue@33 169
Nenue@56 170 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID)
Nenue@49 171 print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r visible =', self:IsVisible())
Nenue@56 172 if self.isZoomedOut ~= isZoomedOut then
Nenue@54 173 self.sizesDirty = true
Nenue@54 174 end
Nenue@56 175
Nenue@56 176 self.isZoomedOut = isZoomedOut
Nenue@56 177 self.isWorldQuestMap = isBrokenIsle
Nenue@56 178 self.currentMapID = mapAreaID
Nenue@56 179
Nenue@43 180 if self:IsVisible() then
Nenue@47 181 self:Refresh(true)
Nenue@43 182 else
Nenue@43 183 self.isStale = true
Nenue@43 184 end
Nenue@41 185 end
Nenue@65 186 local superTrackedQuestID
Nenue@45 187 function Module:OnEvent (event, ...)
Nenue@40 188
Nenue@40 189 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
Nenue@55 190 if (event == 'QUEST_LOG_UPDATE') or (event == 'SUPER_TRACKED_QUEST_CHANGED') then
Nenue@33 191 local questID, added = ...
Nenue@33 192 if questID and added then
Nenue@33 193 local questPOI = self:AcquirePin(questID)
Nenue@40 194 questPOI:GetQuestInfo()
Nenue@40 195 questPOI.isStale = true
Nenue@40 196 self.isStale = true
Nenue@33 197 else
Nick@62 198 self:Refresh()
Nenue@33 199 end
Nenue@33 200 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale)
Nenue@33 201 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
Nenue@33 202 local questID = ...
Nenue@40 203 if questID and db.QuestsByID[questID] then
Nenue@40 204 self:ReleasePin(db.QuestsByID[questID])
Nenue@40 205 rprint('|cFFFF4400release|r', questID)
Nenue@33 206 end
Nenue@65 207 elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then
Nick@62 208 self:Refresh()
Nenue@59 209 elseif event == 'ARTIFACT_UPDATE' then
Nenue@59 210 local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier()
Nenue@59 211 if ak and (ak ~= self.akLevel) then
Nick@62 212 print('push artifact knowledge update', self.akLevel, 'to', ak)
Nenue@59 213 self.akLevel = ak
Nick@62 214 for index, pin in pairs( db.QuestsByID) do
Nick@62 215 pin.dataLoaded = nil
Nick@62 216 end
Nick@62 217 self:Refresh()
Nenue@59 218 end
Nenue@65 219 elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@65 220 if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then
Nenue@65 221 db.QuestsByID[superTrackedQuestID].isStale = true
Nenue@65 222 end
Nenue@65 223 local newID = GetSuperTrackedQuestID()
Nenue@65 224 if newID and db.QuestsByID[newID] then
Nenue@65 225 db.QuestsByID[newID].isStale = true
Nenue@65 226 end
Nenue@33 227 end
Nenue@33 228 end
Nenue@33 229
Nenue@40 230 local totalPins = 0
Nenue@33 231 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@45 232 function Module:AcquirePin (info)
Nenue@40 233 local questID = info.questId
Nenue@40 234 if not questID then
Nenue@40 235 return nil
Nenue@40 236 end
Nenue@40 237
Nenue@40 238 if not QuestUtils_IsQuestWorldQuest(questID) then
Nenue@40 239 return nil
Nenue@40 240 end
Nenue@40 241
Nenue@49 242 -- if we're grabbing a pin, the filters need to be checked
Nenue@40 243 local pin = db.QuestsByID[questID]
Nenue@33 244 if not pin then
Nenue@40 245 local numFree = #db.FreePins
Nenue@33 246 if numFree >= 1 then
Nenue@40 247 pin = tremove(db.FreePins, numFree)
Nenue@33 248 --print('|cFF00FF00Re-using', pin:GetName())
Nenue@33 249 else
Nenue@40 250 totalPins = totalPins + 1
Nenue@33 251 local name = 'WorldPlanQuestMarker' .. NumPinFrames
Nenue@33 252 --print('|cFF00FF00Creating', name)
Nenue@33 253 pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin')
Nenue@33 254
Nenue@33 255 pin:SetFrameStrata('HIGH')
Nenue@33 256 pin.GetTypeInfo = function(frame, typeID)
Nenue@33 257 return self:GetTypeInfo(typeID)
Nenue@33 258 end
Nenue@40 259 pin:SetID(totalPins)
Nenue@33 260 NumPinFrames = NumPinFrames + 1
Nenue@33 261 --pin.iconBorder:SetVertexColor(0,0,0,1)
Nenue@33 262 end
Nenue@40 263 pin.questID = questID
Nenue@40 264 pin.worldQuest = true
Nenue@40 265 pin.throttle = 1
Nenue@33 266 pin.isNew = true
Nenue@33 267 pin.currentWidth = nil
Nenue@40 268 db.QuestsByID[questID] = pin
Nenue@40 269 tinsert(db.UsedPins, pin)
Nenue@40 270 end
Nenue@33 271
Nenue@40 272 if pin and info then
Nenue@40 273 pin.inProgress = info.inProgress
Nenue@40 274 pin.floor = info.floor
Nenue@40 275 pin.numObjectives = info.numObjectives or 0
Nenue@40 276 if info.x and info.y then
Nenue@40 277 pin.x = info.x or pin.x
Nenue@40 278 pin.y = info.y or pin.y
Nenue@40 279 rprint('|cFFFF4400coords|r', info.x, info.y)
Nenue@40 280 end
Nenue@40 281 end
Nenue@33 282
Nick@62 283 if (not pin.dataLoaded) then
Nenue@65 284 local dataLoaded = pin:GetData()
Nenue@65 285 isDataLoaded = (isDataLoaded and dataLoaded)
Nick@63 286 WorldPlan.dataFlush = true
Nenue@49 287 end
Nenue@49 288
Nenue@66 289
Nick@64 290 pin.isActive = TQ_IsActive(questID)
Nenue@57 291 pin:CheckFilterRules()
Nenue@49 292 rprint(pin:GetID(), pin.filtered, pin.used)
Nenue@49 293
Nenue@40 294 return pin
Nenue@33 295 end
Nenue@33 296
Nenue@33 297 -- remove from index and add it to the recycling heap
Nenue@45 298 function Module:ReleasePin (pin)
Nenue@33 299
Nenue@40 300 local id = pin.questID
Nenue@33 301 if id then
Nenue@40 302 db.QuestsByID[id] = nil
Nenue@40 303
Nenue@40 304 for i, zone in pairs(db.QuestsByZone) do
Nenue@33 305 print('-', i, zone[i])
Nenue@33 306 zone[id] = nil
Nenue@33 307 end
Nenue@40 308 db.TasksByID[id] = nil
Nenue@33 309 end
Nick@64 310 pin.isActive = nil
Nick@64 311 pin.dataLoaded = nil
Nick@62 312 pin:HideFrames()
Nenue@40 313 tinsert(db.FreePins, pin)
Nenue@40 314
Nick@63 315 WorldPlan.dataFlush = true
Nenue@40 316 print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title)
Nenue@33 317 end
Nenue@33 318
Nick@64 319
Nenue@45 320 function Module:GetBonusObjectives()
Nenue@40 321
Nenue@40 322
Nenue@40 323 local tasksTable = GetTasksTable()
Nenue@40 324 if tasksTable ~= nil then
Nenue@40 325 print('|cFF00FF88'..self:GetName()..':BonusObjectives()|r ')
Nenue@40 326 self.numTasks = #tasksTable
Nenue@40 327 for i, taskID in ipairs(tasksTable) do
Nenue@40 328 if not QuestUtils_IsQuestWorldQuest(taskID) then
Nenue@40 329 local info = db.TasksByID[taskID]
Nenue@40 330 if not info then
Nenue@40 331 local isInArea, isOnMap, numObjectives, taskName, displayAsObjective = GetTaskInfo(taskID)
Nenue@40 332 if isOnMap then
Nenue@40 333 print(' * '..i, taskID, GetTaskInfo(taskID))
Nenue@40 334 info = {
Nenue@40 335 questID = taskID,
Nenue@40 336 numObjectives = numObjectives,
Nenue@40 337 title = taskName,
Nenue@40 338 isInArea = isInArea,
Nenue@40 339 isOnMap = isOnMap,
Nenue@40 340 displayAsObjective = displayAsObjective,
Nenue@40 341 worldQuest = false,
Nenue@40 342 isPending = false,
Nenue@40 343 isNew = true,
Nenue@40 344 }
Nenue@40 345
Nenue@40 346
Nenue@40 347 db.TasksByID[taskID] = info
Nenue@40 348
Nenue@40 349 local pin = self:AcquirePin(taskID)
Nenue@40 350 for k,v in pairs(info) do
Nenue@40 351 pin[k] = v
Nenue@40 352 end
Nenue@40 353 pin:GetBonusObjectiveInfo(info)
Nenue@40 354 end
Nenue@40 355 end
Nenue@40 356 end
Nenue@40 357
Nenue@40 358
Nenue@40 359 end
Nenue@40 360 end
Nenue@40 361 end
Nenue@40 362
Nenue@40 363
Nenue@40 364 -- use tooltip object to extract item details
Nenue@45 365 function Module:GetRewardHeader(questID)
Nenue@40 366 local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID)
Nenue@40 367 local scanner = _G.WorldPlanTooltip
Nenue@40 368 local print = qprint
Nenue@40 369 if not itemID then
Nenue@40 370 return
Nenue@40 371 end
Nenue@49 372 qprint('GetRewardHeader', questID)
Nenue@40 373
Nenue@40 374 scanner:SetOwner(WorldPlan, "ANCHOR_NONE")
Nenue@40 375 scanner:SetItemByID(itemID)
Nenue@40 376 scanner:Show()
Nenue@40 377 local ttl1 = _G['WorldPlanTooltipTextLeft1']
Nenue@40 378 local ttl2 = _G['WorldPlanTooltipTextLeft2']
Nenue@40 379 local ttl3 = _G['WorldPlanTooltipTextLeft3']
Nenue@40 380 local ttl4 = _G['WorldPlanTooltipTextLeft4']
Nenue@40 381 --print(ttl2, ttl3, ttl4)
Nenue@40 382 if ttl2 then
Nenue@40 383 local text = ttl2:GetText()
Nenue@40 384 -- Artifact Power
Nenue@40 385 --print(text)
Nenue@40 386 if text then
Nenue@40 387 if text:match("|cFFE6CC80") then
Nenue@40 388 --print('AP token!', text)
Nenue@40 389 local power
Nenue@40 390 if ttl4 then
Nenue@40 391 local text = ttl4:GetText()
Nenue@40 392 --print('tip line 4', text)
Nenue@40 393 if text then
Nenue@40 394 power = text:gsub("%p", ""):match("%d+")
Nenue@40 395 power = tonumber(power)
Nenue@40 396 end
Nenue@40 397
Nenue@40 398 end
Nenue@40 399 return REWARD_ARTIFACT_POWER, "Interface\\ICONS\\inv_7xp_inscription_talenttome01", power, name, itemID, quality
Nenue@40 400 elseif text:match("Item Level") then
Nenue@40 401 --print('equipment!', text)
Nenue@40 402 quantity = text:match("Item Level ([%d\+]+)")
Nenue@40 403 return REWARD_GEAR, icon, quantity, name, itemID, quality
Nenue@40 404 elseif text:match("Crafting Reagent") then
Nenue@49 405 qprint('|cFFFF4400it is a reagent', text)
Nenue@40 406 return REWARD_REAGENT, icon, quantity, name, itemID, quality
Nenue@40 407 end
Nenue@40 408 end
Nenue@40 409 end
Nenue@40 410
Nenue@40 411 if ttl3 then
Nenue@40 412 local text = ttl3:GetText()
Nenue@40 413 if text and text:match("Crafting Reagent") then
Nenue@49 414 qprint('|cFFFF4400it is a reagent', text)
Nenue@40 415 return REWARD_REAGENT, icon, quantity, name, itemID, quality
Nenue@40 416 end
Nenue@40 417 end
Nenue@40 418 return 128, icon, quantity, name, itemID, quality
Nenue@40 419 end
Nenue@33 420 -- create of update quest pins for a map and its underlying zones
Nenue@45 421 function Module:UpdateWorldQuests (mapID)
Nenue@40 422
Nenue@40 423 mapID = mapID or db.currentMapID
Nenue@33 424 if not mapID then
Nenue@33 425 -- info not available yet
Nenue@33 426 return
Nenue@33 427 end
Nenue@33 428
Nenue@66 429 local scalingConstant = 1
Nenue@66 430 local style = DEFAULT_STYLE
Nenue@66 431 if self.dataLoaded then
Nenue@66 432 style = REWARD_TYPE_STYLES[self.rewardType]
Nenue@66 433 scalingConstant = db.isContinentMap and 2 or 3
Nenue@66 434 end
Nenue@66 435
Nenue@66 436 local pinScale = SCALE_FACTORS[scalingConstant]
Nenue@66 437 print(pinScale)
Nenue@66 438 self:SetScale(pinScale)
Nenue@66 439 self.Overlay:SetScale(pinScale)
Nenue@34 440
Nenue@40 441 print('|cFF00FF88'..self:GetName()..':UpdateWorldQuests()|r', 'map:', mapID, 'realMap:', db.currentMapID)
Nenue@33 442
Nenue@40 443
Nenue@40 444 self.isStale = nil
Nenue@40 445 print('|cFF00FFFFContinent:|r', BROKEN_ISLES_ID, GetMapNameByID(BROKEN_ISLES_ID))
Nenue@40 446 self.isRecursed = true
Nenue@40 447 for i = 1, MC_GetNumZones(BROKEN_ISLES_ID) do
Nenue@40 448 local submapID, name, depth = MC_GetZoneInfo(BROKEN_ISLES_ID, i)
Nenue@40 449 local taskInfo = TQ_GetQuestsForPlayerByMapID(submapID, BROKEN_ISLES_ID)
Nenue@40 450 if taskInfo then
Nenue@40 451 local zoneName = GetMapNameByID(submapID)
Nenue@40 452 print('|cFF00FFFF Zone:|r', submapID, zoneName, #taskInfo)
Nenue@40 453 db.QuestsByZone[submapID] = db.QuestsByZone[submapID] or {}
Nenue@40 454 for i, info in ipairs(taskInfo) do
Nenue@40 455 if HaveQuestData(info.questId) then
Nenue@40 456 rprint('|cFF44FF44update|r', info.questId, zoneName)
Nenue@40 457 local questID = info.questId
Nenue@40 458 local pin = self:AcquirePin(questID)
Nenue@40 459 local pin = db.QuestsByID[questID]
Nenue@40 460 if pin then
Nenue@40 461 pin.isStale = true
Nenue@40 462 if pin.isPending then
Nenue@40 463 self.isPending = true
Nenue@40 464 end
Nenue@40 465 end
Nenue@40 466 else
Nenue@40 467 rprint('|cFFFF4400no data|r', info.questId, zoneName)
Nenue@40 468 end
Nenue@33 469 end
Nenue@33 470 end
Nenue@33 471 end
Nenue@33 472
Nenue@40 473 self:GetBonusObjectives()
Nenue@40 474
Nenue@40 475 print(' hasUpdate:', self.isStale, 'isPending:', self.isPending, 'timer:', (self.OnNext and 'waiting' or ''))
Nenue@40 476 --WorldPlan.isStale = (self.isStale or WorldPlan.isStale)
Nenue@40 477 if self.isStale and self:IsVisible() then
Nenue@40 478 self:Refresh()
Nenue@40 479 end
Nick@63 480
Nenue@40 481 end
Nenue@40 482
Nenue@45 483 function Module:Report()
Nenue@40 484 for i, pin in ipairs(db.UsedPins) do
Nenue@40 485 db:print(i, pin.questID, pin.title)
Nenue@33 486 end
Nenue@33 487
Nenue@40 488 for id, pin in pairs(db.QuestsByID) do
Nenue@40 489 db:print(id, pin.worldQuestType, pin.rewardType, pin.title)
Nenue@40 490 end
Nenue@33 491 end
Nenue@33 492
Nick@60 493 function Module:Refresh()
Nenue@40 494 self.currentMapID = GetCurrentMapAreaID()
Nick@60 495 rprint('|cFF00FF88'..self:GetName()..':Refresh()|r')
Nick@60 496 print('|cFF00FF88'..self:GetName()..':Refresh()|r')
Nenue@34 497 if not self:IsVisible() then
Nenue@40 498 print(' not visible, flag for later')
Nenue@34 499 self.isStale = true
Nenue@57 500 return self:MarkAllPins()
Nenue@40 501 end
Nick@60 502 wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r')
Nenue@40 503
Nenue@66 504 scaleConstant = db.isContinentMap and 2 or 3
Nenue@40 505 for index, pin in pairs(db.QuestsByID) do
Nenue@40 506 pin.used = nil
Nenue@40 507 end
Nenue@40 508
Nick@62 509 if SpellCanTargetQuest() then
Nick@62 510 self:UpdateBlizzButtons()
Nick@62 511 else
Nick@62 512 self:UpdateAnchors(nil)
Nick@62 513 end
Nick@60 514
Nick@60 515 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
Nick@60 516 rprint('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
Nick@60 517 --local showQuestPOI = db.Config.EnablePins
Nenue@65 518 numShown = 0
Nenue@65 519 numLoaded = 0
Nick@60 520 for questID, pin in pairs(db.QuestsByID) do
Nick@60 521 local oV = pin:IsShown()
Nick@60 522 if pin.used then
Nick@60 523 pin.throttle = 1
Nick@60 524 if oV == false then
Nick@60 525 print('|cFF00FF00cleanup +|r', questID, pin.title)
Nick@60 526 end
Nick@60 527 pin:SetShown(true)
Nenue@65 528 numShown = numShown + 1
Nenue@65 529 if pin.dataLoaded then
Nenue@65 530 numLoaded = numLoaded + 1
Nenue@65 531 end
Nenue@65 532
Nick@60 533 else
Nick@60 534 if oV == true then
Nick@60 535 print('|cFFFF4400 -|r', questID, pin.title)
Nick@60 536 end
Nick@62 537 pin:HideFrames()
Nick@60 538 end
Nick@60 539 end
Nick@60 540
Nenue@65 541 if numShown > numLoaded then
Nenue@65 542 self.Status:Show()
Nenue@65 543 end
Nenue@65 544
Nenue@65 545
Nenue@40 546 self.isStale = nil
Nenue@54 547 self.sizesDirty = nil
Nenue@66 548 self.isZoomDirty = nil
Nenue@40 549 end
Nenue@40 550
Nenue@40 551 -- update visibility states of all pins
Nenue@57 552 function Module:MarkAllPins(pins)
Nenue@57 553 print(' |cFFFFFF00'..self:GetName()..':MarkAllPins()|r', pins)
Nenue@40 554 pins = pins or db.QuestsByID
Nenue@40 555 for questID, pin in pairs(pins) do
Nenue@40 556 pin.isStale = true
Nenue@40 557 rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used)
Nenue@40 558 end
Nenue@40 559 end
Nenue@40 560
Nenue@45 561 function Module:UpdateQuestButton(info, mapID)
Nenue@40 562 local questID, x, y = info.questId, info.x, info.y
Nenue@40 563 local pin = self:AcquirePin(info)
Nenue@40 564 if not pin then
Nenue@34 565 return
Nenue@34 566 end
Nenue@34 567
Nenue@33 568
Nenue@57 569 print('~ ', pin.mapID, pin.questID, pin.title)
Nenue@57 570 rprint('|cFF00FF00update|r', pin.questID, pin.title)
Nenue@40 571
Nenue@40 572 if x and y then
Nenue@66 573 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1]
Nenue@49 574 pin:SetFrameLevel(PinBaseIndex+pin:GetID())
Nenue@57 575 pin.owningFrame = WorldMapFrame
Nenue@66 576 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor)
Nenue@54 577 --tinsert(self.UsedPositions, pin)
Nenue@40 578 end
Nenue@66 579
Nenue@66 580
Nenue@66 581 if self:IsVisible() and (pin.isStale) then
Nenue@57 582 pin:Refresh()
Nenue@54 583 end
Nenue@40 584 if mapID then
Nenue@40 585 if not db.QuestsByZone[mapID] then
Nenue@40 586 db.QuestsByZone[mapID] = {}
Nenue@40 587 end
Nenue@40 588 db.QuestsByZone[mapID][questID] = pin
Nenue@33 589 end
Nenue@33 590 end
Nenue@33 591
Nenue@45 592 function Module:UpdateMap(taskInfo, mapID)
Nenue@49 593 rprint('Map', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID))
Nenue@40 594 for index, info in pairs(taskInfo) do
Nenue@40 595 self:UpdateQuestButton(info, mapID)
Nenue@40 596 end
Nenue@40 597 end
Nenue@33 598
Nick@60 599 function Module:UpdateAnchors ()
Nenue@65 600
Nenue@40 601 wipe(self.UsedPositions)
Nick@60 602 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()')
Nenue@57 603 self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize()
Nenue@40 604 self.nudgeThrescholdX = 16/self.hostWidth
Nenue@40 605 self.nudgeThrescholdY = 16/self.hostHeight
Nenue@40 606 local print = rprint
Nick@60 607 print('|cFF00FF00'..self:GetName()..':UpdateAnchors()')
Nenue@33 608 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo()
Nenue@33 609 if isMicroDungeon then
Nenue@33 610 return
Nenue@33 611 end
Nenue@65 612 -- starts as true
Nenue@65 613 isDataLoaded = true
Nick@62 614
Nenue@40 615 numPins = 0
Nenue@56 616 local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID)
Nenue@40 617 if taskInfo then
Nenue@56 618 self:UpdateMap(taskInfo, self.currentMapID)
Nenue@33 619 end
Nenue@56 620 local numZones = MC_GetNumZones(self.currentMapID)
Nenue@33 621 if numZones then
Nenue@33 622 for i = 1, numZones do
Nenue@40 623 local mapAreaID = MC_GetZoneInfo(self.currentMapID, i)
Nenue@56 624 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, self.currentMapID)
Nenue@40 625 if taskInfo then
Nenue@40 626 self:UpdateMap(taskInfo, mapAreaID)
Nenue@40 627 end
Nenue@33 628 end
Nenue@33 629 end
Nenue@33 630 end
Nenue@33 631