Nenue@121: Nenue@121: local _, db = ... Nenue@121: local print = DEVIAN_WORKSPACE and function(...) _G.print('Map', ...) end or function() end Nenue@121: Nenue@121: Nenue@121: WorldPlanMapMixin = {} Nenue@121: local Map = WorldPlanMapMixin Nenue@121: local wmf = WorldMapFrame Nenue@121: Nenue@121: local ArgusPins = {} Nenue@121: Nenue@121: function Map:OnLoad() Nenue@121: Nenue@121: tinsert(db.modules, self) Nenue@121: --hooksecurefunc("WorldMap_SetupWorldQuestButton", function(taskPOI, ...) Nenue@121: -- self:OnSetupWorldQuestButton(taskPOI, ...) Nenue@121: --end) Nenue@121: Nenue@121: --WorldMapFrame:UnregisterAllEvents() Nenue@121: Nenue@121: Nenue@121: hooksecurefunc("WorldMap_QuantizeWorldQuestPOIs", function(...) Nenue@121: self:OnWorldMap_QuantizeWorldQuestPOIs(...) Nenue@121: end) Nenue@121: Nenue@121: hooksecurefunc("WorldMapPOIFrame_AnchorPOI", function(taskPOI, ...) Nenue@121: self:OnWorldMapPOIFrame_AnchorPOI(taskPOI, ...) Nenue@121: end) Nenue@121: Nenue@121: hooksecurefunc("WorldMapFrame_Update", function() Nenue@121: self:OnWorldMapPOIFrame_Update() Nenue@121: end) Nenue@121: end Nenue@121: Nenue@121: function Map:OnWorldMapPOIFrame_Update() Nenue@121: Nenue@121: Nenue@121: Nenue@121: local map = GetCurrentMapAreaID() Nenue@121: _G.print('WQRefresh', '|cFF88FF00WorldMapFrame_Update()|r', map) Nenue@121: if map == 1007 then Nenue@121: _G.print('WQRefresh', 'is a continent map') Nenue@121: self:Update('WorldMapFrame_Update') Nenue@121: end Nenue@121: Nenue@121: end Nenue@121: Nenue@121: function Map:OnWorldMap_QuantizeWorldQuestPOIs(pois) Nenue@121: --_G.print('WQRefresh', '|cFF88FF00WorldMap_QuantizeWorldQuestPOIs()|r') Nenue@121: for k, worldQuestPOI in pairs(pois) do Nenue@121: --print(worldQuestPOI.questID, worldQuestPOI:GetPoint(1)) Nenue@121: WorldMapPOIFrame_AnchorPOI(worldQuestPOI, worldQuestPOI.quantizedX or worldQuestPOI.x, worldQuestPOI.quantizedY or worldQuestPOI.y, WORLD_MAP_POI_FRAME_LEVEL_OFFSETS.WORLD_QUEST); Nenue@121: end Nenue@121: end Nenue@121: function Map:OnWorldMapPOIFrame_AnchorPOI(taskPOI, x, y, level) Nenue@121: --_G.print('WQRefresh','|cFF88FF00OnWorldMapPOIFrame_AnchorPOI()|r', taskPOI:GetName()) Nenue@121: taskPOI.lastAnchor = time() Nenue@121: end Nenue@121: Nenue@121: function Map:OnSetupWorldQuestButton(taskPOI, ...) Nenue@121: Nenue@121: _G.print('WQRefresh','SetupWorldQuestButton()', taskPOI.questID) Nenue@121: end Nenue@121: Nenue@121: Nenue@121: local usedPOI = {} Nenue@121: function Map:Update(source) Nenue@121: local existingPOI = db.pins.id Nenue@121: print('|cFF00FFFF' .. (source or '?'), '->Refresh()', NUM_WORLDMAP_TASK_POIS) Nenue@121: wipe(usedPOI) Nenue@121: for index = 1, 100 do Nenue@121: Nenue@121: local poi = _G["WorldMapFrameTaskPOI"..index]; Nenue@121: if poi and poi.worldQuest and poi.questID then Nenue@121: print(index, 'used by #', poi.questID) Nenue@121: existingPOI[poi.questID] = poi Nenue@121: end Nenue@121: end Nenue@121: local poiIndex = NUM_WORLDMAP_TASK_POIS Nenue@121: local quests = db.pins.current Nenue@121: for questID, info in pairs(quests) do Nenue@121: Nenue@121: local msg = 'Q #' .. questID .. ' ' .. (existingPOI[questID] and '(!)' or '-') Nenue@121: --print(questID, info.x, info.y) Nenue@121: Nenue@121: --for k,v in pairs(info) do Nenue@121: -- print(questID .. '.' .. tostring(k), '=', v) Nenue@121: --end Nenue@121: Nenue@121: --local taskPOI = existingPOI[questID] Nenue@121: --if not taskPOI or ( taskPOI.questID ~= questID) then Nenue@121: Nenue@121: Nenue@121: local taskPOI Nenue@121: if existingPOI[questID] then Nenue@121: Nenue@121: taskPOI = existingPOI[questID] Nenue@121: msg = msg .. '\n there is a POI for this quest, re-using ' .. taskPOI:GetName() Nenue@121: else Nenue@121: msg = msg .. 'no poi found... create one' Nenue@121: poiIndex = poiIndex + 1 Nenue@121: taskPOI = WorldMap_GetOrCreateTaskPOI(poiIndex); Nenue@121: Nenue@121: local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex, displayTimeLeft = GetQuestTagInfo(info.questId); Nenue@121: Nenue@121: taskPOI.name = tagName Nenue@121: Nenue@121: local selected = info.questId == GetSuperTrackedQuestID(); Nenue@121: Nenue@121: local isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(info.questId); Nenue@121: local isSpellTarget = SpellCanTargetQuest() and IsQuestIDValidSpellTarget(info.questId); Nenue@121: local isEffectivelyTracked = WorldMap_IsWorldQuestEffectivelyTracked(info.questId); Nenue@121: Nenue@121: taskPOI.worldQuest = true; Nenue@121: Nenue@121: taskPOI.questID = questID Nenue@121: taskPOI.Texture:SetDrawLayer("OVERLAY"); Nenue@121: Nenue@121: WorldMap_SetupWorldQuestButton(taskPOI, worldQuestType, rarity, isElite, tradeskillLineIndex, info.inProgress, selected, isCriteria, isSpellTarget, isEffectivelyTracked); Nenue@121: Nenue@121: C_TaskQuest.RequestPreloadRewardData(info.questId); Nenue@121: Nenue@121: end Nenue@121: Nenue@121: if taskPOI then Nenue@121: msg = msg .. "\n taskPOI established/" Nenue@121: end Nenue@121: Nenue@121: --[[ Nenue@121: taskPOI = WorldMap_TryCreatingWorldQuestPOI(info, poiIndex) Nenue@121: print(WorldMap_IsWorldQuestSuppressed(info.questId), not WorldMap_DoesWorldQuestInfoPassFilters(info)) Nenue@121: existingPOI[questID] = taskPOI Nenue@121: if not taskPOI then Nenue@121: print('|cFFFF4400unable to create for|r', questID) Nenue@121: else Nenue@121: --print(taskPOI, 'created',poiIndex) Nenue@121: end Nenue@121: --]] Nenue@121: Nenue@121: Nenue@121: Nenue@121: --else Nenue@121: Nenue@121: --print(taskPOI, 're-used') Nenue@121: --end Nenue@121: if taskPOI then Nenue@121: Nenue@121: Nenue@121: msg = msg .. '\n POS '..tostring(taskPOI:GetName())..' |cFF00FF00x/y:|r ' .. tostring(info.x) ..' '..tostring(info.y) Nenue@121: taskPOI.x = info.x; Nenue@121: taskPOI.y = info.y; Nenue@121: taskPOI.quantizedX = nil; Nenue@121: taskPOI.quantizedY = nil; Nenue@121: taskPOI.questID = info.questId; Nenue@121: taskPOI.numObjectives = info.numObjectives; Nenue@121: taskPOI:Show(); Nenue@121: Nenue@121: usedPOI[questID] = taskPOI Nenue@121: end Nenue@121: print(msg) Nenue@121: Nenue@121: end Nenue@121: Nenue@121: for questID, poi in pairs(existingPOI) do Nenue@121: if not usedPOI[questID] then Nenue@121: print('|cFFFF4400remove un-updated:', poi:GetName()) Nenue@121: poi:Hide() Nenue@121: end Nenue@121: Nenue@121: end Nenue@121: Nenue@121: Nenue@121: Nenue@121: WorldMapFrame.UIElementsFrame.ActionButton:SetHasWorldQuests(#usedPOI > 0); Nenue@121: WorldMap_QuantizeWorldQuestPOIs(usedPOI) Nenue@121: Nenue@121: _G.print('WQRefresh', time()) Nenue@121: end