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
+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>