annotate ObjectiveEvents.lua @ 9:2698173edd40

ObjectiveUI & ObjectiveEvents - securehook to API calls for compatibility with addons that work with the objective tracking interface - let the API hooks invoke ObjectiveUI functions when possible - ObjectiveUI framescript handlers should use the corresponding API call if possible, so that addon space can be fully aware of our actions - Sanity check cached data when possible during 'Remove' hooks ObjectiveInfo - Add cheevID to criteria info ObjectiveCore - Index quest tracker blocks by their watch offset, and use that to verify whether the given block frame should be released into pool ObjectiveFrame - Differentiate between visible and non-visible unused buttons, and only release when their quest has been dropped - Reset 'actualBlocks' count during full updates - Reset scroll Position when the wrapper size shrinks
author Nenue
date Fri, 01 Apr 2016 14:54:01 -0400
parents 7923243ae972
children 880828018bf4
rev   line source
Nenue@1 1 --- ${PACKAGE_NAME}
Nenue@1 2 -- @file-author@
Nenue@1 3 -- @project-revision@ @project-hash@
Nenue@1 4 -- @file-revision@ @file-hash@
Nenue@1 5 -- Created: 3/30/2016 1:23 AM
Nenue@1 6 local B = select(2,...).frame
Nenue@1 7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@1 8 local print = B.print('ObjectiveEvent')
Nenue@1 9
Nenue@6 10 local isHooked
Nenue@6 11 local SmallEvents = {
Nenue@6 12 QUEST_ACCEPTED = 'OnQuestAccepted',
Nenue@6 13 QUEST_REMOVED = 'OnQuestRemoved'
Nenue@6 14 }
Nenue@6 15
Nenue@6 16 local HandlerEvents = {
Nenue@6 17 QUEST_ACCEPTED = mod.Quest,
Nenue@6 18 QUEST_REMOVED = mod.Quest,
Nenue@6 19 QUEST_WATCH_LIST_CHANGED = mod.Quest,
Nenue@6 20 SUPER_TRACKED_QUEST_CHANGED = mod.Quest,
Nenue@6 21 QUEST_LOG_UPDATE = mod.Quest,
Nenue@6 22 TRACKED_ACHIEVEMENT_LIST_CHANGED = mod.Cheevs,
Nenue@6 23 TRACKED_ACHIEVEMENT_UPDATE = mod.Cheevs
Nenue@6 24 }
Nenue@6 25
Nenue@6 26 local BlizzHooks = {
Nenue@6 27 ['AddQuestWatch'] = 'AddQuestWatch',
Nenue@6 28 ['RemoveQuestWatch'] = 'RemoveQuestWatch',
Nenue@6 29 ['AbandonQuest'] = 'AbandonQuest',
Nenue@6 30 ['AcknowledgeAutoAcceptQuest'] = 'AcknowledgeAutoAcceptQuest',
Nenue@8 31 ['AddAutoQuestPopUp'] = 'AddAutoQuestPopUp',
Nenue@8 32 ['RemoveTrackedAchievement'] = 'RemoveTrackedAchievement'
Nenue@6 33 }
Nenue@6 34
Nenue@6 35 mod.SetEvents = function()
Nenue@6 36
Nenue@6 37 for event, _ in pairs(SmallEvents) do
Nenue@6 38 mod:RegisterEvent(event)
Nenue@6 39 end
Nenue@6 40
Nenue@6 41 for event, _ in pairs(HandlerEvents) do
Nenue@6 42 mod:RegisterEvent(event)
Nenue@6 43 end
Nenue@6 44 mod:SetScript('OnEvent', mod.OnEvent)
Nenue@6 45
Nenue@6 46
Nenue@6 47 if not isHooked then
Nenue@6 48 VeneerData.CallLog = {}
Nenue@6 49 isHooked = true
Nenue@6 50 for blizzFunc, veneerFunc in pairs(BlizzHooks) do
Nenue@6 51 if mod[veneerFunc] then
Nenue@6 52 hooksecurefunc(blizzFunc, mod[veneerFunc])
Nenue@6 53 else
Nenue@6 54 hooksecurefunc(blizzFunc, function(...)
Nenue@6 55 print('catching', blizzFunc, ...)
Nenue@6 56 tinsert(VeneerData.CallLog, {blizzFunc, ...})
Nenue@6 57 end)
Nenue@6 58 end
Nenue@6 59 end
Nenue@6 60
Nenue@6 61 end
Nenue@6 62 end
Nenue@6 63
Nenue@6 64 function mod:OnEvent (event, ...)
Nenue@6 65 local isHandled
Nenue@6 66 if SmallEvents[event] then
Nenue@6 67 print('|cFF00FF00'..SmallEvents[event]..'(' ..event..'|r', ...)
Nenue@6 68 mod[SmallEvents[event]](event, ...)
Nenue@6 69 isHandled = true
Nenue@6 70 end
Nenue@6 71 if HandlerEvents[event] then
Nenue@6 72 print('|cFF0088FF'..event..'|r wrapper update')
Nenue@6 73 mod.UpdateWrapper()
Nenue@6 74 isHandled = true
Nenue@6 75 end
Nenue@6 76 if not isHandled then
Nenue@6 77 print('|cFFFF4400'..event..'|r', ...)
Nenue@6 78 end
Nenue@6 79 end
Nenue@6 80
Nenue@1 81 --------------------------------------------------------------------
Nenue@6 82 --- Events that are handled by Blizzard_ObjectiveTracker
Nenue@1 83 --------------------------------------------------------------------
Nenue@1 84 print(mod:GetName())
Nenue@1 85 mod.OnQuestAccepted = function(_, questLogIndex, questID)
Nenue@1 86 AddQuestWatch(questLogIndex)
Nenue@1 87 SetSuperTrackedQuestID(questID)
Nenue@1 88 end
Nenue@1 89
Nenue@1 90 mod.OnQuestComplete = function(_, questLogIndex, questID)
Nenue@1 91 QuestPOIUpdateIcons()
Nenue@1 92 end
Nenue@1 93
Nenue@1 94 mod.OnQuestFinished = function(_, questLogIndex, questID)
Nenue@1 95 mod.TrackClosest()
Nenue@1 96 RemoveQuestWatch(questLogIndex)
Nenue@1 97 end
Nenue@1 98
Nenue@6 99
Nenue@2 100 mod.OnQuestRemoved = function(_, questLogIndex, questID)
Nenue@6 101
Nenue@6 102 mod.UpdateWrapper()
Nenue@6 103
Nenue@2 104 end
Nenue@2 105
Nenue@1 106 mod.OnQuestFromLocation = function(event) end
Nenue@1 107
Nenue@6 108 -------------------------------------------------------------------
Nenue@6 109 --- Function hooks for BlizzUI compatibility
Nenue@6 110 -------------------------------------------------------------------
Nenue@6 111 mod.AddQuestWatch = function(questID)
Nenue@6 112 mod.UpdateWrapper()
Nenue@1 113 end
Nenue@6 114
Nenue@8 115 mod.RemoveQuestWatch = function(questIndex, ...)
Nenue@8 116 print('|cFFFF8800RemoveQuestWatch', questIndex, ...)
Nenue@8 117 local info = mod.Quest.LogInfo[questIndex]
Nenue@8 118
Nenue@8 119 -- remove quest refs
Nenue@8 120 mod.Quest.LogBlock[questIndex] = nil
Nenue@8 121 mod.Quest.QuestBlock[info.questID] = nil
Nenue@8 122
Nenue@8 123 -- remove if they still match
Nenue@8 124 if mod.Quest.WatchInfo[info.watchIndex] == info then
Nenue@8 125 print('cleaning dead WatchInfo entry')
Nenue@8 126 mod.Quest.WatchInfo[info.watchIndex] = nil
Nenue@8 127 end
Nenue@8 128
Nenue@6 129 mod.UpdateWrapper()
Nenue@8 130 QuestPOIUpdateIcons()
Nenue@8 131 end
Nenue@8 132
Nenue@8 133 mod.RemoveTrackedAchievement = function(cheevID)
Nenue@8 134 print('|cFFFF8800UntrackAchievement', cheevID)
Nenue@8 135 mod.CleanWidgets()
Nenue@6 136 end
Nenue@6 137
Nenue@6 138 mod.AcceptQuest = function()
Nenue@6 139 end
Nenue@6 140
Nenue@6 141 mod.AbandonQuest = function()
Nenue@8 142
Nenue@8 143 QuestPOIUpdateIcons()
Nenue@6 144 end
Nenue@6 145
Nenue@6 146 mod.TurnInQuest = function()
Nenue@8 147
Nenue@8 148 QuestPOIUpdateIcons()
Nenue@6 149 end