fix: highlight slots on bag hover

This commit is contained in:
Salikh Gurgenidze
2025-11-22 01:20:30 +04:00
parent 411aea5a6b
commit 7eee412a97
2 changed files with 60 additions and 64 deletions
+27 -34
View File
@@ -1788,47 +1788,40 @@ end
-- Highlight all item slots belonging to a specific bag by dimming others -- Highlight all item slots belonging to a specific bag by dimming others
function Guda_BagFrame_HighlightBagSlots(bagID) function Guda_BagFrame_HighlightBagSlots(bagID)
local itemContainer = getglobal("Guda_BagFrame_ItemContainer") -- Use the tracked itemButtons list because actual buttons are parented under per-bag parents
if not itemContainer then if not itemButtons or type(itemButtons) ~= "table" then return end
return
end
local highlightCount = 0 local highlightCount, dimCount = 0, 0
local dimCount = 0
-- Iterate through all children (item buttons)
local children = { itemContainer:GetChildren() }
for _, button in ipairs(children) do
-- Check if this is an item button
if button.hasItem ~= nil and button:IsShown() then
if button.bagID == bagID then
-- This button belongs to the hovered bag - keep it bright
button:SetAlpha(1.0)
highlightCount = highlightCount + 1
else
-- This button belongs to a different bag - dim it
button:SetAlpha(0.25)
dimCount = dimCount + 1
end
end
end
for _, button in ipairs(itemButtons) do
if button and button:IsShown() and button.hasItem ~= nil and not button.isBagSlot then
if button.bagID == bagID then
button:SetAlpha(1.0)
highlightCount = highlightCount + 1
else
button:SetAlpha(0.25)
dimCount = dimCount + 1
end
end
end
end end
-- Clear all highlighting by restoring full opacity to all slots -- Clear all highlighting by restoring full opacity to all slots
function Guda_BagFrame_ClearHighlightedSlots() function Guda_BagFrame_ClearHighlightedSlots()
local itemContainer = getglobal("Guda_BagFrame_ItemContainer") -- Restore alpha to whatever the search filter dictates (pfUI style). If no search, full opacity.
if not itemContainer then return end if not itemButtons or type(itemButtons) ~= "table" then return end
-- Iterate through all children (item buttons) local searchActive = BagFrame and BagFrame.IsSearchActive and BagFrame:IsSearchActive()
local children = { itemContainer:GetChildren() } for _, button in ipairs(itemButtons) do
for _, button in ipairs(children) do if button and button:IsShown() and button.hasItem ~= nil and not button.isBagSlot then
-- Check if this is an item button if searchActive and BagFrame and BagFrame.PassesSearchFilter then
if button.hasItem ~= nil and button:IsShown() then local matches = BagFrame:PassesSearchFilter(button.itemData)
-- Restore full opacity button:SetAlpha(matches and 1.0 or 0.25)
button:SetAlpha(1.0) else
end button:SetAlpha(1.0)
end end
end
end
end end
-- Highlight a specific bag button in the toolbar -- Highlight a specific bag button in the toolbar
+33 -30
View File
@@ -1270,46 +1270,49 @@ end
-- Highlight all item slots belonging to a specific bank bag by dimming others -- Highlight all item slots belonging to a specific bank bag by dimming others
function Guda_BankFrame_HighlightBagSlots(bagID) function Guda_BankFrame_HighlightBagSlots(bagID)
local itemContainer = getglobal("Guda_BankFrame_ItemContainer") -- Buttons are parented under per-bag parents, not directly under the item container
if not itemContainer then local highlightCount, dimCount = 0, 0
return
end
local highlightCount = 0 for _, bankBagParent in pairs(bankBagParents) do
local dimCount = 0 if bankBagParent then
local children = { bankBagParent:GetChildren() }
-- Iterate through all children (item buttons) for _, button in ipairs(children) do
local children = { itemContainer:GetChildren() } if button and button:IsShown() and button.hasItem ~= nil and not button.isBagSlot then
for _, button in ipairs(children) do if button.bagID == bagID then
-- Check if this is an item button button:SetAlpha(1.0)
if button.hasItem ~= nil and button:IsShown() and not button.isBagSlot then highlightCount = highlightCount + 1
if button.bagID == bagID then else
-- This button belongs to the hovered bag - keep it bright button:SetAlpha(0.25)
button:SetAlpha(1.0) dimCount = dimCount + 1
highlightCount = highlightCount + 1 end
else end
-- This button belongs to a different bag - dim it
button:SetAlpha(0.25)
dimCount = dimCount + 1
end end
end end
end end
addon:Debug(string.format("BankFrame HighlightBagSlots: Highlighted %d slots, dimmed %d slots for bagID %d", highlightCount, dimCount, bagID)) if addon and addon.Debug then
addon:Debug(string.format("BankFrame HighlightBagSlots: Highlighted %d slots, dimmed %d slots for bagID %d", highlightCount, dimCount, bagID))
end
end end
-- Clear all highlighting by restoring full opacity to all slots -- Clear all highlighting by restoring full opacity to all slots
function Guda_BankFrame_ClearHighlightedSlots() function Guda_BankFrame_ClearHighlightedSlots()
local itemContainer = getglobal("Guda_BankFrame_ItemContainer") -- Restore alpha to search-filter state (pfUI style). If no search, full opacity.
if not itemContainer then return end local searchActive = BankFrame and BankFrame.IsSearchActive and BankFrame:IsSearchActive()
-- Iterate through all children (item buttons) for _, bankBagParent in pairs(bankBagParents) do
local children = { itemContainer:GetChildren() } if bankBagParent then
for _, button in ipairs(children) do local children = { bankBagParent:GetChildren() }
-- Check if this is an item button for _, button in ipairs(children) do
if button.hasItem ~= nil and button:IsShown() and not button.isBagSlot then if button and button:IsShown() and button.hasItem ~= nil and not button.isBagSlot then
-- Restore full opacity if searchActive and BankFrame and BankFrame.PassesSearchFilter then
button:SetAlpha(1.0) local matches = BankFrame:PassesSearchFilter(button.itemData)
button:SetAlpha(matches and 1.0 or 0.25)
else
button:SetAlpha(1.0)
end
end
end
end end
end end
end end