annotate WorldQuests.lua @ 48:c0b88bd1e40b

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