-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInit.lua
More file actions
68 lines (57 loc) · 2.44 KB
/
Copy pathInit.lua
File metadata and controls
68 lines (57 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
-------------------------------------------------------------------------------
-- Premade Groups Filter Plus
-- SPDX-License-Identifier: GPL-2.0-or-later
--
-- An enhancement add-on for Premade Groups Filter (PGF). It is a hard
-- dependency of PGF (see the TOC) so the global table `PremadeGroupsFilter`
-- and its internal namespace `PremadeGroupsFilter.Debug` are guaranteed to be
-- available by the time this add-on loads.
-------------------------------------------------------------------------------
PremadeGroupsFilterPlus = {}
PremadeGroupsFilterPlusSettings = PremadeGroupsFilterPlusSettings or {}
local PGFPAddonName = select(1, ...)
local PGFP = select(2, ...)
-- Expose the private namespace for in-game debugging (mirrors PGF.Debug).
PremadeGroupsFilterPlus.Debug = PGFP
PGFP.L = {}
local L = PGFP.L
-- Default account-wide settings. Missing keys are filled in on ADDON_LOADED so
-- that older saved variables keep working after an upgrade.
PGFP.SETTINGS_DEFAULT = {
sortByMembers = true, -- inject "members desc" into the PGF sorting
}
-- Recursively copies any missing default into the target table. Existing user
-- values are never overwritten.
function PGFP.Table_UpdateWithDefaults(target, defaults)
for key, value in pairs(defaults) do
if type(value) == "table" then
if type(target[key]) ~= "table" then target[key] = {} end
PGFP.Table_UpdateWithDefaults(target[key], value)
elseif target[key] == nil then
target[key] = value
end
end
return target
end
local function OnAddonLoaded(name)
if name ~= PGFPAddonName then return end
PGFP.Table_UpdateWithDefaults(PremadeGroupsFilterPlusSettings, PGFP.SETTINGS_DEFAULT)
end
local function OnPlayerLogin()
-- The Blizzard Group Finder frames and PGF are fully built by now.
if PGFP.InitSortByMembers then PGFP.InitSortByMembers() end
if PGFP.InitApplicantKeyLevel then PGFP.InitApplicantKeyLevel() end
if PGFP.InitBrowseAsMember then PGFP.InitBrowseAsMember() end
if PGFP.InitDialogAutoSnap then PGFP.InitDialogAutoSnap() end
end
local eventFrame = CreateFrame("Frame", "PremadeGroupsFilterPlusEventFrame")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:SetScript("OnEvent", function (self, event, ...)
if event == "ADDON_LOADED" then
OnAddonLoaded(...)
elseif event == "PLAYER_LOGIN" then
OnPlayerLogin()
end
end)
PGFP.eventFrame = eventFrame