lock or unlock equipment set item manualy

This commit is contained in:
Vati
2026-03-18 02:07:55 +04:00
parent cdeb330eba
commit f4b901f1cc
2 changed files with 63 additions and 6 deletions
+46 -1
View File
@@ -157,6 +157,11 @@ function DB:Initialize()
Guda_CharDB.lockedItems = {}
end
-- Initialize set protection exceptions storage
if not Guda_CharDB.setProtectionExceptions then
Guda_CharDB.setProtectionExceptions = {}
end
-- Initialize CategoryManager for custom categories
if addon.Modules.CategoryManager then
addon.Modules.CategoryManager:Initialize()
@@ -484,13 +489,53 @@ function DB:ToggleItemLock(itemID)
end
end
-------------------------------------------------
-- Set Protection Exceptions (per-character)
-- Items in equipment sets that the user explicitly
-- chose to unprotect via Ctrl+Right-Click
-------------------------------------------------
function DB:IsSetProtectionException(itemID)
if not itemID or not Guda_CharDB or not Guda_CharDB.setProtectionExceptions then return false end
return Guda_CharDB.setProtectionExceptions[itemID] and true or false
end
function DB:ToggleSetProtectionException(itemID)
if not itemID or not Guda_CharDB then return false end
if not Guda_CharDB.setProtectionExceptions then
Guda_CharDB.setProtectionExceptions = {}
end
if Guda_CharDB.setProtectionExceptions[itemID] then
Guda_CharDB.setProtectionExceptions[itemID] = nil
return false -- protection restored
else
Guda_CharDB.setProtectionExceptions[itemID] = true
return true -- protection removed (excepted)
end
end
-- Remove exceptions for items no longer in any equipment set
function DB:PruneSetProtectionExceptions()
if not Guda_CharDB or not Guda_CharDB.setProtectionExceptions then return end
local EquipSets = addon.Modules.EquipmentSets
if not EquipSets or not EquipSets.IsInSet then return end
for itemID in pairs(Guda_CharDB.setProtectionExceptions) do
if not EquipSets:IsInSet(itemID) then
Guda_CharDB.setProtectionExceptions[itemID] = nil
end
end
end
-- Check if an item is protected (user-locked or in equipment set with autoLockSetItems)
function DB:IsItemProtected(itemID)
if not itemID then return false end
if self:IsItemLocked(itemID) then return true end
if self:GetSetting("autoLockSetItems") then
local EquipSets = addon.Modules.EquipmentSets
if EquipSets and EquipSets.IsInSet and EquipSets:IsInSet(itemID) then return true end
if EquipSets and EquipSets.IsInSet and EquipSets:IsInSet(itemID)
and not self:IsSetProtectionException(itemID) then
return true
end
end
return false
end
+17 -5
View File
@@ -568,7 +568,7 @@ local function UpdateLockIcon(button, iconSize)
if button.hasItem and button.itemData and button.itemData.link then
local Utils = addon.Modules.Utils
local itemID = Utils and Utils.ExtractItemID and Utils:ExtractItemID(button.itemData.link)
if itemID and DB:IsItemLocked(itemID) then
if itemID and DB:IsItemProtected(itemID) then
isLocked = true
end
end
@@ -577,7 +577,7 @@ local function UpdateLockIcon(button, iconSize)
if not button.lockIcon then
button.lockIcon = AcquireLockIcon()
end
local lockSize = math.max(8, math.min(12, iconSize * 0.35 - 2))
local lockSize = math.max(8, math.min(12, iconSize * 0.35 - 3))
button.lockIcon:SetWidth(lockSize)
button.lockIcon:SetHeight(lockSize)
if button.lockIcon.shadow then
@@ -585,7 +585,7 @@ local function UpdateLockIcon(button, iconSize)
button.lockIcon.shadow:SetHeight(lockSize)
end
button.lockIcon:ClearAllPoints()
button.lockIcon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 3, -3)
button.lockIcon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 4, -3)
button.lockIcon:SetFrameLevel(button:GetFrameLevel() + 5)
button.lockIcon:Show()
else
@@ -1005,11 +1005,23 @@ function Guda_ItemButton_OnLoad(self)
if link and addon and addon.Modules and addon.Modules.Utils and addon.Modules.DB then
local itemID = addon.Modules.Utils:ExtractItemID(link)
if itemID then
-- Skip if already protected by equipment set
-- If item is in an equipment set, toggle set protection exception
if addon.Modules.DB:GetSetting("autoLockSetItems") then
local EquipSets = addon.Modules.EquipmentSets
if EquipSets and EquipSets.IsInSet and EquipSets:IsInSet(itemID) then
addon:Print(link .. " is already protected by equipment set")
local isNowExcepted = addon.Modules.DB:ToggleSetProtectionException(itemID)
if isNowExcepted then
addon:Print(link .. " set protection removed")
else
addon:Print(link .. " set protection restored")
end
-- Refresh bag/bank frames
if addon.Modules.BagFrame and addon.Modules.BagFrame.Update then
addon.Modules.BagFrame:Update()
end
if addon.Modules.BankFrame and addon.Modules.BankFrame.Update then
addon.Modules.BankFrame:Update()
end
return
end
end