annotate WorldQuests.lua @ 64:876c3f0bfd0e

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