comparison WorldQuests.lua @ 34:0100d923d8c3

WorldPlan: - Reward filter toggle changed to clear out other reward filters. The assumption being that one is most often looking only for that particular type of quest when they go to use it. - Fixed filter bar info falling out of sync after player-triggered world map updates. - Code stuff: -- Quest pin shown-state management makes better use of OnShow OnHide handlers, SetShown is toggled and it all goes from there -- WorldQuests module re-factored outside of the top level frame script. ClassPlan: - Available missions are now recorded; the mission list can be toggled between in-progress and available by clicking the heading.
author Nenue
date Wed, 02 Nov 2016 19:04:47 -0400
parents be4db60219ca
children 26dfa661daa7
comparison
equal deleted inserted replaced
33:be4db60219ca 34:0100d923d8c3
104 self.isStale, self.isPending = questPOI:RefreshData() 104 self.isStale, self.isPending = questPOI:RefreshData()
105 else 105 else
106 self:RefreshData() 106 self:RefreshData()
107 end 107 end
108 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale) 108 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale)
109 elseif event == 'WORLD_MAP_UPDATE' then 109 elseif event == 'WORLD_MAP_UPDATE' or event == 'PLAYER_ENTERING_WORLD' then
110 self.isStale = true 110 self.isStale = true
111 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then 111 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
112 local questID = ... 112 local questID = ...
113 if questID and self.QuestsByID[questID] then 113 if questID and self.QuestsByID[questID] then
114 self:ReleasePin(self.QuestsByID[questID]) 114 self:ReleasePin(self.QuestsByID[questID])
183 if not mapID then 183 if not mapID then
184 -- info not available yet 184 -- info not available yet
185 return 185 return
186 end 186 end
187 187
188 print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID()) 188 if not self:IsVisible() then
189 self.isStale = true
190 print('frame closed, do it later')
191 return
192 end
193
194
195 print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID())
189 196
190 if mapID == BROKEN_ISLES_ID then 197 if mapID == BROKEN_ISLES_ID then
191 self.isStale = false 198 self.isStale = false
192 print('|cFF00FFFFContinent:|r', mapID, GetMapNameByID(mapID), superTrackedID) 199 print('|cFF00FFFFContinent:|r', mapID, GetMapNameByID(mapID), superTrackedID)
193 self.fullSearch = true 200 self.fullSearch = true
207 for taskID, info in pairs(taskInfo) do 214 for taskID, info in pairs(taskInfo) do
208 local questID = info.questId 215 local questID = info.questId
209 info.mapID = mapID 216 info.mapID = mapID
210 local questPOI = self:AcquirePin(questID, mapID) 217 local questPOI = self:AcquirePin(questID, mapID)
211 local hasUpdate, isPending = questPOI:RefreshData(info) 218 local hasUpdate, isPending = questPOI:RefreshData(info)
219 -- WorldPlan:print('|cFF0088FF'..questPOI.title..'|r', hasUpdate)
212 self.isStale = (self.isStale or hasUpdate) 220 self.isStale = (self.isStale or hasUpdate)
213 self.isPending = (self.isPending or isPending) 221 self.isPending = (self.isPending or isPending)
214 numQuests = numQuests + 1 222 numQuests = numQuests + 1
215 end 223 end
216 qprint('|cFFFF4400END of', GetMapNameByID(mapID)) 224 qprint('|cFFFF4400END of', GetMapNameByID(mapID))
225 end 233 end
226 234
227 function WorldQuests:Refresh() 235 function WorldQuests:Refresh()
228 local print = wqprint 236 local print = wqprint
229 print('|cFF00FF88'..self:GetName()..':Refresh()|r') 237 print('|cFF00FF88'..self:GetName()..':Refresh()|r')
238 if not self:IsVisible() then
239 self.isStale = true
240 print('frame closed, do it later')
241 return
242 end
243
230 self:Reset() 244 self:Reset()
231 self:UpdateAnchors() 245 self:UpdateAnchors()
232 self:Cleanup () 246 self:Cleanup ()
233 end 247 end
234 248
275 pin:IsShowable() 289 pin:IsShowable()
276 if pin.used then 290 if pin.used then
277 pin.hasUpdate = true 291 pin.hasUpdate = true
278 pin:SetFrameLevel(PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) 292 pin:SetFrameLevel(PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins)
279 print('level', PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins) 293 print('level', PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins)
280 pin:SetAnchor(WorldMapPOIFrame, currentMap, mapWidth, mapHeight) 294 pin:SetAnchor(_G.WorldMapPOIFrame, currentMap, mapWidth, mapHeight)
281 numPins = numPins + 1 295 numPins = numPins + 1
282 end 296 end
283 end 297 end
284 end 298 end
285 end 299 end
288 local debug_show = {} 302 local debug_show = {}
289 local debug_animate = {} 303 local debug_animate = {}
290 local debug_hide = {} 304 local debug_hide = {}
291 function WorldQuests:Cleanup () 305 function WorldQuests:Cleanup ()
292 local print = wqprint 306 local print = wqprint
293 local showQuestPOI = db.EnablePins 307 local showQuestPOI = WorldPlan.db.EnablePins
294 print('|cFFFFFF00'..tostring(self)..':Cleanup()|r') 308 WorldPlan:print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
295 local mapID = GetCurrentMapAreaID()
296 isContinentMap = (mapID == BROKEN_ISLES_ID)
297
298 wipe(debug_show)
299 wipe(debug_animate)
300 wipe(debug_hide)
301 -- continent or zone sizing 309 -- continent or zone sizing
302 local fadeGrouped = (db.FadeWhileGrouped and IsInGroup()) 310
303 311
304 numPins = 0 312 numPins = 0
305 for questID, pin in pairs(self.QuestsByID) do 313 for questID, pin in pairs(self.QuestsByID) do
306 -- can we show it? 314 -- can we show it?
307 if showQuestPOI and (pin.used) then 315 pin:SetShown((showQuestPOI and pin.used))
308
309 pin.isStale = true
310 if fadeGrouped then
311 pin:SetAlpha(0.25)
312 else
313 pin:SetAlpha(1)
314 end
315 -- is it a new quest?
316 if pin.isNew then
317 if not pin.isAnimating then
318 pin.isAnimating = true
319 WorldPlan:OnNext(function()
320 pin:ShowNew()
321 end)
322 tinsert(debug_animate,questID)
323 else
324
325 print('animating? ', questID, 'filtered:', pin.filtered)
326 end
327 -- trap new but animating pins here
328 else
329 -- hard show existing pin
330 --print('refresh #', questID, 'filtered:', pin.filtered, 'hasUpdate', pin.hasUpdate)
331 pin:Show()
332 tinsert(debug_show,questID)
333 end
334 else
335 if pin:IsShown() then
336 tinsert(debug_hide,questID)
337 end
338 pin.isAnimating = nil
339 pin.FadeIn:Stop()
340 pin:Hide()
341 end
342 end 316 end
343 print(' adding:', table.concat(debug_animate, ',' )) 317 print(' adding:', table.concat(debug_animate, ',' ))
344 print(' refresh:', table.concat(debug_show, ',' )) 318 print(' refresh:', table.concat(debug_show, ',' ))
345 print(' hiding:', table.concat(debug_hide, ',' )) 319 print(' hiding:', table.concat(debug_hide, ',' ))
346 hasNewQuestPins = nil
347 notifyPlayed = nil
348 self.isStale = nil 320 self.isStale = nil
349 end 321 end
350 322
351 function WorldQuests:FilterCheckByID(questID) 323 function WorldQuests:FilterCheckByID(questID)
352 local pin = WorldQuests:GetPinByQuestID(questID) 324 local pin = WorldQuests:GetPinByQuestID(questID)