1 QuestHelper_File
["manager_event.lua"] = "Development Version"
2 QuestHelper_Loadtime
["manager_event.lua"] = GetTime()
4 -- zorba why does this file exist, are you a terrible person? you are a terrible person aren't you
5 -- yep, I'm a terrible person
7 -- File exists to centralize all the event hooks in one place. QH should never (rarely) eat CPU without going through this file. As a nice side effect, I can use this to measure when QH is using CPU. yaaaaay
10 local EventRegistrar
= {}
12 local qh_event_frame
= CreateFrame("Frame")
14 local function OnEvent(_
, event
, ...)
15 local tstart
= GetTime()
16 for _
, v
in pairs(EventRegistrar
[event
]) do
19 QH_Timeslice_Increment(GetTime() - tstart
, "collect_event")
22 qh_event_frame
:UnregisterAllEvents()
23 qh_event_frame
:SetScript("OnEvent", OnEvent
)
25 function QH_Event(event
, func
, identifier
)
26 QuestHelper
: Assert(func
)
27 if type(event
) == "table" then
28 for _
, v
in ipairs(event
) do
29 QH_Event(v
, func
, identifier
)
32 if not identifier
then identifier
= "(unknown event " .. event
.. ")" end
33 if not EventRegistrar
[event
] then
34 qh_event_frame
:RegisterEvent(event
)
35 EventRegistrar
[event
] = {}
37 table.insert(EventRegistrar
[event
], {func
= func
, id
= identifier
})
43 local OnUpdateHigh
= {}
44 local function OnUpdateTrigger()
45 for _
, v
in pairs(OnUpdateHigh
) do
49 for _
, v
in pairs(OnUpdate
) do
56 function QH_OnUpdate(func
, identifier
)
57 if not identifier
then identifier
= "(unknown onupdate)" end
58 table.insert(OnUpdate
, {func
= func
, id
= identifier
})
61 function QH_OnUpdate_High(func
, identifier
)
62 if not identifier
then identifier
= "(unknown high-onupdate)" end
63 table.insert(OnUpdateHigh
, {func
= func
, id
= identifier
})
66 qh_event_frame
:SetScript("OnUpdate", OnUpdateTrigger
)
69 function QH_Hook(target
, hookname
, func
, identifier
)
70 target
:SetScript(hookname
, func
)