Nenue@7: -- WorldPlan Nenue@7: -- QuestPOI.lua Nenue@7: -- Created: 10/1/2016 7:21 PM Nenue@7: -- %file-revision% Nenue@7: -- Nenue@7: local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation Nenue@7: local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes Nenue@7: local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame Nenue@7: Nenue@7: local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end Nenue@7: local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end Nenue@7: local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end Nenue@7: local QuestPOI = WorldPlanPOIMixin Nenue@7: Nenue@7: local familiars = { Nenue@7: [42159] = {npc = 106552, name = 'Nightwatcher Merayl'}, Nenue@7: [40277] = {npc = 97804, name = 'Tiffany Nelson'}, Nenue@7: [40298] = {npc = 99182, name = 'Sir Galveston'}, Nenue@7: [40282] = {npc= 99150, name = 'Grixis Tinypop'}, Nenue@7: [40278] = {npc = 98270, name = 'Robert Craig'}, Nenue@7: [48195] = {npc = 105250, name = 'Aulier'}, Nenue@7: [41990] = {npc = 105674, name = 'Varenne'}, Nenue@7: [41860] = {npc = 104970, name = 'Xorvasc'}, Nenue@7: [40299] = {npc = 99210, name = 'Bodhi Sunwayver'}, Nenue@7: [42442] = {npc = 107489, name = 'Amalia'}, Nenue@7: [40280] = {npc = 99077, name = 'Bredda Tenderhide'}, Nenue@7: [41687] = {npc = 104553, name = 'Odrogg'}, Nenue@7: [41944] = {npc = 105455, name = 'Trapper Jarrun'}, Nenue@7: [40337] = {npc = 97709, name = 'Master Tamer Flummox'}, Nenue@7: [40279] = {npc = 99035, name = 'Durian Strongfruit'} Nenue@7: } Nenue@7: local familiars_id = 9696 Nenue@7: Nenue@7: Nenue@7: local PIN_TIME_CONTEXT = { Nenue@7: {max = 60, Nenue@7: r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end, Nenue@7: continentAlpha = 1, swipeTime = 1440, Nenue@7: }, Nenue@7: {max = 240, Nenue@7: r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end, Nenue@7: continentAlpha = 1, swipeTime = 1440, Nenue@7: }, Nenue@7: {max = 1440, Nenue@7: r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end, Nenue@7: continentAlpha = .55, swipeTime = 1440 Nenue@7: }, Nenue@7: {max = 10081, Nenue@7: r=0, g=1, b=0, Nenue@7: continentAlpha = .3, Nenue@7: }, -- 7 days + 1 minute Nenue@7: } Nenue@7: Nenue@7: Nenue@7: function QuestPOI:OnEnter() Nenue@7: local completed = select(4,GetAchievementInfo(familiars_id)) Nenue@7: if not completed then Nenue@7: if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then Nenue@7: WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT') Nenue@7: WorldMapTooltip:AddLine('Family Familiars') Nenue@7: local trainer = familiars[self.questID].name Nenue@7: local numCheevs = GetAchievementNumCriteria(familiars_id) Nenue@7: for index = 1, numCheevs do Nenue@7: local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index) Nenue@7: local numTrainers = GetAchievementNumCriteria(cheevID) Nenue@7: for subIndex = 1, numTrainers do Nenue@7: local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex) Nenue@7: if desc == trainer then Nenue@7: if not partCompleted then Nenue@7: local iconPath = select(10, GetAchievementInfo(cheevID)) Nenue@7: WorldMapTooltip:AddLine(cheevName) Nenue@7: WorldMapTooltip:AddTexture(iconPath) Nenue@7: end Nenue@7: end Nenue@7: end Nenue@7: end Nenue@7: WorldMapTooltip:Show() Nenue@7: return Nenue@7: end Nenue@7: end Nenue@7: TaskPOI_OnEnter(self) Nenue@7: end Nenue@7: function QuestPOI:OnLeave() Nenue@7: TaskPOI_OnLeave(self) Nenue@7: end Nenue@7: function QuestPOI:OnMouseDown() Nenue@7: TaskPOI_OnClick(self) Nenue@7: end Nenue@7: Nenue@7: Nenue@7: function WorldPlanPOIMixin:SetAchievementProgressTooltip() Nenue@7: print('cheevos') Nenue@7: Nenue@7: Nenue@7: end Nenue@7: Nenue@7: Nenue@7: function QuestPOI:OnShow () Nenue@7: qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()') Nenue@7: -- pop this on principle Nenue@7: self:Refresh() Nenue@7: end Nenue@7: function QuestPOI:OnHide() Nenue@7: --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()') Nenue@7: end Nenue@7: Nenue@7: function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight) Nenue@7: self:ClearAllPoints() Nenue@7: local dX, dY = TQ_GetQuestLocation(self.questID, mapID) Nenue@7: if not dX or dX == 0 then Nenue@7: local _, x, y = QuestPOIGetIconInfo(self.questID) Nenue@7: if x and floor(x) ~= 0 then Nenue@7: dX, dY = x, y Nenue@7: else Nenue@7: dX, dY = self.x, self.y Nenue@7: end Nenue@7: end Nenue@7: self.x = dX Nenue@7: self.y = dY Nenue@7: Nenue@7: print(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY)) Nenue@7: Nenue@7: local pX = (dX * mapWidth) Nenue@7: local pY = (-dY * mapHeight) Nenue@7: Nenue@7: self:SetParent(WorldMapPOIFrame) Nenue@7: self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY) Nenue@7: end Nenue@7: Nenue@7: Nenue@7: function QuestPOI:OnLoad() Nenue@7: self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') Nenue@7: end Nenue@7: Nenue@7: function QuestPOI:OnEvent(event, ...) Nenue@7: if event == 'SUPER_TRACKED_QUEST_CHANGED' then Nenue@7: if self:IsVisible() then Nenue@7: self:Refresh() Nenue@7: end Nenue@7: end Nenue@7: end Nenue@7: Nenue@7: Nenue@7: local PIN_UPDATE_DELAY = .016 Nenue@7: local TOP_PIN_ID Nenue@7: function QuestPOI:OnUpdate (sinceLast) Nenue@7: -- control update check intervals Nenue@7: self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast Nenue@7: if self.throttle <= 0 then Nenue@7: -- factor overtime into the throttle timer Nenue@7: self.throttle = PIN_UPDATE_DELAY - self.throttle Nenue@7: else Nenue@7: return Nenue@7: end Nenue@7: Nenue@7: -- query for reward data if it wasn't found in the original scan Nenue@7: local questID = self.questID Nenue@7: if self.isPending then Nenue@7: self:Reset() Nenue@7: if not (self.PendingFade:IsPlaying() or self.isAnimating) then Nenue@7: self.PendingFade:Play() Nenue@7: end Nenue@7: return Nenue@7: else Nenue@7: if self.PendingFade:IsPlaying() then Nenue@7: self.PendingFade:Stop() Nenue@7: end Nenue@7: end Nenue@7: Nenue@7: if self.hasUpdate then Nenue@7: self:Refresh() Nenue@7: self.hasUpdate = nil Nenue@7: end Nenue@7: Nenue@7: -- update time elements Nenue@7: local tl = self.timeThreschold Nenue@7: local timeLeft = TQ_GetQuestTimeLeftMinutes(questID) Nenue@7: if timeLeft > 0 then Nenue@7: for i, context in ipairs(PIN_TIME_CONTEXT) do Nenue@7: if i > self.TimeleftStage then Nenue@7: self.timeLabel:SetText(nil) Nenue@7: break Nenue@7: end Nenue@7: Nenue@7: Nenue@7: if timeLeft <= context.max then Nenue@7: if tl ~= i then Nenue@7: tl = i Nenue@7: end Nenue@7: Nenue@7: if context.format then Nenue@7: self.timeLabel:SetText(context.format(timeLeft)) Nenue@7: else Nenue@7: self.timeLabel:SetText(nil) Nenue@7: end Nenue@7: break Nenue@7: end Nenue@7: end Nenue@7: else Nenue@7: -- remove self in a timely manner Nenue@7: if not self.isPending then Nenue@7: self:Hide() Nenue@7: end Nenue@7: end Nenue@7: self.timeThreschold = tl Nenue@7: Nenue@7: if self:IsMouseOver() then Nenue@7: self.MouseGlow:Show() Nenue@7: else Nenue@7: self.MouseGlow:Hide() Nenue@7: end Nenue@7: end