From ad8f26bca742370f5265cf93cccc0680724cd3ef Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Mon, 19 Jan 2026 17:05:30 +0400 Subject: [PATCH] feat: rename category --- Core/CategoryManager.lua | 17 +++++++++++++--- UI/BagFrame.lua | 15 ++++++++++++-- UI/FrameHelpers.lua | 15 ++++++++++++-- UI/SettingsPopup.lua | 43 ++++++++++++++++++++++++++++++---------- 4 files changed, 72 insertions(+), 18 deletions(-) diff --git a/Core/CategoryManager.lua b/Core/CategoryManager.lua index 83ec221..3232c99 100644 --- a/Core/CategoryManager.lua +++ b/Core/CategoryManager.lua @@ -19,7 +19,7 @@ addon.Modules.CategoryManager = CategoryManager -- Default category definitions that replicate the existing hardcoded behavior local DEFAULT_CATEGORIES = { order = { - "BoE", "Weapon", "Armor", "Consumable", "Food", "Drink", + "Home", "BoE", "Weapon", "Armor", "Consumable", "Food", "Drink", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Soul Bag", "Miscellaneous", "Quest", "Junk", "Class Items", "Keyring" }, @@ -212,6 +212,16 @@ local DEFAULT_CATEGORIES = { enabled = true, isBuiltIn = true, }, + ["Home"] = { + name = "Home", + icon = "Interface\\Icons\\INV_Misc_Rune_01", + rules = {}, + matchMode = "all", + priority = 0, + enabled = true, + isBuiltIn = true, + hideControls = true, + }, } } @@ -590,11 +600,12 @@ function CategoryManager:EvaluateRule(rule, itemData, bagID, slotID, isOtherChar -- ruleValue can be a single ID or a table of IDs if type(ruleValue) == "table" then for _, id in ipairs(ruleValue) do - if itemID == id then return true end + if itemID == tonumber(id) then return true end end return false else - return itemID == ruleValue + -- Convert string to number if needed + return itemID == tonumber(ruleValue) end elseif ruleType == "isSoulShard" then diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index c01020d..1510546 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -507,9 +507,16 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) headerIdx = headerIdx + 1 header:SetPoint("TOPLEFT", itemContainer, "TOPLEFT", startX + currentX, startY - currentY) header:SetWidth(blockWidth) - + + -- Get display name from category definition local displayName = catName - header.fullName = catName + if addon.Modules.CategoryManager then + local catDef = addon.Modules.CategoryManager:GetCategory(catName) + if catDef and catDef.name then + displayName = catDef.name + end + end + header.fullName = displayName header.isShortened = false if string.len(displayName) > 8 and numItems < 2 then displayName = string.sub(displayName, 1, 6) .. "..." @@ -574,6 +581,10 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) break end end + -- Also check if Empty section should show + if totalFreeSlots > 0 then + hasAnyBottom = true + end if hasAnyBottom then y = y - 10 diff --git a/UI/FrameHelpers.lua b/UI/FrameHelpers.lua index 7dac7b9..6c48877 100644 --- a/UI/FrameHelpers.lua +++ b/UI/FrameHelpers.lua @@ -35,8 +35,19 @@ function Guda_CategorizeItem(itemData, bagID, slotID, categories, specialItems, -- Priority 1: Special items (Hearthstone, Mounts, Tools) -- These are handled separately and go into specialItems table, not categories if string.find(itemName, "Hearthstone") then - table.insert(specialItems.Hearthstone, {bagID = bagID, slotID = slotID, itemData = itemData}) - return + -- Only show in Home section if Home category is enabled + local showHome = true + if addon.Modules.CategoryManager then + local homeCat = addon.Modules.CategoryManager:GetCategory("Home") + if homeCat then + showHome = homeCat.enabled + end + end + if showHome then + table.insert(specialItems.Hearthstone, {bagID = bagID, slotID = slotID, itemData = itemData}) + return + end + -- If Home is disabled, fall through to normal categorization elseif addon.Modules.SortEngine and addon.Modules.SortEngine.IsMount and addon.Modules.SortEngine.IsMount(itemData.texture) then table.insert(specialItems.Mount, {bagID = bagID, slotID = slotID, itemData = itemData}) return diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index a381d02..854dc3d 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -1345,17 +1345,37 @@ function Guda_SettingsPopup_CategoriesTab_Update() row.builtInText:Hide() end - -- Enable/disable move buttons based on position - if dataIndex == 1 then - row.upBtn:Disable() + -- Hide all controls for hideControls categories (only checkbox visible) + if categoryDef.hideControls then + row.editBtn:Hide() + row.upBtn:Hide() + row.downBtn:Hide() + row.deleteBtn:Hide() + row.builtInText:Hide() else - row.upBtn:Enable() - end + row.editBtn:Show() + row.upBtn:Show() + row.downBtn:Show() - if dataIndex == totalCategories then - row.downBtn:Disable() - else - row.downBtn:Enable() + -- Enable/disable move buttons based on position + if dataIndex == 1 then + row.upBtn:Disable() + else + -- Check if category above has hideControls (can't move above it) + local aboveCatId = categoryOrder[dataIndex - 1] + local aboveCatDef = Guda.Modules.CategoryManager:GetCategory(aboveCatId) + if aboveCatDef and aboveCatDef.hideControls then + row.upBtn:Disable() + else + row.upBtn:Enable() + end + end + + if dataIndex == totalCategories then + row.downBtn:Disable() + else + row.downBtn:Enable() + end end -- Set text color based on enabled state @@ -1404,11 +1424,11 @@ function Guda_SettingsPopup_AddCategory_OnClick() -- Create new category definition local newDef = { - name = "New Category " .. counter, + name = "Custom " .. counter, icon = "Interface\\Icons\\INV_Misc_QuestionMark", rules = {}, matchMode = "any", - priority = 50, + priority = 80, enabled = true, isBuiltIn = false, } @@ -1466,6 +1486,7 @@ local RULE_TYPE_OPTIONS = { { id = "itemType", name = "Item Type" }, { id = "itemSubtype", name = "Item Subtype" }, { id = "namePattern", name = "Name Contains" }, + { id = "itemID", name = "Item ID" }, { id = "quality", name = "Quality (exact)" }, { id = "qualityMin", name = "Quality (min)" }, { id = "isBoE", name = "Bind on Equip" },