feat: add custom category

This commit is contained in:
Salikh Gurgenidze
2026-01-19 14:20:46 +04:00
parent d282ec27b9
commit a2d373e95c
3 changed files with 94 additions and 10 deletions
+30
View File
@@ -329,6 +329,25 @@ function CategoryManager:MigrateCategories()
boeCat.priority = 75
addon:Debug("CategoryManager: Migrated BoE priority to 75")
end
-- Migrate Junk category to ensure proper rules and priority
local junkCat = cats.definitions["Junk"]
if junkCat and junkCat.isBuiltIn then
local needsUpdate = false
-- Check if priority is too low
if not junkCat.priority or junkCat.priority < 85 then
junkCat.priority = 85
needsUpdate = true
end
-- Check if rules are missing or wrong
if not junkCat.rules or table.getn(junkCat.rules) == 0 then
junkCat.rules = { { type = "quality", value = 0 } }
needsUpdate = true
end
if needsUpdate then
addon:Debug("CategoryManager: Migrated Junk category")
end
end
end
-- Get all categories
@@ -497,6 +516,17 @@ function CategoryManager:EvaluateRule(rule, itemData, bagID, slotID, isOtherChar
return string.find(itemName, ruleValue) ~= nil
elseif ruleType == "quality" then
-- For quality 0 (gray/junk), also check tooltip as fallback
if ruleValue == 0 then
if itemData.quality == 0 then
return true
end
-- Tooltip fallback for gray detection (current character only)
if not isOtherChar and addon.Modules.Utils and addon.Modules.Utils.IsItemGrayTooltip then
return addon.Modules.Utils:IsItemGrayTooltip(bagID, slotID, itemData.link)
end
return false
end
return itemData.quality == ruleValue
elseif ruleType == "qualityMin" then
+42 -2
View File
@@ -1375,10 +1375,50 @@ function Guda_SettingsPopup_CategoriesTab_Update()
end
end
-- Set reset button text
-- Set button texts
local addBtn = getglobal("Guda_SettingsPopup_AddCategoryButton")
if addBtn then
addBtn:SetText("+ Add Category")
end
local resetBtn = getglobal("Guda_SettingsPopup_ResetCategoriesButton")
if resetBtn then
resetBtn:SetText("Reset to Defaults")
resetBtn:SetText("Reset Defaults")
end
end
-- Add new custom category
function Guda_SettingsPopup_AddCategory_OnClick()
if not Guda.Modules.CategoryManager then return end
-- Generate unique ID
local baseId = "Custom"
local counter = 1
local newId = baseId .. counter
local cats = Guda.Modules.CategoryManager:GetCategories()
while cats.definitions[newId] do
counter = counter + 1
newId = baseId .. counter
end
-- Create new category definition
local newDef = {
name = "New Category " .. counter,
icon = "Interface\\Icons\\INV_Misc_QuestionMark",
rules = {},
matchMode = "any",
priority = 50,
enabled = true,
isBuiltIn = false,
}
-- Add to database
if Guda.Modules.CategoryManager:AddCategory(newId, newDef) then
-- Update display
Guda_SettingsPopup_CategoriesTab_Update()
-- Open editor for the new category
Guda_CategoryEditor_Open(newId)
end
end
+22 -8
View File
@@ -692,10 +692,10 @@
</Anchors>
</Frame>
<!-- Reset to Defaults Button -->
<Button name="Guda_SettingsPopup_ResetCategoriesButton" inherits="UIPanelButtonTemplate">
<!-- Add Category Button -->
<Button name="Guda_SettingsPopup_AddCategoryButton" inherits="UIPanelButtonTemplate">
<Size>
<AbsDimension x="140" y="25"/>
<AbsDimension x="120" y="25"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="$parent" relativePoint="BOTTOMLEFT">
@@ -704,16 +704,30 @@
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
Guda_SettingsPopup_AddCategory_OnClick()
</OnClick>
</Scripts>
</Button>
<!-- Reset to Defaults Button -->
<Button name="Guda_SettingsPopup_ResetCategoriesButton" inherits="UIPanelButtonTemplate">
<Size>
<AbsDimension x="120" y="25"/>
</Size>
<Anchors>
<Anchor point="LEFT" relativeTo="Guda_SettingsPopup_AddCategoryButton" relativePoint="RIGHT">
<Offset>
<AbsDimension x="10" y="0"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
Guda_SettingsPopup_ResetCategories_OnClick()
</OnClick>
</Scripts>
<NormalText>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
</NormalText>
</Button>
</Frames>
</Frame>