annotate WorldQuests.lua @ 41:79e5e96e5f18 v1.0-rc10

- Clear Garrison minimap button pulse when shown
author Nenue
date Sun, 25 Dec 2016 15:17:35 -0500
parents 589c444d4837
children 77c2ffb5c7f5
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@33 6 local WorldQuests = 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@33 17
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@40 33 WorldQuests.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@40 44 function WorldQuests:OnShow()
Nenue@40 45 self:Refresh(true)
Nenue@40 46 end
Nenue@40 47
Nenue@40 48 function WorldQuests:OnUpdate(sinceLast)
Nenue@40 49 if self.filtersDirty or self.isStale then
Nenue@40 50 self:Refresh()
Nenue@40 51 end
Nenue@40 52 end
Nenue@40 53
Nenue@33 54 function WorldQuests: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@33 61
Nenue@33 62 -- refresh positions any time blizzard does so (i.e. mousewheel zoom)
Nenue@33 63 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function()
Nenue@40 64 print('|cFFFF4400WorldMapScrollFrame_ReanchorQuestPOIs')
Nenue@33 65 self:Refresh(true)
Nenue@33 66 end)
Nenue@33 67
Nenue@40 68
Nenue@33 69 -- hide the original world quest POIs
Nenue@40 70
Nenue@33 71 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function()
Nenue@40 72 print('|cFFFF4400WorldMap_UpdateQuestBonusObjectives')
Nenue@33 73 for i = 1, NUM_WORLDMAP_TASK_POIS do
Nenue@33 74 local button = _G['WorldMapFrameTaskPOI'..i]
Nenue@33 75 if button and button.worldQuest then
Nenue@33 76 button:Hide()
Nenue@33 77 end
Nenue@33 78 end
Nenue@33 79 end)
Nenue@33 80 end
Nenue@33 81 local defaults = {}
Nenue@40 82 local REWARD_UNKNOWN = 768
Nenue@33 83 function WorldQuests:OnLoad()
Nenue@40 84 print('|cFFFF4400'..self:GetName()..':OnLoad()')
Nenue@33 85
Nenue@40 86 self:SetParent(WorldMapFrame)
Nenue@33 87 WorldPlan:AddHandler(self, defaults)
Nenue@33 88
Nenue@40 89 local rgbWhite = {1, 1, 1 }
Nenue@40 90 WorldPlan:AddTypeInfo(self, REWARD_UNKNOWN, { r = 1, g = 1, b = 1})
Nenue@33 91 WorldPlan:AddTypeInfo(self, REWARD_REAGENT, { r = 0, g = 1, b = 1 })
Nenue@33 92 WorldPlan:AddTypeInfo(self, REWARD_ARTIFACT_POWER, { r = 1, g = .25, b = .5, hasNumeric = true, numberRGB = rgbWhite })
Nenue@33 93 WorldPlan:AddTypeInfo(self, REWARD_GEAR, { r = .1, g = .2, b = 1 })
Nenue@33 94 WorldPlan:AddTypeInfo(self, REWARD_CURRENCY, { r = 1, g = 1, b = 0, hasNumeric = true, numberRGB = {1,1,0}, })
Nenue@40 95 WorldPlan:AddTypeInfo(self, REWARD_CASH, { r = 1, g = 1, b = .32, pinMask = false, rewardMask = false })
Nenue@33 96
Nenue@33 97 for areaID, fileName in pairs(WORLD_QUEST_MAPS) do
Nenue@40 98 db.QuestsByZone[areaID] = {}
Nenue@33 99 end
Nenue@33 100
Nenue@41 101 -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level
Nenue@33 102 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL')
Nenue@33 103 self:RegisterEvent('SKILL_LINES_CHANGED')
Nenue@33 104
Nenue@33 105 WorldMapPOIFrame = _G.WorldMapPOIFrame
Nenue@33 106
Nenue@33 107 end
Nenue@33 108
Nenue@41 109 function WorldQuests:OnMapInfo()
Nenue@41 110 self:Refresh(true)
Nenue@41 111 end
Nenue@41 112
Nenue@33 113 function WorldQuests:OnEvent (event, ...)
Nenue@40 114
Nenue@40 115 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
Nenue@41 116 if event == 'QUEST_LOG_UPDATE' then
Nenue@33 117 local questID, added = ...
Nenue@33 118 if questID and added then
Nenue@33 119 local questPOI = self:AcquirePin(questID)
Nenue@40 120 questPOI:GetQuestInfo()
Nenue@40 121 questPOI.isStale = true
Nenue@40 122 self.isStale = true
Nenue@33 123 else
Nenue@40 124 self:Refresh(true)
Nenue@33 125 end
Nenue@33 126 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale)
Nenue@33 127 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
Nenue@33 128 local questID = ...
Nenue@40 129 if questID and db.QuestsByID[questID] then
Nenue@40 130 self:ReleasePin(db.QuestsByID[questID])
Nenue@40 131 rprint('|cFFFF4400release|r', questID)
Nenue@33 132 end
Nenue@33 133 elseif event == 'SKILL_LINES_CHANGED' then
Nenue@40 134 self:SetFilteredPins()
Nenue@33 135 end
Nenue@33 136 end
Nenue@33 137
Nenue@40 138 local totalPins = 0
Nenue@33 139 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@40 140 function WorldQuests:AcquirePin (info)
Nenue@40 141 local questID = info.questId
Nenue@40 142 if not questID then
Nenue@40 143 return nil
Nenue@40 144 end
Nenue@40 145
Nenue@40 146 if not QuestUtils_IsQuestWorldQuest(questID) then
Nenue@40 147 return nil
Nenue@40 148 end
Nenue@40 149
Nenue@40 150
Nenue@40 151 local pin = db.QuestsByID[questID]
Nenue@33 152 if not pin then
Nenue@40 153 local numFree = #db.FreePins
Nenue@33 154 if numFree >= 1 then
Nenue@40 155 pin = tremove(db.FreePins, numFree)
Nenue@33 156 --print('|cFF00FF00Re-using', pin:GetName())
Nenue@33 157 else
Nenue@40 158 totalPins = totalPins + 1
Nenue@33 159 local name = 'WorldPlanQuestMarker' .. NumPinFrames
Nenue@33 160 --print('|cFF00FF00Creating', name)
Nenue@33 161 pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin')
Nenue@33 162
Nenue@33 163 pin:SetFrameStrata('HIGH')
Nenue@33 164 pin.GetTypeInfo = function(frame, typeID)
Nenue@33 165 return self:GetTypeInfo(typeID)
Nenue@33 166 end
Nenue@40 167 pin:SetID(totalPins)
Nenue@33 168 NumPinFrames = NumPinFrames + 1
Nenue@33 169 --pin.iconBorder:SetVertexColor(0,0,0,1)
Nenue@33 170 end
Nenue@40 171 pin.questID = questID
Nenue@40 172 pin.worldQuest = true
Nenue@40 173 pin.throttle = 1
Nenue@33 174 pin.isNew = true
Nenue@33 175 pin.currentWidth = nil
Nenue@40 176 db.QuestsByID[questID] = pin
Nenue@40 177 tinsert(db.UsedPins, pin)
Nenue@40 178 end
Nenue@33 179
Nenue@40 180 if pin and info then
Nenue@40 181 pin.inProgress = info.inProgress
Nenue@40 182 pin.floor = info.floor
Nenue@40 183 pin.numObjectives = info.numObjectives or 0
Nenue@40 184 if info.x and info.y then
Nenue@40 185 pin.x = info.x or pin.x
Nenue@40 186 pin.y = info.y or pin.y
Nenue@40 187 rprint('|cFFFF4400coords|r', info.x, info.y)
Nenue@40 188 end
Nenue@40 189 end
Nenue@33 190
Nenue@40 191 pin:GetData()
Nenue@40 192 C_TaskQuest.RequestPreloadRewardData(info.questId)
Nenue@40 193 return pin
Nenue@33 194 end
Nenue@33 195
Nenue@33 196 -- remove from index and add it to the recycling heap
Nenue@33 197 function WorldQuests:ReleasePin (pin)
Nenue@33 198
Nenue@40 199 local id = pin.questID
Nenue@33 200 if id then
Nenue@40 201 db.QuestsByID[id] = nil
Nenue@40 202
Nenue@40 203 for i, zone in pairs(db.QuestsByZone) do
Nenue@33 204 print('-', i, zone[i])
Nenue@33 205 zone[id] = nil
Nenue@33 206 end
Nenue@40 207 db.TasksByID[id] = nil
Nenue@33 208 end
Nenue@40 209 pin:SetShown(false)
Nenue@33 210 pin:ClearAllPoints()
Nenue@40 211 tinsert(db.FreePins, pin)
Nenue@40 212
Nenue@40 213 print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title)
Nenue@33 214 end
Nenue@33 215
Nenue@40 216 function WorldQuests:GetBonusObjectives()
Nenue@40 217
Nenue@40 218
Nenue@40 219 local tasksTable = GetTasksTable()
Nenue@40 220 if tasksTable ~= nil then
Nenue@40 221 print('|cFF00FF88'..self:GetName()..':BonusObjectives()|r ')
Nenue@40 222 self.numTasks = #tasksTable
Nenue@40 223 for i, taskID in ipairs(tasksTable) do
Nenue@40 224 if not QuestUtils_IsQuestWorldQuest(taskID) then
Nenue@40 225 local info = db.TasksByID[taskID]
Nenue@40 226 if not info then
Nenue@40 227 local isInArea, isOnMap, numObjectives, taskName, displayAsObjective = GetTaskInfo(taskID)
Nenue@40 228 if isOnMap then
Nenue@40 229 print(' * '..i, taskID, GetTaskInfo(taskID))
Nenue@40 230 info = {
Nenue@40 231 questID = taskID,
Nenue@40 232 numObjectives = numObjectives,
Nenue@40 233 title = taskName,
Nenue@40 234 isInArea = isInArea,
Nenue@40 235 isOnMap = isOnMap,
Nenue@40 236 displayAsObjective = displayAsObjective,
Nenue@40 237 worldQuest = false,
Nenue@40 238 isPending = false,
Nenue@40 239 isNew = true,
Nenue@40 240 }
Nenue@40 241
Nenue@40 242
Nenue@40 243 db.TasksByID[taskID] = info
Nenue@40 244
Nenue@40 245 local pin = self:AcquirePin(taskID)
Nenue@40 246 for k,v in pairs(info) do
Nenue@40 247 pin[k] = v
Nenue@40 248 end
Nenue@40 249 pin:GetBonusObjectiveInfo(info)
Nenue@40 250 end
Nenue@40 251 end
Nenue@40 252 end
Nenue@40 253
Nenue@40 254
Nenue@40 255 end
Nenue@40 256 end
Nenue@40 257 end
Nenue@40 258
Nenue@40 259
Nenue@40 260
Nenue@40 261
Nenue@40 262 -- use tooltip object to extract item details
Nenue@40 263 function WorldQuests:GetRewardHeader(questID)
Nenue@40 264 local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID)
Nenue@40 265 local scanner = _G.WorldPlanTooltip
Nenue@40 266 local print = qprint
Nenue@40 267 if not itemID then
Nenue@40 268 return
Nenue@40 269 end
Nenue@40 270 --print('GetRewardHeader', questID)
Nenue@40 271
Nenue@40 272 scanner:SetOwner(WorldPlan, "ANCHOR_NONE")
Nenue@40 273 scanner:SetItemByID(itemID)
Nenue@40 274 scanner:Show()
Nenue@40 275 local ttl1 = _G['WorldPlanTooltipTextLeft1']
Nenue@40 276 local ttl2 = _G['WorldPlanTooltipTextLeft2']
Nenue@40 277 local ttl3 = _G['WorldPlanTooltipTextLeft3']
Nenue@40 278 local ttl4 = _G['WorldPlanTooltipTextLeft4']
Nenue@40 279 --print(ttl2, ttl3, ttl4)
Nenue@40 280 if ttl2 then
Nenue@40 281 local text = ttl2:GetText()
Nenue@40 282 -- Artifact Power
Nenue@40 283 --print(text)
Nenue@40 284 if text then
Nenue@40 285 if text:match("|cFFE6CC80") then
Nenue@40 286 --print('AP token!', text)
Nenue@40 287 local power
Nenue@40 288 if ttl4 then
Nenue@40 289 local text = ttl4:GetText()
Nenue@40 290 --print('tip line 4', text)
Nenue@40 291 if text then
Nenue@40 292 power = text:gsub("%p", ""):match("%d+")
Nenue@40 293 power = tonumber(power)
Nenue@40 294 end
Nenue@40 295
Nenue@40 296 end
Nenue@40 297 return REWARD_ARTIFACT_POWER, "Interface\\ICONS\\inv_7xp_inscription_talenttome01", power, name, itemID, quality
Nenue@40 298 elseif text:match("Item Level") then
Nenue@40 299 --print('equipment!', text)
Nenue@40 300 quantity = text:match("Item Level ([%d\+]+)")
Nenue@40 301 return REWARD_GEAR, icon, quantity, name, itemID, quality
Nenue@40 302 elseif text:match("Crafting Reagent") then
Nenue@40 303 --print('|cFFFF4400it is a reagent', text)
Nenue@40 304 return REWARD_REAGENT, icon, quantity, name, itemID, quality
Nenue@40 305 end
Nenue@40 306 end
Nenue@40 307 end
Nenue@40 308
Nenue@40 309 if ttl3 then
Nenue@40 310 local text = ttl3:GetText()
Nenue@40 311 if text and text:match("Crafting Reagent") then
Nenue@40 312 --print('|cFFFF4400it is a reagent', text)
Nenue@40 313 return REWARD_REAGENT, icon, quantity, name, itemID, quality
Nenue@40 314 end
Nenue@40 315 end
Nenue@40 316 return 128, icon, quantity, name, itemID, quality
Nenue@40 317 end
Nenue@40 318
Nenue@40 319 local GetCurrentMapAreaID, GetMapNameByID= GetCurrentMapAreaID, GetMapNameByID
Nenue@40 320 local wipe, pairs = wipe, pairs
Nenue@33 321 -- create of update quest pins for a map and its underlying zones
Nenue@40 322 function WorldQuests:UpdateWorldQuests (mapID)
Nenue@40 323
Nenue@40 324 mapID = mapID or db.currentMapID
Nenue@33 325 if not mapID then
Nenue@33 326 -- info not available yet
Nenue@33 327 return
Nenue@33 328 end
Nenue@33 329
Nenue@34 330
Nenue@40 331 print('|cFF00FF88'..self:GetName()..':UpdateWorldQuests()|r', 'map:', mapID, 'realMap:', db.currentMapID)
Nenue@33 332
Nenue@40 333
Nenue@40 334 self.isStale = nil
Nenue@40 335 print('|cFF00FFFFContinent:|r', BROKEN_ISLES_ID, GetMapNameByID(BROKEN_ISLES_ID))
Nenue@40 336 self.isRecursed = true
Nenue@40 337 for i = 1, MC_GetNumZones(BROKEN_ISLES_ID) do
Nenue@40 338 local submapID, name, depth = MC_GetZoneInfo(BROKEN_ISLES_ID, i)
Nenue@40 339 local taskInfo = TQ_GetQuestsForPlayerByMapID(submapID, BROKEN_ISLES_ID)
Nenue@40 340 if taskInfo then
Nenue@40 341 local zoneName = GetMapNameByID(submapID)
Nenue@40 342 print('|cFF00FFFF Zone:|r', submapID, zoneName, #taskInfo)
Nenue@40 343 db.QuestsByZone[submapID] = db.QuestsByZone[submapID] or {}
Nenue@40 344 for i, info in ipairs(taskInfo) do
Nenue@40 345 if HaveQuestData(info.questId) then
Nenue@40 346 rprint('|cFF44FF44update|r', info.questId, zoneName)
Nenue@40 347 local questID = info.questId
Nenue@40 348 local pin = self:AcquirePin(questID)
Nenue@40 349 local pin = db.QuestsByID[questID]
Nenue@40 350 if pin then
Nenue@40 351 pin.isStale = true
Nenue@40 352 if pin.isPending then
Nenue@40 353 self.isPending = true
Nenue@40 354 end
Nenue@40 355 end
Nenue@40 356 else
Nenue@40 357 rprint('|cFFFF4400no data|r', info.questId, zoneName)
Nenue@40 358 end
Nenue@33 359 end
Nenue@33 360 end
Nenue@33 361 end
Nenue@33 362
Nenue@40 363 self:GetBonusObjectives()
Nenue@40 364
Nenue@40 365 print(' hasUpdate:', self.isStale, 'isPending:', self.isPending, 'timer:', (self.OnNext and 'waiting' or ''))
Nenue@40 366 --WorldPlan.isStale = (self.isStale or WorldPlan.isStale)
Nenue@40 367 if self.isStale and self:IsVisible() then
Nenue@40 368 self:Refresh()
Nenue@40 369 end
Nenue@40 370 end
Nenue@40 371
Nenue@40 372 function WorldQuests:Report()
Nenue@40 373 for i, pin in ipairs(db.UsedPins) do
Nenue@40 374 db:print(i, pin.questID, pin.title)
Nenue@33 375 end
Nenue@33 376
Nenue@40 377 for id, pin in pairs(db.QuestsByID) do
Nenue@40 378 db:print(id, pin.worldQuestType, pin.rewardType, pin.title)
Nenue@40 379 end
Nenue@33 380 end
Nenue@33 381
Nenue@40 382 function WorldQuests:Refresh(fromUser)
Nenue@40 383 self.currentMapID = GetCurrentMapAreaID()
Nenue@40 384 print('|cFF00FF88'..self:GetName()..':Refresh()|r', fromUser or '|cFFFFFF00internal')
Nenue@34 385 if not self:IsVisible() then
Nenue@40 386 print(' not visible, flag for later')
Nenue@34 387 self.isStale = true
Nenue@40 388 return
Nenue@40 389 end
Nenue@40 390 wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r', fromUser or '|cFFFFFF00internal')
Nenue@40 391
Nenue@40 392 for index, pin in pairs(db.QuestsByID) do
Nenue@40 393 pin.used = nil
Nenue@40 394 pin:SetShown(false)
Nenue@40 395 end
Nenue@40 396
Nenue@40 397 self:SetFilteredPins(db.QuestsByID)
Nenue@40 398 self:UpdateAnchors(nil, fromUser)
Nenue@40 399 self:Cleanup (fromUser)
Nenue@40 400 self.isStale = nil
Nenue@40 401 end
Nenue@40 402
Nenue@40 403 -- update visibility states of all pins
Nenue@40 404 function WorldQuests:SetFilteredPins(pins)
Nenue@40 405 print(' |cFFFFFF00'..self:GetName()..':SetFilteredPins()|r', pins)
Nenue@40 406 pins = pins or db.QuestsByID
Nenue@40 407 for questID, pin in pairs(pins) do
Nenue@40 408 pin.filtered = pin:IsFiltered()
Nenue@40 409 pin.isStale = true
Nenue@40 410 rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used)
Nenue@40 411 end
Nenue@40 412 end
Nenue@40 413
Nenue@40 414 local abs = math.abs
Nenue@40 415 function WorldQuests:UpdateQuestButton(info, mapID)
Nenue@40 416 local questID, x, y = info.questId, info.x, info.y
Nenue@40 417 local pin = self:AcquirePin(info)
Nenue@40 418 if not pin then
Nenue@34 419 return
Nenue@34 420 end
Nenue@34 421
Nenue@33 422
Nenue@40 423 print('~ ', pin.mapID, pin.questID, pin.title)
Nenue@40 424 rprint('|cFF00FF00update|r', x, y, pin.title)
Nenue@40 425 pin:IsShowable()
Nenue@40 426
Nenue@40 427 if x and y then
Nenue@40 428
Nenue@40 429 pin.x = x
Nenue@40 430 pin.y = y
Nenue@40 431 pin:SetFrameLevel(PinBaseIndex+numPins)
Nenue@40 432 pin:SetPoint('CENTER', self.hostFrame, 'TOPLEFT', self.hostWidth * pin.x, -self.hostHeight * pin.y)
Nenue@40 433 pin.throttle = 1
Nenue@40 434 pin:SetShown(pin.used)
Nenue@40 435 tinsert(self.UsedPositions, pin)
Nenue@40 436 end
Nenue@40 437 pin.owningFrame = self.hostFrame
Nenue@40 438 pin:SetParent(self.hostFrame)
Nenue@40 439
Nenue@40 440 if mapID then
Nenue@40 441 if not db.QuestsByZone[mapID] then
Nenue@40 442 db.QuestsByZone[mapID] = {}
Nenue@40 443 end
Nenue@40 444 db.QuestsByZone[mapID][questID] = pin
Nenue@33 445 end
Nenue@33 446 end
Nenue@33 447
Nenue@40 448 function WorldQuests:UpdateMap(taskInfo, mapID)
Nenue@40 449 print('Map', GetMapNameByID(mapID), GetMapNameByID(self.currentMapID))
Nenue@40 450 for index, info in pairs(taskInfo) do
Nenue@40 451 self:UpdateQuestButton(info, mapID)
Nenue@40 452 end
Nenue@40 453 end
Nenue@33 454
Nenue@40 455 function WorldQuests:UpdateAnchors (fromUser)
Nenue@40 456
Nenue@40 457
Nenue@40 458 wipe(self.UsedPositions)
Nenue@40 459 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()', fromUser)
Nenue@40 460 self.hostFrame = WorldMapPOIFrame
Nenue@40 461 self.hostWidth, self.hostHeight = self.hostFrame:GetSize()
Nenue@40 462 self.nudgeThrescholdX = 16/self.hostWidth
Nenue@40 463 self.nudgeThrescholdY = 16/self.hostHeight
Nenue@40 464 local print = rprint
Nenue@40 465 print('|cFF00FF00'..self:GetName()..':UpdateAnchors()', fromUser)
Nenue@33 466 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo()
Nenue@33 467 if isMicroDungeon then
Nenue@33 468 return
Nenue@33 469 end
Nenue@33 470
Nenue@40 471 numPins = 0
Nenue@40 472 local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID)
Nenue@40 473 if taskInfo then
Nenue@40 474 self:UpdateMap(taskInfo, self.currentMapID)
Nenue@33 475 end
Nenue@40 476 local numZones = MC_GetNumZones(self.currentMapID)
Nenue@33 477 if numZones then
Nenue@33 478 for i = 1, numZones do
Nenue@40 479 local mapAreaID = MC_GetZoneInfo(self.currentMapID, i)
Nenue@40 480 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, self.currentMapID)
Nenue@40 481 if taskInfo then
Nenue@40 482 self:UpdateMap(taskInfo, mapAreaID)
Nenue@40 483 end
Nenue@33 484 end
Nenue@33 485 end
Nenue@40 486 if self.filtersDirty then
Nenue@40 487 self:SetFilteredPins(db.QuestsByID)
Nenue@33 488 end
Nenue@33 489 end
Nenue@33 490
Nenue@33 491 -- shows, animates, or hides pins based on their current visibility flags
Nenue@40 492 function WorldQuests:Cleanup (fromUser)
Nenue@40 493
Nenue@35 494 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
Nenue@40 495 local print = rprint
Nenue@40 496 print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
Nenue@40 497 --local showQuestPOI = db.Config.EnablePins
Nenue@40 498 for questID, pin in pairs(db.QuestsByID) do
Nenue@40 499 local oV = pin:IsShown()
Nenue@40 500 if pin.used then
Nenue@40 501 pin:SetShown(true)
Nenue@40 502 pin.throttle = 1
Nenue@40 503 if oV == false then
Nenue@40 504 print('|cFF00FF00cleanup +|r', questID, pin.title)
Nenue@40 505 end
Nenue@40 506 else
Nenue@40 507 if oV == true then
Nenue@40 508 print('|cFFFF4400 -|r', questID, pin.title)
Nenue@40 509 end
Nenue@40 510 end
Nenue@33 511
Nenue@40 512 if pin.worldQuest and (not C_TaskQuest.IsActive(pin.questID)) then
Nenue@40 513 self:ReleasePin(pin)
Nenue@40 514 end
Nenue@40 515 pin.isStale = true
Nenue@33 516 end
Nenue@33 517 end
Nenue@33 518