Mercurial > wow > worldplan
comparison WorldQuests.lua @ 72:6db0b9696936
do bounty criteria checking in the QuestButtonUpdate segment
| author | Nenue |
|---|---|
| date | Fri, 07 Apr 2017 01:07:48 -0400 |
| parents | d6c0bed32c51 |
| children | 25f7dbc20a72 |
comparison
equal
deleted
inserted
replaced
| 71:d6c0bed32c51 | 72:6db0b9696936 |
|---|---|
| 1 -- WorldPlan | 1 -- WorldPlan |
| 2 -- WorldQuests.lua | 2 -- WorldQuests.lua |
| 3 -- Created: 11/2/2016 3:40 PM | 3 -- Created: 11/2/2016 3:40 PM |
| 4 -- %file-revision% | 4 -- %file-revision% |
| 5 | |
| 6 local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end | |
| 7 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end | |
| 8 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end | |
| 9 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | |
| 10 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end | |
| 5 local _, db = ... | 11 local _, db = ... |
| 6 local Module = WorldPlanQuestsMixin | 12 local Module = WorldPlanQuestsMixin |
| 7 | 13 |
| 8 local _G = _G | 14 local _G = _G |
| 15 local type, tostring, tonumber, pairs, ipairs = type, tostring, tonumber, pairs, ipairs | |
| 9 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo | 16 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo |
| 10 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented | 17 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented |
| 11 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID | 18 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID |
| 12 local TQ_IsActive = C_TaskQuest.IsActive | 19 local TQ_IsActive = C_TaskQuest.IsActive |
| 13 local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe | 20 local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe |
| 15 local GetTime = GetTime | 22 local GetTime = GetTime |
| 16 local SpellCanTargetQuest, IsQuestIDValidSpellTarget = SpellCanTargetQuest, IsQuestIDValidSpellTarget | 23 local SpellCanTargetQuest, IsQuestIDValidSpellTarget = SpellCanTargetQuest, IsQuestIDValidSpellTarget |
| 17 local tonumber, abs = tonumber, math.abs | 24 local tonumber, abs = tonumber, math.abs |
| 18 local GetQuestLogRewardInfo = GetQuestLogRewardInfo | 25 local GetQuestLogRewardInfo = GetQuestLogRewardInfo |
| 19 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID | 26 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID |
| 20 | 27 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete |
| 21 | 28 local IsQuestCriteriaForBounty = IsQuestCriteriaForBounty |
| 22 local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end | |
| 23 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end | |
| 24 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end | |
| 25 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | |
| 26 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end | |
| 27 | 29 |
| 28 local ToggleButton = {} | 30 local ToggleButton = {} |
| 29 local callbacks = {} | 31 local callbacks = {} |
| 30 local PinBaseIndex = 1200 | 32 local PinBaseIndex = 1200 |
| 31 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 | 33 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 |
| 35 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD | 37 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD |
| 36 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER | 38 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER |
| 37 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT | 39 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT |
| 38 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES | 40 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES |
| 39 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS | 41 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS |
| 40 local SCALE_FACTORS = { | 42 local SCALE_FACTORS = { 0.25, 0.7, 1 } |
| 41 0.25, 0.7, 1 | 43 |
| 42 } | 44 local BountyBoard = WorldMapFrame.UIElementsFrame.BountyBoard |
| 43 | 45 local ActionButton = WorldMapFrame.UIElementsFrame.ActionButton |
| 46 | |
| 47 local layoutDirty = true | |
| 48 local bountiesDirty = true | |
| 44 local currentScale = WorldMapDetailFrame:GetScale() | 49 local currentScale = WorldMapDetailFrame:GetScale() |
| 45 local canTargetQuests | 50 local canTargetQuests |
| 46 local numShown = 0 | 51 local numShown = 0 |
| 47 local numLoaded = 0 | 52 local numLoaded = 0 |
| 48 local isDataLoaded = true | 53 local isDataLoaded = true |
| 64 if self.filtersDirty or self.isStale then | 69 if self.filtersDirty or self.isStale then |
| 65 self:Refresh() | 70 self:Refresh() |
| 66 end | 71 end |
| 67 if #db.UpdatedPins >= 1 then | 72 if #db.UpdatedPins >= 1 then |
| 68 print('|cFF00FF88pending updates', #db.UpdatedPins) | 73 print('|cFF00FF88pending updates', #db.UpdatedPins) |
| 69 self:UpdateQueuedPins() | 74 self:RefreshIfQueued() |
| 70 end | 75 end |
| 71 | 76 |
| 72 end | 77 end |
| 73 | 78 |
| 74 | 79 |
| 119 | 124 |
| 120 self:SetAllPoints(WorldMapPOIFrame) | 125 self:SetAllPoints(WorldMapPOIFrame) |
| 121 for k,v in pairs( ToggleButton) do | 126 for k,v in pairs( ToggleButton) do |
| 122 self.Toggle:SetScript(k,v) | 127 self.Toggle:SetScript(k,v) |
| 123 end | 128 end |
| 129 | |
| 130 self:UpdateBounties('SETUP') | |
| 131 | |
| 124 self:Show() | 132 self:Show() |
| 125 end | 133 end |
| 126 callbacks.ClickWorldMapActionButton = function(WorldQuests) | 134 callbacks.ClickWorldMapActionButton = function(WorldQuests) |
| 127 WorldQuests:GetUsedPOIs() | 135 WorldQuests:GetUsedPOIs() |
| 128 end | 136 end |
| 133 WorldQuests:RefreshIfChanged() | 141 WorldQuests:RefreshIfChanged() |
| 134 end | 142 end |
| 135 callbacks.WorldMapScrollFrame_ReanchorQuestPOIs = function (WorldQuests) | 143 callbacks.WorldMapScrollFrame_ReanchorQuestPOIs = function (WorldQuests) |
| 136 WorldQuests:RefreshIfChanged() | 144 WorldQuests:RefreshIfChanged() |
| 137 end | 145 end |
| 138 callbacks[WorldMapFrame.UIElementsFrame.BountyBoard] = { | 146 |
| 139 SetSelectedBountyIndex = function(WorldQuests) | 147 callbacks[BountyBoard] = {} |
| 140 WorldQuests:UpdateBountyInfo() | 148 callbacks[BountyBoard].SetSelectedBountyIndex = function(WorldQuests) |
| 141 WorldQuests:Refresh(true) | 149 WorldQuests:UpdateBounties('BOUNTY_SELECTED') |
| 142 end | 150 WorldQuests:RefreshIfChanged() |
| 143 } | 151 end |
| 144 callbacks[WorldMapFrame.UIElementsFrame.ActionButton] = { | 152 |
| 145 UpdateCastingState = function(WorldQuests) | 153 callbacks[ActionButton] = {} |
| 146 WorldQuests:Refresh(true) | 154 callbacks[ActionButton].UpdateCastingState = function(WorldQuests) |
| 147 end | 155 WorldQuests:Refresh(true) |
| 148 } | |
| 149 | |
| 150 | |
| 151 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted | |
| 152 function Module:UpdateBountyInfo() | |
| 153 print('|cFF00FF88BountyInfo()|r') | |
| 154 wipe(db.BountyInfo) | |
| 155 db.selectedBounty = nil | |
| 156 | |
| 157 local selectedBounty = WorldMapFrame.UIElementsFrame.BountyBoard:GetSelectedBountyIndex() | |
| 158 local bounties, numBounties = GetQuestBountyInfoForMapID(db.currentMapID) | |
| 159 | |
| 160 for index, data in ipairs(bounties) do | |
| 161 if data.factionID then | |
| 162 data.title = GetQuestLogTitle(GetQuestLogIndexByID(data.questID)) | |
| 163 data.complete = IsQuestFlaggedCompleted(data.questID) | |
| 164 if not data.complete then | |
| 165 db.BountyInfo[data.factionID] = data | |
| 166 print('bounty', data.factionID, data.title, data.complete) | |
| 167 if index == selectedBounty then | |
| 168 db.selectedBounty = data | |
| 169 end | |
| 170 end | |
| 171 | |
| 172 end | |
| 173 end | |
| 174 | |
| 175 for questID, pin in pairs(db.QuestsByID) do | |
| 176 local doUpdate | |
| 177 if pin.factionID then | |
| 178 if db.BountyInfo[pin.factionID] then | |
| 179 print(pin.questID, pin.factionID, db.BountyInfo[pin.factionID], pin.isCriteria) | |
| 180 pin.isCriteria = true | |
| 181 doUpdate = true | |
| 182 else | |
| 183 doUpdate = true | |
| 184 pin.isCriteria = nil | |
| 185 end | |
| 186 | |
| 187 end | |
| 188 | |
| 189 | |
| 190 if doUpdate then | |
| 191 if pin:IsVisible() then | |
| 192 pin:Refresh() | |
| 193 else | |
| 194 pin.isStale = true | |
| 195 end | |
| 196 end | |
| 197 end | |
| 198 db.BountyUpdate = nil | |
| 199 end | 156 end |
| 200 | 157 |
| 201 function Module:OnConfigUpdate() | 158 function Module:OnConfigUpdate() |
| 202 print('|cFFFFFF00OnConfigUpdate()|r') | 159 print('|cFFFFFF00OnConfigUpdate()|r') |
| 203 if db.Config.FadeWhileGrouped then | 160 if db.Config.FadeWhileGrouped then |
| 267 self:RegisterEvent('SKILL_LINES_CHANGED') | 224 self:RegisterEvent('SKILL_LINES_CHANGED') |
| 268 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') | 225 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') |
| 269 self:RegisterEvent('ARTIFACT_UPDATE') | 226 self:RegisterEvent('ARTIFACT_UPDATE') |
| 270 end | 227 end |
| 271 | 228 |
| 272 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) | 229 local artifactKnowledgeMultiplier |
| 273 | |
| 274 print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) | |
| 275 | |
| 276 if db.BountyUpdate then | |
| 277 self:UpdateBountyInfo() | |
| 278 end | |
| 279 if isNewMap then | |
| 280 print('|cFF00FF88refreshing for changed map') | |
| 281 if isMapOpen then | |
| 282 self:Refresh(true) | |
| 283 else | |
| 284 self.isStale = true | |
| 285 end | |
| 286 end | |
| 287 | |
| 288 end | |
| 289 local superTrackedQuestID | 230 local superTrackedQuestID |
| 290 function Module:OnEvent (event, ...) | 231 function Module:OnEvent (event, ...) |
| 291 | 232 |
| 292 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) | 233 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) |
| 293 if (event == 'QUEST_LOG_UPDATE') then | 234 if (event == 'QUEST_LOG_UPDATE') then |
| 294 if self:IsVisible() then | 235 if self:IsVisible() then |
| 295 self:Refresh() | 236 self:Refresh() |
| 296 else | 237 else |
| 297 self.isStale = true | 238 self.isStale = true |
| 298 end | 239 end |
| 240 | |
| 299 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale) | 241 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale) |
| 300 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then | 242 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then |
| 301 local questID = ... | 243 local questID = ... |
| 302 if questID and db.QuestsByID[questID] then | 244 if questID and db.QuestsByID[questID] then |
| 303 self:ReleasePin(db.QuestsByID[questID]) | 245 self:ReleasePin(db.QuestsByID[questID]) |
| 304 rprint('|cFFFF4400release|r', questID) | 246 rprint('|cFFFF4400release|r', questID) |
| 305 end | 247 end |
| 306 elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then | 248 elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then |
| 307 self:Refresh() | 249 self:Refresh(event) |
| 308 elseif event == 'ARTIFACT_UPDATE' then | 250 elseif event == 'ARTIFACT_UPDATE' then |
| 309 local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier() | 251 local akCheck = C_ArtifactUI.GetArtifactKnowledgeMultiplier() |
| 310 if ak and (ak ~= self.akLevel) then | 252 if akCheck and (akCheck ~= artifactKnowledgeMultiplier) then |
| 311 print('push artifact knowledge update', self.akLevel, 'to', ak) | 253 if artifactKnowledgeMultiplier then |
| 312 self.akLevel = ak | 254 print('push artifact knowledge update', artifactKnowledgeMultiplier, 'to', akCheck) |
| 313 for index, pin in pairs( db.QuestsByID) do | 255 for index, pin in pairs( db.QuestsByID) do |
| 314 if pin.rewardType == REWARD_ARTIFACT_POWER then | 256 if pin.rewardType == REWARD_ARTIFACT_POWER then |
| 315 pin.dataLoaded = nil | 257 db.log(pin.questID .. ' ' .. tostring(pin.title) .. ' Flagged for artifact power.') |
| 258 pin.itemNumber = 0 | |
| 259 pin.dataLoaded = nil | |
| 260 end | |
| 316 end | 261 end |
| 317 end | 262 else |
| 263 | |
| 264 print('artifact knowledge multiplier is known', akCheck) | |
| 265 end | |
| 266 artifactKnowledgeMultiplier = akCheck | |
| 318 end | 267 end |
| 319 elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then | 268 elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then |
| 320 if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then | 269 if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then |
| 321 db.QuestsByID[superTrackedQuestID].isStale = true | 270 db.QuestsByID[superTrackedQuestID].isStale = true |
| 322 end | 271 end |
| 324 if newID and db.QuestsByID[newID] then | 273 if newID and db.QuestsByID[newID] then |
| 325 db.QuestsByID[newID].isStale = true | 274 db.QuestsByID[newID].isStale = true |
| 326 end | 275 end |
| 327 end | 276 end |
| 328 end | 277 end |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 local bountyInfo = {} | |
| 283 local bountyDisplayLocation, bountyLockedQuestID, selectedBountyIndex, selectedBountyQuestID | |
| 284 function Module:UpdateBounties(...) | |
| 285 print('|cFF00FF88BountyInfo()|r', ...) | |
| 286 wipe(db.BountiesByFactionID) | |
| 287 | |
| 288 bountiesDirty = nil | |
| 289 db.selectedBounty = nil | |
| 290 selectedBountyIndex = BountyBoard:GetSelectedBountyIndex() | |
| 291 bountyInfo, bountyDisplayLocation, bountyLockedQuestID = GetQuestBountyInfoForMapID(db.currentMapID, bountyInfo) | |
| 292 local numBounties = 0 | |
| 293 for index, data in ipairs(bountyInfo) do | |
| 294 if data.factionID then | |
| 295 numBounties = numBounties + 1 | |
| 296 data.index = index | |
| 297 data.complete = IsQuestComplete(data.questID) | |
| 298 if not data.complete then | |
| 299 db.BountiesByFactionID[data.factionID] = data | |
| 300 if index == selectedBountyIndex then | |
| 301 db.selectedBounty = data | |
| 302 selectedBountyQuestID = data.questID | |
| 303 end | |
| 304 print(' ', index, data.factionID, GetQuestLogTitle(GetQuestLogIndexByID(data.questID)), data.complete, (index == selectedBountyIndex) and 'SELECTED' or '') | |
| 305 end | |
| 306 end | |
| 307 end | |
| 308 | |
| 309 local numUpdated = 0 | |
| 310 local numHidden = 0 | |
| 311 for questID, pin in pairs(db.QuestsByID) do | |
| 312 end | |
| 313 --print(numUpdated, 'changes from Bounty Board ('..tostring(numHidden)..' hidden)') | |
| 314 end | |
| 315 | |
| 316 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) | |
| 317 if isNewMap then | |
| 318 print('|cFF00FF88'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) | |
| 319 if isMapOpen then | |
| 320 self:Refresh(true) | |
| 321 else | |
| 322 self.isStale = true | |
| 323 end | |
| 324 else | |
| 325 | |
| 326 rprint('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) | |
| 327 end | |
| 328 end | |
| 329 | |
| 329 | 330 |
| 330 local totalPins = 0 | 331 local totalPins = 0 |
| 331 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation | 332 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation |
| 332 function Module:AcquirePin (info) | 333 function Module:AcquirePin (info) |
| 333 local questID = info.questId | 334 local questID = info.questId |
| 414 | 415 |
| 415 WorldPlan.dataFlush = true | 416 WorldPlan.dataFlush = true |
| 416 print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title) | 417 print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title) |
| 417 end | 418 end |
| 418 | 419 |
| 419 | 420 -- re-anchors and scales pins that have had either of these changed due to data loading delays |
| 420 function Module:GetBonusObjectives() | 421 function Module:RefreshIfQueued() |
| 421 | 422 print('|cFF00FF88RefreshIfQueued()') |
| 422 | |
| 423 local tasksTable = GetTasksTable() | |
| 424 if tasksTable ~= nil then | |
| 425 print('|cFF00FF88'..self:GetName()..':BonusObjectives()|r ') | |
| 426 self.numTasks = #tasksTable | |
| 427 for i, taskID in ipairs(tasksTable) do | |
| 428 if not QuestUtils_IsQuestWorldQuest(taskID) then | |
| 429 local info = db.TasksByID[taskID] | |
| 430 if not info then | |
| 431 local isInArea, isOnMap, numObjectives, taskName, displayAsObjective = GetTaskInfo(taskID) | |
| 432 if isOnMap then | |
| 433 print(' * '..i, taskID, GetTaskInfo(taskID)) | |
| 434 info = { | |
| 435 questID = taskID, | |
| 436 numObjectives = numObjectives, | |
| 437 title = taskName, | |
| 438 isInArea = isInArea, | |
| 439 isOnMap = isOnMap, | |
| 440 displayAsObjective = displayAsObjective, | |
| 441 worldQuest = false, | |
| 442 isPending = false, | |
| 443 isNew = true, | |
| 444 } | |
| 445 | |
| 446 | |
| 447 db.TasksByID[taskID] = info | |
| 448 | |
| 449 local pin = self:AcquirePin(taskID) | |
| 450 for k,v in pairs(info) do | |
| 451 pin[k] = v | |
| 452 end | |
| 453 pin:GetBonusObjectiveInfo(info) | |
| 454 end | |
| 455 end | |
| 456 end | |
| 457 | |
| 458 | |
| 459 end | |
| 460 end | |
| 461 end | |
| 462 | |
| 463 | |
| 464 -- use tooltip object to extract item details | |
| 465 function Module:GetRewardHeader(questID) | |
| 466 local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID) | |
| 467 local scanner = _G.WorldPlanTooltip | |
| 468 local print = qprint | |
| 469 if not itemID then | |
| 470 return | |
| 471 end | |
| 472 qprint('GetRewardHeader', questID) | |
| 473 | |
| 474 scanner:SetOwner(WorldPlan, "ANCHOR_NONE") | |
| 475 scanner:SetItemByID(itemID) | |
| 476 scanner:Show() | |
| 477 local ttl1 = _G['WorldPlanTooltipTextLeft1'] | |
| 478 local ttl2 = _G['WorldPlanTooltipTextLeft2'] | |
| 479 local ttl3 = _G['WorldPlanTooltipTextLeft3'] | |
| 480 local ttl4 = _G['WorldPlanTooltipTextLeft4'] | |
| 481 --print(ttl2, ttl3, ttl4) | |
| 482 if ttl2 then | |
| 483 local text = ttl2:GetText() | |
| 484 -- Artifact Power | |
| 485 --print(text) | |
| 486 if text then | |
| 487 if text:match("|cFFE6CC80") then | |
| 488 --print('AP token!', text) | |
| 489 local power | |
| 490 if ttl4 then | |
| 491 local text = ttl4:GetText() | |
| 492 --print('tip line 4', text) | |
| 493 if text then | |
| 494 power = text:gsub("%p", ""):match("%d+") | |
| 495 power = tonumber(power) | |
| 496 end | |
| 497 | |
| 498 end | |
| 499 return REWARD_ARTIFACT_POWER, "Interface\\ICONS\\inv_7xp_inscription_talenttome01", power, name, itemID, quality | |
| 500 elseif text:match("Item Level") then | |
| 501 --print('equipment!', text) | |
| 502 quantity = text:match("Item Level ([%d\+]+)") | |
| 503 return REWARD_GEAR, icon, quantity, name, itemID, quality | |
| 504 elseif text:match("Crafting Reagent") then | |
| 505 qprint('|cFFFF4400it is a reagent', text) | |
| 506 return REWARD_REAGENT, icon, quantity, name, itemID, quality | |
| 507 end | |
| 508 end | |
| 509 end | |
| 510 | |
| 511 if ttl3 then | |
| 512 local text = ttl3:GetText() | |
| 513 if text and text:match("Crafting Reagent") then | |
| 514 qprint('|cFFFF4400it is a reagent', text) | |
| 515 return REWARD_REAGENT, icon, quantity, name, itemID, quality | |
| 516 end | |
| 517 end | |
| 518 return 128, icon, quantity, name, itemID, quality | |
| 519 end | |
| 520 | |
| 521 -- pins are queued by their OnUpdate and are ostensibly already visible, we just need to fix the zoom and anchor | |
| 522 function Module:UpdateQueuedPins() | |
| 523 print('|cFF00FF88UpdateQueuedPins()') | |
| 524 local pin = tremove(db.UpdatedPins) | 423 local pin = tremove(db.UpdatedPins) |
| 525 while pin do | 424 while pin do |
| 526 pin:CheckFilterRules() | 425 pin:CheckFilterRules() |
| 527 | 426 |
| 528 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] | 427 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] |
| 537 pin = tremove(db.UpdatedPins) | 436 pin = tremove(db.UpdatedPins) |
| 538 | 437 |
| 539 end | 438 end |
| 540 end | 439 end |
| 541 | 440 |
| 542 -- create of update quest pins for a map and its underlying zones | 441 |
| 543 function Module:UpdateWorldQuests (mapID) | 442 local msg = '|cFF00FF88WorldQuests:Refresh()|r|cFF00FFFF' |
| 544 | |
| 545 mapID = mapID or db.currentMapID | |
| 546 if not mapID then | |
| 547 -- info not available yet | |
| 548 return | |
| 549 end | |
| 550 | |
| 551 local scalingConstant = 1 | |
| 552 local style = DEFAULT_STYLE | |
| 553 if self.dataLoaded then | |
| 554 style = REWARD_TYPE_STYLES[self.rewardType] | |
| 555 scalingConstant = db.isContinentMap and 2 or 3 | |
| 556 end | |
| 557 | |
| 558 local pinScale = SCALE_FACTORS[scalingConstant] | |
| 559 print(pinScale) | |
| 560 self:SetScale(pinScale) | |
| 561 self.Overlay:SetScale(pinScale) | |
| 562 | |
| 563 print('|cFF00FF88'..self:GetName()..':UpdateWorldQuests()|r', 'map:', mapID, 'realMap:', db.currentMapID) | |
| 564 | |
| 565 | |
| 566 self.isStale = nil | |
| 567 print('|cFF00FFFFContinent:|r', BROKEN_ISLES_ID, GetMapNameByID(BROKEN_ISLES_ID)) | |
| 568 self.isRecursed = true | |
| 569 for i = 1, MC_GetNumZones(BROKEN_ISLES_ID) do | |
| 570 local submapID, name, depth = MC_GetZoneInfo(BROKEN_ISLES_ID, i) | |
| 571 local taskInfo = TQ_GetQuestsForPlayerByMapID(submapID, BROKEN_ISLES_ID) | |
| 572 if taskInfo then | |
| 573 local zoneName = GetMapNameByID(submapID) | |
| 574 print('|cFF00FFFF Zone:|r', submapID, zoneName, #taskInfo) | |
| 575 db.QuestsByZone[submapID] = db.QuestsByZone[submapID] or {} | |
| 576 for i, info in ipairs(taskInfo) do | |
| 577 if HaveQuestData(info.questId) then | |
| 578 rprint('|cFF44FF44update|r', info.questId, zoneName) | |
| 579 local questID = info.questId | |
| 580 local pin = self:AcquirePin(questID) | |
| 581 local pin = db.QuestsByID[questID] | |
| 582 if pin then | |
| 583 pin.isStale = true | |
| 584 if pin.isPending then | |
| 585 self.isPending = true | |
| 586 end | |
| 587 end | |
| 588 else | |
| 589 rprint('|cFFFF4400no data|r', info.questId, zoneName) | |
| 590 end | |
| 591 end | |
| 592 end | |
| 593 end | |
| 594 | |
| 595 self:GetBonusObjectives() | |
| 596 | |
| 597 print(' hasUpdate:', self.isStale, 'isPending:', self.isPending, 'timer:', (self.OnNext and 'waiting' or '')) | |
| 598 --WorldPlan.isStale = (self.isStale or WorldPlan.isStale) | |
| 599 if self.isStale and self:IsVisible() then | |
| 600 self:Refresh() | |
| 601 end | |
| 602 | |
| 603 end | |
| 604 | |
| 605 function Module:Report() | |
| 606 for i, pin in ipairs(db.UsedPins) do | |
| 607 db:print(i, pin.questID, pin.title) | |
| 608 end | |
| 609 | |
| 610 for id, pin in pairs(db.QuestsByID) do | |
| 611 db:print(id, pin.worldQuestType, pin.rewardType, pin.title) | |
| 612 end | |
| 613 end | |
| 614 | |
| 615 local bountiesInitialized | |
| 616 function Module:Refresh(...) | 443 function Module:Refresh(...) |
| 617 rprint('|cFF00FF88'..self:GetName()..':Refresh()|r', ...) | 444 |
| 618 print('|cFF00FF88'..self:GetName()..':Refresh()|r', ...) | 445 rprint(msg, ...) |
| 446 print('|cFF00FF88WorldQuests:Refresh()|r', ...) | |
| 619 if not self:IsVisible() then | 447 if not self:IsVisible() then |
| 620 print(' not visible, flag for later') | 448 print(' not visible, flag for later') |
| 621 self.isStale = true | 449 self.isStale = true |
| 622 return self:MarkAllPins() | 450 return self:MarkAllPins() |
| 623 end | 451 end |
| 624 if not db.Config.EnablePins then | 452 if not db.Config.EnablePins then |
| 625 numShown = 0 | 453 numShown = 0 |
| 626 return | 454 return |
| 627 end | 455 end |
| 628 | 456 wprint(' '..msg) |
| 629 | 457 |
| 630 wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r') | 458 layoutDirty = nil |
| 631 | |
| 632 scaleConstant = db.isContinentMap and 2 or 3 | 459 scaleConstant = db.isContinentMap and 2 or 3 |
| 460 canTargetQuests = SpellCanTargetQuest() | |
| 461 | |
| 633 for index, pin in pairs(db.QuestsByID) do | 462 for index, pin in pairs(db.QuestsByID) do |
| 634 pin.used = nil | 463 pin.used = nil |
| 635 end | 464 end |
| 636 | 465 |
| 637 canTargetQuests = SpellCanTargetQuest() | |
| 638 self:UpdateAnchors() | 466 self:UpdateAnchors() |
| 467 if bountiesDirty then | |
| 468 print(' bounties dirty, pushing that') | |
| 469 self:UpdateBounties() | |
| 470 bountiesDirty = nil | |
| 471 end | |
| 472 | |
| 639 | 473 |
| 640 -- calculate quests shown | 474 -- calculate quests shown |
| 641 numShown = 0 | 475 numShown = 0 |
| 642 numLoaded = 0 | 476 numLoaded = 0 |
| 643 for questID, pin in pairs(db.QuestsByID) do | 477 for questID, pin in pairs(db.QuestsByID) do |
| 661 pin:HideFrames() | 495 pin:HideFrames() |
| 662 end | 496 end |
| 663 end | 497 end |
| 664 | 498 |
| 665 | 499 |
| 666 self:UpdateBountyInfo() | 500 |
| 667 | 501 print(numShown, 'shown,', numLoaded, 'with data') |
| 668 print(numShown, 'shown', numLoaded, 'loaded') | |
| 669 if numShown > numLoaded then | 502 if numShown > numLoaded then |
| 670 self.Status:Show() | 503 self.Status:Show() |
| 671 end | 504 end |
| 672 | 505 |
| 673 | 506 |
| 677 end | 510 end |
| 678 | 511 |
| 679 function Module:RefreshIfChanged() | 512 function Module:RefreshIfChanged() |
| 680 local scaleCheck = WorldMapDetailFrame:GetScale() | 513 local scaleCheck = WorldMapDetailFrame:GetScale() |
| 681 if scaleCheck ~= currentScale then | 514 if scaleCheck ~= currentScale then |
| 682 print('|cFF00FF88scale changed from', currentScale, 'to', scaleCheck) | 515 print('|cFF00FF88RefreshIfChanged()|r map scale updated') |
| 683 self:Refresh() | 516 self:Refresh('WORLD_MAP_SCALE_CHANGED') |
| 684 currentScale = scaleCheck | 517 currentScale = scaleCheck |
| 685 elseif self.isStale then | 518 elseif self.isStale or layoutDirty then |
| 686 print('|cFF00FF88isStale flag was set') | 519 print('|cFF00FF88RefreshIfChanged()|r layout is dirty') |
| 687 self:Refresh() | 520 self:Refresh() |
| 688 end | 521 end |
| 689 end | 522 end |
| 690 | 523 |
| 691 -- update visibility states of all pins | 524 -- update visibility states of all pins |
| 713 pin.owningFrame = WorldMapFrame | 546 pin.owningFrame = WorldMapFrame |
| 714 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) | 547 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) |
| 715 --tinsert(self.UsedPositions, pin) | 548 --tinsert(self.UsedPositions, pin) |
| 716 end | 549 end |
| 717 | 550 |
| 551 | |
| 552 local isCriteria, isBounty | |
| 553 if pin.factionID then | |
| 554 if db.BountiesByFactionID[pin.factionID] then | |
| 555 isCriteria = true | |
| 556 end | |
| 557 if selectedBountyQuestID then | |
| 558 isBounty = IsQuestCriteriaForBounty(pin.questID, selectedBountyQuestID) and true or nil | |
| 559 end | |
| 560 end | |
| 561 | |
| 562 if (pin.isBounty ~= isBounty) or (pin.isCriteria ~= isCriteria) then | |
| 563 print(pin.isBounty, '~=', isBounty) | |
| 564 print(pin.isCriteria, '~=', isCriteria) | |
| 565 pin.isBounty = isBounty | |
| 566 pin.isCriteria = isCriteria | |
| 567 if pin:IsVisible() then | |
| 568 --print(' changed', pin.title) | |
| 569 --numUpdated = numUpdated + 1 | |
| 570 pin:Refresh('BOUNTY_UPDATE') | |
| 571 else | |
| 572 --numHidden = numHidden + 1 | |
| 573 pin.isStale = true | |
| 574 end | |
| 575 layoutDirty = true | |
| 576 end | |
| 577 | |
| 718 if self:IsVisible() and (pin.isStale) then | 578 if self:IsVisible() and (pin.isStale) then |
| 719 pin:Refresh() | 579 pin:Refresh() |
| 720 end | 580 end |
| 721 | 581 |
| 722 if mapID then | 582 if mapID then |
