# HG changeset patch # User Nenue # Date 1460754066 14400 # Node ID 64f2a9bbea79a0733aaafb2544f057ba345b427a # Parent a3afe6c3771e929da5a96a2b31d4cf053fb88bc9 - implementing structural revisions in bonus objectives - prevent instances of nil arithmetic - decide on where to keep style values - start widgets with dummy values for operability diff -r a3afe6c3771e -r 64f2a9bbea79 ObjectiveTracker/BonusObjectives.lua --- a/ObjectiveTracker/BonusObjectives.lua Fri Apr 15 07:01:40 2016 -0400 +++ b/ObjectiveTracker/BonusObjectives.lua Fri Apr 15 17:01:06 2016 -0400 @@ -8,16 +8,14 @@ local Default, Quest = T.DefaultHandler, T.Quest local print = B.print('Tracker') local lprint = B.print('Line') +local iprint = B.print('Info') local Bonus = T.Bonus 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 GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo -local GetNumQuestLogRewards, GetQuestLogRewardInfo = GetNumQuestLogRewards, GetQuestLogRewardInfo -local GetQuestLogRewardMoney, GetMoneyString = GetQuestLogRewardMoney, GetMoneyString local GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime = GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime - +local STICKY_TASKS = true --- Returns a tasks table modified to include recently completed objectives local InternalGetTasksTable = function() @@ -88,11 +86,13 @@ Bonus.QuestBlock = {} Bonus.WatchInfo = {} function Bonus:GetNumWatched () + local print = iprint print(self.name, self) local tasks = InternalGetTasksTable() local numWatched = 0 local numAll = 0 + local existingTasks = {} self.WatchInfo = {} print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) print(' TasksTable pull:') @@ -106,19 +106,15 @@ self.Info[questID] = self.Info[questID] or {} local t = self.Info[questID] - self.WatchInfo[i] = t - t.isInArea = isInArea - t.isOnMap = isOnMap - t.existingTask = existingTask - t.questID = questID - t.id = questID - t.objectives = {} - t.taskIndex = i - - - T.SetRewards(t, questID) + if (isOnMap or isInArea) and existingTask then + t.areaID = GetCurrentMapAreaID() + local _ + t.mapName, _, _, t.isMicroDungeon, t.microDungeonMapName = GetMapInfo() + print('|cFF00FF00scooping map info (questID '..questID..'):|r', t.areaID, t.mapName) + end local taskTitle + t.objectives = {} local taskFinished = true; for objectiveIndex = 1, numObjectives do local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false); @@ -143,13 +139,23 @@ print(' |cFF00FF88*', objectiveIndex, text) end + T.SetRewards(t, questID) + -- didn't get a name from progress bar? what about area name if not taskTitle then if isInArea then taskTitle = GetMapNameByID(GetCurrentMapAreaID()) end end + + t.isInArea = isInArea + t.isOnMap = isOnMap + t.existingTask = existingTask + t.questID = questID + t.id = questID + t.taskIndex = i t.title = taskTitle + self.WatchInfo[i] = t end print (' |cFF00FF88#', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r')) @@ -164,10 +170,10 @@ end --- info cleanup done when turn-ins are detected -Bonus.OnTurnIn = function(self, questID, xp, money) - - if #self.info.rewardInfo >= 1 then - for i, reward in ipairs(self.info.rewardInfo) do +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 --[[ type = 'item', index = i , @@ -182,13 +188,15 @@ end end - print('|cFFFF8800'..self.name..':OnTurnIn call', questID, xp, money) + print('|cFFFF8800'..block.name..':OnTurnIn call', questID, xp, money) local savedTasks = B.Conf.TasksLog - self.Info[questID].completedTime = GetTime() - self.Info[questID].animate = true - T.SetAnimate(self.watchReasonModule) - savedTasks[questID] = self.Info[questID] + info.completedTime = GetTime() + info.animate = true + T.SetAnimate(handler.watchReasonModule) + savedTasks[questID] = info + + print('adding', info.title, 'to cache') end Bonus.GetInfo = function(self, taskIndex) @@ -203,7 +211,7 @@ Default.UpdateObjectives(handler, block) end -Bonus.UpdateLine = function(handler, objectiveType, line, data) +Bonus.UpdateLine = function(handler, block, line, data) local info = block.info local print = lprint local text, attachment = '', nil @@ -211,11 +219,15 @@ print(' ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text) if data.objectiveType == 'progressbar' then print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) - data.value = GetQuestProgressBarPercent(info.questID) or 0 - data.maxValue = 100 + local percent = 100 attachment = T.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex) + if not data.finished then + percent = GetQuestProgressBarPercent(info.questID) + end + attachment.value = percent + attachment.maxValue = 100 attachment:SetPoint('TOP', line, 'TOP', 0, 0) - attachment.status:SetFormattedText(PERCENTAGE_STRING, (data.value / data.maxValue)) + attachment.status:SetFormattedText(PERCENTAGE_STRING, (percent / 100)) print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) else text = data.text @@ -223,8 +235,9 @@ return text, attachment end -Bonus.Select = function(self) - Bonus:OnTurnIn(self.info.questID) +Bonus.Select = function(handler, block) + print(handler, block) + handler:OnTurnIn(block, block.info.questID) end Bonus.Remove = function(self) diff -r a3afe6c3771e -r 64f2a9bbea79 ObjectiveTracker/Frame.lua --- a/ObjectiveTracker/Frame.lua Fri Apr 15 07:01:40 2016 -0400 +++ b/ObjectiveTracker/Frame.lua Fri Apr 15 17:01:06 2016 -0400 @@ -57,7 +57,7 @@ text = {.5,.75,1}, }, completed = { - text = {1,0,.1} + text = {0, 1, 0} }, failed = { text = {1,0,0 } @@ -147,9 +147,10 @@ -- For progressbar and timer lines, status text may be used as the title heading if attachment then local widgetOffset = 0 + line.height = attachment:GetHeight() + textSpacing if text and #text >= 1 then widgetOffset = line.status:GetHeight() + textSpacing - line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + attachment.height + line.height = line.height + floor(line.status:GetStringHeight()+.5) + textSpacing print(' |cFFFF0088doing things with captioned widget') else print(' |cFFFF0088doing things with a widget') @@ -229,6 +230,7 @@ block.title:SetSpacing(c.TitleSpacing) block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) + block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0) block.titlebg:SetTexture(1,1,1,1) block.titlebg:SetGradientAlpha(unpack(titlebg)) @@ -541,9 +543,9 @@ local numCurrency = 0 for i, rewardTile in ipairs(block.rewardTile) do - local reward = info.rewardInfo[i] - if reward then - --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2) + if info.rewardInfo and info.rewardInfo[i] then + local reward = info.rewardInfo[i] + --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2) rewardTile:SetTexture(reward.texture) rewardTile:Show() @@ -608,7 +610,7 @@ if (info.isComplete or info.numObjectives == 0) and info.completionText then print(' overriding line #1 for completion text:', info.completionText) text = info.completionText - handler:AddLine(block, text, nil) + handler:AddLine(block, text, nil, 'completed') else if info.objectives then for i, data in ipairs(info.objectives) do diff -r a3afe6c3771e -r 64f2a9bbea79 ObjectiveTracker/ObjectiveTracker.lua --- a/ObjectiveTracker/ObjectiveTracker.lua Fri Apr 15 07:01:40 2016 -0400 +++ b/ObjectiveTracker/ObjectiveTracker.lua Fri Apr 15 17:01:06 2016 -0400 @@ -127,7 +127,9 @@ Width = WRAPPER_WIDTH, HeaderHeight = WRAPPER_HEADER_HEIGHT, TextSpacing = 3, + TextIndent = 4, TitleSpacing = 3, + TitleIndent = 4, } @@ -304,7 +306,6 @@ return OBJECTIVE_TRACKER_UPDATE_QUEST end Event.ZONE_CHANGED = function() - local inMicroDungeon = IsPlayerInMicroDungeon(); if ( inMicroDungeon ~= T.inMicroDungeon ) then if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then @@ -313,6 +314,7 @@ --SortQuestWatches(); T.inMicroDungeon = inMicroDungeon; end + return OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE + OBJECTIVE_TRACKER_UPDATE_MODULE_SCENARIO end Event.QUEST_AUTOCOMPLETE = function(questId) AddAutoQuestPopUp(questId, "COMPLETE"); @@ -534,7 +536,7 @@ ObjectiveTrackerFrame:UnregisterAllEvents() ObjectiveTrackerFrame:Hide() - + _G.MinimapCluster:Hide() for id, name in ipairs(T.orderedNames) do if not T.orderedHandlers[id] then diff -r a3afe6c3771e -r 64f2a9bbea79 ObjectiveTracker/Widgets.lua --- a/ObjectiveTracker/Widgets.lua Fri Apr 15 07:01:40 2016 -0400 +++ b/ObjectiveTracker/Widgets.lua Fri Apr 15 17:01:06 2016 -0400 @@ -308,13 +308,17 @@ wr[widgetType].lastn = wr[widgetType].lastn + 1 end end - --- WidgetTemplate 'OnShow' +local wrapperWidth, textIndent T.InitializeWidget = setmetatable({}, { __call = function(t, frame) -- todo: config pull + if not wrapperWidth then + wrapperWidth = T.Conf.Wrapper.Width + textIndent = T.Conf.Wrapper.TextIndent + end - frame:SetWidth(T.Conf.Wrapper.Width - T.Conf.Style.Format.status.Indent * 2) + frame:SetWidth(wrapperWidth - textIndent * 2) frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType]) frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE') frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED') @@ -394,6 +398,8 @@ self.height = progressHeight + c.TextSpacing self.width = c.Width - c.TextSpacing self.indent = progressIndent + self.value = 1 + self.maxValue = 1 self:SetHeight(progressHeight) self.bg:SetHeight(progressHeight) @@ -406,7 +412,7 @@ end T.UpdateWidget.ProgressBar = function (self) - local quantity, requiredQuantity = self.objective.value, self.objective.maxValue + local quantity, requiredQuantity = self.value, self.maxValue print('update vals:') for k,v in pairs(self.line) do print(k, v)