diff --git a/Baggins-Filtering.lua b/Baggins-Filtering.lua index 94df519..ca0c152 100644 --- a/Baggins-Filtering.lua +++ b/Baggins-Filtering.lua @@ -12,8 +12,8 @@ local Baggins = _G.Baggins -- TODO: Clean up this section -- LUA Functions -local pairs, ipairs, type, tonumber, tostring, format, min, max, wipe = - _G.pairs, _G.ipairs, _G.type, _G.tonumber, _G.tostring, _G.format, _G.min, _G.max, _G.wipe +local pairs, ipairs, type, tonumber, format, wipe = + _G.pairs, _G.ipairs, _G.type, _G.tonumber, _G.format, _G.wipe local tinsert, tsort = _G.tinsert, _G.table.sort @@ -21,23 +21,12 @@ local tinsert, tsort = -- WoW API local BANK_CONTAINER = _G.BANK_CONTAINER -local GetItemInfo, GetContainerItemLink, GetContainerItemID, GetContainerItemInfo, GetContainerNumFreeSlots, GetContainerNumSlots = - _G.GetItemInfo, _G.GetContainerItemLink, _G.GetContainerItemID, _G.GetContainerItemInfo, _G.GetContainerNumFreeSlots, _G.GetContainerNumSlots -local GetItemInfoInstant, GetItemClassInfo, GetItemSubClassInfo = - _G.GetItemInfoInstant, _G.GetItemClassInfo, _G.GetItemSubClassInfo -local UnitLevel = _G.UnitLevel +local GetContainerItemInfo, GetContainerNumFreeSlots, GetContainerNumSlots = + _G.GetContainerItemInfo, _G.GetContainerNumFreeSlots, _G.GetContainerNumSlots local C_Item, ItemLocation = _G.C_Item, _G.ItemLocation -local BankButtonIDToInvSlotID = _G.BankButtonIDToInvSlotID ---[===[@non-retail@ -local GetAuctionItemSubClasses = _G.GetAuctionItemSubClasses ---@end-non-retail@]===] ---@retail@ -local GetAuctionItemSubClasses = _G.C_AuctionHouse.GetAuctionItemSubClasses ---@end-retail@ -- Libs -local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) -local LG = LibStub("LibGratuity-3.0") --luacheck: ignore 211 +--local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) local LIUI = LibStub("LibItemUpgradeInfo-1.0") --luacheck: ignore 211 local LBU = LibStub("LibBagUtils-1.0") @@ -95,42 +84,6 @@ function Baggins:SetCategoryTable(cats) --luacheck: ignore 212 categories = cats end - -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 - function Baggins:AddCustomRule(ruletype,description) --luacheck: ignore 212 RuleTypes[ruletype] = description end @@ -571,607 +524,5 @@ function Baggins:GetCachedItem(item) --luacheck: ignore 212 return slotcache[item] end ------------------------------------------------------------------------ --- ItemType - --------------------------- --- Baggins: AH category scanned 2016-07-21 22:56:38 - patch 7.0.3 - -local ItemTypes = { - [1]="Container", - [2]="Weapon", - [3]="Gem", - [4]="Armor", - [5]="Reagent",--won't use in classic -- - [6]="Projectile", - [7]="Tradeskill", - [8]="Item Enhancement", - [9]="Recipe", - [10]="Money(OBSOLETE)", - [11]="Quiver", - [12]="Quest", - [13]="Key", - [14]="Permanent(OBSOLETE)", - [15]="Miscellaneous", - [16]="Glyph",--won't use in classic -- - [17]="Battle Pets",--won't use in classic -- - [18]="WoW Token",--won't use in classic -- - [0]="Consumable" -} - ---[[ -local ItemTypes = { - ["Weapon"] = {"One-Handed Axes", "Two-Handed Axes", "Bows", "Guns", "One-Handed Maces", "Two-Handed Maces", "Polearms", "One-Handed Swords", "Two-Handed Swords", "Staves", "Fist Weapons", "Miscellaneous", "Daggers", "Thrown", "Crossbows", "Wands", "Fishing Poles"}, - ["Armor"] = {"Miscellaneous", "Cloth", "Leather", "Mail", "Plate", "Cosmetic", "Shields"}, - ["Container"] = {"Bag", "Herb Bag", "Enchanting Bag", "Engineering Bag", "Gem Bag", "Mining Bag", "Leatherworking Bag", "Inscription Bag", "Tackle Box", "Cooking Bag"}, - ["Gem"] = {"Red", "Blue", "Yellow", "Purple", "Green", "Orange", "Meta", "Simple", "Prismatic", "Cogwheel"}, - ["Consumable"] = {"Food & Drink", "Potion", "Elixir", "Flask", "Bandage", "Item Enhancement", "Scroll", "Other"}, - ["Glyph"] = {"Warrior", "Paladin", "Hunter", "Rogue", "Priest", "Death Knight", "Shaman", "Mage", "Warlock", "Monk", "Druid"}, - ["Item Enhancement"] = {}, - ["Trade Goods"] = {"Elemental", "Cloth", "Leather", "Metal & Stone", "Cooking", "Herb", "Enchanting", "Jewelcrafting", "Parts", "Devices", "Explosives", "Materials", "Other", "Item Enchantment"}, - ["Quest"] = {}, - ["Recipe"] = {"Book", "Leatherworking", "Tailoring", "Engineering", "Blacksmithing", "Cooking", "Alchemy", "First Aid", "Enchanting", "Fishing", "Jewelcrafting", "Inscription"}, - ["Miscellaneous"] = {"Junk", "Reagent", "Companion Pets", "Holiday", "Other", "Mount"}, - ["Battle Pets"] = {"Humanoid", "Dragonkin", "Flying", "Undead", "Critter", "Magic", "Elemental", "Beast", "Aquatic", "Mechanical"}, -}--]] - - ---[[ -SELECTED_CHAT_FRAME:AddMessage("--------------------------") -SELECTED_CHAT_FRAME:AddMessage("-- scanned "..date("%c").. " - patch "..(GetBuildInfo())) -SELECTED_CHAT_FRAME:AddMessage("local ItemTypes = {") -for i,class in pairs{GetAuctionItemClasses()} do - local subs={GetAuctionItemSubClasses(i)} - if #subs>0 then - - SELECTED_CHAT_FRAME:AddMessage(' ["'..class..'"] = {"'.. - table.concat(subs, '", "') .. - '"},') - else - SELECTED_CHAT_FRAME:AddMessage(' ["'..class..'"] = {},') - end -end -SELECTED_CHAT_FRAME:AddMessage("}") ---]] - -Baggins:AddCustomRule("ItemType", { - DisplayName = L["Item Type"], - Description = L["Filter by Item type and sub-type as returned by GetItemInfo"], - Matches = function(bag,slot,rule) - if not (rule.itype or rule.isubtype) then return end - local itemid = GetContainerItemID(bag, slot) - if itemid then - local _, _, _, _, _, TypeID, SubTypeID = GetItemInfoInstant(itemid) - if TypeID and SubTypeID then - return TypeID == rule.itype and (rule.isubtype == nil or SubTypeID == rule.isubtype ) - end - end - end, - GetName = function(rule) - local ltype, lsubtype = "*", "*" - if rule.itype then - ltype = GetItemClassInfo(rule.itype) or "?" - end - if rule.isubtype then - lsubtype = GetItemSubClassInfo(rule.itype, rule.isubtype) or "?" - end - return L["ItemType - "]..ltype..":"..lsubtype - end, - Ace3Options = { - itype = { - type = 'select', - name = L["Item Type"], - desc = "", - values = function(info) --luacheck: ignore 212 - local tmp = {} - for i in pairs(ItemTypes) do - tmp[i] = GetItemClassInfo(i) - end - return tmp - end, - order = 10, - }, - isubtype = { - name = L["Item Subtype"], - desc = "", - type = "select", - get = function(info) - return tostring(info.arg.isubtype or "ALL") - end, - set = function(info, value) - local rule = info.arg - if value == "ALL" then - rule.isubtype = nil - else - rule.isubtype = tonumber(value) - end - Baggins:OnRuleChanged() - end, - values = function(info) - local rule = info.arg - local tmp = {} - tmp.ALL = _G.ALL - if rule.itype and ItemTypes[rule.itype] then - - --[===[@non-retail@ - for _,k in pairs({GetAuctionItemSubClasses(rule.itype)}) do - --@end-non-retail@]===] - --@retail@ - for _,k in pairs(GetAuctionItemSubClasses(rule.itype)) do - --@end-retail@ - tmp[tostring(k)] = GetItemSubClassInfo(rule.itype, k) or UNKNOWN - end - - end - return tmp - end, - order = 20, - } - }, - CleanRule = function(rule) - rule.itype="Miscellaneous" - end -}) - - - - ------------------------------------------------------------------------ --- ItemID - -local function getItemIdSummary(info) - local ids = info.arg.ids - if not ids then return "" end - local result = "" - for k in pairs(ids) do - local _,v = GetItemInfo(k) - result = ("%s\n%s (%d)"):format(result, v or _G.UNKNOWN, k) - end - return result -end - -local function setItemIdList(info, value) - local idList = { (" "):split(value) } - local ids - if not info.arg.ids then - ids = {} - info.arg.ids = ids - else - ids = wipe(info.arg.ids) - end - for _,v in ipairs(idList) do - if v then - ids[tonumber(v)] = true - end - end - Baggins:OnRuleChanged() -end - -local function getItemIdList(info) - local result = "" - if not info.arg.ids then return "" end - for k in pairs(info.arg.ids) do - result = ("%s %s"):format(result, k) - end - return result:sub(2) -end - -Baggins:AddCustomRule("ItemID", { - DisplayName = L["Item ID"], - Description = L["Filter by ItemID, this can be a space delimited list or ids to match."], - Matches = function(bag,slot,rule) - if not rule.ids then return end - local itemid = GetContainerItemID(bag, slot) - return rule.ids[itemid] - end, - GetName = function(rule) --luacheck: ignore 212 - return L["ItemIDs "] - end, - Ace3Options = { - ids = { - type = 'input', - name = L["Item IDs "], - desc = "", - set = setItemIdList, - get = getItemIdList, - order = 10, - }, - desc = { - type = 'description', - name = getItemIdSummary, - order = 11, - } - }, -}) - - - ------------------------------------------------------------------------ --- Empty - -Baggins:AddCustomRule("Empty", { - DisplayName = L["Empty Slots"], - Description = L["Empty bag slots"], - Matches = function(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, - GetName = function() - return L["Empty Slots"] - end, -}) - - ------------------------------------------------------------------------ --- NewItems - -Baggins:AddCustomRule("NewItems", { - DisplayName = L["New Items"], - Description = L["New Items"], - Matches = function(bag,slot) - if not (bag and slot) then return end - if BagTypes[bag] ~= 1 then return end - local link = GetContainerItemLink(bag, slot) - if link then - return Baggins:IsNew(link) - end - end, - GetName = function() - return L["New Items"] - end, -}) - - - - ------------------------------------------------------------------------ --- Category - -Baggins:AddCustomRule("Category", { - DisplayName = L["Category"], - Description = L["Items that match another category"], - Matches = function(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, - GetName = function(rule) - if rule.category then - return L["Category"].." :"..rule.category - else - return L["Category"] - end - end, - Ace3Options = { - category = { - name = L["Category"], - desc = "", - type = 'select', - values = function() - local tmp = {} - for k in pairs(Baggins.db.profile.categories) do - tmp[k] = k - end - return tmp - end, - }, - }, -}) - - ------------------------------------------------------------------------ --- EquipLoc - -Baggins:AddCustomRule("EquipLoc", { - DisplayName = L["Equip Location"], - Description = L["Filter by Equip Location as returned by GetItemInfo"], - Matches = function(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, - GetName = function(rule) - return "Equip Location: "..(_G[rule.equiploc] or rule.equiploc or "*None*") - end, - Ace3Options = { - equiploc = { - name = L["Location"], - desc = "", - type = 'select', - values = EquipLocs2, - }, - }, - CleanRule = function(rule) - rule.equiploc = EquipLocs[1] - end, -}) - - - ------------------------------------------------------------------------ --- ItemLevel - -Baggins:AddCustomRule("ItemLevel", { - DisplayName = L["Item Level"], - Description = L["Filter by item's level - either \"ilvl\" or minimum required level"], - Matches = function(bag,slot,rule) - local link = GetContainerItemLink(bag, slot) - if not link then return false end - - local _,_,_, itemLevel, itemMinLevel = GetItemInfo(link) --luacheck: ignore 211 - local itemLevel = LIUI:GetUpgradedItemLevel(link) --luacheck: ignore 411 - -- local itemLevel = GetDetailedItemLevelInfo(link) - local lvl = rule.useminlvl and itemMinLevel or itemLevel - - if not lvl then -- can happen if itemcache hasn't been updated yet - return false - end - - if rule.include0 and lvl==0 then - return true - end - if rule.include1 and lvl==1 then - return true - end - - local minlvl = rule.minlvl or -9999 - local maxlvl = rule.maxlvl or 9999 - if rule.minlvl_rel then - minlvl = UnitLevel("player")+minlvl - end - if rule.maxlvl_rel then - maxlvl = UnitLevel("player")+maxlvl - end - - return lvl>=minlvl and lvl<=maxlvl - end, - GetName = function(rule) - local minlvl = rule.minlvl or -9999 - local maxlvl = rule.maxlvl or 9999 - if rule.minlvl_rel then - minlvl = UnitLevel("player")+minlvl - end - if rule.maxlvl_rel then - maxlvl = UnitLevel("player")+maxlvl - end - return (rule.useminlvl and L["ReqLvl"] or L["ILvl"]) .. ": " .. - (rule.include0 and "0, " or "") .. - (rule.include1 and "1, " or "") .. - max(minlvl,0) .. "-" .. - min(maxlvl,9999); - end, - Ace3Options = { - include0 = { - name = L["Include Level 0"], - desc = "", - type = 'toggle', - order = 10, - }, - include1 = { - name = L["Include Level 1"], - desc = "", - type = 'toggle', - order = 11, - }, - useminlvl = { - name = L["Look at Required Level"], - desc = "Look at 'minimum level required' rather than item level", - descStyle = "inline", - type = 'toggle', - order = 12, - width = "full" - }, - minlvl = { - name = L["From level:"], - desc = "", - type = 'input', - set = function(info, value) - info.arg.minlvl = tonumber(value) - Baggins:OnRuleChanged() - end, - get = function(info) - return tostring(info.arg.minlvl or "") - end, - validate = function(info, value) --luacheck: ignore 212 - return tonumber(value) ~= nil - end, - order = 20, - }, - minlvl_rel = { - name = L["... plus Player's Level"], - desc = "", - type = 'toggle', - order = 21, - }, - maxlvl = { - name = L["To level:"], - desc = "", - type = 'input', - set = function(info, value) - info.arg.maxlvl = tonumber(value) - Baggins:OnRuleChanged() - end, - get = function(info) - return tostring(info.arg.maxlvl or "") - end, - validate = function(info, value) --luacheck: ignore 212 - return tonumber(value) ~= nil - end, - order = 30, - }, - maxlvl_rel = { - name = L["... plus Player's Level"], - desc = "", - type = 'toggle', - order = 31, - }, - }, - CleanRule = function(rule) - rule.include0 = true - rule.include1 = false - rule.useminlvl = false - rule.minlvl_rel = true - rule.minlvl = -15 - rule.maxlvl_rel = true - rule.maxlvl = 10 - end, -}) - - - ------------------------------------------------------------------------ --- Other - -Baggins:AddCustomRule("Other", { - DisplayName = L["Unfiltered Items"], - Description = L["Matches all items that arent matched by any other bag, NOTE: this should be the only rule in a category, others will be ignored"], - Matches = function() - - --local key = bag..":"..slot - --return not useditems[key] - end, - GetName = function() - return L["Unfiltered"] - end, -}) - - - ------------------------------------------------------------------------ --- Bind - -Baggins:AddCustomRule("Bind", { - DisplayName = L["Bind"], - Description = L["Filter based on if the item binds, or if it is already bound"], - Matches = function(bag, slot, rule) - local status = rule.status - if not status then return end - if bag == -1 then - LG:SetInventoryItem("player", BankButtonIDToInvSlotID(slot)) - else - LG:SetBagItem(bag,slot) - end - if status == 'unset' or status == 'unbound' then - return not (LG:Find(_G.ITEM_SOULBOUND, 2, 6, false, true)) - end - return (LG:Find(status, 2, 6, false, true)) - end, - GetName = function(rule) - if not rule.status then - return L["Bind *unset*"] - elseif rule.status == 'unbound' then - return L["Unbound"] - end - return rule.status - end, - Ace3Options = { - status = { - name = L["Bind Type"], - desc = "", - type = 'select', - values = { - unbound = L["Unbound"], - [ITEM_SOULBOUND] = ITEM_SOULBOUND, - [ITEM_BIND_ON_EQUIP] = ITEM_BIND_ON_EQUIP, - [ITEM_ACCOUNTBOUND] = ITEM_ACCOUNTBOUND, - [ITEM_BIND_ON_USE] = ITEM_BIND_ON_USE, - } - }, - }, -}) - - - -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 - Baggins:OnRuleChanged() -end - -Baggins:AddCustomRule("EquipmentSlot", { - DisplayName = L["Equipment Slot"], - Description = L["Filter by Equipment Slot"], - GetName = function(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, - Matches = function(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, - Ace3Options = { - slots = { - name = L["Equipment Slots"], - desc = "", - type = 'multiselect', - values = INV_TYPES, - get = getSlotValue, - set = toggleSlotValue, - }, - }, -}) - -- Initialize module BuildBagTypes() diff --git a/Baggins.toc b/Baggins.toc index 944b46c..3fbc133 100644 --- a/Baggins.toc +++ b/Baggins.toc @@ -81,9 +81,19 @@ Baggins_ItemOps.lua # Filters src\filters\Bag.lua +src\filters\Category.lua src\filters\ContainerType.lua +src\filters\Empty.lua +src\filters\EquipLocation.lua src\filters\EquipmentSet.lua +src\filters\EquipmentSlot.lua +src\filters\ItemBind.lua +src\filters\ItemID.lua +src\filters\ItemLevel.lua src\filters\ItemName.lua +src\filters\ItemType.lua +src\filters\NewItems.lua +src\filters\Other.lua src\filters\PeriodicTable.lua src\filters\Quality.lua src\filters\Tooltip.lua diff --git a/src/filters/Category.lua b/src/filters/Category.lua new file mode 100644 index 0000000..f22a580 --- /dev/null +++ b/src/filters/Category.lua @@ -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, + }, + }, + } +) \ No newline at end of file diff --git a/src/filters/Empty.lua b/src/filters/Empty.lua new file mode 100644 index 0000000..2d14ffb --- /dev/null +++ b/src/filters/Empty.lua @@ -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, +}) \ No newline at end of file diff --git a/src/filters/EquipLocation.lua b/src/filters/EquipLocation.lua new file mode 100644 index 0000000..a35ab7b --- /dev/null +++ b/src/filters/EquipLocation.lua @@ -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, + } +) \ No newline at end of file diff --git a/src/filters/EquipmentSlot.lua b/src/filters/EquipmentSlot.lua new file mode 100644 index 0000000..3a793eb --- /dev/null +++ b/src/filters/EquipmentSlot.lua @@ -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, + }, + }, + } +) \ No newline at end of file diff --git a/src/filters/ItemBind.lua b/src/filters/ItemBind.lua new file mode 100644 index 0000000..ee8b7fa --- /dev/null +++ b/src/filters/ItemBind.lua @@ -0,0 +1,61 @@ +--[[ ========================================================================== + +ItemBind.lua + +========================================================================== ]]-- + +local _G = _G + +local AddOnName, _ = ... +local AddOn = _G[AddOnName] + +-- WoW API +local BankButtonIDToInvSlotID = _G.BankButtonIDToInvSlotID + +-- Libs +local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) +local LG = LibStub("LibGratuity-3.0") --luacheck: ignore 211 + +local function Matches(bag, slot, rule) + local status = rule.status + if not status then return end + if bag == -1 then + LG:SetInventoryItem("player", BankButtonIDToInvSlotID(slot)) + else + LG:SetBagItem(bag,slot) + end + if status == 'unset' or status == 'unbound' then + return not (LG:Find(_G.ITEM_SOULBOUND, 2, 6, false, true)) + end + return (LG:Find(status, 2, 6, false, true)) +end + +local function GetName(rule) + if not rule.status then + return L["Bind *unset*"] + elseif rule.status == 'unbound' then + return L["Unbound"] + end + return rule.status +end + +AddOn:AddCustomRule("Bind", { + DisplayName = L["Bind"], + Description = L["Filter based on if the item binds, or if it is already bound"], + Matches = Matches, + GetName = GetName, + Ace3Options = { + status = { + name = L["Bind Type"], + desc = "", + type = 'select', + values = { + unbound = L["Unbound"], + [ITEM_SOULBOUND] = ITEM_SOULBOUND, + [ITEM_BIND_ON_EQUIP] = ITEM_BIND_ON_EQUIP, + [ITEM_ACCOUNTBOUND] = ITEM_ACCOUNTBOUND, + [ITEM_BIND_ON_USE] = ITEM_BIND_ON_USE, + } + }, + }, +}) \ No newline at end of file diff --git a/src/filters/ItemID.lua b/src/filters/ItemID.lua new file mode 100644 index 0000000..d9a0edf --- /dev/null +++ b/src/filters/ItemID.lua @@ -0,0 +1,93 @@ +--[[ ========================================================================== + +ItemID.lua + +========================================================================== ]]-- + +local _G = _G + +local AddOnName, _ = ... +local AddOn = _G[AddOnName] + +-- LUA Functions +local pairs = _G.pairs +local ipairs = _G.ipairs +local tonumber = _G.tonumber +local wipe = _G.wipe + +-- WoW API +local GetItemInfo = _G.GetItemInfo +local GetContainerItemID = _G.GetContainerItemID + +-- Libs +local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) +local function getItemIdSummary(info) + local ids = info.arg.ids + if not ids then return "" end + local result = "" + for k in pairs(ids) do + local _,v = GetItemInfo(k) + result = ("%s\n%s (%d)"):format(result, v or _G.UNKNOWN, k) + end + return result +end + +local function setItemIdList(info, value) + local idList = { (" "):split(value) } + local ids + if not info.arg.ids then + ids = {} + info.arg.ids = ids + else + ids = wipe(info.arg.ids) + end + for _,v in ipairs(idList) do + if v then + ids[tonumber(v)] = true + end + end + AddOn:OnRuleChanged() +end + +local function getItemIdList(info) + local result = "" + if not info.arg.ids then return "" end + for k in pairs(info.arg.ids) do + result = ("%s %s"):format(result, k) + end + return result:sub(2) +end + +local function Matches(bag,slot,rule) + if not rule.ids then return end + local itemid = GetContainerItemID(bag, slot) + return rule.ids[itemid] +end + +local function GetName(rule) --luacheck: ignore 212 + return L["ItemIDs "] +end + +AddOn:AddCustomRule("ItemID", + { + DisplayName = L["Item ID"], + Description = L["Filter by ItemID, this can be a space delimited list or ids to match."], + Matches = Matches, + GetName = GetName, + Ace3Options = { + ids = { + type = 'input', + name = L["Item IDs "], + desc = "", + set = setItemIdList, + get = getItemIdList, + order = 10, + }, + desc = { + type = 'description', + name = getItemIdSummary, + order = 11, + } + }, + } +) \ No newline at end of file diff --git a/src/filters/ItemLevel.lua b/src/filters/ItemLevel.lua new file mode 100644 index 0000000..ca13f7e --- /dev/null +++ b/src/filters/ItemLevel.lua @@ -0,0 +1,150 @@ +--[[ ========================================================================== + +ItemLevel.lua + +========================================================================== ]]-- + +local _G = _G + +local AddOnName, _ = ... +local AddOn = _G[AddOnName] + +-- WoW API +local GetContainerItemLink = _G.GetContainerItemLink +local GetItemInfo = _G.GetItemInfo +local UnitLevel = _G.UnitLevel + +-- Libs +local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) + +local function Matches(bag,slot,rule) + local link = GetContainerItemLink(bag, slot) + if not link then return false end + + local _,_,_, itemLevel, itemMinLevel = GetItemInfo(link) --luacheck: ignore 211 + local itemLevel = LIUI:GetUpgradedItemLevel(link) --luacheck: ignore 411 + -- local itemLevel = GetDetailedItemLevelInfo(link) + local lvl = rule.useminlvl and itemMinLevel or itemLevel + + if not lvl then -- can happen if itemcache hasn't been updated yet + return false + end + + if rule.include0 and lvl==0 then + return true + end + if rule.include1 and lvl==1 then + return true + end + + local minlvl = rule.minlvl or -9999 + local maxlvl = rule.maxlvl or 9999 + if rule.minlvl_rel then + minlvl = UnitLevel("player")+minlvl + end + if rule.maxlvl_rel then + maxlvl = UnitLevel("player")+maxlvl + end + + return lvl>=minlvl and lvl<=maxlvl +end + +local function GetName(rule) + local minlvl = rule.minlvl or -9999 + local maxlvl = rule.maxlvl or 9999 + if rule.minlvl_rel then + minlvl = UnitLevel("player")+minlvl + end + if rule.maxlvl_rel then + maxlvl = UnitLevel("player")+maxlvl + end + return (rule.useminlvl and L["ReqLvl"] or L["ILvl"]) .. ": " .. + (rule.include0 and "0, " or "") .. + (rule.include1 and "1, " or "") .. + max(minlvl,0) .. "-" .. + min(maxlvl,9999); +end + +AddOn:AddCustomRule("ItemLevel", + { + DisplayName = L["Item Level"], + Description = L["Filter by item's level - either \"ilvl\" or minimum required level"], + Matches = Matches, + GetName = GetName, + Ace3Options = { + include0 = { + name = L["Include Level 0"], + desc = "", + type = 'toggle', + order = 10, + }, + include1 = { + name = L["Include Level 1"], + desc = "", + type = 'toggle', + order = 11, + }, + useminlvl = { + name = L["Look at Required Level"], + desc = "Look at 'minimum level required' rather than item level", + descStyle = "inline", + type = 'toggle', + order = 12, + width = "full" + }, + minlvl = { + name = L["From level:"], + desc = "", + type = 'input', + set = function(info, value) + info.arg.minlvl = tonumber(value) + AddOn:OnRuleChanged() + end, + get = function(info) + return tostring(info.arg.minlvl or "") + end, + validate = function(info, value) --luacheck: ignore 212 + return tonumber(value) ~= nil + end, + order = 20, + }, + minlvl_rel = { + name = L["... plus Player's Level"], + desc = "", + type = 'toggle', + order = 21, + }, + maxlvl = { + name = L["To level:"], + desc = "", + type = 'input', + set = function(info, value) + info.arg.maxlvl = tonumber(value) + AddOn:OnRuleChanged() + end, + get = function(info) + return tostring(info.arg.maxlvl or "") + end, + validate = function(info, value) --luacheck: ignore 212 + return tonumber(value) ~= nil + end, + order = 30, + }, + maxlvl_rel = { + name = L["... plus Player's Level"], + desc = "", + type = 'toggle', + order = 31, + }, + }, + CleanRule = function(rule) + rule.include0 = true + rule.include1 = false + rule.useminlvl = false + rule.minlvl_rel = true + rule.minlvl = -15 + rule.maxlvl_rel = true + rule.maxlvl = 10 + end, + } +) \ No newline at end of file diff --git a/src/filters/ItemType.lua b/src/filters/ItemType.lua new file mode 100644 index 0000000..a08884d --- /dev/null +++ b/src/filters/ItemType.lua @@ -0,0 +1,203 @@ +--[[ ========================================================================== + +ItemType.lua + +========================================================================== ]]-- + +local _G = _G + +local AddOnName, _ = ... +local AddOn = _G[AddOnName] + +-- LUA Functions +local pairs = _G.pairs +local tostring = _G.tostring +local tonumber = _G.tonumber + +-- WoW API +local GetItemClassInfo = _G.GetItemClassInfo +local GetItemSubClassInfo = _G.GetItemSubClassInfo +local GetContainerItemID = _G.GetContainerItemID +local GetItemInfoInstant = _G.GetItemInfoInstant + +--[===[@non-retail@ +local GetAuctionItemSubClasses = _G.GetAuctionItemSubClasses +--@end-non-retail@]===] +--@retail@ +local GetAuctionItemSubClasses = _G.C_AuctionHouse.GetAuctionItemSubClasses +--@end-retail@ + +-- Libs +local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) + +--@retail@ +-- Baggins: AH category scanned 2020-05-20 3:40:00 - patch 8.3.0 +local ItemTypes = { + [0]="Consumable", + [1]="Container", + [2]="Weapon", + [3]="Gem", + [4]="Armor", + [5]="Reagent",--won't use in classic -- + [6]="Projectile", + [7]="Tradeskill", + [8]="Item Enhancement", + [9]="Recipe", + [10]="Money(OBSOLETE)", + [11]="Quiver", + [12]="Quest", + [13]="Key", + [14]="Permanent(OBSOLETE)", + [15]="Miscellaneous", + [16]="Glyph",--won't use in classic -- + [17]="Battle Pets",--won't use in classic -- + [18]="WoW Token"--won't use in classic -- +} +--@end-retail@ +--[===[@non-retail@ +-- scanned Wed May 20 05:04:36 2020 - patch 1.13.4 +local ItemTypes = { + [0]="Consumable", + [1]="Container", + [2]="Weapon", + [3]="Jewelry(OBSOLETE)", + [4]="Armor", + [5]="Reagent", + [6]="Projectile", + [7]="Trade Goods", + [8]="Generic(OBSOLETE)", + [9]="Recipe", + [10]="Money(OBSOLETE)", + [11]="Quiver", + [12]="Quest", + [13]="Key", + [14]="Permanent(OBSOLETE)", + [15]="Miscellaneous", + [18]="WoW Token" +} +--@end-non-retail@]===] + + --[[ + local ItemTypes = { + ["Weapon"] = {"One-Handed Axes", "Two-Handed Axes", "Bows", "Guns", "One-Handed Maces", "Two-Handed Maces", "Polearms", "One-Handed Swords", "Two-Handed Swords", "Staves", "Fist Weapons", "Miscellaneous", "Daggers", "Thrown", "Crossbows", "Wands", "Fishing Poles"}, + ["Armor"] = {"Miscellaneous", "Cloth", "Leather", "Mail", "Plate", "Cosmetic", "Shields"}, + ["Container"] = {"Bag", "Herb Bag", "Enchanting Bag", "Engineering Bag", "Gem Bag", "Mining Bag", "Leatherworking Bag", "Inscription Bag", "Tackle Box", "Cooking Bag"}, + ["Gem"] = {"Red", "Blue", "Yellow", "Purple", "Green", "Orange", "Meta", "Simple", "Prismatic", "Cogwheel"}, + ["Consumable"] = {"Food & Drink", "Potion", "Elixir", "Flask", "Bandage", "Item Enhancement", "Scroll", "Other"}, + ["Glyph"] = {"Warrior", "Paladin", "Hunter", "Rogue", "Priest", "Death Knight", "Shaman", "Mage", "Warlock", "Monk", "Druid"}, + ["Item Enhancement"] = {}, + ["Trade Goods"] = {"Elemental", "Cloth", "Leather", "Metal & Stone", "Cooking", "Herb", "Enchanting", "Jewelcrafting", "Parts", "Devices", "Explosives", "Materials", "Other", "Item Enchantment"}, + ["Quest"] = {}, + ["Recipe"] = {"Book", "Leatherworking", "Tailoring", "Engineering", "Blacksmithing", "Cooking", "Alchemy", "First Aid", "Enchanting", "Fishing", "Jewelcrafting", "Inscription"}, + ["Miscellaneous"] = {"Junk", "Reagent", "Companion Pets", "Holiday", "Other", "Mount"}, + ["Battle Pets"] = {"Humanoid", "Dragonkin", "Flying", "Undead", "Critter", "Magic", "Elemental", "Beast", "Aquatic", "Mechanical"}, + }--]] + + + -- Old Scan Method + --[[ + SELECTED_CHAT_FRAME:AddMessage("--------------------------") + SELECTED_CHAT_FRAME:AddMessage("-- scanned "..date("%c").. " - patch "..(GetBuildInfo())) + SELECTED_CHAT_FRAME:AddMessage("local ItemTypes = {") + for i,class in pairs{GetAuctionItemClasses()} do + local subs={GetAuctionItemSubClasses(i)} + if #subs>0 then + + SELECTED_CHAT_FRAME:AddMessage(' ["'..class..'"] = {"'.. + table.concat(subs, '", "') .. + '"},') + else + SELECTED_CHAT_FRAME:AddMessage(' ["'..class..'"] = {},') + end + end + SELECTED_CHAT_FRAME:AddMessage("}") + --]] +--New Retail Scan +--print("--------------------------") +--print("-- scanned "..date("%c").. " - patch "..(GetBuildInfo())) +--for i = 0, NUM_LE_ITEM_CLASSS-1 do +-- print(i, GetItemClassInfo(i)) +--end + +local function Matches(bag,slot,rule) + if not (rule.itype or rule.isubtype) then return end + local itemid = GetContainerItemID(bag, slot) + if itemid then + local _, _, _, _, _, TypeID, SubTypeID = GetItemInfoInstant(itemid) + if TypeID and SubTypeID then + return TypeID == rule.itype and (rule.isubtype == nil or SubTypeID == rule.isubtype ) + end + end +end + +local function GetName(rule) + local ltype, lsubtype = "*", "*" + if rule.itype then + ltype = GetItemClassInfo(rule.itype) or "?" + end + if rule.isubtype then + lsubtype = GetItemSubClassInfo(rule.itype, rule.isubtype) or "?" + end + return L["ItemType - "]..ltype..":"..lsubtype +end + +AddOn:AddCustomRule("ItemType", + { + DisplayName = L["Item Type"], + Description = L["Filter by Item type and sub-type as returned by GetItemInfo"], + Matches = Matches, + GetName = GetName, + Ace3Options = { + itype = { + type = 'select', + name = L["Item Type"], + desc = "", + values = function(info) --luacheck: ignore 212 + local tmp = {} + for i in pairs(ItemTypes) do + tmp[i] = GetItemClassInfo(i) + end + return tmp + end, + order = 10, + }, + isubtype = { + name = L["Item Subtype"], + desc = "", + type = "select", + get = function(info) + return tostring(info.arg.isubtype or "ALL") + end, + set = function(info, value) + local rule = info.arg + if value == "ALL" then + rule.isubtype = nil + else + rule.isubtype = tonumber(value) + end + AddOn:OnRuleChanged() + end, + values = function(info) + local rule = info.arg + local tmp = {} + tmp.ALL = _G.ALL + if rule.itype and ItemTypes[rule.itype] then + --[===[@non-retail@ + for _,k in pairs({GetAuctionItemSubClasses(rule.itype)}) do + --@end-non-retail@]===] + --@retail@ + for _,k in pairs(GetAuctionItemSubClasses(rule.itype)) do + --@end-retail@ + tmp[tostring(k)] = GetItemSubClassInfo(rule.itype, k) or UNKNOWN + end + end + return tmp + end, + order = 20, + } + }, + CleanRule = function(rule) + rule.itype="Miscellaneous" + end + } +) \ No newline at end of file diff --git a/src/filters/NewItems.lua b/src/filters/NewItems.lua new file mode 100644 index 0000000..727b6d7 --- /dev/null +++ b/src/filters/NewItems.lua @@ -0,0 +1,72 @@ +--[[ ========================================================================== + +NewItems.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] ~= 1 then return end + local link = GetContainerItemLink(bag, slot) + if link then + return AddOn:IsNew(link) + end +end + +local function GetName() + return L["New Items"] +end + +AddOn:AddCustomRule("NewItems", + { + DisplayName = L["New Items"], + Description = L["New Items"], + Matches = Matches, + GetName = GetName, + } +) \ No newline at end of file diff --git a/src/filters/Other.lua b/src/filters/Other.lua new file mode 100644 index 0000000..79436e1 --- /dev/null +++ b/src/filters/Other.lua @@ -0,0 +1,29 @@ +--[[ ========================================================================== + +Other.lua + +========================================================================== ]]-- + +local _G = _G + +local AddOnName, _ = ... +local AddOn = _G[AddOnName] + +-- Libs +local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) + +local function Matches() +--local key = bag..":"..slot +--return not useditems[key] +end + +local function GetName() + return L["Unfiltered"] +end + +AddOn:AddCustomRule("Other", { + DisplayName = L["Unfiltered Items"], + Description = L["Matches all items that arent matched by any other bag, NOTE: this should be the only rule in a category, others will be ignored"], + Matches = Matches, + GetName = GetName, +}) \ No newline at end of file diff --git a/src/filters/PeriodicTable.lua b/src/filters/PeriodicTable.lua index 6daf387..efd8b75 100644 --- a/src/filters/PeriodicTable.lua +++ b/src/filters/PeriodicTable.lua @@ -1,3 +1,9 @@ +--[[ ========================================================================== + +PeriodicTable.lua + +========================================================================== ]]-- + local _G = _G local AddOnName, _ = ...