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