forked from Eliote/SimpleAddonManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
296 lines (290 loc) · 7.11 KB
/
Copy pathOptions.lua
File metadata and controls
296 lines (290 loc) · 7.11 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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
local _, T = ...
local L = T.L
local EDDM = LibStub("ElioteDropDownMenu-1.0")
local dropdownFrame = EDDM.UIDropDownMenu_GetOrCreate("SimpleAddonManager_MenuFrame")
--- @type SimpleAddonManager
local frame = T.AddonFrame
local module = frame:RegisterModule("Options")
local function MemoryUpdateMenuList()
local db = frame:GetDb()
local menu = {}
local periods = { 0, 5, 10, 15, 30 }
for _, v in ipairs(periods) do
table.insert(menu, {
text = (v == 0) and L["Update only when opening the main window"] or L("${n} seconds", { n = v }),
checked = function()
return db.config.memoryUpdate == v
end,
func = function()
db.config.memoryUpdate = v
frame:UpdateMemoryTickerPeriod(v)
end,
})
end
return menu
end
local function ConfigDropDownCreate()
local db = frame:GetDb()
return {
{ text = L["Options"], isTitle = true, notCheckable = true },
{
text = ADDON_FORCE_LOAD,
checked = function()
return not frame.compat.IsAddonVersionCheckEnabled()
end,
func = function(_, _, _, checked)
frame.compat.SetAddonVersionCheck(checked)
frame:Update()
end,
},
{
text = L["Replace original Addon wow menu button"],
checked = function()
return db.config.hookMenuButton
end,
func = function()
db.config.hookMenuButton = not db.config.hookMenuButton
if (db.config.hookMenuButton) then
frame:HookMenuButton()
end
end,
},
{
text = L["Show minimap button"],
checked = function()
return not db.config.minimap.hide
end,
func = function()
frame:GetModule("Minimap"):ToggleMinimapButton()
end,
},
{
text = L["Show memory usage in broker/minimap tooltip"],
checked = function()
return db.config.showMemoryInBrokerTtp
end,
func = function()
db.config.showMemoryInBrokerTtp = not db.config.showMemoryInBrokerTtp
end,
},
{
text = L["Memory Update"],
notCheckable = true,
hasArrow = true,
menuList = MemoryUpdateMenuList(),
},
T.separatorInfo,
{ text = L["List Options"], isTitle = true, notCheckable = true },
{
text = L["Show versions in AddOns list"],
checked = function()
return db.config.showVersions
end,
func = function()
db.config.showVersions = not db.config.showVersions
frame:Update()
end,
},
{
text = L["View AddOn list as dependency tree"],
checked = function()
return db.config.addonListStyle == "tree"
end,
func = function(_, _, _, value)
db.config.addonListStyle = (not value) and "tree" or "list"
frame:Update()
end,
},
{
text = L["Show Blizzard addons found in dependencies"],
checked = function()
return db.config.showSecureAddons
end,
func = function()
local isEnabling = not db.config.showSecureAddons
if (isEnabling) then
frame:ShowWarningDialog(
L["Be careful with this option, enabling/disabling Blizzard Addons might have unintended consequences!"],
function()
db.config.showSecureAddons = true
frame:Update()
end
)
else
db.config.showSecureAddons = false
frame:Update()
end
end,
},
{
text = L["Collapse all"],
notCheckable = true,
func = function()
for _, v in pairs(frame:GetAddonsList()) do
frame:SetAddonCollapsed(v.key, v.parentKey, true)
end
frame:Update()
end,
disabled = db.config.addonListStyle ~= "tree",
},
{
text = L["Expand all"],
notCheckable = true,
func = function()
frame:GetDb().collapsedAddons = {}
frame:Update()
end,
disabled = db.config.addonListStyle ~= "tree",
},
{
text = L["Sort by"],
notCheckable = true,
hasArrow = true,
menuList = {
{
text = L["Name (improved)"],
checked = function()
return db.config.sorting == "smart"
end,
func = function()
db.config.sorting = "smart"
frame:Update()
end,
},
{
text = L["Internal name"],
checked = function()
return db.config.sorting == "name"
end,
func = function()
db.config.sorting = "name"
frame:Update()
end,
},
{
text = L["Title"],
checked = function()
return db.config.sorting == "title"
end,
func = function()
db.config.sorting = "title"
frame:Update()
end,
},
{
text = L["None"],
checked = function()
return db.config.sorting == nil
end,
func = function()
db.config.sorting = false
frame:Update()
end,
},
},
},
T.separatorInfo,
{ text = L["Category Options"], isTitle = true, notCheckable = true },
{
text = L["Hide autogenerated categories"],
checked = function()
return db.config.hideTocCategories
end,
func = function()
db.config.hideTocCategories = not db.config.hideTocCategories
frame:Update()
end,
},
{
text = L["Localize autogenerated categories name"],
checked = function()
return db.config.localizeCategoryName
end,
func = function()
db.config.localizeCategoryName = not db.config.localizeCategoryName
frame:Update()
end,
},
T.separatorInfo,
{ text = L["Search Options"], isTitle = true, notCheckable = true },
{
text = L["Autofocus searchbar when opening the UI"],
checked = function()
return db.config.autofocusSearch
end,
func = function()
db.config.autofocusSearch = not db.config.autofocusSearch
end,
},
{
text = L["Search By"],
notCheckable = true,
hasArrow = true,
menuList = {
{
text = L["Internal name"],
checked = function()
return db.config.searchBy.name
end,
func = function()
db.config.searchBy.name = not db.config.searchBy.name
frame:Update()
end,
},
{
text = L["Title"],
checked = function()
return db.config.searchBy.title
end,
func = function()
db.config.searchBy.title = not db.config.searchBy.title
frame:Update()
end,
},
{
text = L["Author"],
checked = function()
return db.config.searchBy.author
end,
func = function()
db.config.searchBy.author = not db.config.searchBy.author
frame:Update()
end,
},
},
},
T.separatorInfo,
{ text = L["Utilities"], isTitle = true, notCheckable = true },
{
text = L["AddOn binary search"] .. " (beta)",
notCheckable = true,
func = function()
frame:GetModule("AddonFinder"):StartSearch()
end,
disabled = db.addonFinder and db.addonFinder.isSearching,
},
T.separatorInfo,
T.closeMenuInfo
}
end
function module:OnLoad()
frame:CreateDefaultOptions(frame:GetDb().config, {
showMemoryInBrokerTtp = true,
})
end
function module:PreInitialize()
frame.ConfigButton = Mixin(
CreateFrame("Button", nil, frame, "UIPanelSquareButton"),
EDDM.HandlesGlobalMouseEventMixin
)
end
function module:Initialize()
frame.ConfigButton:SetPoint("RIGHT", frame.CategoryButton, "LEFT", -4, 0)
frame.ConfigButton:SetSize(30, 30)
frame.ConfigButton.icon:SetAtlas("OptionsIcon-Brown")
frame.ConfigButton.icon:SetTexCoord(0, 1, 0, 1)
frame.ConfigButton.icon:SetSize(16, 16)
frame.ConfigButton:SetScript("OnClick", function()
EDDM.ToggleEasyMenu(ConfigDropDownCreate(), dropdownFrame, frame.ConfigButton, 0, 0, "MENU")
end)
end