Mercurial > wow > worldplan
view QuestPOI.lua @ 8:802abb8a10ea
Fixed loss of mission progress data while changing zones by using `GARRISON_LANDINGPAGE_SHIPMENTS' as the trigger point for mission scoops.
* `MISSION_LIST_UPDATE' fires before all data is available, and if this is happens on a loading screen, then several landing page items may get snipped.
author | Nenue |
---|---|
date | Sun, 23 Oct 2016 07:19:53 -0400 |
parents | 34d9fbf7af20 |
children | a2b623043970 |
line wrap: on
line source
-- WorldPlan -- QuestPOI.lua -- Created: 10/1/2016 7:21 PM -- %file-revision% -- local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end local QuestPOI = WorldPlanPOIMixin local familiars = { [42159] = {npc = 106552, name = 'Nightwatcher Merayl'}, [40277] = {npc = 97804, name = 'Tiffany Nelson'}, [40298] = {npc = 99182, name = 'Sir Galveston'}, [40282] = {npc= 99150, name = 'Grixis Tinypop'}, [40278] = {npc = 98270, name = 'Robert Craig'}, [48195] = {npc = 105250, name = 'Aulier'}, [41990] = {npc = 105674, name = 'Varenne'}, [41860] = {npc = 104970, name = 'Xorvasc'}, [40299] = {npc = 99210, name = 'Bodhi Sunwayver'}, [42442] = {npc = 107489, name = 'Amalia'}, [40280] = {npc = 99077, name = 'Bredda Tenderhide'}, [41687] = {npc = 104553, name = 'Odrogg'}, [41944] = {npc = 105455, name = 'Trapper Jarrun'}, [40337] = {npc = 97709, name = 'Master Tamer Flummox'}, [40279] = {npc = 99035, name = 'Durian Strongfruit'} } local familiars_id = 9696 local PIN_TIME_CONTEXT = { {max = 60, r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end, continentAlpha = 1, swipeTime = 1440, }, {max = 240, r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end, continentAlpha = 1, swipeTime = 1440, }, {max = 1440, r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end, continentAlpha = .55, swipeTime = 1440 }, {max = 10081, r=0, g=1, b=0, continentAlpha = .3, }, -- 7 days + 1 minute } function QuestPOI:OnEnter() local completed = select(4,GetAchievementInfo(familiars_id)) if not completed then if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT') WorldMapTooltip:AddLine('Family Familiars') local trainer = familiars[self.questID].name local numCheevs = GetAchievementNumCriteria(familiars_id) for index = 1, numCheevs do local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index) local numTrainers = GetAchievementNumCriteria(cheevID) for subIndex = 1, numTrainers do local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex) if desc == trainer then if not partCompleted then local iconPath = select(10, GetAchievementInfo(cheevID)) WorldMapTooltip:AddLine(cheevName) WorldMapTooltip:AddTexture(iconPath) end end end end WorldMapTooltip:Show() return end end TaskPOI_OnEnter(self) end function QuestPOI:OnLeave() TaskPOI_OnLeave(self) end function QuestPOI:OnMouseDown() TaskPOI_OnClick(self) end function WorldPlanPOIMixin:SetAchievementProgressTooltip() print('cheevos') end function QuestPOI:OnShow () qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()') -- pop this on principle self:Refresh() end function QuestPOI:OnHide() --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()') end function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight) self:ClearAllPoints() local dX, dY = TQ_GetQuestLocation(self.questID, mapID) if not dX or dX == 0 then local _, x, y = QuestPOIGetIconInfo(self.questID) if x and floor(x) ~= 0 then dX, dY = x, y else dX, dY = self.x, self.y end end self.x = dX self.y = dY print(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY)) local pX = (dX * mapWidth) local pY = (-dY * mapHeight) self:SetParent(WorldMapPOIFrame) self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY) end function QuestPOI:OnLoad() self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') end function QuestPOI:OnEvent(event, ...) if event == 'SUPER_TRACKED_QUEST_CHANGED' then if self:IsVisible() then self:Refresh() end end end local PIN_UPDATE_DELAY = .016 local TOP_PIN_ID function QuestPOI:OnUpdate (sinceLast) -- control update check intervals self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast if self.throttle <= 0 then -- factor overtime into the throttle timer self.throttle = PIN_UPDATE_DELAY - self.throttle else return end -- query for reward data if it wasn't found in the original scan local questID = self.questID if self.isPending then self:Reset() if not (self.PendingFade:IsPlaying() or self.isAnimating) then self.PendingFade:Play() end return else if self.PendingFade:IsPlaying() then self.PendingFade:Stop() end end if self.hasUpdate then self:Refresh() self.hasUpdate = nil end -- update time elements local tl = self.timeThreschold local timeLeft = TQ_GetQuestTimeLeftMinutes(questID) if timeLeft > 0 then for i, context in ipairs(PIN_TIME_CONTEXT) do if i > self.TimeleftStage then self.timeLabel:SetText(nil) break end if timeLeft <= context.max then if tl ~= i then tl = i end if context.format then self.timeLabel:SetText(context.format(timeLeft)) else self.timeLabel:SetText(nil) end break end end else -- remove self in a timely manner if not self.isPending then self:Hide() end end self.timeThreschold = tl if self:IsMouseOver() then self.MouseGlow:Show() else self.MouseGlow:Hide() end end function WorldPlanFilterPinMixin:OnEnter () local filter = WorldPlan.FilterOptions[self:GetID()] local mapID = GetCurrentMapAreaID() local quests = (mapID == WorldPlan.BrokenIsleID) and WorldPlan.QuestsByID or WorldPlan.QuestsByZone[mapID] if quests then GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') GameTooltip:AddLine(filter.label) local filterKey = self.filterKey local filterValue = self.filterValue if filterKey then for questID, pin in pairs(quests) do if pin.used and not pin.filtered then if pin[filterKey] == filterValue then local style = pin.style or WorldPlan.FilterStyle if familiars[questID] then GameTooltip:AddLine(pin.title,0,1,0) else GameTooltip:AddLine(pin.title,1,1,1) end end end end else GameTooltip:AddLine('Reset all filters') end GameTooltip:Show() end end