annotate QuestPOI.lua @ 7:34d9fbf7af20

beginning of reflecting code path isolation in file structure
author Nenue
date Sat, 22 Oct 2016 15:36:25 -0400
parents
children 802abb8a10ea
rev   line source
Nenue@7 1 -- WorldPlan
Nenue@7 2 -- QuestPOI.lua
Nenue@7 3 -- Created: 10/1/2016 7:21 PM
Nenue@7 4 -- %file-revision%
Nenue@7 5 --
Nenue@7 6 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@7 7 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
Nenue@7 8 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
Nenue@7 9
Nenue@7 10 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@7 11 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@7 12 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
Nenue@7 13 local QuestPOI = WorldPlanPOIMixin
Nenue@7 14
Nenue@7 15 local familiars = {
Nenue@7 16 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'},
Nenue@7 17 [40277] = {npc = 97804, name = 'Tiffany Nelson'},
Nenue@7 18 [40298] = {npc = 99182, name = 'Sir Galveston'},
Nenue@7 19 [40282] = {npc= 99150, name = 'Grixis Tinypop'},
Nenue@7 20 [40278] = {npc = 98270, name = 'Robert Craig'},
Nenue@7 21 [48195] = {npc = 105250, name = 'Aulier'},
Nenue@7 22 [41990] = {npc = 105674, name = 'Varenne'},
Nenue@7 23 [41860] = {npc = 104970, name = 'Xorvasc'},
Nenue@7 24 [40299] = {npc = 99210, name = 'Bodhi Sunwayver'},
Nenue@7 25 [42442] = {npc = 107489, name = 'Amalia'},
Nenue@7 26 [40280] = {npc = 99077, name = 'Bredda Tenderhide'},
Nenue@7 27 [41687] = {npc = 104553, name = 'Odrogg'},
Nenue@7 28 [41944] = {npc = 105455, name = 'Trapper Jarrun'},
Nenue@7 29 [40337] = {npc = 97709, name = 'Master Tamer Flummox'},
Nenue@7 30 [40279] = {npc = 99035, name = 'Durian Strongfruit'}
Nenue@7 31 }
Nenue@7 32 local familiars_id = 9696
Nenue@7 33
Nenue@7 34
Nenue@7 35 local PIN_TIME_CONTEXT = {
Nenue@7 36 {max = 60,
Nenue@7 37 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@7 38 continentAlpha = 1, swipeTime = 1440,
Nenue@7 39 },
Nenue@7 40 {max = 240,
Nenue@7 41 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@7 42 continentAlpha = 1, swipeTime = 1440,
Nenue@7 43 },
Nenue@7 44 {max = 1440,
Nenue@7 45 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@7 46 continentAlpha = .55, swipeTime = 1440
Nenue@7 47 },
Nenue@7 48 {max = 10081,
Nenue@7 49 r=0, g=1, b=0,
Nenue@7 50 continentAlpha = .3,
Nenue@7 51 }, -- 7 days + 1 minute
Nenue@7 52 }
Nenue@7 53
Nenue@7 54
Nenue@7 55 function QuestPOI:OnEnter()
Nenue@7 56 local completed = select(4,GetAchievementInfo(familiars_id))
Nenue@7 57 if not completed then
Nenue@7 58 if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then
Nenue@7 59 WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT')
Nenue@7 60 WorldMapTooltip:AddLine('Family Familiars')
Nenue@7 61 local trainer = familiars[self.questID].name
Nenue@7 62 local numCheevs = GetAchievementNumCriteria(familiars_id)
Nenue@7 63 for index = 1, numCheevs do
Nenue@7 64 local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index)
Nenue@7 65 local numTrainers = GetAchievementNumCriteria(cheevID)
Nenue@7 66 for subIndex = 1, numTrainers do
Nenue@7 67 local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex)
Nenue@7 68 if desc == trainer then
Nenue@7 69 if not partCompleted then
Nenue@7 70 local iconPath = select(10, GetAchievementInfo(cheevID))
Nenue@7 71 WorldMapTooltip:AddLine(cheevName)
Nenue@7 72 WorldMapTooltip:AddTexture(iconPath)
Nenue@7 73 end
Nenue@7 74 end
Nenue@7 75 end
Nenue@7 76 end
Nenue@7 77 WorldMapTooltip:Show()
Nenue@7 78 return
Nenue@7 79 end
Nenue@7 80 end
Nenue@7 81 TaskPOI_OnEnter(self)
Nenue@7 82 end
Nenue@7 83 function QuestPOI:OnLeave()
Nenue@7 84 TaskPOI_OnLeave(self)
Nenue@7 85 end
Nenue@7 86 function QuestPOI:OnMouseDown()
Nenue@7 87 TaskPOI_OnClick(self)
Nenue@7 88 end
Nenue@7 89
Nenue@7 90
Nenue@7 91 function WorldPlanPOIMixin:SetAchievementProgressTooltip()
Nenue@7 92 print('cheevos')
Nenue@7 93
Nenue@7 94
Nenue@7 95 end
Nenue@7 96
Nenue@7 97
Nenue@7 98 function QuestPOI:OnShow ()
Nenue@7 99 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()')
Nenue@7 100 -- pop this on principle
Nenue@7 101 self:Refresh()
Nenue@7 102 end
Nenue@7 103 function QuestPOI:OnHide()
Nenue@7 104 --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
Nenue@7 105 end
Nenue@7 106
Nenue@7 107 function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight)
Nenue@7 108 self:ClearAllPoints()
Nenue@7 109 local dX, dY = TQ_GetQuestLocation(self.questID, mapID)
Nenue@7 110 if not dX or dX == 0 then
Nenue@7 111 local _, x, y = QuestPOIGetIconInfo(self.questID)
Nenue@7 112 if x and floor(x) ~= 0 then
Nenue@7 113 dX, dY = x, y
Nenue@7 114 else
Nenue@7 115 dX, dY = self.x, self.y
Nenue@7 116 end
Nenue@7 117 end
Nenue@7 118 self.x = dX
Nenue@7 119 self.y = dY
Nenue@7 120
Nenue@7 121 print(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
Nenue@7 122
Nenue@7 123 local pX = (dX * mapWidth)
Nenue@7 124 local pY = (-dY * mapHeight)
Nenue@7 125
Nenue@7 126 self:SetParent(WorldMapPOIFrame)
Nenue@7 127 self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
Nenue@7 128 end
Nenue@7 129
Nenue@7 130
Nenue@7 131 function QuestPOI:OnLoad()
Nenue@7 132 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@7 133 end
Nenue@7 134
Nenue@7 135 function QuestPOI:OnEvent(event, ...)
Nenue@7 136 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@7 137 if self:IsVisible() then
Nenue@7 138 self:Refresh()
Nenue@7 139 end
Nenue@7 140 end
Nenue@7 141 end
Nenue@7 142
Nenue@7 143
Nenue@7 144 local PIN_UPDATE_DELAY = .016
Nenue@7 145 local TOP_PIN_ID
Nenue@7 146 function QuestPOI:OnUpdate (sinceLast)
Nenue@7 147 -- control update check intervals
Nenue@7 148 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
Nenue@7 149 if self.throttle <= 0 then
Nenue@7 150 -- factor overtime into the throttle timer
Nenue@7 151 self.throttle = PIN_UPDATE_DELAY - self.throttle
Nenue@7 152 else
Nenue@7 153 return
Nenue@7 154 end
Nenue@7 155
Nenue@7 156 -- query for reward data if it wasn't found in the original scan
Nenue@7 157 local questID = self.questID
Nenue@7 158 if self.isPending then
Nenue@7 159 self:Reset()
Nenue@7 160 if not (self.PendingFade:IsPlaying() or self.isAnimating) then
Nenue@7 161 self.PendingFade:Play()
Nenue@7 162 end
Nenue@7 163 return
Nenue@7 164 else
Nenue@7 165 if self.PendingFade:IsPlaying() then
Nenue@7 166 self.PendingFade:Stop()
Nenue@7 167 end
Nenue@7 168 end
Nenue@7 169
Nenue@7 170 if self.hasUpdate then
Nenue@7 171 self:Refresh()
Nenue@7 172 self.hasUpdate = nil
Nenue@7 173 end
Nenue@7 174
Nenue@7 175 -- update time elements
Nenue@7 176 local tl = self.timeThreschold
Nenue@7 177 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@7 178 if timeLeft > 0 then
Nenue@7 179 for i, context in ipairs(PIN_TIME_CONTEXT) do
Nenue@7 180 if i > self.TimeleftStage then
Nenue@7 181 self.timeLabel:SetText(nil)
Nenue@7 182 break
Nenue@7 183 end
Nenue@7 184
Nenue@7 185
Nenue@7 186 if timeLeft <= context.max then
Nenue@7 187 if tl ~= i then
Nenue@7 188 tl = i
Nenue@7 189 end
Nenue@7 190
Nenue@7 191 if context.format then
Nenue@7 192 self.timeLabel:SetText(context.format(timeLeft))
Nenue@7 193 else
Nenue@7 194 self.timeLabel:SetText(nil)
Nenue@7 195 end
Nenue@7 196 break
Nenue@7 197 end
Nenue@7 198 end
Nenue@7 199 else
Nenue@7 200 -- remove self in a timely manner
Nenue@7 201 if not self.isPending then
Nenue@7 202 self:Hide()
Nenue@7 203 end
Nenue@7 204 end
Nenue@7 205 self.timeThreschold = tl
Nenue@7 206
Nenue@7 207 if self:IsMouseOver() then
Nenue@7 208 self.MouseGlow:Show()
Nenue@7 209 else
Nenue@7 210 self.MouseGlow:Hide()
Nenue@7 211 end
Nenue@7 212 end