view ObjectiveTracker/AutoQuestPopupData.lua @ 45:dd1ae565f559

Hooks and Handlers: - correct argument mix-ups for AcceptQuest/QUEST_ACCEPTED handlers; fixes auto-watch - respond to AcknowledgeAutoAcceptQuest; fixes lingering popups - include Popup and Quest trackers in the response code for CompleteQuest; fixes content artifacts following the rollover of repeating popups seen in Ashran - clean up wacky OnEvent header Layout - add alpha blend options QuestData - reset objectives data when a quest is in a completed state; keeps old data from ever reaching the Default.x code
author Nenue
date Tue, 26 Apr 2016 14:57:18 -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: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