1 QuestHelper_File
["collect.lua"] = "Development Version"
2 QuestHelper_Loadtime
["collect.lua"] = GetTime()
4 local QuestHelper_Collector_Version_Current
= 3
6 QuestHelper_Collector
= {}
7 QuestHelper_Collector_Version
= QuestHelper_Collector_Version_Current
9 local EventRegistrar
= {}
10 local OnUpdateRegistrar
= {}
11 local TooltipRegistrar
= {}
13 local frame
= CreateFrame("Frame")
15 local function OnEvent(_
, event
, ...)
16 local tstart
= GetTime()
17 for _
, v
in pairs(EventRegistrar
[event
]) do
20 QH_Timeslice_Increment(GetTime() - tstart
, "collect_event")
23 frame
:UnregisterAllEvents()
24 frame
:SetScript("OnEvent", OnEvent
)
28 function EventHookRegistrar(event
, func
)
29 QuestHelper
:Assert(func
)
30 if not EventRegistrar
[event
] then
31 frame
:RegisterEvent(event
)
32 EventRegistrar
[event
] = {}
34 table.insert(EventRegistrar
[event
], func
)
37 function OnUpdateHookRegistrar(func
)
38 QuestHelper
:Assert(func
)
39 table.insert(OnUpdateRegistrar
, func
)
42 local OriginalScript
= GameTooltip
:GetScript("OnShow")
43 GameTooltip
:SetScript("OnShow", function (self
, ...)
44 if not self
then self
= GameTooltip
end
46 local tstart
= GetTime()
47 for k
, v
in pairs(TooltipRegistrar
) do
50 QH_Timeslice_Increment(GetTime() - tstart
, "collect_tooltip") -- anything past here is not my fault
51 if OriginalScript
then
52 return OriginalScript(self
, ...)
56 function TooltipHookRegistrar(func
)
57 QuestHelper
:Assert(func
)
58 table.insert(TooltipRegistrar
, func
)
62 Registrar_EventHook
= EventHookRegistrar
,
63 Registrar_OnUpdateHook
= OnUpdateHookRegistrar
,
64 Registrar_TooltipHook
= TooltipHookRegistrar
,
65 Callback_RawLocation
= function () return QuestHelper
:RetrieveRawLocation() end,
68 function QH_Collector_Init()
69 -- First we update shit
70 if QuestHelper_Collector_Version
== 1 then
71 -- We basically just want to clobber all our old route data, it's not worth storing - it's all good data, it's just that we don't want to preserve relics of the old location system.
72 for _
, v
in pairs(QuestHelper_Collector
) do
76 QuestHelper_Collector_Version
= 2
79 if QuestHelper_Collector_Version
== 2 then
80 -- Originally I split the zones based on locale. Later I just split everything based on locale. Discarding old data rather than doing the gymnastics needed to preserve it.
81 -- This is turning into a routine. :D
82 for _
, v
in pairs(QuestHelper_Collector
) do
86 QuestHelper_Collector_Version
= 3
89 QuestHelper
: Assert(QuestHelper_Collector_Version
== QuestHelper_Collector_Version_Current
)
91 local sig
= string.format("%s on %s/%s/%d", GetAddOnMetadata("QuestHelper", "Version"), GetBuildInfo(), GetLocale(), QuestHelper
:PlayerFaction())
92 if not QuestHelper_Collector
[sig
] then QuestHelper_Collector
[sig
] = {} end
93 local QHCData
= QuestHelper_Collector
[sig
]
95 QH_Collect_Location_Init(nil, API
) -- Some may actually add their own functions to the API, and should go first. There's no real formalized order, I just know which depend on others. Location's sole job is to provide the standard location bolus. (Yeah. It's a bolus. Deal.)
96 QH_Collect_Merger_Init(nil, API
) -- etc
97 QH_Collect_Patterns_Init(nil, API
) -- etc
99 QH_Collect_LZW_Init(nil, API
) -- Depends on Merger
101 QH_Collect_Achievement_Init(QHCData
, API
)
102 QH_Collect_Traveled_Init(QHCData
, API
)
103 QH_Collect_Zone_Init(QHCData
, API
)
104 QH_Collect_Monster_Init(QHCData
, API
)
105 QH_Collect_Item_Init(QHCData
, API
)
106 QH_Collect_Object_Init(QHCData
, API
)
107 QH_Collect_Flight_Init(QHCData
, API
)
109 if not QHCData
.realms
then QHCData
.realms
= {} end
110 QHCData
.realms
[GetRealmName()] = (QHCData
.realms
[GetRealmName()] or 0) + 1 -- I'm not entirely sure why I'm counting
113 function QH_Collector_OnUpdate()
114 local tstart
= GetTime()
115 for _
, v
in pairs(OnUpdateRegistrar
) do
118 QH_Timeslice_Increment(GetTime() - tstart
, "collect_update")