-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathconfig.lua
530 lines (475 loc) · 17.2 KB
/
config.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
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
local addonName = ... ---@type string
---@class BetterBags: AceAddon
local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)
---@class Localization: AceModule
local L = addon:GetModule('Localization')
---@class Database: AceModule
local db = addon:GetModule('Database')
---@class Constants: AceModule
local const = addon:GetModule('Constants')
---@class Context: AceModule
local context = addon:GetModule('Context')
---@class Events: AceModule
local events = addon:GetModule('Events')
---@class Themes: AceModule
local themes = addon:GetModule('Themes')
---@class Debug: AceModule
local debug = addon:GetModule('Debug')
---@class Bucket: AceModule
local bucket = addon:GetModule('Bucket')
---@class Form: AceModule
local form = addon:GetModule('Form')
---@class Config: AceModule
---@field configFrame FormFrame
local config = addon:NewModule('Config')
function config:CreateConfig()
local f = form:Create({
title = 'BetterBags Settings',
layout = const.FORM_LAYOUT.STACKED,
index = true
})
f:AddSection({
title = 'General',
description = 'General settings for BetterBags.',
})
f:AddCheckbox({
title = 'Enable In-Bag Search',
description = 'If enabled, a search bar will appear at the top of your bags.',
getValue = function(_)
return db:GetInBagSearch()
end,
setValue = function(ctx, value)
db:SetInBagSearch(value)
events:SendMessage(ctx, 'search/SetInFrame', value)
end
})
f:AddCheckbox({
title = 'Enable Enter to Make Category',
description = 'If enabled, pressing Enter with a search query will open the make category menu.',
getValue = function(_)
return db:GetEnterToMakeCategory()
end,
setValue = function(_, value)
db:SetEnterToMakeCategory(value)
end
})
f:AddCheckbox({
title = 'Enable Category Sell and Deposit',
description = 'If enabled, right-clicking a category header at an NPC shop will sell all its contents, or deposit to bank.',
getValue = function(_)
return db:GetCategorySell()
end,
setValue = function(_, value)
db:SetCategorySell(value)
end
})
f:AddCheckbox({
title = 'Show Blizzard Bag Button',
description = 'Show or hide the default Blizzard bag button.',
getValue = function(_)
return db:GetShowBagButton()
end,
setValue = function(_, value)
db:SetShowBagButton(value)
local sneakyFrame = _G["BetterBagsSneakyFrame"] ---@type Frame
if value then
BagsBar:SetParent(UIParent)
else
BagsBar:SetParent(sneakyFrame)
end
end
})
f:AddDropdown({
title = 'Upgrade Icon Provider',
description = 'Select the icon provider for item upgrades.',
items = {'None', 'BetterBags'},
getValue = function(_, value)
return value == db:GetUpgradeIconProvider()
end,
setValue = function(ctx, value)
db:SetUpgradeIconProvider(value)
events:SendMessage(ctx, 'bag/RedrawIcons')
end,
})
f:AddSlider({
title = 'New Item Duration',
description = 'The duration in minutes that an item is considered new.',
min = 1,
max = 120,
step = 1,
getValue = function(_)
return db:GetData().profile.newItemTime / 60
end,
setValue = function(_, value)
db:GetData().profile.newItemTime = value * 60
end,
})
local bagTypes = {
{name = 'Backpack', kind = const.BAG_KIND.BACKPACK},
{name = 'Bank', kind = const.BAG_KIND.BANK}
}
for _, bagType in ipairs(bagTypes) do
f:AddSection({
title = bagType.name,
description = 'Settings for the ' .. string.lower(bagType.name) .. '.',
})
local sectionOrders = {
["Alphabetically"] = const.SECTION_SORT_TYPE.ALPHABETICALLY,
["Size Descending"] = const.SECTION_SORT_TYPE.SIZE_DESCENDING,
["Size Ascending"] = const.SECTION_SORT_TYPE.SIZE_ASCENDING,
}
f:AddDropdown({
title = 'Section Order',
description = 'The order of sections in the ' .. string.lower(bagType.name) .. ' when not pinned.',
items = {'Alphabetically', 'Size Descending', 'Size Ascending'},
getValue = function(_, value)
return sectionOrders[value] == db:GetSectionSortType(bagType.kind, db:GetBagView(bagType.kind))
end,
setValue = function(ctx, value)
db:SetSectionSortType(bagType.kind, db:GetBagView(bagType.kind), sectionOrders[value])
events:SendMessage(ctx, 'bags/FullRefreshAll')
end,
})
local itemOrders = {
["Alphabetically"] = const.ITEM_SORT_TYPE.ALPHABETICALLY_THEN_QUALITY,
["Quality"] = const.ITEM_SORT_TYPE.QUALITY_THEN_ALPHABETICALLY,
["Item Level"] = const.ITEM_SORT_TYPE.ITEM_LEVEL,
}
f:AddDropdown({
title = 'Item Order',
description = 'The default order of items within each section.',
items = {'Alphabetically', 'Quality', 'Item Level'},
getValue = function(_, value)
return itemOrders[value] == db:GetItemSortType(bagType.kind, db:GetBagView(bagType.kind))
end,
setValue = function(ctx, value)
db:SetItemSortType(bagType.kind, db:GetBagView(bagType.kind), itemOrders[value])
events:SendMessage(ctx, 'bags/FullRefreshAll')
end,
})
f:AddSubSection({
title = 'Categories',
description = 'Settings for Blizzard item categories in the ' .. string.lower(bagType.name) .. '.',
})
f:AddLabel({
description = 'To create a custom category, drag an item into the bag button on the top of your bag and let go.',
})
f:AddCheckbox({
title = 'Equipment Location',
description = 'Sort items into categories based on equipment location (Main Hand, Head, etc).',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).EquipmentLocation
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).EquipmentLocation = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Expansion',
description = 'Sort items into categories based on their expansion.',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).Expansion
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).Expansion = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Equipment Set',
description = 'Sort items into categories based on equipment sets.',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).GearSet
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).GearSet = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Recent Items',
description = 'Enable the Recent Items category for new items.',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).RecentItems
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).RecentItems = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Trade Skill',
description = 'Sort items into categories based on their trade skill usage.',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).TradeSkill
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).TradeSkill = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Type',
description = 'Sort items into categories based on their equipment type (Consumable, Quest, etc).',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).Type
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).Type = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Sub Type',
description = 'Sort items into categories based on sub type (Potions, Bandages, etc).',
getValue = function(_)
return db:GetCategoryFilters(bagType.kind).Subtype
end,
setValue = function(ctx, value)
db:GetCategoryFilters(bagType.kind).Subtype = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddSubSection({
title = 'Item Stacking',
description = 'Settings for item stacking in the ' .. string.lower(bagType.name) .. '.',
})
f:AddCheckbox({
title = 'All Items Recent',
description = 'All new items you loot, pickup, or move into the bag will be marked as recent.',
getValue = function(_)
return db:GetMarkRecentItems(bagType.kind)
end,
setValue = function(_, value)
db:SetMarkRecentItems(bagType.kind, value)
end
})
f:AddCheckbox({
title = 'Flash Stacks',
description = 'When a stack of items gets a new item, the stack will flash.',
getValue = function(_)
return db:GetShowNewItemFlash(bagType.kind)
end,
setValue = function(_, value)
db:SetShowNewItemFlash(bagType.kind, value)
end
})
f:AddCheckbox({
title = 'Merge Stacks',
description = 'Stackable items will merge into a single item button in your ' .. string.lower(bagType.name) .. '.',
getValue = function(_)
return db:GetStackingOptions(bagType.kind).mergeStacks
end,
setValue = function(ctx, value)
db:GetStackingOptions(bagType.kind).mergeStacks = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Merge Unstackable',
description = 'Unstackable items, such as armor and weapons, will merge into a single item button in your ' .. string.lower(bagType.name) .. '.',
getValue = function(_)
return db:GetStackingOptions(bagType.kind).mergeUnstackable
end,
setValue = function(ctx, value)
db:GetStackingOptions(bagType.kind).mergeUnstackable = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = "Don't Merge Partial Stacks",
description = 'Partial stacks of items will not merge with other partial or full stacks.',
getValue = function(_)
return db:GetStackingOptions(bagType.kind).dontMergePartial
end,
setValue = function(ctx, value)
db:GetStackingOptions(bagType.kind).dontMergePartial = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = "Split Transmogged Items",
description = 'Transmogged items will be split into a separate, stackable button in your ' .. string.lower(bagType.name) .. '.',
getValue = function(_)
return db:GetStackingOptions(bagType.kind).dontMergeTransmog
end,
setValue = function(ctx, value)
db:GetStackingOptions(bagType.kind).dontMergeTransmog = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Unmerge on Interactions',
description = 'When you interact a vendor, mailbox, auction house, etc, all merged items will unmerge.',
getValue = function(_)
return db:GetStackingOptions(bagType.kind).unmergeAtShop
end,
setValue = function(ctx, value)
db:GetStackingOptions(bagType.kind).unmergeAtShop = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddSubSection({
title = 'Item Level',
description = 'Settings for item level in the ' .. string.lower(bagType.name) .. '.',
})
f:AddCheckbox({
title = 'Show Item Level',
description = 'Show the item level on item buttons in the ' .. string.lower(bagType.name) .. '.',
getValue = function(_)
return db:GetItemLevelOptions(bagType.kind).enabled
end,
setValue = function(ctx, value)
db:GetItemLevelOptions(bagType.kind).enabled = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Show Item Level Color',
description = 'Show the item level in color on item buttons in the ' .. string.lower(bagType.name) .. '.',
getValue = function(_)
return db:GetItemLevelOptions(bagType.kind).color
end,
setValue = function(ctx, value)
db:GetItemLevelOptions(bagType.kind).color = value
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddSubSection({
title = 'Display',
description = 'Settings that adjust layout and visual aspects of the ' .. string.lower(bagType.name) .. '.',
})
f:AddCheckbox({
title = 'Show Full Section Names',
description = 'Show the full section names for each section and do not cut them off.',
getValue = function(_)
return db:GetShowFullSectionNames(bagType.kind)
end,
setValue = function(ctx, value)
db:SetShowFullSectionNames(bagType.kind, value)
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Show All Free Space Slots',
description = 'Show all free space slots, individually, at the bottom of the ' .. string.lower(bagType.name) .. '.',
getValue = function(_)
return db:GetShowAllFreeSpace(bagType.kind)
end,
setValue = function(ctx, value)
db:SetShowAllFreeSpace(bagType.kind, value)
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddCheckbox({
title = 'Extra Glowy Item Buttons',
description = 'Item buttons will have an enhanced glow effect using the item quality color.',
getValue = function(_)
return db:GetExtraGlowyButtons(bagType.kind)
end,
setValue = function(ctx, value)
db:SetExtraGlowyButtons(bagType.kind, value)
events:SendMessage(ctx, 'bags/FullRefreshAll')
end
})
f:AddSlider({
title = 'Items Per Row',
description = 'The number of items per row in each section.',
min = 3,
max = 20,
step = 1,
getValue = function(_)
return db:GetBagSizeInfo(bagType.kind, db:GetBagView(bagType.kind)).itemsPerRow > 20 and 20 or db:GetBagSizeInfo(bagType.kind, db:GetBagView(bagType.kind)).itemsPerRow
end,
setValue = function(ctx, value)
db:SetBagViewSizeItems(bagType.kind, db:GetBagView(bagType.kind), value)
bucket:Later("setItemsPerRow", 0.2, function()
events:SendMessage(ctx, 'bags/FullRefreshAll')
end)
end,
})
f:AddSlider({
title = 'Columns',
description = 'The number of columns in the ' .. string.lower(bagType.name) .. '.',
min = 1,
max = 20,
step = 1,
getValue = function(_)
return db:GetBagSizeInfo(bagType.kind, db:GetBagView(bagType.kind)).columnCount > 20 and 20 or db:GetBagSizeInfo(bagType.kind, db:GetBagView(bagType.kind)).columnCount
end,
setValue = function(ctx, value)
db:SetBagViewSizeColumn(bagType.kind, db:GetBagView(bagType.kind), value)
bucket:Later("setSectionsPerRow", 0.2, function()
events:SendMessage(ctx, 'bags/FullRefreshAll')
end)
end,
})
f:AddSlider({
title = 'Opacity',
description = 'The opacity of the background of the ' .. string.lower(bagType.name) .. '.',
min = 0,
max = 100,
step = 1,
getValue = function(_)
return db:GetBagSizeInfo(bagType.kind, db:GetBagView(bagType.kind)).opacity
end,
setValue = function(_, value)
db:SetBagViewSizeOpacity(bagType.kind, db:GetBagView(bagType.kind), value)
themes:UpdateOpacity()
end,
})
f:AddSlider({
title = 'Scale',
description = 'The scale of the ' .. string.lower(bagType.name) .. '.',
min = 50,
max = 200,
step = 1,
getValue = function(_)
return db:GetBagSizeInfo(bagType.kind, db:GetBagView(bagType.kind)).scale
end,
setValue = function(_, value)
-- TODO(lobato): This should be an event.
local bag = addon:GetBagFromKind(bagType.kind)
if not bag then return end
bag.frame:SetScale(value / 100)
db:SetBagViewSizeScale(bagType.kind, db:GetBagView(bagType.kind), value)
end,
})
end
f:GetFrame():SetSize(600, 800)
f:GetFrame():SetPoint("CENTER")
self.configFrame = f
end
---@diagnostic disable-next-line: duplicate-set-field
function config:Open()
self.configFrame:Show()
end
function config:RegisterSettings()
LibStub('AceConsole-3.0'):RegisterChatCommand("bb", function()
self:Open()
end)
LibStub('AceConsole-3.0'):RegisterChatCommand("bbanchor", function()
addon.Bags.Backpack.anchor:Activate()
addon.Bags.Backpack.anchor:Show()
addon.Bags.Bank.anchor:Activate()
addon.Bags.Bank.anchor:Show()
end)
events:RegisterMessage('categories/Changed', function()
--LibStub('AceConfigRegistry-3.0'):NotifyChange(addonName)
end)
events:RegisterMessage('config/Open', function()
self:Open()
end)
LibStub('AceConsole-3.0'):RegisterChatCommand("bbdb", function()
db:SetDebugMode(not db:GetDebugMode())
local ctx = context:New('on_click')
events:SendMessage(ctx, 'config/DebugMode', db:GetDebugMode())
end)
end
function config:OnEnable()
if self.configFrame then return end
self:CreateConfig()
self:RegisterSettings()
table.insert(UISpecialFrames, self.configFrame.frame:GetName())
end