view ObjectiveEvents.lua @ 19:605e8f0e46db

ObjectiveCore / Style / Events / Frame - polishing the execution path for better performance - make use of the Blizzard_ObjectiveTracker bitfield values to ensure compatibility in possible secure hooks - avoid full updates when possible (using said bitfield values to indicate targeted sections) - extreme streamlining of event handling layout: specific reason updates are invoked from API hooks; broader updates are invoked by when the event listener catches something vague like 'QUEST_LOG_UPDATE'
author Nenue
date Wed, 06 Apr 2016 07:38:35 -0400
parents 880828018bf4
children 6bd2102d340b
line wrap: on
line source
--- ${PACKAGE_NAME}
-- @file-author@
-- @project-revision@ @project-hash@
-- @file-revision@ @file-hash@
-- Created: 3/30/2016 1:23 AM
local B = select(2,...).frame
local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
local print = B.print('Objectives')

--------------------------------------------------------------------
--- Events that are handled by Blizzard_ObjectiveTracker
--------------------------------------------------------------------

-------------------------------------------------------------------
--- Function hooks for BlizzUI compatibility
-------------------------------------------------------------------
mod.AddQuestWatch = function(questID)
    mod:Update(0x00000003)
end

mod.RemoveQuestWatch = function(questIndex, ...)
  print('|cFFFF8800RemoveQuestWatch', questIndex, ...)
  local info = mod.Quest.LogInfo[questIndex]

  -- remove quest refs
  mod.Quest.LogBlock[questIndex] = nil
  mod.Quest.QuestBlock[info.questID] = nil

  -- remove if they still match
  if mod.Quest.WatchInfo[info.watchIndex] == info then
    print('cleaning dead WatchInfo entry')
    mod.Quest.WatchInfo[info.watchIndex] = nil
  end
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST)
end

mod.AddTrackedAchievement = function(cheevID)
  mod.CleanWidgets()
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT)
end


mod.RemoveTrackedAchievement = function(cheevID)
  print('|cFFFF8800UntrackAchievement', cheevID)
  mod.CleanWidgets()
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT)
end

mod.AcceptQuest = function()
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST_ADDED)
end

mod.AbandonQuest = function()
  QuestPOIUpdateIcons()
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST)
end
mod.TurnInQuest = function()
  QuestPOIUpdateIcons()
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST)
end
mod.AddAutoQuestPopUp = function(...)
   mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP)
end
mod.RemoveAutoQuestPopUp = function(...)
  mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP)
end

mod.SetSuperTrackedQuestID = function(questID)
  mod:Update()
end