-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.lua
More file actions
64 lines (55 loc) · 1.74 KB
/
Settings.lua
File metadata and controls
64 lines (55 loc) · 1.74 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
local _, ADDON = ...
FavoriteContactsSettings = FavoriteContactsSettings or {}
local defaultSettings = {
contacts = {},
columnCount = 2,
rowCount = 9,
position = "RIGHT",
scale = "AUTO",
clickToSend = false,
switchTabOnEmptyInbox = true,
}
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_DRAGONFLIGHT then
defaultSettings['craftOrder'] = {
contacts = {},
columnCount = 2,
rowCount = 12,
position = "RIGHT",
scale = "AUTO",
}
end
function ADDON:ResetUISettings()
ADDON.settings.columnCount = 2
ADDON.settings.rowCount = 9
ADDON.settings.position = "RIGHT"
ADDON.settings.scale = "AUTO"
ADDON.settings.clickToSend = false
ADDON.settings.switchTabOnEmptyInbox = true
end
local function CombineSettings(settings, defaultSettings)
for key, value in pairs(defaultSettings) do
if (settings[key] == nil) then
settings[key] = value
elseif (type(value) == "table") and next(value) ~= nil then
if type(settings[key]) ~= "table" then
settings[key] = {}
end
CombineSettings(settings[key], value)
end
end
-- cleanup old still existing settings
for key, _ in pairs(settings) do
if (defaultSettings[key] == nil) then
settings[key] = nil
end
end
end
-- Settings have to be loaded during PLAYER_LOGIN
ADDON.Events:RegisterCallback('PreLogin', function()
local realmName = "realm_" .. GetRealmName()
if not FavoriteContactsSettings[realmName] then
FavoriteContactsSettings[realmName] = {}
end
CombineSettings(FavoriteContactsSettings[realmName], defaultSettings)
ADDON.settings = FavoriteContactsSettings[realmName]
end, 'settings')