Don't show pickables if level is too low

If the player's level is too low to open a locked box, this suppresses the box from being displayed (unless the player enables the new option to show it anyway).
This commit is contained in:
2022-11-29 23:24:47 -06:00
parent cba6773d1c
commit fb982f7f9d

View File

@ -797,6 +797,25 @@ function Breakables:GetOptions()
end, end,
order = 9, order = 9,
}, },
showNonUnlockableItems = {
type = 'toggle',
name = L['Show high-level lockboxes'],
desc = L['If checked, a lockbox that is too high level for the player to pick will still be shown in the list, otherwise it will be hidden.'],
get = function(info)
return self.settings.showNonUnlockableItems
end,
set = function(info, v)
self.settings.showNonUnlockableItems = v
self:FindBreakables()
if info.uiType == "cmd" then
print("|cff33ff99Breakables|r: set |cffffff78showNonUnlockableItems|r to " .. tostring(self.settings.showNonUnlockableItems))
end
end,
hidden = function()
return not CanPickLock or not C_TooltipInfo
end,
order = 10,
},
ignoreList = { ignoreList = {
type = 'multiselect', type = 'multiselect',
name = L["Ignore list"], name = L["Ignore list"],
@ -1474,7 +1493,7 @@ function Breakables:FindBreakablesInSlot(bagId, slotId)
end end
end end
if CanPickLock and self:ItemIsPickable(itemId) and self:ItemIsLocked(bagId, slotId) then if CanPickLock and self:ItemIsPickable(itemId) and self:ItemIsLocked(bagId, slotId) and self:PlayerHasSkillToPickItem(bagId, slotId) then
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_PICK, false, itemName, itemRarity} return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_PICK, false, itemName, itemRarity}
end end
end end
@ -1482,6 +1501,33 @@ function Breakables:FindBreakablesInSlot(bagId, slotId)
return nil return nil
end end
function Breakables:PlayerHasSkillToPickItem(bagId, slotId)
if not C_TooltipInfo or self.settings.showNonUnlockableItems then
return true
end
local tooltipData = C_TooltipInfo.GetBagItem(bagId, slotId)
if not tooltipData then
return true
end
TooltipUtil.SurfaceArgs(tooltipData)
local inspectNextLine = false
for _, line in ipairs(tooltipData.lines) do
TooltipUtil.SurfaceArgs(line)
if inspectNextLine then
inspectNextLine = false
if line.leftColor and line.leftColor.r == 1 then
return false
end
elseif line.leftText == LOCKED then
inspectNextLine = true
end
end
return true
end
function Breakables:ItemIsPickable(itemId) function Breakables:ItemIsPickable(itemId)
for i=1,#PickableItems do for i=1,#PickableItems do
if PickableItems[i] == itemId then if PickableItems[i] == itemId then