Mercurial > wow > buffalo2
view ObjectiveTracker/AchievementData.lua @ 53:5cedcb683eda
more consolidate buffs fixing
author | Nenue |
---|---|
date | Fri, 29 Apr 2016 17:06:48 -0400 |
parents | 9480bd904f4c |
children |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 4/13/2016 7:48 PM local B = select(2,...).frame local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local band = bit.band local RemoveTrackedAchievement, GetAchievementLink = RemoveTrackedAchievement, GetAchievementLink local AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement = AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement local GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo = GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo local GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo = GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo local Default, Cheevs = T.DefaultHandler, T.Cheevs local wipe = table.wipe local print, bprint, lprint, iprint = B.print('Tracker'), B.print('Block'), B.print('Line'), B.print('iprint') --- Frame data Cheevs.UpdateObjectives = function(handler, block, block_schema) -- if completed on another character, only show the heading for CHATLINK if block.info.completed then return 0, block_schema end if block.info.description then handler:AddLine(block, block.info.description, nil, 'defalut') end local attachments = Default.UpdateObjectives(handler, block, block_schema) return attachments, block_schema end Cheevs.UpdateLine = function(handler, block, data) local print = lprint local attachment local text local lineSchema = 'default' print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text) if data.type == CRITERIA_TYPE_ACHIEVEMENT then if data.value == 1 then return nil, nil end text = data.text lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement' elseif band(data.flags, 0x00000001) > 0 then attachment = T.GetWidget(data, 'StatusBar', data.criteriaID) attachment.format = "%d/%d" attachment.value = data.value attachment.maxValue = data.maxValue attachment:SetParent(block) print(attachment:GetNumPoints()) for i = 1, attachment:GetNumPoints() do print(' ',attachment:GetPoint(i)) end attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) attachment:SetPoint('TOP', line, 'TOP') lineSchema = 'progressbar' else text = format("%d/%d %s", data.value, data.maxValue, data.text) lineSchema = 'default' end print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) return text, attachment, lineSchema end Cheevs.Select = function(self, block) Cheevs.Link(self, block) T:Update(self.updateReasonModule, block.info.cheevID) end Cheevs.Remove = function(self, block) RemoveTrackedAchievement(block.info.cheevID) end Cheevs.OnMouseUp = function(self, button) Default.OnMouseUp(self, button) end Cheevs.Link = function(self, block) local achievementLink = GetAchievementLink(block.info.cheevID); if ( achievementLink ) then _G.ChatEdit_InsertLink(achievementLink); end end --- Data accessors Cheevs.GetNumWatched = function(self, targetID, isNew) local trackedList = {GetTrackedAchievements() } local numWatched, numAll = #trackedList, #self.WatchList print(' |cFF'..self.internalColor..'GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)') local start = 1 local limit = max(numAll, #trackedList) if targetID then if not isNew and self.Info[targetID] then -- if it's only an update, we can limit the scope start = self.Info[targetID].watchIndex print(' |cFF'..self.internalColor..'GetNumWatched: limit selection to['..start..'-'..limit..']') if self.InfoBlock[targetID] then self.InfoBlock[targetID]:Hide() end end end for index = start, limit do if index > numWatched then self.WatchList[index] = nil print(' % dropping watch entry #'..index) else local cheevID = trackedList[index] if not self.Info[cheevID] then self.Info[cheevID] = self:GetInfo(cheevID, index) else print(' |cFF'..self.internalColor..'GetInfo:', cheevID, 'already pulled') end self:GetObjectives(cheevID) local info = self.Info[cheevID] local watchBlock = self.WatchBlock[cheevID] self.Info[cheevID].watchIndex = index self.WatchList[index] = info end end numAll = #self.WatchList return numWatched, numAll, self.WatchList end Cheevs.GetInfo = function(self, cheevID, watchIndex) --- step 1: confirm primary data and begin an entry if needed local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) if not id then return nil end print(' |cFF'..self.internalColor..'GetInfo: pulling', id..',', name, earnedBy) self.Info[cheevID] = self.Info[cheevID] or {} local c = self.Info[cheevID] local rewards = {} c.schema = 'achievement' c.rewardInfo = rewards c.type = 'Cheevs' c.title = name c.points = points c.completed = completed c.month = month c.day = day c.year = year c.description = description c.flags = flags c.icon = icon c.rewardText = rewardText c.isGuildAch = isGuildAch c.wasEarnedByMe = wasEarnedByMe c.earnedBy = earnedBy local tagInfo = {} c.tagInfo = tagInfo c.watchIndex = watchIndex c.id = cheevID c.cheevID = cheevID self.Info[cheevID] = c self.WatchInfo[watchIndex] = c return c end Cheevs.GetObjectives = function(self, cheevID) local c = self.Info[cheevID] c.numObjectives = GetAchievementNumCriteria(cheevID) c.objectives = c.objectives or {} for i = 1, c.numObjectives do local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) local line = c.objectives[i] or {} line.objectiveIndex = i line.cheevID = cheevID line.text = description line.type = type line.finished = completed line.value = quantity line.maxValue = requiredQuantity line.characterName = characterName line.flags = flags line.assetID = assetID line.quantityString = quantityString line.criteriaID = criteriaID c.objectives[i] = line print(' |cFF'..self.internalColor..'GetObjectives:|r', i, format('|cFF0088FF%02X|r(%d)', type, type), format('|cFF88FF00%01X|r', flags or 0), '|cFF00FF00'..tostring(quantity)..'|r/|cFF00FF00'.. tostring(requiredQuantity)..'|r', '"|cFF88FF00'..tostring(description)..'|r"') end end Cheevs.Open = function(self, block) if ( not _G.AchievementFrame ) then _G.AchievementFrame_LoadUI(); end if ( not _G.AchievementFrame:IsShown() ) then _G.AchievementFrame_ToggleAchievementFrame(); end _G.AchievementFrame_SelectAchievement(block.info.cheevID); end