Nenue@33: -- WorldPlan Nenue@33: -- WorldQuests.lua Nenue@33: -- Created: 11/2/2016 3:40 PM Nenue@33: -- %file-revision% Nenue@40: local _, db = ... Nenue@45: local Module = WorldPlanQuestsMixin Nenue@33: Nick@64: local _G = _G Nenue@33: local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo Nenue@33: local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented Nenue@33: local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID Nick@64: local TQ_IsActive = C_TaskQuest.IsActive Nick@64: local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe Nick@64: local GetTaskInfo, GetTasksTable, HaveQuestData = GetTaskInfo, GetTasksTable, HaveQuestData Nick@64: local GetTime = GetTime Nick@64: local SpellCanTargetQuest = SpellCanTargetQuest Nick@64: local tonumber, abs = tonumber, math.abs Nick@64: local GetQuestLogRewardInfo = GetQuestLogRewardInfo Nick@64: local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID Nick@64: Nenue@40: local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end Nenue@40: local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end Nenue@33: local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end Nenue@33: local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end Nenue@35: local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end Nenue@33: Nenue@40: local PinBaseIndex = 1200 Nenue@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 Nenue@33: local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", Nenue@33: [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } Nenue@33: Nenue@33: local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD Nenue@33: local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER Nenue@33: local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT Nenue@33: local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES Nenue@33: local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS Nenue@33: Nenue@33: Nenue@33: local numPins = 0 Nenue@33: local NumPinFrames = 1 Nenue@45: Module.TasksByID = {} Nenue@33: Nenue@33: --%debug% Nenue@33: local SetTimedCallbackForAllPins = function(seconds, callback) Nenue@33: C_Timer.After(seconds, function() Nenue@33: for id, pin in pairs(WorldPlanQuests.QuestsByID) do Nenue@33: callback(pin) Nenue@33: end Nenue@33: end) Nenue@33: end Nenue@33: Nenue@45: function Module:OnUpdate(sinceLast) Nenue@40: if self.filtersDirty or self.isStale then Nenue@40: self:Refresh() Nenue@40: end Nenue@40: end Nenue@40: Nenue@52: local InternalDoRefresh = function (self) Nick@60: WorldPlanQuests:Refresh() Nenue@52: end Nenue@52: Nenue@45: function Module:Setup() Nenue@40: print('|cFFFF4400'..self:GetName()..':Setup()') Nenue@33: Nenue@33: for mapID, mapName in pairs(WORLD_QUEST_MAPS) do Nenue@40: db.QuestsByZone[mapID] = {} Nenue@33: end Nenue@33: Nenue@45: hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end) Nenue@56: hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", InternalDoRefresh) Nenue@45: hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end) Nenue@56: hooksecurefunc("WorldMapFrame_UpdateMap", InternalDoRefresh) Nenue@52: WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(InternalDoRefresh); Nenue@52: WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(InternalDoRefresh); Nenue@45: end Nenue@33: Nenue@49: function Module:OnConfigUpdate() Nenue@49: if db.Config.FadeWhileGrouped then Nenue@49: db.PinAlpha = 0.15 Nenue@49: else Nenue@49: db.PinAlpha = 1 Nenue@49: end Nenue@49: end Nenue@49: Nenue@45: local InternalHideButton = function(button, index) Nenue@45: button:Hide() Nenue@45: if button.questID and db.QuestsByID[button.questID] then Nenue@45: if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then Nenue@45: db.QuestsByID[button.questID]:SetShown(true) Nenue@45: end Nenue@45: end Nenue@45: end Nenue@45: local InternalShowButton = function(button, index) Nenue@45: button:Show() Nenue@45: if button.questID and db.QuestsByID[button.questID] then Nenue@45: db.QuestsByID[button.questID]:SetShown(false) Nenue@45: end Nenue@45: end Nenue@33: Nick@62: function Module:UpdateBlizzButtons() Nick@62: Nenue@45: local func = SpellCanTargetQuest() and InternalShowButton or InternalHideButton Nenue@45: for i = 1, NUM_WORLDMAP_TASK_POIS do Nenue@45: local button = _G['WorldMapFrameTaskPOI'..i] Nenue@45: if button and button.worldQuest then Nenue@45: func(button, i) Nenue@45: end Nenue@45: end Nenue@45: end Nenue@40: Nick@62: function Module:OnUpdateQuestBonusObjectives() Nick@62: print('|cFFFF4400WorldMap_UpdateQuestBonusObjectives') Nick@62: self:UpdateBlizzButtons() Nick@62: end Nick@62: Nenue@45: function Module:OnClickWorldMapActionButton() Nick@62: self:UpdateBlizzButtons() Nenue@45: end Nenue@40: Nenue@33: local defaults = {} Nenue@40: local REWARD_UNKNOWN = 768 Nenue@45: function Module:OnLoad() Nenue@40: print('|cFFFF4400'..self:GetName()..':OnLoad()') Nenue@33: Nenue@48: self:SetParent(WorldMapPOIFrame) Nenue@33: WorldPlan:AddHandler(self, defaults) Nenue@33: Nenue@40: local rgbWhite = {1, 1, 1 } Nenue@47: WorldPlan:AddTypeInfo(self, REWARD_UNKNOWN, { r = 0, g = 0, b = 0}) Nenue@48: WorldPlan:AddTypeInfo(self, REWARD_REAGENT, { r = 0, g = 1, b = .5 }) Nenue@33: WorldPlan:AddTypeInfo(self, REWARD_ARTIFACT_POWER, { r = 1, g = .25, b = .5, hasNumeric = true, numberRGB = rgbWhite }) Nenue@48: WorldPlan:AddTypeInfo(self, REWARD_GEAR, { r = .3, g = .7, b = 1 }) Nenue@33: WorldPlan:AddTypeInfo(self, REWARD_CURRENCY, { r = 1, g = 1, b = 0, hasNumeric = true, numberRGB = {1,1,0}, }) Nenue@40: WorldPlan:AddTypeInfo(self, REWARD_CASH, { r = 1, g = 1, b = .32, pinMask = false, rewardMask = false }) Nenue@33: Nenue@33: for areaID, fileName in pairs(WORLD_QUEST_MAPS) do Nenue@40: db.QuestsByZone[areaID] = {} Nenue@33: end Nenue@33: Nenue@41: -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level Nenue@33: self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL') Nenue@55: self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') Nenue@33: self:RegisterEvent('SKILL_LINES_CHANGED') Nick@62: self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') Nenue@33: end Nenue@33: Nenue@56: function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID) Nenue@49: print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r visible =', self:IsVisible()) Nenue@56: if self.isZoomedOut ~= isZoomedOut then Nenue@54: self.sizesDirty = true Nenue@54: end Nenue@56: Nenue@56: self.isZoomedOut = isZoomedOut Nenue@56: self.isWorldQuestMap = isBrokenIsle Nenue@56: self.currentMapID = mapAreaID Nenue@56: Nenue@43: if self:IsVisible() then Nenue@47: self:Refresh(true) Nenue@43: else Nenue@43: self.isStale = true Nenue@43: end Nenue@41: end Nenue@41: Nenue@45: function Module:OnEvent (event, ...) Nenue@40: Nenue@40: print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) Nenue@55: if (event == 'QUEST_LOG_UPDATE') or (event == 'SUPER_TRACKED_QUEST_CHANGED') then Nenue@33: local questID, added = ... Nenue@33: if questID and added then Nenue@33: local questPOI = self:AcquirePin(questID) Nenue@40: questPOI:GetQuestInfo() Nenue@40: questPOI.isStale = true Nenue@40: self.isStale = true Nenue@33: else Nick@62: self:Refresh() Nenue@33: end Nenue@33: print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale) Nenue@33: elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then Nenue@33: local questID = ... Nenue@40: if questID and db.QuestsByID[questID] then Nenue@40: self:ReleasePin(db.QuestsByID[questID]) Nenue@40: rprint('|cFFFF4400release|r', questID) Nenue@33: end Nenue@33: elseif event == 'SKILL_LINES_CHANGED' then Nick@62: self:Refresh() Nick@62: elseif event == 'CURRENT_SPELL_CAST_CHANGED' then Nick@62: Nick@62: self:Refresh() Nenue@59: elseif event == 'ARTIFACT_UPDATE' then Nenue@59: local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier() Nenue@59: if ak and (ak ~= self.akLevel) then Nick@62: print('push artifact knowledge update', self.akLevel, 'to', ak) Nenue@59: self.akLevel = ak Nick@62: for index, pin in pairs( db.QuestsByID) do Nick@62: pin.dataLoaded = nil Nick@62: end Nick@62: self:Refresh() Nenue@59: end Nenue@33: end Nenue@33: end Nenue@33: Nenue@40: local totalPins = 0 Nenue@33: local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation Nenue@45: function Module:AcquirePin (info) Nenue@40: local questID = info.questId Nenue@40: if not questID then Nenue@40: return nil Nenue@40: end Nenue@40: Nenue@40: if not QuestUtils_IsQuestWorldQuest(questID) then Nenue@40: return nil Nenue@40: end Nenue@40: Nenue@49: -- if we're grabbing a pin, the filters need to be checked Nenue@40: local pin = db.QuestsByID[questID] Nenue@33: if not pin then Nenue@40: local numFree = #db.FreePins Nenue@33: if numFree >= 1 then Nenue@40: pin = tremove(db.FreePins, numFree) Nenue@33: --print('|cFF00FF00Re-using', pin:GetName()) Nenue@33: else Nenue@40: totalPins = totalPins + 1 Nenue@33: local name = 'WorldPlanQuestMarker' .. NumPinFrames Nenue@33: --print('|cFF00FF00Creating', name) Nenue@33: pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin') Nenue@33: Nenue@33: pin:SetFrameStrata('HIGH') Nenue@33: pin.GetTypeInfo = function(frame, typeID) Nenue@33: return self:GetTypeInfo(typeID) Nenue@33: end Nenue@40: pin:SetID(totalPins) Nenue@33: NumPinFrames = NumPinFrames + 1 Nenue@33: --pin.iconBorder:SetVertexColor(0,0,0,1) Nenue@33: end Nenue@40: pin.questID = questID Nenue@40: pin.worldQuest = true Nenue@40: pin.throttle = 1 Nenue@33: pin.isNew = true Nenue@33: pin.currentWidth = nil Nenue@40: db.QuestsByID[questID] = pin Nenue@40: tinsert(db.UsedPins, pin) Nenue@40: end Nenue@33: Nenue@40: if pin and info then Nenue@40: pin.inProgress = info.inProgress Nenue@40: pin.floor = info.floor Nenue@40: pin.numObjectives = info.numObjectives or 0 Nenue@40: if info.x and info.y then Nenue@40: pin.x = info.x or pin.x Nenue@40: pin.y = info.y or pin.y Nenue@40: rprint('|cFFFF4400coords|r', info.x, info.y) Nenue@40: end Nenue@40: end Nenue@33: Nick@62: if (not pin.dataLoaded) then Nenue@49: pin:GetData() Nick@63: WorldPlan.dataFlush = true Nenue@49: end Nenue@49: Nick@64: pin.isActive = TQ_IsActive(questID) Nick@64: Nenue@57: pin:CheckFilterRules() Nenue@49: pin.isStale = true Nenue@49: rprint(pin:GetID(), pin.filtered, pin.used) Nenue@49: Nenue@40: return pin Nenue@33: end Nenue@33: Nenue@33: -- remove from index and add it to the recycling heap Nenue@45: function Module:ReleasePin (pin) Nenue@33: Nenue@40: local id = pin.questID Nenue@33: if id then Nenue@40: db.QuestsByID[id] = nil Nenue@40: Nenue@40: for i, zone in pairs(db.QuestsByZone) do Nenue@33: print('-', i, zone[i]) Nenue@33: zone[id] = nil Nenue@33: end Nenue@40: db.TasksByID[id] = nil Nenue@33: end Nick@64: pin.isActive = nil Nick@64: pin.dataLoaded = nil Nick@62: pin:HideFrames() Nenue@40: tinsert(db.FreePins, pin) Nenue@40: Nick@63: WorldPlan.dataFlush = true Nenue@40: print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title) Nenue@33: end Nenue@33: Nick@64: Nenue@45: function Module:GetBonusObjectives() Nenue@40: Nenue@40: Nenue@40: local tasksTable = GetTasksTable() Nenue@40: if tasksTable ~= nil then Nenue@40: print('|cFF00FF88'..self:GetName()..':BonusObjectives()|r ') Nenue@40: self.numTasks = #tasksTable Nenue@40: for i, taskID in ipairs(tasksTable) do Nenue@40: if not QuestUtils_IsQuestWorldQuest(taskID) then Nenue@40: local info = db.TasksByID[taskID] Nenue@40: if not info then Nenue@40: local isInArea, isOnMap, numObjectives, taskName, displayAsObjective = GetTaskInfo(taskID) Nenue@40: if isOnMap then Nenue@40: print(' * '..i, taskID, GetTaskInfo(taskID)) Nenue@40: info = { Nenue@40: questID = taskID, Nenue@40: numObjectives = numObjectives, Nenue@40: title = taskName, Nenue@40: isInArea = isInArea, Nenue@40: isOnMap = isOnMap, Nenue@40: displayAsObjective = displayAsObjective, Nenue@40: worldQuest = false, Nenue@40: isPending = false, Nenue@40: isNew = true, Nenue@40: } Nenue@40: Nenue@40: Nenue@40: db.TasksByID[taskID] = info Nenue@40: Nenue@40: local pin = self:AcquirePin(taskID) Nenue@40: for k,v in pairs(info) do Nenue@40: pin[k] = v Nenue@40: end Nenue@40: pin:GetBonusObjectiveInfo(info) Nenue@40: end Nenue@40: end Nenue@40: end Nenue@40: Nenue@40: Nenue@40: end Nenue@40: end Nenue@40: end Nenue@40: Nenue@40: Nenue@40: -- use tooltip object to extract item details Nenue@45: function Module:GetRewardHeader(questID) Nenue@40: local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID) Nenue@40: local scanner = _G.WorldPlanTooltip Nenue@40: local print = qprint Nenue@40: if not itemID then Nenue@40: return Nenue@40: end Nenue@49: qprint('GetRewardHeader', questID) Nenue@40: Nenue@40: scanner:SetOwner(WorldPlan, "ANCHOR_NONE") Nenue@40: scanner:SetItemByID(itemID) Nenue@40: scanner:Show() Nenue@40: local ttl1 = _G['WorldPlanTooltipTextLeft1'] Nenue@40: local ttl2 = _G['WorldPlanTooltipTextLeft2'] Nenue@40: local ttl3 = _G['WorldPlanTooltipTextLeft3'] Nenue@40: local ttl4 = _G['WorldPlanTooltipTextLeft4'] Nenue@40: --print(ttl2, ttl3, ttl4) Nenue@40: if ttl2 then Nenue@40: local text = ttl2:GetText() Nenue@40: -- Artifact Power Nenue@40: --print(text) Nenue@40: if text then Nenue@40: if text:match("|cFFE6CC80") then Nenue@40: --print('AP token!', text) Nenue@40: local power Nenue@40: if ttl4 then Nenue@40: local text = ttl4:GetText() Nenue@40: --print('tip line 4', text) Nenue@40: if text then Nenue@40: power = text:gsub("%p", ""):match("%d+") Nenue@40: power = tonumber(power) Nenue@40: end Nenue@40: Nenue@40: end Nenue@40: return REWARD_ARTIFACT_POWER, "Interface\\ICONS\\inv_7xp_inscription_talenttome01", power, name, itemID, quality Nenue@40: elseif text:match("Item Level") then Nenue@40: --print('equipment!', text) Nenue@40: quantity = text:match("Item Level ([%d\+]+)") Nenue@40: return REWARD_GEAR, icon, quantity, name, itemID, quality Nenue@40: elseif text:match("Crafting Reagent") then Nenue@49: qprint('|cFFFF4400it is a reagent', text) Nenue@40: return REWARD_REAGENT, icon, quantity, name, itemID, quality Nenue@40: end Nenue@40: end Nenue@40: end Nenue@40: Nenue@40: if ttl3 then Nenue@40: local text = ttl3:GetText() Nenue@40: if text and text:match("Crafting Reagent") then Nenue@49: qprint('|cFFFF4400it is a reagent', text) Nenue@40: return REWARD_REAGENT, icon, quantity, name, itemID, quality Nenue@40: end Nenue@40: end Nenue@40: return 128, icon, quantity, name, itemID, quality Nenue@40: end Nenue@33: -- create of update quest pins for a map and its underlying zones Nenue@45: function Module:UpdateWorldQuests (mapID) Nenue@40: Nenue@40: mapID = mapID or db.currentMapID Nenue@33: if not mapID then Nenue@33: -- info not available yet Nenue@33: return Nenue@33: end Nenue@33: Nenue@34: Nenue@40: print('|cFF00FF88'..self:GetName()..':UpdateWorldQuests()|r', 'map:', mapID, 'realMap:', db.currentMapID) Nenue@33: Nenue@40: Nenue@40: self.isStale = nil Nenue@40: print('|cFF00FFFFContinent:|r', BROKEN_ISLES_ID, GetMapNameByID(BROKEN_ISLES_ID)) Nenue@40: self.isRecursed = true Nenue@40: for i = 1, MC_GetNumZones(BROKEN_ISLES_ID) do Nenue@40: local submapID, name, depth = MC_GetZoneInfo(BROKEN_ISLES_ID, i) Nenue@40: local taskInfo = TQ_GetQuestsForPlayerByMapID(submapID, BROKEN_ISLES_ID) Nenue@40: if taskInfo then Nenue@40: local zoneName = GetMapNameByID(submapID) Nenue@40: print('|cFF00FFFF Zone:|r', submapID, zoneName, #taskInfo) Nenue@40: db.QuestsByZone[submapID] = db.QuestsByZone[submapID] or {} Nenue@40: for i, info in ipairs(taskInfo) do Nenue@40: if HaveQuestData(info.questId) then Nenue@40: rprint('|cFF44FF44update|r', info.questId, zoneName) Nenue@40: local questID = info.questId Nenue@40: local pin = self:AcquirePin(questID) Nenue@40: local pin = db.QuestsByID[questID] Nenue@40: if pin then Nenue@40: pin.isStale = true Nenue@40: if pin.isPending then Nenue@40: self.isPending = true Nenue@40: end Nenue@40: end Nenue@40: else Nenue@40: rprint('|cFFFF4400no data|r', info.questId, zoneName) Nenue@40: end Nenue@33: end Nenue@33: end Nenue@33: end Nenue@33: Nenue@40: self:GetBonusObjectives() Nenue@40: Nenue@40: print(' hasUpdate:', self.isStale, 'isPending:', self.isPending, 'timer:', (self.OnNext and 'waiting' or '')) Nenue@40: --WorldPlan.isStale = (self.isStale or WorldPlan.isStale) Nenue@40: if self.isStale and self:IsVisible() then Nenue@40: self:Refresh() Nenue@40: end Nick@63: Nenue@40: end Nenue@40: Nenue@45: function Module:Report() Nenue@40: for i, pin in ipairs(db.UsedPins) do Nenue@40: db:print(i, pin.questID, pin.title) Nenue@33: end Nenue@33: Nenue@40: for id, pin in pairs(db.QuestsByID) do Nenue@40: db:print(id, pin.worldQuestType, pin.rewardType, pin.title) Nenue@40: end Nenue@33: end Nenue@33: Nick@60: function Module:Refresh() Nenue@40: self.currentMapID = GetCurrentMapAreaID() Nick@60: rprint('|cFF00FF88'..self:GetName()..':Refresh()|r') Nick@60: print('|cFF00FF88'..self:GetName()..':Refresh()|r') Nenue@34: if not self:IsVisible() then Nenue@40: print(' not visible, flag for later') Nenue@34: self.isStale = true Nenue@57: return self:MarkAllPins() Nenue@40: end Nick@60: wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r') Nenue@40: Nenue@40: for index, pin in pairs(db.QuestsByID) do Nenue@40: pin.used = nil Nenue@40: end Nenue@40: Nick@62: if SpellCanTargetQuest() then Nick@62: self:UpdateBlizzButtons() Nick@62: else Nick@62: self:UpdateAnchors(nil) Nick@62: end Nick@60: Nick@60: print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') Nick@60: rprint('|cFFFFFF00'..self:GetName()..':Cleanup()|r') Nick@60: --local showQuestPOI = db.Config.EnablePins Nick@60: for questID, pin in pairs(db.QuestsByID) do Nick@60: local oV = pin:IsShown() Nick@60: if pin.used then Nick@60: pin.throttle = 1 Nick@60: if oV == false then Nick@60: print('|cFF00FF00cleanup +|r', questID, pin.title) Nick@60: end Nick@60: pin:SetShown(true) Nick@60: else Nick@60: if oV == true then Nick@60: print('|cFFFF4400 -|r', questID, pin.title) Nick@60: end Nick@62: pin:HideFrames() Nick@60: end Nick@60: end Nick@60: Nenue@40: self.isStale = nil Nenue@54: self.sizesDirty = nil Nenue@40: end Nenue@40: Nenue@40: -- update visibility states of all pins Nenue@57: function Module:MarkAllPins(pins) Nenue@57: print(' |cFFFFFF00'..self:GetName()..':MarkAllPins()|r', pins) Nenue@40: pins = pins or db.QuestsByID Nenue@40: for questID, pin in pairs(pins) do Nenue@40: pin.isStale = true Nenue@40: rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used) Nenue@40: end Nenue@40: end Nenue@40: Nenue@45: function Module:UpdateQuestButton(info, mapID) Nenue@40: local questID, x, y = info.questId, info.x, info.y Nenue@40: local pin = self:AcquirePin(info) Nenue@40: if not pin then Nenue@34: return Nenue@34: end Nenue@34: Nenue@33: Nenue@57: print('~ ', pin.mapID, pin.questID, pin.title) Nenue@57: rprint('|cFF00FF00update|r', pin.questID, pin.title) Nenue@40: Nenue@40: if x and y then Nenue@40: pin.x = x Nenue@40: pin.y = y Nenue@49: pin:SetFrameLevel(PinBaseIndex+pin:GetID()) Nenue@57: pin.owningFrame = WorldMapFrame Nenue@57: pin:SetAnchor(WorldMapPOIFrame, pin.x, pin.y, self.hostWidth, self.hostHeight) Nenue@54: --tinsert(self.UsedPositions, pin) Nenue@40: end Nenue@57: if self:IsVisible() then Nenue@57: pin:Refresh() Nenue@57: else Nenue@57: pin.isStale = true Nenue@54: end Nenue@40: if mapID then Nenue@40: if not db.QuestsByZone[mapID] then Nenue@40: db.QuestsByZone[mapID] = {} Nenue@40: end Nenue@40: db.QuestsByZone[mapID][questID] = pin Nenue@33: end Nenue@33: end Nenue@33: Nenue@45: function Module:UpdateMap(taskInfo, mapID) Nenue@49: rprint('Map', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID)) Nenue@40: for index, info in pairs(taskInfo) do Nenue@40: self:UpdateQuestButton(info, mapID) Nenue@40: end Nenue@40: end Nenue@33: Nick@60: function Module:UpdateAnchors () Nenue@40: wipe(self.UsedPositions) Nick@60: print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()') Nenue@57: self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize() Nenue@40: self.nudgeThrescholdX = 16/self.hostWidth Nenue@40: self.nudgeThrescholdY = 16/self.hostHeight Nenue@40: local print = rprint Nick@60: print('|cFF00FF00'..self:GetName()..':UpdateAnchors()') Nenue@33: local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo() Nenue@33: if isMicroDungeon then Nenue@33: return Nenue@33: end Nenue@33: Nick@62: Nenue@40: numPins = 0 Nenue@56: local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID) Nenue@40: if taskInfo then Nenue@56: self:UpdateMap(taskInfo, self.currentMapID) Nenue@33: end Nenue@56: local numZones = MC_GetNumZones(self.currentMapID) Nenue@33: if numZones then Nenue@33: for i = 1, numZones do Nenue@40: local mapAreaID = MC_GetZoneInfo(self.currentMapID, i) Nenue@56: local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, self.currentMapID) Nenue@40: if taskInfo then Nenue@40: self:UpdateMap(taskInfo, mapAreaID) Nenue@40: end Nenue@33: end Nenue@33: end Nenue@33: end Nenue@33: Nenue@40: