annotate WorldQuests.lua @ 63:8e130c92698f

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