This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocialiteOptions.lua
248 lines (241 loc) · 9.11 KB
/
SocialiteOptions.lua
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
local AddonName, Addon = ...
local L = LibStub("AceLocale-3.0"):GetLocale(AddonName, true)
local defaultOptions = {
global = {
config = {
tracking = {
bossKills = true,
lfg = true,
bg = true,
lfr = false,
arena = true
},
tooltip = {
enabled = true,
bossKills = true,
lfg = true,
bg = true,
lfr = false,
arena = true
},
notifications = {
onJoin = true,
onJoinSound = true
}
},
data = {}
}
}
local orderNum = 0;
local function order()
orderNum = orderNum + 1;
return orderNum
end
local function tcount(tbl)
local count = 0;
for _,_ in ipairs(tbl) do
count = count + 1
end
return count
end
local optionsTable = {
name = L["Socialite"],
handler = SCL,
type = 'group',
args = {
trackingHeader = {
name = L["Track"],
order = order(),
type = "header",
},
trackingBossKills = {
name = L["Bosses Killed"],
type = "toggle",
order = order(),
set = function(_, val) SCL.db.global.config.tracking.bossKills = val end,
get = function() return SCL.db.global.config.tracking.bossKills end
},
trackingLFGComplete = {
name = L["Dungeons"],
type = "toggle",
order = order(),
set = function(_,val) SCL.db.global.config.tracking.lfg = val end,
get = function() return SCL.db.global.config.tracking.lfg end
},
trackingBGComplete = {
name = L["Battlegrounds"],
type = "toggle",
order = order(),
set = function(_, val) SCL.db.global.config.tracking.bg = val end,
get = function() return SCL.db.global.config.tracking.bg end
},
trackingArenaComplete = {
name = L["Arena"],
type = "toggle",
order = order(),
set = function(_, val) SCL.db.global.config.tracking.arena = val end,
get = function() return SCL.db.global.config.tracking.arena end
},
trackingLFRComplete = {
name = L["LFR Complete"],
type = "toggle",
order = order(),
disabled = true,
set = function(_,val) SCL.db.global.config.tracking.lfr = val end,
get = function() return SCL.db.global.config.tracking.lfr end
},
tooltipHeader = {
name = L["Tooltip"],
order = order(),
type = "header",
},
tooltipEnabled = {
name = L["Enabled"],
order = order(),
type = "toggle",
set = function(_, val) SCL.db.global.config.tooltip.enabled = val end,
get = function() return SCL.db.global.config.tooltip.enabled end
},
tooltipBossKills = {
name = L["Bosses Killed"],
type = "toggle",
order = order(),
disabled = function() return not SCL.db.global.config.tooltip.enabled end,
set = function(_, val) SCL.db.global.config.tooltip.bossKills = val end,
get = function() return SCL.db.global.config.tooltip.bossKills end
},
tooltipLFGComplete = {
name = L["Dungeons"],
type = "toggle",
order = order(),
disabled = function() return not SCL.db.global.config.tooltip.enabled end,
set = function(_,val) SCL.db.global.config.tooltip.lfg = val end,
get = function() return SCL.db.global.config.tooltip.lfg end
},
tooltipBGComplete = {
name = L["Battlegrounds"],
type = "toggle",
order = order(),
disabled = function() return not SCL.db.global.config.tooltip.enabled end,
set = function(_, val) SCL.db.global.config.tooltip.bg = val end,
get = function() return SCL.db.global.config.tooltip.bg end
},
tooltipArenaComplete = {
name = L["Arena"],
type = "toggle",
order = order(),
disabled = function() return not SCL.db.global.config.tooltip.enabled end,
set = function(_, val) SCL.db.global.config.tooltip.arena = val end,
get = function() return SCL.db.global.config.tooltip.arena end
},
tooltipLFRComplete = {
name = L["LFR Complete"],
type = "toggle",
order = order(),
disabled = true,
set = function(_,val) SCL.db.global.config.tooltip.lfr = val end,
get = function() return SCL.db.global.config.tooltip.lfr end
},
notificationHeader = {
name = L["Group Join Notifications"],
order = order(),
type = "header"
},
notificationOnJoin = {
name = L["Enabled"],
type = "toggle",
order = order(),
set = function(_, val) SCL.db.global.config.notifications.onJoin = val end,
get = function() return SCL.db.global.config.notifications.onJoin end
},
notificationOnJoinSound = {
name = L["Play Sound"],
type = "toggle",
order = order(),
disabled = function () return not SCL.db.global.config.notifications.onJoin end,
set = function(_, val)
SCL.db.global.config.notifications.onJoinSound = val
if val then
PlaySound(SOUNDKIT.TELL_MESSAGE, "Master")
end
end,
get = function() return SCL.db.global.config.notifications.onJoinSound end
},
utilityHeader = {
name = L["Utility"],
type = "header",
order = order()
},
-- First rendition pruned anyone over a year. It'll be awhile before that's relevant and
-- there's no explanation as to what "Prune" does to the user, so disabling for now
-- until I can add pruning options and more information about what it does.
--@alpha@
pruneHandler = {
name = L["Prune"],
type = "execute",
order = order(),
confirm = true,
confirmText = L["Are you sure? This will delete data and may hang your client."],
func = function()
SCL:Print("Starting prune...")
local startCount = tcount(SCL.db.global.data)
local oneYearAgo = GetServerTime() - 31557600
for k,v in pairs(SCL.db.global.data) do
if v.lastSeen < oneYearAgo then
SCL:Debug(("Deleting %s-%s, last seen %s"):format(v.name, v.realm, v.lastSeen))
SCL.db.global.data[k] = nil
end
end
local endCount = tcount(SCL.db.global.data)
SCL:Print(("Prune complete. %d of %d entries deleted."):format(startCount - endCount, startCount))
end
},
--@end-alpha@
debug = {
name = L["Debug"],
desc = "",
type = 'toggle',
order = order(),
hidden = false,
confirm = function(_, val) return val and "Are you sure? This is VERY spammy and will self-disable on next reload." end,
set = function(_, val)
SCL.debugEnabled = val
SCL:Print(L["Debug"].." "..(function ()
if SCL.debugEnabled then
return ("|cFFFF0000%s|r"):format(L["Enabled"])
else
return ("|cFF00FF00%s|r"):format(L["Disabled"])
end
end)())
--@do-not-package@
SCL.db.global.config.debugEnabled = val
--@end-do-not-package@
end,
get = function() return SCL.debugEnabled end
},
}
}
function SCL:OpenOptionsFrame(input)
if not input or input:trim() == "" then
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
--@do-not-package@
elseif input == "dump" then
self:Dump()
--@end-do-not-package@
else
LibStub("AceConfigCmd-3.0"):HandleCommand("scl", AddonName, input)
end
end
function SCL:InitOpts()
LibStub("AceConfig-3.0"):RegisterOptionsTable(AddonName, optionsTable)
self.db = LibStub("AceDB-3.0"):New("SocialiteDB", defaultOptions, true)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddonName, L["Socialite"], nil)
self:RegisterChatCommand("socialite", "OpenOptionsFrame")
self:RegisterChatCommand("scl", "OpenOptionsFrame")
if (GetLocale() ~= "enUS" and GetLocale() ~= "enGB") then
self:Debug(("Registering non-enUS chat commands: /%s and /%s"):format(L["Socialite"], L["SCL"]))
self:RegisterChatCommand(L["Socialite"], "OpenOptionsFrame")
self:RegisterChatCommand(L["SCL"], "OpenOptionsFrame")
end
end