fix: prevent disenchanting locked item
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+28
-6
@@ -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)
|
||||
|
||||
@@ -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" ..
|
||||
|
||||
Reference in New Issue
Block a user