-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.lua
691 lines (613 loc) · 27 KB
/
settings.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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
local IS = ItemSaver
IS.settings = {}
local util = IS.util
local settings = IS.settings
local vars
local function refreshSettingsPanelSetChoices()
local def = WINDOW_MANAGER:GetControlByName("IS_DefaultSetDropdown")
local edit = WINDOW_MANAGER:GetControlByName("IS_EditSetDropdown")
if not def then return end
def:UpdateValue()
edit:UpdateValue()
end
local function toggleFilter(setName, filterTagSuffix, filterType)
local filterTag = "ItemSaver_"..setName..filterTagSuffix
local isRegistered = util.LibFilters:IsFilterRegistered(filterTag, filterType)
local function filterCallback(slotOrBagId, slotIndex)
local bagId
if type(slotOrBagId) == "number" then
if not slotIndex then return false end
bagId = slotOrBagId
else
bagId, slotIndex = util.GetInfoFromRowControl(slotOrBagId)
end
local _, savedSet = ItemSaver_IsItemSaved(bagId, slotIndex)
return not (savedSet == setName)
end
if not isRegistered then
util.LibFilters:RegisterFilter(filterTag, filterType, filterCallback)
util.LibFilters:RequestUpdate(filterType)
else
util.LibFilters:UnregisterFilter(filterTag, filterType)
util.LibFilters:RequestUpdate(filterType)
end
end
local function toggleFilters()
for setName, setInfo in pairs(vars.savedSetInfo) do
if setInfo.filterStore then toggleFilter(setName, "_VendorSell", LF_VENDOR_SELL) end
if setInfo.filterDeconstruction then
toggleFilter(setName, "_SmithingDeconstruct", LF_SMITHING_DECONSTRUCT)
toggleFilter(setName, "_JewelryDeconstruct", LF_JEWELRY_DECONSTRUCT)
end
if setInfo.filterResearch then
toggleFilter(setName, "_SmithingResearch", LF_SMITHING_RESEARCH)
toggleFilter(setName, "_JewelryResearch", LF_JEWELRY_RESEARCH)
end
if setInfo.filterGuildStore then toggleFilter(setName, "_GuildStoreSell", LF_GUILDSTORE_SELL) end
if setInfo.filterMail then toggleFilter(setName, "_MailSend", LF_MAIL_SEND) end
if setInfo.filterTrade then toggleFilter(setName, "_Trade", LF_TRADE) end
end
end
function settings.InitializeSettings()
local function createOptionsMenu()
local function clearSet(setName)
for savedItem, name in pairs(vars.savedItems) do
if name == setName then
vars.savedItems[savedItem] = nil
end
end
d(GetString(SI_ITEMSAVER_CLEAR_SET_CONFIRMATION) .. " " .. setName)
end
local function updateEditSetSettings(setName)
local setData = ItemSaver_GetSetData(setName)
WINDOW_MANAGER:GetControlByName("IS_EditSetHeader").data.name = GetString(SI_ITEMSAVER_SET_DATA_HEADER) .. " - " .. setName
WINDOW_MANAGER:GetControlByName("IS_DeleteButton").data.disabled = vars.defaultSet == setName
local iconPicker = WINDOW_MANAGER:GetControlByName("IS_IconPicker")
local r, g, b = util.HexToRGB(setData.markerColor)
iconPicker.icon.color.r = r
iconPicker.icon.color.g = g
iconPicker.icon.color.b = b
iconPicker:SetColor(iconPicker.icon.color)
end
local ANCHOR_OPTIONS = {
GetString(SI_ITEMSAVER_ANCHOR_LABEL_TOPLEFT),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_TOP),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_TOPRIGHT),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_RIGHT),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_BOTTOMRIGHT),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_BOTTOM),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_BOTTOMLEFT),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_LEFT),
GetString(SI_ITEMSAVER_ANCHOR_LABEL_CENTER),
}
local DEFER_SUBMENU_OPTIONS = {"1", "2", "3", "4", "5"}
local SAVE_TYPE_OPTIONS = {
GetString(SI_ITEMSAVER_SAVE_TYPE_DROPDOWN_GENERAL),
GetString(SI_ITEMSAVER_SAVE_TYPE_DROPDOWN_UNIQUE),
}
local markerTexturePaths, markerTextureNames = util.GetMarkerTextureArrays()
local editSetName = vars.defaultSet
local editSetData = ItemSaver_GetSetData(editSetName)
local panel = {
type = "panel",
name = GetString(SI_ITEMSAVER_ADDON_NAME),
author = "Randactyl",
version = IS.addonVersion,
website = "http://www.esoui.com/downloads/info300-ItemSaver.html",
slashCommand = "/itemsaver",
registerForRefresh = true,
}
local optionsData = {
{
type = "header",
name = SI_ITEMSAVER_GENERAL_OPTIONS_HEADER,
},
{
type = "dropdown",
name = SI_ITEMSAVER_DEFAULT_SET_DROPDOWN_LABEL,
tooltip = SI_ITEMSAVER_DEFAULT_SET_DROPDOWN_TOOLTIP,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_DefaultSetDropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return vars.defaultSet
end,
setFunc = function(value)
WINDOW_MANAGER:GetControlByName("IS_DeleteButton").data.disabled = value == editSetName
vars.defaultSet = value
end,
reference = "IS_DefaultSetDropdown",
},
{
type = "dropdown",
name = SI_ITEMSAVER_MARKER_ANCHOR_LABEL,
tooltip = SI_ITEMSAVER_MARKER_ANCHOR_TOOLTIP,
choices = ANCHOR_OPTIONS,
getFunc = function()
local anchor = vars.markerAnchor
if anchor == TOPLEFT then return ANCHOR_OPTIONS[1] end
if anchor == TOP then return ANCHOR_OPTIONS[2] end
if anchor == TOPRIGHT then return ANCHOR_OPTIONS[3] end
if anchor == RIGHT then return ANCHOR_OPTIONS[4] end
if anchor == BOTTOMRIGHT then return ANCHOR_OPTIONS[5] end
if anchor == BOTTOM then return ANCHOR_OPTIONS[6] end
if anchor == BOTTOMLEFT then return ANCHOR_OPTIONS[7] end
if anchor == LEFT then return ANCHOR_OPTIONS[8] end
if anchor == CENTER then return ANCHOR_OPTIONS[9] end
end,
setFunc = function(value)
if value == ANCHOR_OPTIONS[1] then vars.markerAnchor = TOPLEFT end
if value == ANCHOR_OPTIONS[2] then vars.markerAnchor = TOP end
if value == ANCHOR_OPTIONS[3] then vars.markerAnchor = TOPRIGHT end
if value == ANCHOR_OPTIONS[4] then vars.markerAnchor = RIGHT end
if value == ANCHOR_OPTIONS[5] then vars.markerAnchor = BOTTOMRIGHT end
if value == ANCHOR_OPTIONS[6] then vars.markerAnchor = BOTTOM end
if value == ANCHOR_OPTIONS[7] then vars.markerAnchor = BOTTOMLEFT end
if value == ANCHOR_OPTIONS[8] then vars.markerAnchor = LEFT end
if value == ANCHOR_OPTIONS[9] then vars.markerAnchor = CENTER end
end,
},
{
type = "slider",
name = SI_ITEMSAVER_OFFSET_X_SLIDER,
tooltip = SI_ITEMSAVER_OFFSET_X_TOOLTIP,
getFunc = function() return vars.offsetX end,
setFunc = function(value) vars.offsetX = value end,
min = -10,
max = 10,
step = 1,
autoSelect = true,
width = "half",
},
{
type = "slider",
name = SI_ITEMSAVER_OFFSET_Y_SLIDER,
tooltip = SI_ITEMSAVER_OFFSET_Y_TOOLTIP,
getFunc = function() return vars.offsetY end,
setFunc = function(value) vars.offsetY = value end,
min = -10,
max = 10,
step = 1,
autoSelect = true,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_DEFER_SUBMENU_CHECKBOX_LABEL,
tooltip = SI_ITEMSAVER_DEFER_SUBMENU_CHECKBOX_TOOLTIP,
getFunc = function() return vars.deferSubmenu end,
setFunc = function(value)
vars.deferSubmenu = value
local dropdown = WINDOW_MANAGER:GetControlByName("IS_DeferSubmenuDropdown")
dropdown.data.disabled = not value
end,
width = "half",
},
{
type = "dropdown",
name = SI_ITEMSAVER_DEFER_SUBMENU_DROPDOWN_LABEL,
tooltip = SI_ITEMSAVER_DEFER_SUBMENU_DROPDOWN_TOOLTIP,
choices = DEFER_SUBMENU_OPTIONS,
getFunc = function()
local num = vars.deferSubmenuNum
if num == 1 then return DEFER_SUBMENU_OPTIONS[1] end
if num == 2 then return DEFER_SUBMENU_OPTIONS[2] end
if num == 3 then return DEFER_SUBMENU_OPTIONS[3] end
if num == 4 then return DEFER_SUBMENU_OPTIONS[4] end
if num == 5 then return DEFER_SUBMENU_OPTIONS[5] end
end,
setFunc = function(value)
if value == DEFER_SUBMENU_OPTIONS[1] then vars.deferSubmenuNum = 1 end
if value == DEFER_SUBMENU_OPTIONS[2] then vars.deferSubmenuNum = 2 end
if value == DEFER_SUBMENU_OPTIONS[3] then vars.deferSubmenuNum = 3 end
if value == DEFER_SUBMENU_OPTIONS[4] then vars.deferSubmenuNum = 4 end
if value == DEFER_SUBMENU_OPTIONS[5] then vars.deferSubmenuNum = 5 end
end,
width = "half",
disabled = not vars.deferSubmenu,
reference = "IS_DeferSubmenuDropdown",
},
{
type = "submenu",
name = SI_ITEMSAVER_KEYBIND_SUBMENU_NAME,
controls = {
{
type = "dropdown",
name = SI_ITEMSAVER_KEYBIND_SET_1_NAME,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_KeybindSet1Dropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return vars.keybindSetMap[1] or ItemSaver_GetDefaultSet()
end,
setFunc = function(value)
vars.keybindSetMap[1] = value
end,
reference = "IS_KeybindSet1Dropdown",
},
{
type = "dropdown",
name = SI_ITEMSAVER_KEYBIND_SET_2_NAME,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_KeybindSet2Dropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return vars.keybindSetMap[2] or ItemSaver_GetDefaultSet()
end,
setFunc = function(value)
vars.keybindSetMap[2] = value
end,
reference = "IS_KeybindSet2Dropdown",
},
{
type = "dropdown",
name = SI_ITEMSAVER_KEYBIND_SET_3_NAME,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_KeybindSet3Dropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return vars.keybindSetMap[3] or ItemSaver_GetDefaultSet()
end,
setFunc = function(value)
vars.keybindSetMap[3] = value
end,
reference = "IS_KeybindSet3Dropdown",
},
{
type = "dropdown",
name = SI_ITEMSAVER_KEYBIND_SET_4_NAME,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_KeybindSet4Dropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return vars.keybindSetMap[4] or ItemSaver_GetDefaultSet()
end,
setFunc = function(value)
vars.keybindSetMap[4] = value
end,
reference = "IS_KeybindSet4Dropdown",
},
{
type = "dropdown",
name = SI_ITEMSAVER_KEYBIND_SET_5_NAME,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_KeybindSet5Dropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return vars.keybindSetMap[5] or ItemSaver_GetDefaultSet()
end,
setFunc = function(value)
vars.keybindSetMap[5] = value
end,
reference = "IS_KeybindSet5Dropdown",
},
},
},
{
type = "dropdown",
name = SI_ITEMSAVER_EDIT_SET_DROPDOWN_LABEL,
choices = ItemSaver_GetSaveSets(),
getFunc = function()
this = WINDOW_MANAGER:GetControlByName("IS_EditSetDropdown")
this:UpdateChoices(ItemSaver_GetSaveSets())
return editSetName
end,
setFunc = function(setName)
editSetName = setName
editSetData = ItemSaver_GetSetData(setName)
updateEditSetSettings(setName)
end,
tooltip = SI_ITEMSAVER_EDIT_SET_DROPDOWN_TOOLTIP,
reference = "IS_EditSetDropdown",
},
{
type = "header",
name = GetString(SI_ITEMSAVER_SET_DATA_HEADER) .. " - " .. editSetName,
reference = "IS_EditSetHeader",
},
{
type = "dropdown",
name = SI_ITEMSAVER_SAVE_TYPE_DROPDOWN_LABEL,
tooltip = SI_ITEMSAVER_SAVE_TYPE_DROPDOWN_TOOLTIP,
choices = SAVE_TYPE_OPTIONS,
getFunc = function()
local areItemsUnique = editSetData.areItemsUnique or false
if areItemsUnique then return SAVE_TYPE_OPTIONS[2] end
return SAVE_TYPE_OPTIONS[1]
end,
setFunc = function(value)
--get new selection
local newSelection = true
if value == SAVE_TYPE_OPTIONS[1] then
newSelection = false
end
--clear the set if the user has set this before (migration)
if editSetData.areItemsUnique ~= nil then
clearSet(editSetName)
end
--set selection
editSetData.areItemsUnique = newSelection
end,
warning = SI_ITEMSAVER_SAVE_TYPE_DROPDOWN_WARNING,
reference = "IS_SaveTypeDropdown",
},
{
type = "iconpicker",
name = SI_ITEMSAVER_MARKER_LABEL,
tooltip = SI_ITEMSAVER_MARKER_TOOLTIP,
choices = markerTexturePaths,
choicesTooltips = markerTextureNames,
getFunc = function()
local markerTextureName = editSetData.markerTexture
for i, name in ipairs(markerTextureNames) do
if name == markerTextureName then
return markerTexturePaths[i]
end
end
end,
setFunc = function(markerTexturePath)
for i, path in ipairs(markerTexturePaths) do
if path == markerTexturePath then
editSetData.markerTexture = markerTextureNames[i]
end
end
end,
maxColumns = 5,
visibleRows = zo_min(zo_max(zo_floor(#markerTexturePaths/5), 1), 4.5),
iconSize = 32,
defaultColor = ZO_ColorDef:New(util.HexToRGB(editSetData.markerColor)),
width = "half",
reference = "IS_IconPicker",
},
{
type = "colorpicker",
name = SI_ITEMSAVER_TEXTURE_COLOR_LABEL,
tooltip = SI_ITEMSAVER_TEXTURE_COLOR_TOOLTIP,
getFunc = function()
return util.HexToRGB(editSetData.markerColor)
end,
setFunc = function(r, g, b)
local iconPicker = WINDOW_MANAGER:GetControlByName("IS_IconPicker")
iconPicker.icon.color.r = r
iconPicker.icon.color.g = g
iconPicker.icon.color.b = b
iconPicker:SetColor(iconPicker.icon.color)
editSetData.markerColor = util.RGBToHex(r, g, b)
end,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_FILTERS_VENDORSELL_LABEL,
tooltip = SI_ITEMSAVER_FILTERS_VENDORSELL_TOOLTIP,
getFunc = function() return editSetData.filterStore end,
setFunc = function(value)
editSetData.filterStore = value
toggleFilter(editSetName, "_VendorSell", LF_VENDOR_SELL)
end,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_FILTERS_SMITHINGDECONSTRUCT_LABEL,
tooltip = SI_ITEMSAVER_FILTERS_SMITHINGDECONSTRUCT_TOOLTIP,
getFunc = function() return editSetData.filterDeconstruction end,
setFunc = function(value)
editSetData.filterDeconstruction = value
toggleFilter(editSetName, "_SmithingDeconstruct", LF_SMITHING_DECONSTRUCT)
toggleFilter(editSetName, "_JewelryDeconstruct", LF_JEWELRY_DECONSTRUCT)
end,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_FILTERS_SMITHINGRESEARCH_LABEL,
tooltip = SI_ITEMSAVER_FILTERS_SMITHINGRESEARCH_TOOLTIP,
getFunc = function() return editSetData.filterResearch end,
setFunc = function(value)
editSetData.filterResearch = value
toggleFilter(editSetName, "_SmithingResearch", LF_SMITHING_RESEARCH)
toggleFilter(editSetName, "_JewelryResearch", LF_JEWELRY_RESEARCH)
end,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_FILTERS_GUILDSTORESELL_LABEL,
tooltip = SI_ITEMSAVER_FILTERS_GUILDSTORESELL_TOOLTIP,
getFunc = function() return editSetData.filterGuildStore end,
setFunc = function(value)
editSetData.filterGuildStore = value
toggleFilter(editSetName, "_GuildStoreSell", LF_GUILDSTORE_SELL)
end,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_FILTERS_MAILSEND_LABEL,
tooltip = SI_ITEMSAVER_FILTERS_MAILSEND_TOOLTIP,
getFunc = function() return editSetData.filterMail end,
setFunc = function(value)
editSetData.filterMail = value
toggleFilter(editSetName, "_MailSend", LF_MAIL_SEND)
end,
width = "half",
},
{
type = "checkbox",
name = SI_ITEMSAVER_FILTERS_TRADE_LABEL,
tooltip = SI_ITEMSAVER_FILTERS_TRADE_TOOLTIP,
getFunc = function() return editSetData.filterTrade end,
setFunc = function(value)
editSetData.filterTrade = value
toggleFilter(editSetName, "_Trade", LF_TRADE)
end,
width = "half",
},
{
type = "button",
name = SI_ITEMSAVER_CLEAR_SET_BUTTON,
tooltip = SI_ITEMSAVER_CLEAR_SET_TOOLTIP,
func = function() clearSet(editSetName) end,
isDangerous = true,
},
{
type = "button",
name = SI_ITEMSAVER_DELETE_SET_BUTTON,
tooltip = SI_ITEMSAVER_DELETE_SET_TOOLTIP,
func = function()
vars.savedSetInfo[editSetName] = nil
for index, setName in ipairs(vars.keybindSetMap) do
if setName == editSetName then vars.keybindSetMap[index] = nil end
end
clearSet(editSetName)
if setName == "Default" then
vars.shouldCreateDefault = false
end
editSetName = vars.defaultSet
editSetData = ItemSaver_GetSetData(vars.defaultSet)
WINDOW_MANAGER:GetControlByName("IS_DefaultSetDropdown"):UpdateValue()
WINDOW_MANAGER:GetControlByName("IS_EditSetDropdown"):UpdateValue()
updateEditSetSettings(vars.defaultSet)
end,
disabled = editSetName == vars.defaultSet,
isDangerous = true,
reference = "IS_DeleteButton",
},
}
util.lam:RegisterAddonPanel("ItemSaverSettingsPanel", panel)
util.lam:RegisterOptionControls("ItemSaverSettingsPanel", optionsData)
end
local defaults = {
markerAnchor = TOPLEFT,
offsetX = 0,
offsetY = 0,
savedSetInfo = {},
savedItems = {},
deferSubmenu = false,
deferSubmenuNum = 3,
defaultSet = "Default",
shouldCreateDefault = true,
keybindSetMap = {},
}
settings.vars = ZO_SavedVars:NewAccountWide("ItemSaver_Settings", 2.0, nil, defaults)
vars = settings.vars
if vars.shouldCreateDefault then
vars.savedSetInfo["Default"] = {
markerTexture = "Star",
markerColor = util.RGBToHex(1, 1, 0),
filterStore = true,
filterDeconstruction = true,
filterResearch = true,
filterGuildStore = false,
filterMail = false,
filterTrade = false,
}
vars.shouldCreateDefault = false
end
toggleFilters()
createOptionsMenu()
end
function settings.AddSet(setName, setData)
if setName == "" or ItemSaver_GetSetData(setName) then
return false
end
vars.savedSetInfo[setName] = setData
toggleFilter(setName, "_VendorSell", LF_VENDOR_SELL)
toggleFilter(setName, "_SmithingDeconstruct", LF_SMITHING_DECONSTRUCT)
toggleFilter(setName, "_JewelryDeconstruct", LF_JEWELRY_DECONSTRUCT)
toggleFilter(setName, "_SmithingResearch", LF_SMITHING_RESEARCH)
toggleFilter(setName, "_JewelryResearch", LF_JEWELRY_RESEARCH)
toggleFilter(setName, "_GuildStoreSell", LF_GUILDSTORE_SELL)
toggleFilter(setName, "_MailSend", LF_MAIL_SEND)
toggleFilter(setName, "_Trade", LF_TRADE)
refreshSettingsPanelSetChoices()
return true
end
function settings.GetDefaultSet()
return vars.defaultSet
end
function settings.GetFilters(setName)
local setData = ItemSaver_GetSetData(setName)
if setData then
return {
store = setData.filterStore,
deconstruction = setData.filterDeconstruction,
research = setData.filterResearch,
guildStore = setData.filterGuildStore,
mail = setData.filterMail,
trade = setData.filterTrade,
}
end
end
function settings.GetMarkerAnchor()
return vars.markerAnchor, vars.offsetX, vars.offsetY
end
function settings.GetMarkerInfo(bagId, slotIndex)
local _, setName = ItemSaver_IsItemSaved(bagId, slotIndex)
if setName then
local savedSet = ItemSaver_GetSetData(setName)
return util.markerTextures[savedSet.markerTexture], util.HexToRGB(savedSet.markerColor)
end
return nil
end
function settings.GetSaveSets()
local setNames = {}
for setName, _ in pairs(vars.savedSetInfo) do
table.insert(setNames, setName)
end
table.sort(setNames)
return setNames
end
function settings.GetSetData(setName)
return vars.savedSetInfo[setName]
end
function settings.GetSetNameByKeybindIndex(index)
return vars.keybindSetMap[index]
end
function settings.IsItemSaved(bagId, slotIndex)
local uIdString = Id64ToString(GetItemUniqueId(bagId, slotIndex))
local signedInstanceId = util.SignItemInstanceId(GetItemInstanceId(bagId, slotIndex))
if vars.savedItems[uIdString] then
return true, vars.savedItems[uIdString]
elseif vars.savedItems[signedInstanceId] then
return true, vars.savedItems[signedInstanceId]
end
return false
end
function settings.IsSubmenuDeferred()
if vars.deferSubmenu then
return vars.deferSubmenu, vars.deferSubmenuNum
end
return vars.deferSubmenu
end
function settings.ToggleItemSave(setName, bagId, slotIndex)
if type(setName) == "number" then
setName = ItemSaver_GetSetNameByKeybindIndex(setName)
end
if not setName then
setName = ItemSaver_GetDefaultSet()
end
local isSaved, oldSetName = ItemSaver_IsItemSaved(bagId, slotIndex)
local areItemsUnique, id
--unsave item
if isSaved then
areItemsUnique = ItemSaver_GetSetData(oldSetName).areItemsUnique or false
if areItemsUnique then
id = Id64ToString(GetItemUniqueId(bagId, slotIndex))
else
id = util.SignItemInstanceId(GetItemInstanceId(bagId, slotIndex))
end
vars.savedItems[id] = nil
return false
end
--save item
areItemsUnique = ItemSaver_GetSetData(setName).areItemsUnique or false
if areItemsUnique then
id = Id64ToString(GetItemUniqueId(bagId, slotIndex))
else
id = util.SignItemInstanceId(GetItemInstanceId(bagId, slotIndex))
end
vars.savedItems[id] = setName
return true
end