comparison ObjectiveTracker/Quests.lua @ 38:1f8f9cc3d956

- module integration brought up to speed with current frame management structure
author Nenue
date Thu, 21 Apr 2016 11:36:41 -0400
parents e84d645c8ab8
children 92534dc793f2
comparison
equal deleted inserted replaced
37:e84d645c8ab8 38:1f8f9cc3d956
12 local format, wipe, select = format, table.wipe, select 12 local format, wipe, select = format, table.wipe, select
13 local wipeall = B.wipeall 13 local wipeall = B.wipeall
14 local lprint, iprint, tprint = B.print('Line'), B.print('Info'), B.print('Tracker') 14 local lprint, iprint, tprint = B.print('Line'), B.print('Info'), B.print('Tracker')
15 local print = tprint 15 local print = tprint
16 16
17
18
17 local superTrackQuestID, playerMoney, inScenario, showPOIs 19 local superTrackQuestID, playerMoney, inScenario, showPOIs
18 Quest.Update = function(self, reason, ...) 20 Quest.Update = function(self, reason, ...)
19 local print = tprint 21 local print = self.print
20 print('QuestTracker:Update() received') 22 print('QuestTracker:Update() received')
21 T.UpdateActionButtons() 23 T.UpdateActionButtons()
22 Default.Update(self, reason, ...) 24 Default.Update(self, reason, ...)
23 end 25 end
24 26
25 T.Quest.numButtons = 0 27 T.Quest.numButtons = 0
26 local usedButtons = T.Quest.itemButtons 28 local usedButtons = T.Quest.itemButtons
27 local freeButtons = T.Quest.freeButtons 29 local freeButtons = T.Quest.freeButtons
28 30
29 Quest.UpdateObjectives = function(handler, block) 31 Quest.UpdateObjectives = function(self, block)
30 local print = lprint 32 local print = lprint
31 print('|cFF00FFFFUpdateObjectives()') 33 print('|cFF'..self.internalColor..'UpdateObjectives()')
32 local info = block.info 34 local info = block.info
33 35
34 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)
35 37
38 local displayObjectives = true
36 local block_schema = 'default' 39 local block_schema = 'default'
37 if info.isAccount then 40 if info.isAccount then
38 if info.isFaction then 41 if info.isFaction then
39 print(' faction', info.tagID) 42 print(' faction', info.tagID)
40 block_schema = 'faction_'..info.tagID 43 block_schema = 'faction_'..info.tagID
53 if info.isComplete then 56 if info.isComplete then
54 if info.isAutoComplete then 57 if info.isAutoComplete then
55 local questID, popupType = GetAutoQuestPopUp(info.logIndex) 58 local questID, popupType = GetAutoQuestPopUp(info.logIndex)
56 if popupType == 'COMPLETE' then 59 if popupType == 'COMPLETE' then
57 print(' :: auto-complete quest :: set the message') 60 print(' :: auto-complete quest :: set the message')
58 info.completionText = T.strings.CLICK_TO_COMPLETE 61 self:AddLine(block, T.strings.CLICK_TO_COMPLETE, nil, 'complete')
59 end 62 end
60 else 63 else
61 if not completionText or info.completionText then 64 if not completionText or info.completionText then
62 info.completionText = GetQuestLogCompletionText(info.logIndex) 65 info.completionText = GetQuestLogCompletionText(info.logIndex)
63 end 66 end
64 end 67 end
65 print(' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"') 68 self:AddLine(block, info.completionText, nil, 'complete')
66 end 69 displayObjectives = false
67 70 print('|cFF'..self.internalColor..' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"')
68 Default.UpdateObjectives(handler, block, block_schema) 71 end
72
73 Default.UpdateObjectives(self, block, block_schema, displayObjectives)
69 return block_schema 74 return block_schema
70 end 75 end
71 76
72 Quest.UpdateLine = function(handler, block, line, data) 77 Quest.UpdateLine = function(handler, block, data)
73 local print = lprint
74 local objectiveType = data.type 78 local objectiveType = data.type
75 return data.text, nil, objectiveType 79 return data.text, nil, objectiveType
76 end 80 end
77 81
78 ----------------------------- 82 -----------------------------
128 local blocksChecked = {} 132 local blocksChecked = {}
129 local GetQuestWatchIndex = GetQuestWatchIndex 133 local GetQuestWatchIndex = GetQuestWatchIndex
130 --- Get a total of things to show, and straighten out the index while we're at it 134 --- Get a total of things to show, and straighten out the index while we're at it
131 --- Return the number shown, total in log, and the info table to parse 135 --- Return the number shown, total in log, and the info table to parse
132 Quest.GetNumWatched = function (self, id, added) 136 Quest.GetNumWatched = function (self, id, added)
137 local print = self.print
133 superTrackQuestID = GetSuperTrackedQuestID() 138 superTrackQuestID = GetSuperTrackedQuestID()
134 playerMoney = GetMoney(); 139 playerMoney = GetMoney();
135 inScenario = C_Scenario.IsInScenario(); 140 inScenario = C_Scenario.IsInScenario();
136 showPOIs = GetCVarBool("questPOI"); 141 showPOIs = GetCVarBool("questPOI");
137 local numAll = GetNumQuestLogEntries() 142 local numAll = GetNumQuestLogEntries()
138 local numWatched = GetNumQuestWatches() 143 local numWatched = GetNumQuestWatches()
139 local bottomIndex = 1 144 local bottomIndex = 1
140 print(' |cFF00FF88GetNumWatched:|r',self.name, numWatched, 'of', numAll) 145 print('GetNumWatched', self.name, numWatched, 'of', numAll)
141 local start, limit = 1, numAll 146 local start, limit = 1, numAll
142 147
143 --- start a list of blocks affected by this function 148 --- start a list of blocks affected by this function
144 wipe(blocksChecked) 149 wipe(blocksChecked)
145 if id and not added then 150 if id and not added then
155 160
156 if watchIndex and watchIndex >= bottomIndex then 161 if watchIndex and watchIndex >= bottomIndex then
157 local watchInfo = self.WatchInfo[watchIndex] 162 local watchInfo = self.WatchInfo[watchIndex]
158 local watchBlock = self.WatchBlock[watchIndex] 163 local watchBlock = self.WatchBlock[watchIndex]
159 if watchInfo and watchInfo.questID ~= questID then 164 if watchInfo and watchInfo.questID ~= questID then
160 print(' |cFFBBFF00GetNumWatched: trimming WatchInfo ['..watchIndex..'] =/=', questID) 165 print('GetNumWatched', 'trimming WatchInfo ['..watchIndex..'] =/=', questID)
161 self.WatchInfo[watchIndex] = nil 166 self.WatchInfo[watchIndex] = nil
162 end 167 end
163 if watchBlock and watchBlock.info.questID ~= questID then 168 if watchBlock and watchBlock.info.questID ~= questID then
164 print(' |cFFBBFF00GetNumWatched: trimming WatchBlock ['..watchIndex..'] =/=', watchBlock:GetName()) 169 print('GetNumWatched', 'trimming WatchBlock ['..watchIndex..'] =/=', watchBlock:GetName())
165 self.WatchBlock[watchIndex] = nil 170 self.WatchBlock[watchIndex] = nil
166 tinsert(blocksChecked, watchBlock) 171 tinsert(blocksChecked, watchBlock)
167 end 172 end
168 end 173 end
169 174
181 end 186 end
182 187
183 --- remove any orphaned blocks from view and, if possible, free it for re-use 188 --- remove any orphaned blocks from view and, if possible, free it for re-use
184 for i, block in ipairs(blocksChecked) do 189 for i, block in ipairs(blocksChecked) do
185 if not GetQuestLogIndexByID(block.info.questID, 'player') then 190 if not GetQuestLogIndexByID(block.info.questID, 'player') then
186 print(' |cFFBBFF00GetNumWatched:|r literating a block without an index |cFFBBFF00'.. block:GetName()..'|r') 191 print('GetNumWatched', 'iterating a block without an index |cFFBBFF00'.. block:GetName()..'|r')
187 block:Hide() 192 block:Hide()
188 self:FreeBlock(block) 193 self:FreeBlock(block)
189 end 194 end
190 if not IsQuestWatched(block.info.logIndex) then 195 if not IsQuestWatched(block.info.logIndex) then
191 print(' |cFFBBFF00GetNumWatched:|r hiding untracked quest |cFFBBFF00'.. block:GetName()..'|r') 196 print('GetNumWatched', 'hiding untracked quest |cFFBBFF00'.. block:GetName()..'|r')
192 block:Hide() 197 block:Hide()
193 end 198 end
194 end 199 end
195 200
196 self.numWatched = numWatched 201 self.numWatched = numWatched
205 -- Manifest of line data to be displayed in relation to the tracked object 210 -- Manifest of line data to be displayed in relation to the tracked object
206 Quest.GetInfo = function (self, logIndex, watchIndex) 211 Quest.GetInfo = function (self, logIndex, watchIndex)
207 local print = iprint 212 local print = iprint
208 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex) 213 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
209 if ( not questID ) then 214 if ( not questID ) then
210 tprint(' |cFFFF0088GetInfo:|r', logIndex, watchIndex, '|cFFFF2299no data|r') 215 tprint('GetNumWatched', logIndex, watchIndex, '|cFFFF2299no data|r')
211 return 216 return
212 end 217 end
213 218
214 Quest.Info[questID] = Quest.Info[questID] or {} 219 Quest.Info[questID] = Quest.Info[questID] or {}
215 local q = Quest.Info[questID] 220 local q = Quest.Info[questID]
224 local _ 229 local _
225 _,_,_, numObjectives, requiredMoney, _, _, isAutoComplete, 230 _,_,_, numObjectives, requiredMoney, _, _, isAutoComplete,
226 failureTime, timeElapsed, questType = GetQuestWatchInfo(watchIndex) 231 failureTime, timeElapsed, questType = GetQuestWatchInfo(watchIndex)
227 self.WatchList[watchIndex] = q 232 self.WatchList[watchIndex] = q
228 --tprint(' |cFF88FF00GetInfo:|r set watch entry', watchIndex) 233 --tprint(' |cFF88FF00GetInfo:|r set watch entry', watchIndex)
229 tprint(' |cFFFFBB00GetInfo:|r', logIndex, watchIndex, '|cFFFF2299'..title..'|r') 234 print('GetInfo:', logIndex, watchIndex, '|cFFFF2299'..title..'|r')
230 end 235 end
231 self.LogInfo[logIndex] = q 236 self.LogInfo[logIndex] = q
232 237
233 q.numObjectives = numObjectives 238 q.numObjectives = numObjectives
234 q.requiredMoney = requiredMoney 239 q.requiredMoney = requiredMoney
266 questFailed = false 271 questFailed = false
267 if ( requiredMoney == 0 ) then 272 if ( requiredMoney == 0 ) then
268 isBreadcrumb = true; 273 isBreadcrumb = true;
269 end 274 end
270 end 275 end
271 print('|cFF0088FFflags:|r', (isComplete and 'isComplete' or ''), (questFailed and 'questFailed' or ''), (isBreadcrumb and 'isBreadcrumb' or '')) 276 print('QuestFlags', (isComplete and 'isComplete' or ''), (questFailed and 'questFailed' or ''), (isBreadcrumb and 'isBreadcrumb' or ''))
272 277
273 -- completion message? 278 -- completion message?
274 local isSequenced = IsQuestSequenced(questID) 279 local isSequenced = IsQuestSequenced(questID)
275 local temp_status = '' 280 local temp_status = ''
276 if ( isComplete ) then 281 if ( isComplete ) then
472 q.watchIndex = watchIndex 477 q.watchIndex = watchIndex
473 q.id = questID 478 q.id = questID
474 q.schema = schema 479 q.schema = schema
475 480
476 if Devian and Devian.InWorkspace() then 481 if Devian and Devian.InWorkspace() then
477 print('|cFF00DDFFstatus:|r', temp_status, '|cFF00FF00questLogIndex|r:', logIndex, title) 482 print('QuestStatus', temp_status, '|cFF00FF00questLogIndex|r:', logIndex, title)
478 local temp ={} 483 local temp ={}
479 local data_txt = '|cFFFF4400values:|r' 484 local data_txt = '|cFF'..self.internalColor..'values:|r'
480 for k,v in pairs(q) do 485 for k,v in pairs(q) do
481 if type(v) =='number' then 486 if type(v) =='number' then
482 data_txt = data_txt .. ' |cFFFFFF00'..k..'|r: ' .. tostring(v) 487 data_txt = data_txt .. ' |cFFFFFF00'..k..'|r: ' .. tostring(v)
483 elseif type(v) == 'table' then 488 elseif type(v) == 'table' then
484 tinsert(temp, k) 489 tinsert(temp, k)
485 end 490 end
486 end 491 end
487 print(data_txt) 492 print('DataStatus',data_txt)
488 sort(temp, function(a,b) return a < b end) 493 sort(temp, function(a,b) return a < b end)
489 for i, k in ipairs(temp) do 494 for i, k in ipairs(temp) do
490 print('|cFF00FF00'..k..'|r') 495 iprint('GetInfo', questID, ''..k..'|r')
491 for kk,v in pairs(q[k]) do 496 for kk,v in pairs(q[k]) do
492 print(' ', kk, '=', v) 497 iprint('GetInfo', questID, kk, '=', v)
493 end 498 end
494 end 499 end
495 end 500 end
496 501
497 return q 502 return q
498 end 503 end
499 504
500 Quest.GetObjectives = function(logIndex, numObjectives, isComplete, isSequenced, isStory) 505 Quest.GetObjectives = function(logIndex, numObjectives, isComplete, isSequenced, isStory)
506 local print = Quest.print
501 local objectives = {} 507 local objectives = {}
502 for i = 1, numObjectives do 508 for i = 1, numObjectives do
503 local text, type, finished = GetQuestLogLeaderBoard(i, logIndex) 509 local text, type, finished = GetQuestLogLeaderBoard(i, logIndex)
504 print(format(' |cFFFF4400GetObjectives:|r #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished))) 510 print('GetObjectives', format('|cFF88FF88#%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)))
505 objectives[i] = { 511 objectives[i] = {
506 index = i, 512 index = i,
507 type = type, 513 type = type,
508 text = text, 514 text = text,
509 finished = finished 515 finished = finished