From fc802454f0a1cd9547cef020e714f6803c2402b6 Mon Sep 17 00:00:00 2001 From: Vati Date: Sat, 14 Mar 2026 17:24:23 +0400 Subject: [PATCH] fix: prevent disenchanting locked item --- Guda.toc | 2 +- UI/ItemButton.lua | 34 ++++++++++++++++++++++++++++------ UI/SettingsPopup.lua | 2 +- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Guda.toc b/Guda.toc index de8c00b..68a03ef 100644 --- a/Guda.toc +++ b/Guda.toc @@ -2,7 +2,7 @@ ## Title: Guda ## Notes: All-in-one bag and bank addon for World of Warcraft 1.12.1 (Turtle WoW) ## Author: Vati -## Version: 2.1.3 +## Version: 2.1.4 ## SavedVariables: Guda_DB ## SavedVariablesPerCharacter: Guda_CharDB diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index c79f5a9..9595322 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -535,7 +535,7 @@ local function UpdateLockIcon(button, iconSize) if not button.lockIcon then button.lockIcon = AcquireLockIcon() end - local lockSize = math.max(10, math.min(14, iconSize * 0.35)) + local lockSize = math.max(8, math.min(12, iconSize * 0.35 - 2)) button.lockIcon:SetWidth(lockSize) button.lockIcon:SetHeight(lockSize) if button.lockIcon.shadow then @@ -543,7 +543,7 @@ local function UpdateLockIcon(button, iconSize) button.lockIcon.shadow:SetHeight(lockSize) end button.lockIcon:ClearAllPoints() - button.lockIcon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 1, -1) + button.lockIcon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 3, -3) button.lockIcon:SetFrameLevel(button:GetFrameLevel() + 5) button.lockIcon:Show() else @@ -561,18 +561,27 @@ local function HideLockIcon(button) end end --- Hook UseContainerItem to prevent selling protected items at vendor +-- Hook UseContainerItem to prevent selling/disenchanting protected items local OriginalUseContainerItem = UseContainerItem UseContainerItem = function(bag, slot, ...) local DB = addon.Modules.DB - if DB and MerchantFrame and MerchantFrame:IsVisible() then + if DB then local link = GetContainerItemLink(bag, slot) if link then local Utils = addon.Modules.Utils local itemID = Utils and Utils.ExtractItemID and Utils:ExtractItemID(link) if itemID and DB:IsItemProtected(itemID) then - addon:Print("Cannot sell " .. link .. " — item is protected") - return + -- Block selling at merchant + if MerchantFrame and MerchantFrame:IsVisible() then + addon:Print("Cannot sell " .. link .. " — item is protected") + return + end + -- Block disenchant/milling/prospecting (spell targeting an item) + if SpellIsTargeting and SpellIsTargeting() then + SpellStopTargeting() + addon:Print("Cannot disenchant " .. link .. " — item is protected") + return + end end end end @@ -1000,6 +1009,19 @@ function Guda_ItemButton_OnLoad(self) end end + -- Block disenchant/milling/prospecting on protected items + if SpellIsTargeting and SpellIsTargeting() and this.hasItem and this.bagID and this.slotID then + local link = GetContainerItemLink(this.bagID, this.slotID) + 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 and addon.Modules.DB:IsItemProtected(itemID) then + SpellStopTargeting() + addon:Print("Cannot disenchant " .. link .. " — item is protected") + return + end + end + end + -- Default behavior if ContainerFrameItemButton_OnClick then -- Mailbox clicks should be ignored except for Ctrl+Click (preview) diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index 9a40dc4..9877136 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -54,7 +54,7 @@ function Guda_SettingsPopup_OnLoad(self) "Alt + Left Click on an item in the bar to untrack it.\n\n" .. "|cffffd100Locked Items:|r\n" .. "Ctrl + Right Click on any item to lock/unlock it.\n" .. - "Locked items cannot be sold at vendors or deleted.\n" .. + "Locked items cannot be sold at vendors, deleted, or disenchanted.\n" .. "Equipment set items are automatically protected.\n" .. "A lock icon appears on the bottom-right corner.\n\n" .. "|cffffd100Moving Bars:|r\n" ..