view ObjectiveTracker/AutoQuestPopups.lua @ 37:e84d645c8ab8

- revised the tracker update function to build its complete data list up front and use the values as points of comparison for determining possible out of place blocks, which will be iterated over afterward to remove what wasn't re-used - also entailed revising the exact role of global event handlers and function hooks, limiting their directions of communication so one doesn't end up calling the other multiple or inifinity times - schema handling polish
author Nenue
date Mon, 18 Apr 2016 07:56:23 -0400
parents 9856ebc63fa4
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 ()
  if true then return 0, 0, nil end
  print(self.name, self)
  --Quest:GetNumWatched()
  self.numWatched = GetNumAutoQuestPopUps()

  return self.numWatched
end
AutoQuest.GetInfo = function(self, popupIndex)


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

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

  self.Info[questID] = popup
  self.WatchInfo[popupIndex] = 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