view ObjectiveTracker/BonusObjectives.lua @ 27:c3aa94bc6be2

collating module-specific function into their own files and dropping the UI and Style scripts
author Nenue
date Wed, 13 Apr 2016 20:18:50 -0400
parents
children adcd7c328d07
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 _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
local Default, Quest = T.DefaultHandler, T.Quest
local format = format
local print = B.print('Tracker')
local lprint = B.print('Line')
local iprint = B.print('Info')
local Bonus = mod.Bonus


--- Module-specific data wrangling that has to happen during UpdateBlock()
-- Most of this is sculpting objectives data into a parsible list.
-- Some of it is additional block manipulation that doesn't quite fit with the other modules..
Bonus.UpdateObjectives = function(handler, block)
  Default.UpdateObjectives(handler, block)
end



Bonus.UpdateLine = function(handler, block, line, data)
  local info = block.info
  local print = lprint


  line.displayColor = 'FFFFFF'
  line.displayText = data.text
  line.progress = 0
  print('  ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text)
  if data.objectiveType == 'progressbar' then
    line.widgetType = 'ProgressBar'
    print('    |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID)))
    data.value = GetQuestProgressBarPercent(info.questID) or 0
    data.maxValue = 100
    if  data.value >= data.maxValue then
      line.progress = 1
    elseif data.value > 0 then
      line.progress = 2
    end
    line.format = PERCENTAGE_STRING
    local widget = T.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex)
    print('    |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue)
    widget:SetPoint('TOP', line, 'TOP', 0, 0)

    line.widget = widget
    line.height = widget.height
  else
    line.displayText = data.text
    line.widget = nil
  end
  return line
end

Bonus.Select = function(self)

  Bonus:OnTurnIn(self.info.questID)
end
Bonus.Remove = function(self)

end