Mercurial > wow > buffalo2
diff ObjectiveTracker/BonusObjectives.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 | 03ed70f846de |
line wrap: on
line diff
--- a/ObjectiveTracker/BonusObjectives.lua Mon Apr 18 07:56:23 2016 -0400 +++ b/ObjectiveTracker/BonusObjectives.lua Thu Apr 21 11:36:41 2016 -0400 @@ -13,27 +13,25 @@ local UnitName, GetRealmName, GetQuestObjectiveInfo, GetTasksTable, GetTaskInfo = UnitName, GetRealmName, GetQuestObjectiveInfo, GetTasksTable, GetTaskInfo local GetMapNameByID, GetCurrentMapAreaID = GetMapNameByID, GetCurrentMapAreaID -local tinsert, ipairs, pairs, tostring = tinsert, ipairs, pairs, tostring +local tinsert, ipairs, pairs, tostring, wipe = tinsert, ipairs, pairs, tostring, table.wipe local GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime = GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime -local STICKY_TASKS = true +local TASK_DISPLAY_TEST = 1 -- 1: normal (is nearby or on the map) 2: strict (is nearby) 3: data exists --- Returns a tasks table modified to include recently completed objectives local InternalGetTasksTable = function() + local print = Bonus.print local savedTasks = T.Conf.TasksLog local char = UnitName("player") local realm = GetRealmName() local tasks = GetTasksTable() for questID, data in pairs(Bonus.Info) do - - print(' -- questID:', questID, #data.objectives) + print('GetTasksTable', questID, #data.objectives) for i, o in ipairs(data.objectives) do - print(' --', i, o.text) + print('GetTasksTable', questID, i, o.text) end - end - for questID, data in pairs(savedTasks) do if questID > 0 then local found = false @@ -85,25 +83,36 @@ Bonus.Scenario = {} Bonus.QuestBlock = {} Bonus.WatchInfo = {} + +local function CanShowTask(isInArea, isOnMap, existingTask, numObjectives) + if TASK_DISPLAY_TEST == 1 then + return (isInArea) + elseif TASK_DISPLAY_TEST == 2 then + return (isInArea and(isOnMap and existingTask)) + elseif TASK_DISPLAY_TEST == 3 then + return true + end +end + function Bonus:GetNumWatched () - if true then return 0, 0, nil end - local print = iprint + + local print = self.print print(self.name, self) local tasks = InternalGetTasksTable() local numWatched = 0 local numAll = 0 local existingTasks = {} - self.WatchInfo = {} - print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) - print(' |cFF00FFFFInternalGetTaskInfo|r:') + wipe(self.WatchList) + print('|cFF'..self.internalColor..'Bonus.GetNumWatched()|r', #tasks) + print('InternalGetTaskInfo') + for i, questID in ipairs(tasks) do local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) - local existingTask = self.QuestBlock[questID] + local existingTask = self.InfoBlock[questID] local displayObjectiveHeader = false; - local test = (isInArea or (isOnMap and existingTask)) - --local test = true - if test then + if CanShowTask(isInArea, isOnMap, existingTask) then + print('TaskInfo', '|cFF00FF00showable objective list', questID) self.Info[questID] = self.Info[questID] or {} local t = self.Info[questID] @@ -111,10 +120,11 @@ t.areaID = GetCurrentMapAreaID() local _ t.mapName, _, _, t.isMicroDungeon, t.microDungeonMapName = GetMapInfo() - print('|cFF00FF00scooping map info (questID '..questID..'):|r', t.areaID, t.mapName) + print('InternalGetTaskInfo', 'map data', t.areaID, t.mapName) end local taskTitle + t.id = questID t.objectives = {} local taskFinished = true; for objectiveIndex = 1, numObjectives do @@ -128,7 +138,7 @@ end - print(' --', text, objectiveType, finished, displayAsObjective) + print('TaskObjective', text, objectiveType, finished, displayAsObjective) t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {} local o = t.objectives[objectiveIndex] @@ -155,26 +165,24 @@ t.id = questID t.taskIndex = i t.title = taskTitle - self.WatchInfo[i] = t + self.WatchList[i] = t + elseif existingTask then + print('TaskInfo', '|cFFFF4400hideable task', questID) + existingTask:Hide() end - print (' |cFF00FF88#', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r')) + print ('TaskInfo', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r')) end - for i = 1, #self.usedBlocks do - self.usedBlocks[i]:Hide() - end - - self.numAll = #tasks - self.numWatched = #self.WatchInfo - print(' stats:', self.numAll, 'active tasks,', self.numWatched, 'nearby or animating') - --return #tasks - return #self.WatchInfo + self.numWatched = #self.WatchList + self.numAll = #existingTasks + return self.numWatched, self.numWatched, self.WatchList end --- info cleanup done when turn-ins are detected Bonus.OnTurnIn = function(self, block, questID, xp, money) + --[=[ local info = self.Info[questID] if info.rewardInfo and #info.rewardInfo >= 1 then for i, reward in ipairs(info.rewardInfo) do @@ -218,6 +226,7 @@ end print('adding', info.title, 'to cache') + --]=] end Bonus.GetInfo = function(self, taskIndex) @@ -228,20 +237,26 @@ --- Update hooks -Bonus.UpdateObjectives = function(handler, block) +Bonus.UpdateObjectives = function(handler, block, blockSchema) + block.schema = blockSchema or 'default' + local info = block.info + block.title:SetText(info.title) + + Default.UpdateObjectives(handler, block) - return 'default' + return blockSchema end -Bonus.UpdateLine = function(handler, block, line, data) +Bonus.UpdateLine = function(handler, block, data) local info = block.info local print = lprint local text, attachment = '', nil - line.displayColor = 'FFFFFF' if data.type == 'progressbar' then print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) local percent = 100 - attachment = T.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.index) + attachment = T.GetWidget(data, 'StatusBar', info.questID..'-'..data.index) + attachment:SetParent(block) + if not data.finished then percent = GetQuestProgressBarPercent(info.questID) end @@ -256,14 +271,13 @@ attachment.value = percent attachment.maxValue = 100 - attachment:SetPoint('TOP', line, 'TOP', 0, 0) attachment.status:SetFormattedText(PERCENTAGE_STRING, percent) - attachment:SetParent(handler.frame) - print(attachment.status:GetText()) + --attachment:SetParent(handler.frame) + --print(attachment.status:GetText()) print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) end text = data.text - return text, attachment + return text, attachment, 'default' end Bonus.Select = function(handler, block)