Mercurial > wow > buffalo2
diff 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 diff
--- a/ObjectiveEvents.lua Tue Apr 05 02:38:01 2016 -0400 +++ b/ObjectiveEvents.lua Wed Apr 06 07:38:35 2016 -0400 @@ -5,133 +5,17 @@ -- Created: 3/30/2016 1:23 AM local B = select(2,...).frame local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') -local print = B.print('ObjectiveEvent') - -local isHooked -local SmallEvents = { - QUEST_ACCEPTED = 'OnQuestAccepted', - QUEST_REMOVED = 'OnQuestRemoved' -} - ---- Using the same values as Blizzard_ObjectiveTracker for use in securehook -local OBJECTIVE_TRACKER_UPDATE_QUEST = 0x0001; -local OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED = 0x0002; -local OBJECTIVE_TRACKER_UPDATE_TASK_ADDED = 0x0004; -local OBJECTIVE_TRACKER_UPDATE_SCENARIO = 0x0008; -local OBJECTIVE_TRACKER_UPDATE_SCENARIO_NEW_STAGE = 0x0010; -local OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT = 0x0020; -local OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED = 0x0040; -local OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED = 0x0080; - -local OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST = 0x0100; -local OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP = 0x0200; -local OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE = 0x0400; -local OBJECTIVE_TRACKER_UPDATE_MODULE_SCENARIO = 0x0800; -local OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT = 0x1000; - -local OBJECTIVE_TRACKER_UPDATE_STATIC = 0x0000; -local OBJECTIVE_TRACKER_UPDATE_ALL = 0xFFFF; - -local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL; -- default -local OBJECTIVE_TRACKER_UPDATE_ID = 0; - -local HandlerEvents = { - QUEST_ACCEPTED = 0x0003, - QUEST_WATCH_LIST_CHANGED = 0x0003, - SUPER_TRACKED_QUEST_CHANGED = mod.Quest, - QUEST_LOG_UPDATE = mod.Quest, - TRACKED_ACHIEVEMENT_LIST_CHANGED = mod.Cheevs, - TRACKED_ACHIEVEMENT_UPDATE = mod.Cheevs -} - -local BlizzHooks = { - ['AddQuestWatch'] = 'AddQuestWatch', - ['RemoveQuestWatch'] = 'RemoveQuestWatch', - ['AbandonQuest'] = 'AbandonQuest', - ['AcknowledgeAutoAcceptQuest'] = 'AcknowledgeAutoAcceptQuest', - ['AddAutoQuestPopUp'] = 'AddAutoQuestPopUp', - ['RemoveAutoQuestPopUp'] = 'RemoveAutoQuestPopUp', - ['RemoveTrackedAchievement'] = 'RemoveTrackedAchievement' -} - -mod.SetEvents = function() - - for event, _ in pairs(SmallEvents) do - mod:RegisterEvent(event) - end - - for event, _ in pairs(HandlerEvents) do - mod:RegisterEvent(event) - end - mod:SetScript('OnEvent', mod.OnEvent) - - - if not isHooked then - VeneerData.CallLog = {} - isHooked = true - for blizzFunc, veneerFunc in pairs(BlizzHooks) do - if mod[veneerFunc] then - hooksecurefunc(blizzFunc, mod[veneerFunc]) - else - hooksecurefunc(blizzFunc, function(...) - print('catching', blizzFunc, ...) - tinsert(VeneerData.CallLog, {blizzFunc, ...}) - end) - end - end - - end -end - -function mod:OnEvent (event, ...) - local isHandled - if SmallEvents[event] then - print('|cFF00FF00'..SmallEvents[event]..'(' ..event..'|r', ...) - mod[SmallEvents[event]](event, ...) - isHandled = true - end - if HandlerEvents[event] then - print('|cFF0088FF'..event..'|r wrapper update') - mod.UpdateWrapper(event) - isHandled = true - end - if not isHandled then - print('|cFFFF4400'..event..'|r', ...) - end -end +local print = B.print('Objectives') -------------------------------------------------------------------- --- Events that are handled by Blizzard_ObjectiveTracker -------------------------------------------------------------------- -print(mod:GetName()) -mod.OnQuestAccepted = function(_, questLogIndex, questID) - AddQuestWatch(questLogIndex) - SetSuperTrackedQuestID(questID) -end - -mod.OnQuestComplete = function(_, questLogIndex, questID) - QuestPOIUpdateIcons() -end - -mod.OnQuestFinished = function(_, questLogIndex, questID) - mod.TrackClosest() - RemoveQuestWatch(questLogIndex) -end - - -mod.OnQuestRemoved = function(_, questLogIndex, questID) - - mod.UpdateWrapper(0x00000003) - -end - -mod.OnQuestFromLocation = function(event) end ------------------------------------------------------------------- --- Function hooks for BlizzUI compatibility ------------------------------------------------------------------- mod.AddQuestWatch = function(questID) - mod.UpdateWrapper(0x00000003) + mod:Update(0x00000003) end mod.RemoveQuestWatch = function(questIndex, ...) @@ -147,34 +31,40 @@ print('cleaning dead WatchInfo entry') mod.Quest.WatchInfo[info.watchIndex] = nil end + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) +end - mod.UpdateWrapper('RemovedQuestWatch' .. tostring(questIndex)) - QuestPOIUpdateIcons() +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.TurnInQuest = function() - - QuestPOIUpdateIcons() -end - -mod.AddAutoQuestPopUp = function(...) - print('|cFFFF8800AddAutoQuestPopUp|r', ...) - mod.UpdateWrapper(OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP) -end -mod.RemoveAutoQuestPopUp = function(...) - print('|cFFFF8800RemoveAutoQuestPopUp|r', ...) - mod.UpdateWrapper(OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP) +mod.SetSuperTrackedQuestID = function(questID) + mod:Update() end \ No newline at end of file