comparison ObjectiveTracker/Quests.lua @ 34:9856ebc63fa4

- half solution to Update being fired multiple times during load - change securefunc handlers to dispense a reason code; catch that reason code in the enclosure passed to hooksecurefunc, and decide whether to update or not from there.
author Nenue
date Sun, 17 Apr 2016 00:21:45 -0400
parents a3afe6c3771e
children 69d03f8e293e
comparison
equal deleted inserted replaced
33:64f2a9bbea79 34:9856ebc63fa4
31 Quest.UpdateObjectives = function(handler, block) 31 Quest.UpdateObjectives = function(handler, block)
32 local print = lprint 32 local print = lprint
33 print('|cFF00FFFFUpdateObjectives()') 33 print('|cFF00FFFFUpdateObjectives()')
34 local info = block.info 34 local info = block.info
35 35
36 local titlebg, textbg = colors.default.titlebg, colors.default.textbg
37 print((info.isAccount and 'isAccount' or ''), (info.isFaction and 'isFaction' or ''), (info.isDaily and 'isDaily' or ''), (info.isWeekly and 'isWeekly' or ''), info.tagID, info.tagName) 36 print((info.isAccount and 'isAccount' or ''), (info.isFaction and 'isFaction' or ''), (info.isDaily and 'isDaily' or ''), (info.isWeekly and 'isWeekly' or ''), info.tagID, info.tagName)
38 37
38 local block_schema = 'default'
39 if info.isAccount then 39 if info.isAccount then
40 if info.isFaction then 40 if info.isFaction then
41 print(' faction', info.tagID) 41 print(' faction', info.tagID)
42 titlebg, textbg = colors['faction_'..info.tagID].titlebg, colors.default.textbg 42 block_schema = 'faction_'..info.tagID
43 else 43 else
44 print(' account', info.isAccount, info.isFaction) 44 print(' account', info.isAccount, info.isFaction)
45 titlebg, textbg = colors.account.titlebg, colors.account.textbg 45 block_schema = 'account'
46 end 46 end
47 elseif info.isDaily then 47 elseif info.isDaily then
48 print(' daily', info.frequency) 48 print(' daily', info.frequency)
49 titlebg, textbg = colors.daily.titlebg, colors.daily.textbg 49 block_schema = 'daily'
50 elseif info.isWeekly then 50 elseif info.isWeekly then
51 print(' weekly', info.frequency) 51 print(' weekly', info.frequency)
52 titlebg, textbg = colors.weekly.titlebg, colors.weekly.textbg 52 block_schema = 'weekly'
53 end 53 end
54
55 block.titlebg:SetGradientAlpha(unpack(titlebg))
56 block.statusbg:SetGradientAlpha(unpack(textbg))
57
58 local completionText 54 local completionText
59 if info.isComplete then 55 if info.isComplete then
60 if info.isAutoComplete then 56 if info.isAutoComplete then
61 local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) 57 local questID, popupType = GetAutoQuestPopUp(info.logIndex)
62 if popupType == 'COMPLETE' then 58 if popupType == 'COMPLETE' then
63 print(' :: auto-complete quest :: set the message') 59 print(' :: auto-complete quest :: set the message')
64 info.completionText = T.strings.CLICK_TO_COMPLETE 60 info.completionText = T.strings.CLICK_TO_COMPLETE
65 end 61 end
66 else 62 else
67 if not completionText or info.completionText then 63 if not completionText or info.completionText then
68 info.completionText = GetQuestLogCompletionText(info.questLogIndex) 64 info.completionText = GetQuestLogCompletionText(info.logIndex)
69 end 65 end
70 end 66 end
71 print(' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"') 67 print(' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"')
72 end 68 end
73 69
74 Default.UpdateObjectives(handler, block) 70 Default.UpdateObjectives(handler, block, block_schema)
71 return block_schema
75 end 72 end
76 73
77 Quest.UpdateLine = function(handler, block, line, data) 74 Quest.UpdateLine = function(handler, block, line, data)
78 local print = lprint 75 local print = lprint
79 local objectiveType = data.type 76 local objectiveType = data.type
85 Quest.QuestBlock = {} 82 Quest.QuestBlock = {}
86 Quest.LogBlock = {} 83 Quest.LogBlock = {}
87 Quest.LogInfo = {} 84 Quest.LogInfo = {}
88 85
89 function Quest:GetNumWatched () 86 function Quest:GetNumWatched ()
90 print(self.name, self)
91 superTrackQuestID = GetSuperTrackedQuestID() 87 superTrackQuestID = GetSuperTrackedQuestID()
92 playerMoney = GetMoney(); 88 playerMoney = GetMoney();
93 inScenario = C_Scenario.IsInScenario(); 89 inScenario = C_Scenario.IsInScenario();
94 showPOIs = GetCVarBool("questPOI"); 90 showPOIs = GetCVarBool("questPOI");
95 self.numAll = GetNumQuestLogEntries() 91 self.numAll = GetNumQuestLogEntries()
100 --- Returns an iterable table from which tracker blocks can be filled out. Data includes: 96 --- Returns an iterable table from which tracker blocks can be filled out. Data includes:
101 -- All entry-layer GetXInfo return values 97 -- All entry-layer GetXInfo return values
102 -- Manifest of line data to be displayed in relation to the tracked object 98 -- Manifest of line data to be displayed in relation to the tracked object
103 Quest.GetInfo = function (self, watchIndex) 99 Quest.GetInfo = function (self, watchIndex)
104 local print = iprint 100 local print = iprint
105 print('')
106 print('|cFF00DDFFindex: |r'.. tostring(watchIndex))
107 101
108 local questID, title, questLogIndex, numObjectives, requiredMoney, isComplete, startEvent, isAutoComplete, 102 local questID, title, questLogIndex, numObjectives, requiredMoney, isComplete, startEvent, isAutoComplete,
109 failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex) 103 failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
110 if ( not questID ) then 104 if ( not questID ) then
111 return 105 return
112 end 106 end
113 107
108 tprint(' |cFFFFBB00GetInfo:|r', watchIndex, '|cFFFF2299'..title..'|r')
114 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questLogIndex) 109 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questLogIndex)
115 110
116 Quest.Info[questID] = Quest.Info[questID] or {} 111 Quest.Info[questID] = Quest.Info[questID] or {}
117 112
118 113
119 local q = Quest.Info[questID] 114 local q = Quest.Info[questID]
120 q.watchIndex = watchIndex
121 q.type = 'Quest' 115 q.type = 'Quest'
122 q.id = questID
123 q.questID = questID
124 q.title = title 116 q.title = title
125 q.level = level 117 q.level = level
126 q.displayQuestID = displayQuestID 118 q.displayQuestID = displayQuestID
127 q.suggestedGroup = suggestedGroup 119 q.suggestedGroup = suggestedGroup
128 q.questLogIndex = questLogIndex
129 120
130 -- re-use Blizzard logic for consistency 121 -- re-use Blizzard logic for consistency
131 local showQuest = true 122 local showQuest = true
132 if isTask then showQuest = false end 123 if isTask then showQuest = false end
133 local watchMoney = false; 124 local watchMoney = false;
347 q.statusKey = temp_status 338 q.statusKey = temp_status
348 q.selected = (questID == superTrackQuestID) 339 q.selected = (questID == superTrackQuestID)
349 340
350 T.SetRewards(q, questID) 341 T.SetRewards(q, questID)
351 342
343 q.questID = questID
344 q.logIndex = questLogIndex
345 q.watchIndex = watchIndex
346 q.id = questID
352 self.WatchInfo[watchIndex] = q 347 self.WatchInfo[watchIndex] = q
353 self.LogInfo[questLogIndex] = q 348 self.LogInfo[questLogIndex] = q
354 349
355 if Devian and Devian.InWorkspace() then 350 if Devian and Devian.InWorkspace() then
356 print('|cFF00DDFFstatus:|r', temp_status, '|cFF00FF00questLogIndex|r:', title) 351 print('|cFF00DDFFstatus:|r', temp_status, '|cFF00FF00questLogIndex|r:', questLogIndex, title)
357 local temp ={} 352 local temp ={}
358 local data_txt = '|cFFFF4400values:|r' 353 local data_txt = '|cFFFF4400values:|r'
359 for k,v in pairs(q) do 354 for k,v in pairs(q) do
360 if type(v) =='number' then 355 if type(v) =='number' then
361 data_txt = data_txt .. ' |cFFFFFF00'..k..'|r: ' .. tostring(v) 356 data_txt = data_txt .. ' |cFFFFFF00'..k..'|r: ' .. tostring(v)
378 373
379 Quest.GetObjectives = function(questLogIndex, numObjectives, isComplete, isSequenced, isStory) 374 Quest.GetObjectives = function(questLogIndex, numObjectives, isComplete, isSequenced, isStory)
380 local objectives = {} 375 local objectives = {}
381 for i = 1, numObjectives do 376 for i = 1, numObjectives do
382 local text, type, finished = GetQuestLogLeaderBoard(i, questLogIndex) 377 local text, type, finished = GetQuestLogLeaderBoard(i, questLogIndex)
383 print(format(' #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished))) 378 print(format(' |cFFFF4400GetObjectives:|r #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)))
384 objectives[i] = { 379 objectives[i] = {
385 index = i, 380 index = i,
386 type = type, 381 type = type,
387 text = text, 382 text = text,
388 finished = finished 383 finished = finished
415 end 410 end
416 411
417 412
418 Quest.Select = function (handler, block) 413 Quest.Select = function (handler, block)
419 if block.info.isAutoComplete and block.info.isComplete then 414 if block.info.isAutoComplete and block.info.isComplete then
420 ShowQuestComplete(block.info.questLogIndex) 415 ShowQuestComplete(block.info.logIndex)
421 else 416 else
422 SetSuperTrackedQuestID(block.info.questID) 417 SetSuperTrackedQuestID(block.info.questID)
423 end 418 end
424 end 419 end
425 420
426 Quest.Link = function(handler, block) 421 Quest.Link = function(handler, block)
427 422
428 local questLink = GetQuestLink(block.info.questLogIndex); 423 local questLink = GetQuestLink(block.info.logIndex);
429 if ( questLink ) then 424 if ( questLink ) then
430 ChatEdit_InsertLink(questLink); 425 ChatEdit_InsertLink(questLink);
431 end 426 end
432 end 427 end
433 428
436 QuestMapFrame_OpenToQuestDetails(block.info.questID) 431 QuestMapFrame_OpenToQuestDetails(block.info.questID)
437 end 432 end
438 433
439 Quest.Remove = function(handler, block) 434 Quest.Remove = function(handler, block)
440 435
441 print('removing', block.info.questLogIndex, 'from watcher') 436 print('removing', block.info.logIndex, 'from watcher')
442 RemoveQuestWatch(block.info.questLogIndex) 437 RemoveQuestWatch(block.info.logIndex)
443 end 438 end