-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
952 additions
and
654 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--[[ ========================================================================== | ||
Category.lua | ||
========================================================================== ]]-- | ||
|
||
local _G = _G | ||
|
||
local AddOnName, _ = ... | ||
local AddOn = _G[AddOnName] | ||
|
||
-- LUA Functions | ||
local pairs = _G.pairs | ||
|
||
-- Libs | ||
local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) | ||
|
||
-- Local storage | ||
local BagTypes = {} | ||
local bankcategorycache = {} | ||
local categorycache = {} | ||
|
||
local function Matches(bag,slot,rule) | ||
if not (bag and slot and rule.category) then return end | ||
local key = bag..":"..slot | ||
if BagTypes[bag] == 2 or BagTypes[bag] == 4 then | ||
return bankcategorycache[rule.category] and bankcategorycache[rule.category][key] | ||
else | ||
return categorycache[rule.category] and categorycache[rule.category][key] | ||
end | ||
end | ||
|
||
local function GetName(rule) | ||
if rule.category then | ||
return L["Category"].." :"..rule.category | ||
else | ||
return L["Category"] | ||
end | ||
end | ||
|
||
AddOn:AddCustomRule("Category", | ||
{ | ||
DisplayName = L["Category"], | ||
Description = L["Items that match another category"], | ||
Matches = Matches, | ||
GetName = GetName, | ||
Ace3Options = { | ||
category = { | ||
name = L["Category"], | ||
desc = "", | ||
type = 'select', | ||
values = function() | ||
local tmp = {} | ||
for k in pairs(AddOn.db.profile.categories) do | ||
tmp[k] = k | ||
end | ||
return tmp | ||
end, | ||
}, | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--[[ ========================================================================== | ||
Empty.lua | ||
========================================================================== ]]-- | ||
|
||
local _G = _G | ||
|
||
local AddOnName, _ = ... | ||
local AddOn = _G[AddOnName] | ||
|
||
-- WoW API | ||
local GetContainerItemLink = _G.GetContainerItemLink | ||
|
||
-- Libs | ||
local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) | ||
|
||
-- Local storage | ||
local BagTypes = {} | ||
|
||
-- Build list of bag types | ||
local function BuildBagTypes() | ||
|
||
-- Common bags | ||
BagTypes[BACKPACK_CONTAINER] = 1 | ||
BagTypes[BANK_CONTAINER] = 2 | ||
|
||
for i = 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do | ||
|
||
if i <= NUM_BAG_SLOTS then | ||
BagTypes[i] = 1 -- Bags | ||
else | ||
BagTypes[i] = 2 -- Bank bags | ||
end | ||
|
||
end | ||
|
||
-- Classic specific bag | ||
--[===[@non-retail@ | ||
BagTypes[KEYRING_CONTAINER] = 3 | ||
--@end-non-retail@]===] | ||
|
||
-- Retail specific bag | ||
--@retail@ | ||
BagTypes[REAGENTBANK_CONTAINER] = 4 | ||
--@end-retail@ | ||
|
||
end | ||
|
||
BuildBagTypes() | ||
|
||
local function Matches(bag,slot,_) | ||
if not (bag and slot) then return end | ||
if BagTypes[bag] == 3 then return end | ||
local link = GetContainerItemLink(bag, slot) | ||
if not link then | ||
return true | ||
end | ||
end | ||
|
||
local function GetName() | ||
return L["Empty Slots"] | ||
end | ||
|
||
AddOn:AddCustomRule("Empty", { | ||
DisplayName = L["Empty Slots"], | ||
Description = L["Empty bag slots"], | ||
Matches = Matches, | ||
GetName = GetName, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--[[ ========================================================================== | ||
EquipLocation.lua | ||
========================================================================== ]]-- | ||
|
||
local _G = _G | ||
|
||
local AddOnName, _ = ... | ||
local AddOn = _G[AddOnName] | ||
|
||
-- WoW API | ||
local GetContainerItemLink = _G.GetContainerItemLink | ||
local GetItemInfoInstant = _G.GetItemInfoInstant | ||
|
||
-- Libs | ||
local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) | ||
|
||
local EquipLocs = { | ||
"INVTYPE_AMMO", | ||
"INVTYPE_HEAD", | ||
"INVTYPE_NECK", | ||
"INVTYPE_SHOULDER", | ||
"INVTYPE_BODY", | ||
"INVTYPE_CHEST", | ||
"INVTYPE_ROBE", | ||
"INVTYPE_WAIST", | ||
"INVTYPE_LEGS", | ||
"INVTYPE_FEET", | ||
"INVTYPE_WRIST", | ||
"INVTYPE_HAND", | ||
"INVTYPE_FINGER", | ||
"INVTYPE_TRINKET", | ||
"INVTYPE_CLOAK", | ||
"INVTYPE_WEAPON", | ||
"INVTYPE_SHIELD", | ||
"INVTYPE_2HWEAPON", | ||
"INVTYPE_WEAPONMAINHAND", | ||
"INVTYPE_WEAPONOFFHAND", | ||
"INVTYPE_HOLDABLE", | ||
"INVTYPE_RANGED", | ||
"INVTYPE_THROWN", | ||
"INVTYPE_RANGEDRIGHT", | ||
"INVTYPE_RELIC", | ||
"INVTYPE_TABARD", | ||
"INVTYPE_BAG" | ||
} | ||
|
||
local EquipLocs2 = {} | ||
for _,v in ipairs(EquipLocs) do | ||
EquipLocs2[v] = _G[v] or v | ||
end | ||
|
||
local function Matches(bag,slot,rule) | ||
if not rule.equiploc then return end | ||
local link = GetContainerItemLink(bag, slot) | ||
if link then | ||
local _, _, _, EquipLoc = GetItemInfoInstant(link) | ||
if EquipLoc then | ||
return EquipLoc == rule.equiploc | ||
end | ||
end | ||
end | ||
|
||
local function GetName(rule) | ||
return "Equip Location: "..(_G[rule.equiploc] or rule.equiploc or "*None*") | ||
end | ||
|
||
AddOn:AddCustomRule("EquipLoc", | ||
{ | ||
DisplayName = L["Equip Location"], | ||
Description = L["Filter by Equip Location as returned by GetItemInfo"], | ||
Matches = Matches, | ||
GetName = GetName, | ||
Ace3Options = { | ||
equiploc = { | ||
name = L["Location"], | ||
desc = "", | ||
type = 'select', | ||
values = EquipLocs2, | ||
}, | ||
}, | ||
CleanRule = function(rule) | ||
rule.equiploc = EquipLocs[1] | ||
end, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--[[ ========================================================================== | ||
EquipmentSlot.lua | ||
========================================================================== ]]-- | ||
|
||
local _G = _G | ||
|
||
local AddOnName, _ = ... | ||
local AddOn = _G[AddOnName] | ||
|
||
-- LUA Functions | ||
local pairs = _G.pairs | ||
|
||
-- WoW API | ||
local GetContainerItemID = _G.GetContainerItemID | ||
local GetItemInfoInstant = _G.GetItemInfoInstant | ||
|
||
-- Libs | ||
local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) | ||
|
||
local INV_TYPES = { | ||
INVTYPE_HEAD = INVTYPE_HEAD, | ||
INVTYPE_NECK = INVTYPE_NECK, | ||
INVTYPE_SHOULDER = INVTYPE_SHOULDER, | ||
INVTYPE_BODY = INVTYPE_BODY, | ||
INVTYPE_CHEST = INVTYPE_CHEST, | ||
INVTYPE_ROBE = INVTYPE_ROBE, | ||
INVTYPE_WAIST = INVTYPE_WAIST, | ||
INVTYPE_LEGS = INVTYPE_LEGS, | ||
INVTYPE_FEET = INVTYPE_FEET, | ||
INVTYPE_WRIST = INVTYPE_WRIST, | ||
INVTYPE_HAND = INVTYPE_HAND, | ||
INVTYPE_FINGER = INVTYPE_FINGER, | ||
INVTYPE_TRINKET = INVTYPE_TRINKET, | ||
INVTYPE_CLOAK = INVTYPE_CLOAK, | ||
INVTYPE_WEAPON = INVTYPE_WEAPON, | ||
INVTYPE_SHIELD = INVTYPE_SHIELD, | ||
INVTYPE_2HWEAPON = INVTYPE_2HWEAPON, | ||
INVTYPE_WEAPONMAINHAND = INVTYPE_WEAPONMAINHAND, | ||
INVTYPE_WEAPONOFFHAND = INVTYPE_WEAPONOFFHAND, | ||
INVTYPE_HOLDABLE = INVTYPE_HOLDABLE, | ||
INVTYPE_RANGED = INVTYPE_RANGED, | ||
INVTYPE_THROWN = INVTYPE_THROWN, | ||
INVTYPE_RANGEDRIGHT = INVTYPE_RANGEDRIGHT, | ||
INVTYPE_RELIC = INVTYPE_RELIC, | ||
INVTYPE_TABARD = INVTYPE_TABARD, | ||
INVTYPE_BAG = INVTYPE_BAG, | ||
INVTYPE_QUIVER = INVTYPE_QUIVER, | ||
} | ||
|
||
local function getSlotValue(info, key) | ||
return info.arg.slots and info.arg.slots[key] | ||
end | ||
|
||
local function toggleSlotValue(info, key, value) | ||
if not info.arg.slots then | ||
info.arg.slots = {} | ||
end | ||
info.arg.slots[key] = value | ||
AddOn:OnRuleChanged() | ||
end | ||
|
||
local function Matches(bag, slot, rule) | ||
local itemId = GetContainerItemID(bag, slot) | ||
if not rule.slots then | ||
return "" | ||
end | ||
if not itemId then return end | ||
local _, _, _, equiploc = GetItemInfoInstant(itemId) | ||
return rule.slots[equiploc] ~= nil | ||
end | ||
|
||
local function GetName(rule) | ||
if not rule.slots then | ||
return "" | ||
end | ||
local slotlist = {} | ||
for k in pairs(rule.slots) do | ||
tinsert(slotlist, k) | ||
end | ||
local result = (","):join(slotlist) | ||
wipe(slotlist) | ||
return result | ||
end | ||
|
||
AddOn:AddCustomRule("EquipmentSlot", | ||
{ | ||
DisplayName = L["Equipment Slot"], | ||
Description = L["Filter by Equipment Slot"], | ||
GetName = GetName, | ||
Matches = Matches, | ||
Ace3Options = { | ||
slots = { | ||
name = L["Equipment Slots"], | ||
desc = "", | ||
type = 'multiselect', | ||
values = INV_TYPES, | ||
get = getSlotValue, | ||
set = toggleSlotValue, | ||
}, | ||
}, | ||
} | ||
) |
Oops, something went wrong.