view ObjectiveTracker/AutoQuestPopupData.lua @ 55:dd9b5f59632c v1.0a-release

Core - updated comment notes Objectives - force hide blocks when their tracker is hidden Clock - convert clock into its own module - display zone coordinates alongside time
author Nenue
date Fri, 10 Jun 2016 20:52:27 -0400
parents dd1ae565f559
children
line wrap: on
line source
--- ${PACKAGE_NAME}
-- @file-author@
-- @project-revision@ @project-hash@
-- @file-revision@ @file-hash@
-- Created: 4/13/2016 7:49 PM
local B = select(2,...).frame
local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
local print = B.print('Info')
local lprint = B.print('Line')
local AutoQuest, Quest = T.AutoQuest, T.Quest
local ShowQuestOffer, ShowQuestComplete, RemoveAutoQuestPopUp = ShowQuestOffer, ShowQuestComplete, RemoveAutoQuestPopUp
local GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetQuestLogIndexByID, GetQuestLogTitle = GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetQuestLogIndexByID, GetQuestLogTitle
--- Data retrieval
function AutoQuest:GetNumWatched ()
  local numWatched = GetNumAutoQuestPopUps()
  local numAll = numWatched

  self.print('GetNumWatched', numWatched, 'popups detected')
  for i = 1, numWatched do
      self:GetInfo(i)
  end

  for i, block in ipairs(self.usedBlocks) do
    if not GetAutoQuestPopUp(block.info.id) then
      self:FreeBlock(block)
    end
  end

  self.numWatched = numWatched
  self.WatchList = self.Info
  return numWatched
end
AutoQuest.GetInfo = function(self, index)


  local questID, type = GetAutoQuestPopUp(index)
  local questLogIndex = GetQuestLogIndexByID(questID)
  local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questLogIndex)

  self.Info[index] = self.Info[index] or {}
  local popup = self.Info[index]
  popup.questID = questID
  popup.id = index
  popup.title = title
  popup.description = type
  popup.popupType = type
  popup.logIndex = questLogIndex

  self.Info[questID] = popup
  self.WatchInfo[index] = popup


  return self.Info[questID]
end

AutoQuest.UpdateObjectives = function(handler, block)
  local print = lprint
  if block.info.type == 'OFFER' then
    block.status:SetText(T.strings.CLICK_TO_ACCEPT)
  end
end

AutoQuest.Select = function(handler, block)

  if block.info.popupType == 'OFFER'  then
    ShowQuestOffer(block.info.logIndex)
  else
    ShowQuestComplete(block.info.logIndex)
  end
  RemoveAutoQuestPopUp(block.info.questID)
end

AutoQuest.Link = T.Quest.Link