annotate Map.lua @ 121:1fcc4fe645dc tip

- Removed legionfall war supplies from the list of reward currencies to display
author Nenue
date Fri, 16 Feb 2018 14:27:59 -0500
parents
children
rev   line source
Nenue@121 1
Nenue@121 2 local _, db = ...
Nenue@121 3 local print = DEVIAN_WORKSPACE and function(...) _G.print('Map', ...) end or function() end
Nenue@121 4
Nenue@121 5
Nenue@121 6 WorldPlanMapMixin = {}
Nenue@121 7 local Map = WorldPlanMapMixin
Nenue@121 8 local wmf = WorldMapFrame
Nenue@121 9
Nenue@121 10 local ArgusPins = {}
Nenue@121 11
Nenue@121 12 function Map:OnLoad()
Nenue@121 13
Nenue@121 14 tinsert(db.modules, self)
Nenue@121 15 --hooksecurefunc("WorldMap_SetupWorldQuestButton", function(taskPOI, ...)
Nenue@121 16 -- self:OnSetupWorldQuestButton(taskPOI, ...)
Nenue@121 17 --end)
Nenue@121 18
Nenue@121 19 --WorldMapFrame:UnregisterAllEvents()
Nenue@121 20
Nenue@121 21
Nenue@121 22 hooksecurefunc("WorldMap_QuantizeWorldQuestPOIs", function(...)
Nenue@121 23 self:OnWorldMap_QuantizeWorldQuestPOIs(...)
Nenue@121 24 end)
Nenue@121 25
Nenue@121 26 hooksecurefunc("WorldMapPOIFrame_AnchorPOI", function(taskPOI, ...)
Nenue@121 27 self:OnWorldMapPOIFrame_AnchorPOI(taskPOI, ...)
Nenue@121 28 end)
Nenue@121 29
Nenue@121 30 hooksecurefunc("WorldMapFrame_Update", function()
Nenue@121 31 self:OnWorldMapPOIFrame_Update()
Nenue@121 32 end)
Nenue@121 33 end
Nenue@121 34
Nenue@121 35 function Map:OnWorldMapPOIFrame_Update()
Nenue@121 36
Nenue@121 37
Nenue@121 38
Nenue@121 39 local map = GetCurrentMapAreaID()
Nenue@121 40 _G.print('WQRefresh', '|cFF88FF00WorldMapFrame_Update()|r', map)
Nenue@121 41 if map == 1007 then
Nenue@121 42 _G.print('WQRefresh', 'is a continent map')
Nenue@121 43 self:Update('WorldMapFrame_Update')
Nenue@121 44 end
Nenue@121 45
Nenue@121 46 end
Nenue@121 47
Nenue@121 48 function Map:OnWorldMap_QuantizeWorldQuestPOIs(pois)
Nenue@121 49 --_G.print('WQRefresh', '|cFF88FF00WorldMap_QuantizeWorldQuestPOIs()|r')
Nenue@121 50 for k, worldQuestPOI in pairs(pois) do
Nenue@121 51 --print(worldQuestPOI.questID, worldQuestPOI:GetPoint(1))
Nenue@121 52 WorldMapPOIFrame_AnchorPOI(worldQuestPOI, worldQuestPOI.quantizedX or worldQuestPOI.x, worldQuestPOI.quantizedY or worldQuestPOI.y, WORLD_MAP_POI_FRAME_LEVEL_OFFSETS.WORLD_QUEST);
Nenue@121 53 end
Nenue@121 54 end
Nenue@121 55 function Map:OnWorldMapPOIFrame_AnchorPOI(taskPOI, x, y, level)
Nenue@121 56 --_G.print('WQRefresh','|cFF88FF00OnWorldMapPOIFrame_AnchorPOI()|r', taskPOI:GetName())
Nenue@121 57 taskPOI.lastAnchor = time()
Nenue@121 58 end
Nenue@121 59
Nenue@121 60 function Map:OnSetupWorldQuestButton(taskPOI, ...)
Nenue@121 61
Nenue@121 62 _G.print('WQRefresh','SetupWorldQuestButton()', taskPOI.questID)
Nenue@121 63 end
Nenue@121 64
Nenue@121 65
Nenue@121 66 local usedPOI = {}
Nenue@121 67 function Map:Update(source)
Nenue@121 68 local existingPOI = db.pins.id
Nenue@121 69 print('|cFF00FFFF' .. (source or '?'), '->Refresh()', NUM_WORLDMAP_TASK_POIS)
Nenue@121 70 wipe(usedPOI)
Nenue@121 71 for index = 1, 100 do
Nenue@121 72
Nenue@121 73 local poi = _G["WorldMapFrameTaskPOI"..index];
Nenue@121 74 if poi and poi.worldQuest and poi.questID then
Nenue@121 75 print(index, 'used by #', poi.questID)
Nenue@121 76 existingPOI[poi.questID] = poi
Nenue@121 77 end
Nenue@121 78 end
Nenue@121 79 local poiIndex = NUM_WORLDMAP_TASK_POIS
Nenue@121 80 local quests = db.pins.current
Nenue@121 81 for questID, info in pairs(quests) do
Nenue@121 82
Nenue@121 83 local msg = 'Q #' .. questID .. ' ' .. (existingPOI[questID] and '(!)' or '-')
Nenue@121 84 --print(questID, info.x, info.y)
Nenue@121 85
Nenue@121 86 --for k,v in pairs(info) do
Nenue@121 87 -- print(questID .. '.' .. tostring(k), '=', v)
Nenue@121 88 --end
Nenue@121 89
Nenue@121 90 --local taskPOI = existingPOI[questID]
Nenue@121 91 --if not taskPOI or ( taskPOI.questID ~= questID) then
Nenue@121 92
Nenue@121 93
Nenue@121 94 local taskPOI
Nenue@121 95 if existingPOI[questID] then
Nenue@121 96
Nenue@121 97 taskPOI = existingPOI[questID]
Nenue@121 98 msg = msg .. '\n there is a POI for this quest, re-using ' .. taskPOI:GetName()
Nenue@121 99 else
Nenue@121 100 msg = msg .. 'no poi found... create one'
Nenue@121 101 poiIndex = poiIndex + 1
Nenue@121 102 taskPOI = WorldMap_GetOrCreateTaskPOI(poiIndex);
Nenue@121 103
Nenue@121 104 local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex, displayTimeLeft = GetQuestTagInfo(info.questId);
Nenue@121 105
Nenue@121 106 taskPOI.name = tagName
Nenue@121 107
Nenue@121 108 local selected = info.questId == GetSuperTrackedQuestID();
Nenue@121 109
Nenue@121 110 local isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(info.questId);
Nenue@121 111 local isSpellTarget = SpellCanTargetQuest() and IsQuestIDValidSpellTarget(info.questId);
Nenue@121 112 local isEffectivelyTracked = WorldMap_IsWorldQuestEffectivelyTracked(info.questId);
Nenue@121 113
Nenue@121 114 taskPOI.worldQuest = true;
Nenue@121 115
Nenue@121 116 taskPOI.questID = questID
Nenue@121 117 taskPOI.Texture:SetDrawLayer("OVERLAY");
Nenue@121 118
Nenue@121 119 WorldMap_SetupWorldQuestButton(taskPOI, worldQuestType, rarity, isElite, tradeskillLineIndex, info.inProgress, selected, isCriteria, isSpellTarget, isEffectivelyTracked);
Nenue@121 120
Nenue@121 121 C_TaskQuest.RequestPreloadRewardData(info.questId);
Nenue@121 122
Nenue@121 123 end
Nenue@121 124
Nenue@121 125 if taskPOI then
Nenue@121 126 msg = msg .. "\n taskPOI established/"
Nenue@121 127 end
Nenue@121 128
Nenue@121 129 --[[
Nenue@121 130 taskPOI = WorldMap_TryCreatingWorldQuestPOI(info, poiIndex)
Nenue@121 131 print(WorldMap_IsWorldQuestSuppressed(info.questId), not WorldMap_DoesWorldQuestInfoPassFilters(info))
Nenue@121 132 existingPOI[questID] = taskPOI
Nenue@121 133 if not taskPOI then
Nenue@121 134 print('|cFFFF4400unable to create for|r', questID)
Nenue@121 135 else
Nenue@121 136 --print(taskPOI, 'created',poiIndex)
Nenue@121 137 end
Nenue@121 138 --]]
Nenue@121 139
Nenue@121 140
Nenue@121 141
Nenue@121 142 --else
Nenue@121 143
Nenue@121 144 --print(taskPOI, 're-used')
Nenue@121 145 --end
Nenue@121 146 if taskPOI then
Nenue@121 147
Nenue@121 148
Nenue@121 149 msg = msg .. '\n POS '..tostring(taskPOI:GetName())..' |cFF00FF00x/y:|r ' .. tostring(info.x) ..' '..tostring(info.y)
Nenue@121 150 taskPOI.x = info.x;
Nenue@121 151 taskPOI.y = info.y;
Nenue@121 152 taskPOI.quantizedX = nil;
Nenue@121 153 taskPOI.quantizedY = nil;
Nenue@121 154 taskPOI.questID = info.questId;
Nenue@121 155 taskPOI.numObjectives = info.numObjectives;
Nenue@121 156 taskPOI:Show();
Nenue@121 157
Nenue@121 158 usedPOI[questID] = taskPOI
Nenue@121 159 end
Nenue@121 160 print(msg)
Nenue@121 161
Nenue@121 162 end
Nenue@121 163
Nenue@121 164 for questID, poi in pairs(existingPOI) do
Nenue@121 165 if not usedPOI[questID] then
Nenue@121 166 print('|cFFFF4400remove un-updated:', poi:GetName())
Nenue@121 167 poi:Hide()
Nenue@121 168 end
Nenue@121 169
Nenue@121 170 end
Nenue@121 171
Nenue@121 172
Nenue@121 173
Nenue@121 174 WorldMapFrame.UIElementsFrame.ActionButton:SetHasWorldQuests(#usedPOI > 0);
Nenue@121 175 WorldMap_QuantizeWorldQuestPOIs(usedPOI)
Nenue@121 176
Nenue@121 177 _G.print('WQRefresh', time())
Nenue@121 178 end