forked from kemayo/wow-bankstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.lua
More file actions
347 lines (332 loc) · 11.4 KB
/
config.lua
File metadata and controls
347 lines (332 loc) · 11.4 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
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
local myname, ns = ...
local core = BankStack
local Debug = core.Debug
local announce = core.announce
local sorted_bag_groups = {}
local function print_groups(groups)
for group in pairs(groups) do
table.insert(sorted_bag_groups, group)
end
table.sort(sorted_bag_groups)
for _,group in ipairs(sorted_bag_groups) do
announce(0, "-"..group..": "..string.join(", ", unpack(groups[group])), 1, 1, 1)
end
wipe(sorted_bag_groups)
end
local options = {
name = "Config", desc = "Basic settings", type = "group", order = 10,
get = function(info) return core.db[info[#info]] end,
set = function(info, value) core.db[info[#info]] = value end,
args = {
sorting = {
name = "Sorting",
type = "group",
inline = true,
order = 10,
args = {
junk = {
name = "Junk", desc = "Move junk to the end", type = "select",
descStyle = "inline",
values = {
[0] = "No",
[1] = "End of your items",
[2] = "Back of your bags",
},
order = 10,
},
conjured = {
name = "Conjured", desc = "Move conjured items to the end", type = "toggle",
descStyle = "inline",
order = 20,
},
soulbound = {
name = "Soulbound", desc = "Move soulbound items to the front", type = "toggle",
descStyle = "inline",
order = 30,
},
reverse = {
name = "Reverse", desc = "Reverse the sort", type = "toggle",
descStyle = "inline",
order = 40,
},
backfill = {
name = "Backfill", desc = "Fill starting at the back of your bags", type = "toggle",
descStyle = "inline",
order = 50,
},
},
},
blizzard = {
name = "Blizzard",
type = "group",
inline = true,
order = 20,
args = {
respect = {
name = "Respect Blizzard settings",
desc = "Respect \"ignore this bag\" and item-type assignments from the default UI",
descStyle = "inline", width="full",
type = "toggle",
get = function() return core.db.ignore_blizzard end,
set = function(info, value) core.db.ignore_blizzard = value end,
order = 10,
},
},
plugins = {},
},
},
plugins = {},
}
core.options = options
local bag_slot_pattern = "^(-?[%d]+)%s*(%d*)$"
local ignore_options = {
name = "Ignore", desc = "Slots to ignore", type = "group", order = 20,
args = {
list = {
name = "List", desc = "List all ignored slots", type = "execute", order = 1,
func = function()
for ignored,_ in pairs(core.db.ignore_bags) do
core.announce(0, "Ignoring bag: "..ignored, 1, 1, 1)
end
for ignored,_ in pairs(core.db.ignore) do
local bag, slot = core.decode_bagslot(ignored)
core.announce(0, "Ignoring: "..bag.." "..slot, 1, 1, 1)
end
end,
},
add = {
name = "Add", desc = "Add an ignore", type = "input", order = 2,
get = false,
set = function(info, v)
local bag, slot = v:match(bag_slot_pattern)
bag = tonumber(bag)
slot = tonumber(slot)
if bag and slot then
local bagslot = core.encode_bagslot(bag, slot)
core.db.ignore[bagslot] = true
core.announce(0, "bag:"..bag.." slot:"..slot.." ignored.", 1, 1, 1)
elseif bag then
core.db.ignore_bags[bag] = true
core.announce(0, "bag:"..bag.." ignored.", 1, 1, 1)
end
end,
usage = "[bag] [slot] (see http://wowwiki.com/BagID)",
validate = function(info, v)
-- "and true or false" because returning a string counts as false
return v:match(bag_slot_pattern) and true or false
end,
},
remove = {
name = "Remove", desc = "Remove an ignore", type = "input", order = 3,
get = false,
set = function(info, v)
local bag, slot = v:match(bag_slot_pattern)
bag = tonumber(bag)
slot = tonumber(slot)
if bag and slot then
local bagslot = core.encode_bagslot(bag, slot)
core.db.ignore[bagslot] = nil
announce(0, "bag:"..bag.." slot:"..slot.." no longer ignored.", 1, 1, 1)
elseif bag then
core.db.ignore_bags[bag] = nil
announce(0, "bag:"..bag.." no longer ignored.", 1, 1, 1)
end
end,
usage = "[bag] [slot] (see http://wowwiki.com/BagID)",
validate = function(info, v)
-- "and true or false" because returning a string counts as false
return v:match(bag_slot_pattern) and true or false
end,
},
},
}
local group_options = {
name = "Groups", desc = "Bag groups", type = "group", order = 30,
args = {
list = {
name = "List", desc = "List all groups", type = "execute", order = 1,
func = function()
announce(0, "Built in groups:", 1, 1, 1)
print_groups(core.groups)
announce(0, "Custom groups:", 1, 1, 1)
print_groups(core.db.groups)
end,
},
add = {
name = "Add", desc = "Add a group (see http://wowwiki.com/BagID)", type = "input", order = 2,
get = false,
set = function(info, v)
local group, action = string.match(v, "^([^%s]+) (.*)$")
if not core.db.groups[group] then
core.db.groups[group] = {}
end
local bags = wipe(core.db.groups[group])
-- Populate with the new group:
for maybe_bagid in string.gmatch(action, "[^%s,]+") do
local bag = tonumber(maybe_bagid)
if core.is_valid_bag(bag) or core.is_guild_bank_bag(bag) then
table.insert(bags, bag)
else
announce(0, maybe_bagid.." was not a valid bag id.", 1, 0, 0)
end
end
announce(0, "Added group: "..group.." ("..string.join(", ", unpack(bags))..")", 1, 1, 1)
end,
usage = "[name] [bagid],[bagid],[bagid]",
validate = function(_, v) return string.match(v, "^[^%s]+ [-%d%s,]+$") and true or false end,
},
remove = {
name = "Remove", desc = "Remove a group", type = "input", order = 3,
get = false,
set = function(info, v)
core.db.groups[v] = nil
announce(0, v .. " removed.", 1, 1, 1)
end,
usage = "[name]",
}
},
}
local help_options = {
name = "BankStack Help", type="group",
args = {
header = { name = "BankStack: Things in your bags, they move", type = "header", order = 10, },
commands = {
type = "description", order = 20,
name = "/bankstack -- this menu.\n"..
"/sort -- rearrange your bags\n"..
"/sort bank -- rearrange your bank\n"..
"/stack -- fills stacks in your bank from your bags\n"..
"/stack bank bags -- fills stacks in your bags from your bank\n"..
"/compress -- merges stacks in your bags\n"..
"/compress bank -- merges stacks in your bank\n"..
"/fill -- fills empty slots in your bank from your bags",
},
},
}
local keybindings = {
['BUTTON1'] = "Left Click",
['ALT-BUTTON1'] = "Alt Left Click",
['CTRL-BUTTON1'] = "Ctrl Left Click",
['ALT-CTRL-BUTTON1'] = "Ctrl Alt Left Click",
['SHIFT-BUTTON1'] = "Shift Left Click",
['ALT-SHIFT-BUTTON1'] = "Alt Shift Left Click",
['CTRL-SHIFT-BUTTON1'] = "Ctrl Shift Left Click",
['ALT-CTRL-SHIFT-BUTTON1'] = "Ctrl Alt Shift Left Click",
}
local launcher_options = {
name = "Click assignments", desc = "Modified left-clicks only",
type = "group",
get = function(info)
local k = info[#info]
for b, a in pairs(core.db.fubar_keybinds) do
if a == k then
return b
end
end
end,
set = function(info, v)
-- clear current binding
local k = info[#info]
for b, a in pairs(core.db.fubar_keybinds) do
if a == k then
core.db.fubar_keybinds[b] = false
end
end
-- set new binding
if keybindings[v] then
core.db.fubar_keybinds[v] = k
end
end,
args = {
help = {
type = "description", order = 1,
name = "BankStack contains a LibDataBroker-1.1 launcher, which can be shown by display addons such as "..
"StatBlockCore, Fortress, ButtonBin, Broker2FuBar, and others, which can be used as a quick way to "..
"sort your bags.",
},
sortbags = {name = "Sort Bags", desc = "Modified left-clicks only", type = "select", values = keybindings, order = 10,},
sortbank = {name = "Sort Bank", desc = "Modified left-clicks only", type = "select", values = keybindings, order = 20,},
stackbank = {name = "Stack to Bank", desc = "Modified left-clicks only", type = "select", values = keybindings, order = 30,},
stackbags = {name = "Stack to Bags", desc = "Modified left-clicks only", type = "select", values = keybindings, order = 40,},
compressbags = {name = "Compress Bags", desc = "Modified left-clicks only", type = "select", values = keybindings, order = 50,},
compressbank = {name = "Compress Bank", desc = "Modified left-clicks only", type = "select", values = keybindings, order = 60,},
},
}
local advanced_options = {
name = "Advanced", desc = "Advanced settings", type = "group", order = 100,
get = function(info) return core.db[info[#info]] end,
set = function(info, value) core.db[info[#info]] = value end,
args = {
verbosity = {
name = "Verbosity", desc = "Talkativitinessism", type = "range", min = 0, max = 2, step = 1,
descStyle = "inline",
},
conservative_guild = {
name = "Cautious guild",
desc = "If this option is enabled, only one move at a time will be made. This is slower, but is nearly certain to work. If you turn this off, I make no promises.",
descStyle = "inline",
type = "toggle",
},
timing = {
name = "Timing", inline = true, type = "group",
args = {
desc = {
type = "description", order = 0,
name = "How long to wait during sorting. If you run into problems with Blizzard throttling moves, especially in the guild bank, you can adjust these settings.",
},
stutter_duration = {
name = "Stutter Interval", type = "range",
desc = "How long to spend moving items before pausing to avoid the game noticably stuttering",
min = 0, max = 1, step = 0.05,
order = 10,
},
stutter_delay = {
name = "Stutter Delay", type = "range",
desc = "How long to wait after the stutter interval before starting to move items again",
min = 0, max = 1, step = 0.05,
order = 20,
},
processing_delay = {
name = "Processing Delay", type = "range",
desc = "How long to wait while a move operation is pending. Lower values might make sorting faster, but will use more CPU time.",
min = 0, max = 1, step = 0.05,
order = 30,
},
processing_delay_guild = {
name = "Processing Delay (Guild)", type = "range",
desc = "How long to wait while a move operation is pending if it involves the guild bank.",
min = 0, max = 1, step = 0.05,
order = 40,
},
},
}
},
}
local categoryID
core.setup_config = function()
local acreg = LibStub("AceConfigRegistry-3.0")
acreg:RegisterOptionsTable(myname, options)
acreg:RegisterOptionsTable(myname .. "Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(core.db_object))
acreg:RegisterOptionsTable(myname .. "Help", help_options)
acreg:RegisterOptionsTable(myname .. "Launcher", launcher_options)
acreg:RegisterOptionsTable(myname .. "Advanced", advanced_options)
acreg:RegisterOptionsTable(myname .. "Groups", group_options)
acreg:RegisterOptionsTable(myname .. "Ignore", ignore_options)
local acdia = LibStub("AceConfigDialog-3.0")
categoryID = select(2, acdia:AddToBlizOptions(myname, myname))
acdia:AddToBlizOptions(myname .. "Ignore", "Ignore", myname)
acdia:AddToBlizOptions(myname .. "Groups", "Groups", myname)
acdia:AddToBlizOptions(myname .. "Launcher", "Launcher", myname)
acdia:AddToBlizOptions(myname .. "Advanced", "Advanced", myname)
acdia:AddToBlizOptions(myname .. "Profiles", "Profiles", myname)
acdia:AddToBlizOptions(myname .. "Help", "Help", myname)
end
core.open_config = function()
if not categoryID then return end
Settings.OpenToCategory(categoryID)
--LibStub("AceConfigDialog-3.0"):Open(myname)
end
SLASH_BANKSTACKCONFIG1 = "/bankstack"
SlashCmdList["BANKSTACKCONFIG"] = function(arg)
core.open_config()
end