Mercurial > wow > buffalo2
diff ObjectiveTracker/Quests.lua @ 39:92534dc793f2
- restore the previous QuestLogSelection after pulling for selection-restricted quest data; fixes icon mixups while quest map is open
- moved progressbar builders into the schema environment, with all the other Frame.lua functions; prep for configuration access
- relegate the various removal events to a framescript in their corresponding blocks; this takes care of resolving dead frames
author | Nenue |
---|---|
date | Thu, 21 Apr 2016 16:43:37 -0400 |
parents | 1f8f9cc3d956 |
children | 03ed70f846de |
line wrap: on
line diff
--- a/ObjectiveTracker/Quests.lua Thu Apr 21 11:36:41 2016 -0400 +++ b/ObjectiveTracker/Quests.lua Thu Apr 21 16:43:37 2016 -0400 @@ -124,9 +124,19 @@ tremove(used, info.posIndex) tinsert(free, block) end +end +Quest.OnRemoved = function(block) end + +Quest.GetBlock = function(self, index) + local block = Default.GetBlock(self, index) + block:SetScript('OnEvent', Quest.OnRemoved) + block:RegisterEvent('QUEST_REMOVED') + return block +end + local watchesChecked = {} local infosChecked = {} local blocksChecked = {} @@ -304,6 +314,7 @@ -- Case 3: quest in progress -- * Multiple objective lines -- * Possible extra lines for money and timer data respectively + self.print(' QuestInfo', title, questType, isAutoComplete) objectives = Quest.GetObjectives(logIndex, numObjectives, false, isSequenced, isStory) q.objectives = objectives @@ -505,14 +516,33 @@ Quest.GetObjectives = function(logIndex, numObjectives, isComplete, isSequenced, isStory) local print = Quest.print local objectives = {} + if not logIndex then + return + end + for i = 1, numObjectives do local text, type, finished = GetQuestLogLeaderBoard(i, logIndex) - print('GetObjectives', format('|cFF88FF88#%d %s %s %s', i, tostring(type), tostring(text), tostring(finished))) + + local progress = 0 + if finished then + progress = 1 + elseif text then + local quantity, maxQuantity = text:match('^(%d+)/(%d+)') + if quantity and maxQuantity then + progress = quantity / maxQuantity + --print('GetObjectives', 'calculated objective progress:', quantity, '/', maxQuantity, '=', progress) + end + end + + print('GetObjectives', format('|cFF88FF88#%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)), '('.. tostring(progress)..')') + + objectives[i] = { index = i, type = type, text = text, - finished = finished + finished = finished, + progress = progress } end return objectives