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@9: local TQ_IsActive = C_TaskQuest.IsActive 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@9: local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" Nenue@9: local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" Nenue@9: Nenue@9: local POI_BORDER_MASK = "Interface\\Minimap\\UI-Minimap-Background" Nenue@9: local POI_BORDER_FILL = "Interface\\BUTTONS\\YELLOWORANGE64" Nenue@9: local POI_BORDER_BLUE = "Interface\\BUTTONS\\GRADBLUE" Nenue@9: local POI_BORDER_RED = "Interface\\BUTTONS\\RedGrad64" Nenue@9: local POI_BORDER_YELLOW = "Interface\\BUTTONS\\YELLOWORANGE64" Nenue@9: local POI_BORDER_GREEN = "Interface\\BUTTONS\\GREENGRAD64" Nenue@9: 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@9: -- update a masked texture without messing up its blending mask Nenue@9: local SetMaskedTexture = function(region, file, mask) Nenue@9: mask = mask or POI_BORDER_MASK Nenue@9: region:SetMask(nil) Nenue@9: region:SetTexture(file) Nenue@9: region:SetMask(mask) Nenue@9: end 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@9: qprint(' |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@9: if not TQ_IsActive(self.questID) then Nenue@9: print('|cFFFF4400'..self:GetName()..' pin hard timeout') Nenue@9: if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then Nenue@9: self:Hide() Nenue@9: end 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@8: end Nenue@8: Nenue@8: Nenue@9: Nenue@9: function QuestPOI:Refresh () Nenue@9: local db = WorldPlan.db Nenue@9: local print = qprint Nenue@9: print('|cFF00FF88["'..tostring(self.title)..'"]|r:Refresh()', tostring(self.title), "|T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName)) Nenue@9: print(self.style) Nenue@9: Nenue@9: Nenue@9: Nenue@9: local questID = self.questId Nenue@9: local style = self.style Nenue@9: local borderMask = style.mask Nenue@9: local borderFill = style.texture Nenue@9: local iconBorder = self.iconBorder Nenue@9: local icon = self.icon Nenue@9: local count = self.count Nenue@9: Nenue@9: Nenue@9: local subStyle = self.filtered and 'minimized' or 'continent' Nenue@9: if subStyle ~= self.subStyle then Nenue@9: print( ' - changed subStyle, need to redo masks') Nenue@9: end Nenue@9: self.subStyle = subStyle Nenue@9: print(' - subStyle:', (self.filtered == true), self.subStyle) Nenue@9: Nenue@9: --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName)) Nenue@9: SetMaskedTexture(icon, self.itemTexture or ICON_UNKNOWN, borderMask) Nenue@9: icon:SetAllPoints(self) Nenue@9: Nenue@9: if self.itemName then Nenue@9: local color = self.rewardColor or COMMON_COLOR Nenue@9: if self.itemNumber and self.target then Nenue@9: self.count:SetText(color.hex .. tostring(self.itemNumber)) Nenue@9: else Nenue@9: self.count:SetText(nil) Nenue@9: end Nenue@9: end Nenue@9: Nenue@9: SetMaskedTexture(iconBorder, borderFill, borderMask) Nenue@9: local border = (self.rewardType and db.rewardStyle[self.rewardType]) or (WORLD_QUEST_QUALITY_COLORS[self.rarity] or db.defaultStyle) Nenue@9: iconBorder:SetVertexColor(border.r, border.g, border.b, border.a) Nenue@9: iconBorder:SetDesaturated(true) Nenue@9: Nenue@9: local trackingBorder = self.supertrackBorder Nenue@9: Nenue@9: self.highlight:SetMask(nil) Nenue@9: if questID == GetSuperTrackedQuestID() then Nenue@9: trackingBorder:SetVertexColor(0,0,0,1) Nenue@9: else Nenue@9: trackingBorder:SetVertexColor(0,0,0,0.5) Nenue@9: end Nenue@9: self.highlight:SetAllPoints(trackingBorder) Nenue@9: Nenue@9: SetMaskedTexture(trackingBorder, borderFill, borderMask) Nenue@9: self.highlight:SetMask(borderMask) Nenue@9: Nenue@9: local qType = self.worldQuestType Nenue@9: self.tagIcon:SetAtlas(self.tagAtlas) Nenue@9: self.tagIcon:SetTexCoord(0,1,0,1) Nenue@9: Nenue@9: Nenue@9: if self.isElite then Nenue@9: self.EliteDecal:Show() Nenue@9: else Nenue@9: self.EliteDecal:Hide() Nenue@9: end Nenue@9: Nenue@9: if style.showNumber then Nenue@9: self.label:SetText(self.itemNumber) Nenue@9: else Nenue@9: self.label:SetText(nil) Nenue@9: end Nenue@9: qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '') Nenue@9: Nenue@9: Nenue@9: self:UpdateSize() Nenue@9: end Nenue@9: Nenue@8: function WorldPlanFilterPinMixin:OnEnter () Nenue@8: local filter = WorldPlan.FilterOptions[self:GetID()] Nenue@8: local mapID = GetCurrentMapAreaID() Nenue@8: local quests = (mapID == WorldPlan.BrokenIsleID) and WorldPlan.QuestsByID or WorldPlan.QuestsByZone[mapID] Nenue@8: if quests then Nenue@8: GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') Nenue@8: GameTooltip:AddLine(filter.label) Nenue@8: local filterKey = self.filterKey Nenue@8: local filterValue = self.filterValue Nenue@8: if filterKey then Nenue@8: for questID, pin in pairs(quests) do Nenue@8: if pin.used and not pin.filtered then Nenue@8: if pin[filterKey] == filterValue then Nenue@8: local style = pin.style or WorldPlan.FilterStyle Nenue@8: Nenue@8: if familiars[questID] then Nenue@8: GameTooltip:AddLine(pin.title,0,1,0) Nenue@8: else Nenue@8: GameTooltip:AddLine(pin.title,1,1,1) Nenue@8: end Nenue@8: Nenue@8: end Nenue@8: end Nenue@8: end Nenue@8: else Nenue@8: GameTooltip:AddLine('Reset all filters') Nenue@8: end Nenue@8: GameTooltip:Show() Nenue@8: end Nenue@7: end