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