From 85c9cb1dc63e6bedb39668f0b59882eca09d1b12 Mon Sep 17 00:00:00 2001 From: Guilherme Caulada Date: Mon, 1 Apr 2024 17:15:09 -0300 Subject: [PATCH 1/3] Add BetterBags category function Register a category for each equipment set on the AdiBags successor addon BetterBags --- Equipment.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Equipment.lua b/Equipment.lua index 33ad572..1177c9c 100644 --- a/Equipment.lua +++ b/Equipment.lua @@ -3017,6 +3017,24 @@ if LibStub and LibStub:GetLibrary("AceAddon-3.0", true) then end end +-- BetterBags +if LibStub and LibStub:GetLibrary("AceAddon-3.0", true) then + local BetterBags = LibStub("AceAddon-3.0"):GetAddon("BetterBags", true) + + if BetterBags then + local categories = BetterBags:GetModule('Categories') + categories:RegisterCategoryFunction("BtWLoadouts", function(data) + local location = PackLocation(data.bagid, data.slotid) + local sets = {} + local set = GetEnabledSetsForLocation(location, sets)[1] + if set then + return format(L["Set: %s"], set.name) + end + return nil + end) + end +end + -- LibItemSearch, used by Bagnon to display borders around items within equipment sets if LibStub and LibStub:GetLibrary("LibItemSearch-1.2", true) then local Lib = LibStub("LibItemSearch-1.2") From 28b0f82ef6efa9a507325257ce77910fdfebd819 Mon Sep 17 00:00:00 2001 From: Guilherme Caulada Date: Mon, 1 Apr 2024 18:19:55 -0300 Subject: [PATCH 2/3] Fix custom categories persisting across characters --- Equipment.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Equipment.lua b/Equipment.lua index 1177c9c..6fda055 100644 --- a/Equipment.lua +++ b/Equipment.lua @@ -3022,16 +3022,30 @@ if LibStub and LibStub:GetLibrary("AceAddon-3.0", true) then local BetterBags = LibStub("AceAddon-3.0"):GetAddon("BetterBags", true) if BetterBags then + local setCategories = {} local categories = BetterBags:GetModule('Categories') categories:RegisterCategoryFunction("BtWLoadouts", function(data) local location = PackLocation(data.bagid, data.slotid) local sets = {} local set = GetEnabledSetsForLocation(location, sets)[1] if set then - return format(L["Set: %s"], set.name) + local category = format(L["Set: %s"], set.name) + setCategories[category] = true + return category end return nil end) + + -- Delete custom categories created by BtWLoadouts on haracter logout + -- This ensures only categories for sets of the current character are displayed + local frame = CreateFrame("Frame") + frame:SetScript("OnEvent", function () + for category in pairs(setCategories) do + categories:DeleteCategory(category) + end + end) + frame:RegisterEvent("PLAYER_LOGOUT") + frame:Hide() end end From af2daf9ed3282a335adfd12861460e8a134be732 Mon Sep 17 00:00:00 2001 From: Guilherme Caulada Date: Mon, 1 Apr 2024 18:22:22 -0300 Subject: [PATCH 3/3] Fix minor typo and wording on comment --- Equipment.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Equipment.lua b/Equipment.lua index 6fda055..afaf9c9 100644 --- a/Equipment.lua +++ b/Equipment.lua @@ -3036,8 +3036,8 @@ if LibStub and LibStub:GetLibrary("AceAddon-3.0", true) then return nil end) - -- Delete custom categories created by BtWLoadouts on haracter logout - -- This ensures only categories for sets of the current character are displayed + -- Delete custom categories created by BtWLoadouts on character logout + -- This ensures only categories for sets enabled for the current character are displayed local frame = CreateFrame("Frame") frame:SetScript("OnEvent", function () for category in pairs(setCategories) do