-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdiBags_Item_Sets.lua
96 lines (85 loc) · 2.48 KB
/
AdiBags_Item_Sets.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
-- This addon/module
local _, addon = ...
-- AdiBags addon
local AdiBags = LibStub("AceAddon-3.0"):GetAddon("AdiBags")
-- Dababase
local db = addon.db
-- Filter Setup
local filter = AdiBags:RegisterFilter('Item Sets', 98)
filter.uiName = 'Item Sets'
filter.uiDesc = 'Put sets items in their own sections.'
-- Filter events
function filter:OnEnable()
AdiBags:UpdateFilters()
end
function filter:OnDisable()
AdiBags:UpdateFilters()
end
function filter:Update()
self:SendMessage("AdiBags_FiltersChanged")
end
function filter:OnInitialize()
self.db = AdiBags.db:RegisterNamespace(self.filterName, {
profile = {
enablePVE = true,
enablePVP = true,
enablePVPHonor = true,
enablePVPArena = true,
},
})
end
-- Filter UI Options
function filter:GetOptions()
return {
enablePVE = {
name ="PVE Sets",
desc = "Enable section for PVE sets.",
type = "toggle",
width = "double",
order = 10,
},
enablePVP = {
name ="PVP Sets",
desc = "Enable section for PVP sets.",
type = "toggle",
width = "double",
order = 15,
},
includeWeapons = {
name ="Include Weapons",
desc = "Include weapons in sets.",
type = "toggle",
width = "double",
order = 20,
disabled = function() return not self.db.profile.enablePVE and not self.db.profile.enablePVP end,
},
}, AdiBags:GetOptionHandler(self, true, function() return self:Update() end)
end
-- Filter action
function filter:Filter(slotData)
local _, _, _, slotItemId = slotData.bag, slotData.slot, slotData.quality, slotData.itemId
for _, categories in pairs(db) do -- Expansions (Vanilla, TBC, Wrath...)
for categoryName, sources in pairs(categories) do -- Categories (Armor, Weapons)
if ((categoryName == "Armor") or ((categoryName == "Weapons") and self.db.profile.includeWeapons)) then
for sourceName, tags in pairs(sources) do -- Sources (PVE, PVP)
if ((sourceName == "PVE") and self.db.profile.enablePVE) or
((sourceName == "PVP") and self.db.profile.enablePVP) then
for tagName, itemSets in pairs(tags) do -- Tags (Dungeon, Tier, Honor, Arena)
if (tagName == "Tier") or
((tagName == "Honor") and self.db.profile.enablePVPHonor) or
((tagName == "Arena") and self.db.profile.enablePVPArena) then
for setName, items in pairs(itemSets) do
for _, itemId in ipairs(items) do
if (itemId == slotItemId) then
return "Item Set: " .. setName;
end
end
end
end
end
end
end
end
end
end
end