Mercurial > wow > worldplan
comparison WorldQuests.lua @ 64:876c3f0bfd0e
- script upvalues cleanup
- add quest active status to pin metadata
| author | Nick@Zahhak |
|---|---|
| date | Thu, 23 Mar 2017 05:26:51 -0400 |
| parents | 8e130c92698f |
| children | 02f1d3bce558 |
comparison
equal
deleted
inserted
replaced
| 63:8e130c92698f | 64:876c3f0bfd0e |
|---|---|
| 3 -- Created: 11/2/2016 3:40 PM | 3 -- Created: 11/2/2016 3:40 PM |
| 4 -- %file-revision% | 4 -- %file-revision% |
| 5 local _, db = ... | 5 local _, db = ... |
| 6 local Module = WorldPlanQuestsMixin | 6 local Module = WorldPlanQuestsMixin |
| 7 | 7 |
| 8 local _G = _G | |
| 8 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo | 9 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo |
| 9 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented | 10 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented |
| 10 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID | 11 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID |
| 11 local GetMapInfo = GetMapInfo | 12 local TQ_IsActive = C_TaskQuest.IsActive |
| 13 local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe | |
| 14 local GetTaskInfo, GetTasksTable, HaveQuestData = GetTaskInfo, GetTasksTable, HaveQuestData | |
| 15 local GetTime = GetTime | |
| 16 local SpellCanTargetQuest = SpellCanTargetQuest | |
| 17 local tonumber, abs = tonumber, math.abs | |
| 18 local GetQuestLogRewardInfo = GetQuestLogRewardInfo | |
| 19 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID | |
| 20 | |
| 12 local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end | 21 local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end |
| 13 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end | 22 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end |
| 14 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end | 23 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end |
| 15 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end | 24 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end |
| 16 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end | 25 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end |
| 17 local pairs = pairs | |
| 18 | 26 |
| 19 local PinBaseIndex = 1200 | 27 local PinBaseIndex = 1200 |
| 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 | 28 local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096 |
| 21 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", | 29 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", |
| 22 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } | 30 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } |
| 87 if button.questID and db.QuestsByID[button.questID] then | 95 if button.questID and db.QuestsByID[button.questID] then |
| 88 db.QuestsByID[button.questID]:SetShown(false) | 96 db.QuestsByID[button.questID]:SetShown(false) |
| 89 end | 97 end |
| 90 end | 98 end |
| 91 | 99 |
| 92 local SpellCanTargetQuest = SpellCanTargetQuest | |
| 93 function Module:UpdateBlizzButtons() | 100 function Module:UpdateBlizzButtons() |
| 94 | 101 |
| 95 local func = SpellCanTargetQuest() and InternalShowButton or InternalHideButton | 102 local func = SpellCanTargetQuest() and InternalShowButton or InternalHideButton |
| 96 for i = 1, NUM_WORLDMAP_TASK_POIS do | 103 for i = 1, NUM_WORLDMAP_TASK_POIS do |
| 97 local button = _G['WorldMapFrameTaskPOI'..i] | 104 local button = _G['WorldMapFrameTaskPOI'..i] |
| 248 if (not pin.dataLoaded) then | 255 if (not pin.dataLoaded) then |
| 249 pin:GetData() | 256 pin:GetData() |
| 250 WorldPlan.dataFlush = true | 257 WorldPlan.dataFlush = true |
| 251 end | 258 end |
| 252 | 259 |
| 260 pin.isActive = TQ_IsActive(questID) | |
| 261 | |
| 253 pin:CheckFilterRules() | 262 pin:CheckFilterRules() |
| 254 pin.isStale = true | 263 pin.isStale = true |
| 255 rprint(pin:GetID(), pin.filtered, pin.used) | 264 rprint(pin:GetID(), pin.filtered, pin.used) |
| 256 | 265 |
| 257 return pin | 266 return pin |
| 268 print('-', i, zone[i]) | 277 print('-', i, zone[i]) |
| 269 zone[id] = nil | 278 zone[id] = nil |
| 270 end | 279 end |
| 271 db.TasksByID[id] = nil | 280 db.TasksByID[id] = nil |
| 272 end | 281 end |
| 282 pin.isActive = nil | |
| 283 pin.dataLoaded = nil | |
| 273 pin:HideFrames() | 284 pin:HideFrames() |
| 274 tinsert(db.FreePins, pin) | 285 tinsert(db.FreePins, pin) |
| 275 | 286 |
| 276 WorldPlan.dataFlush = true | 287 WorldPlan.dataFlush = true |
| 277 print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title) | 288 print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title) |
| 278 end | 289 end |
| 290 | |
| 279 | 291 |
| 280 function Module:GetBonusObjectives() | 292 function Module:GetBonusObjectives() |
| 281 | 293 |
| 282 | 294 |
| 283 local tasksTable = GetTasksTable() | 295 local tasksTable = GetTasksTable() |
| 317 | 329 |
| 318 | 330 |
| 319 end | 331 end |
| 320 end | 332 end |
| 321 end | 333 end |
| 322 | |
| 323 | |
| 324 | 334 |
| 325 | 335 |
| 326 -- use tooltip object to extract item details | 336 -- use tooltip object to extract item details |
| 327 function Module:GetRewardHeader(questID) | 337 function Module:GetRewardHeader(questID) |
| 328 local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID) | 338 local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID) |
| 377 return REWARD_REAGENT, icon, quantity, name, itemID, quality | 387 return REWARD_REAGENT, icon, quantity, name, itemID, quality |
| 378 end | 388 end |
| 379 end | 389 end |
| 380 return 128, icon, quantity, name, itemID, quality | 390 return 128, icon, quantity, name, itemID, quality |
| 381 end | 391 end |
| 382 | |
| 383 local GetCurrentMapAreaID, GetMapNameByID= GetCurrentMapAreaID, GetMapNameByID | |
| 384 local wipe, pairs = wipe, pairs | |
| 385 -- create of update quest pins for a map and its underlying zones | 392 -- create of update quest pins for a map and its underlying zones |
| 386 function Module:UpdateWorldQuests (mapID) | 393 function Module:UpdateWorldQuests (mapID) |
| 387 | 394 |
| 388 mapID = mapID or db.currentMapID | 395 mapID = mapID or db.currentMapID |
| 389 if not mapID then | 396 if not mapID then |
| 496 pin.isStale = true | 503 pin.isStale = true |
| 497 rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used) | 504 rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used) |
| 498 end | 505 end |
| 499 end | 506 end |
| 500 | 507 |
| 501 local abs = math.abs | |
| 502 function Module:UpdateQuestButton(info, mapID) | 508 function Module:UpdateQuestButton(info, mapID) |
| 503 local questID, x, y = info.questId, info.x, info.y | 509 local questID, x, y = info.questId, info.x, info.y |
| 504 local pin = self:AcquirePin(info) | 510 local pin = self:AcquirePin(info) |
| 505 if not pin then | 511 if not pin then |
| 506 return | 512 return |
