From 7eee412a974231edea0578339b89fb64d509278e Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Sat, 22 Nov 2025 01:20:30 +0400 Subject: [PATCH] fix: highlight slots on bag hover --- UI/BagFrame.lua | 61 +++++++++++++++++++++------------------------- UI/BankFrame.lua | 63 +++++++++++++++++++++++++----------------------- 2 files changed, 60 insertions(+), 64 deletions(-) diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index 7f81d41..02da17b 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -1788,47 +1788,40 @@ end -- Highlight all item slots belonging to a specific bag by dimming others function Guda_BagFrame_HighlightBagSlots(bagID) - local itemContainer = getglobal("Guda_BagFrame_ItemContainer") - if not itemContainer then - return - end + -- Use the tracked itemButtons list because actual buttons are parented under per-bag parents + if not itemButtons or type(itemButtons) ~= "table" then return end - local highlightCount = 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 + local highlightCount, dimCount = 0, 0 + 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 -- Clear all highlighting by restoring full opacity to all slots function Guda_BagFrame_ClearHighlightedSlots() - local itemContainer = getglobal("Guda_BagFrame_ItemContainer") - if not itemContainer then return end + -- Restore alpha to whatever the search filter dictates (pfUI style). If no search, full opacity. + if not itemButtons or type(itemButtons) ~= "table" then return end - -- 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 - -- Restore full opacity - button:SetAlpha(1.0) - end - end + local searchActive = BagFrame and BagFrame.IsSearchActive and BagFrame:IsSearchActive() + for _, button in ipairs(itemButtons) do + if button and button:IsShown() and button.hasItem ~= nil and not button.isBagSlot then + if searchActive and BagFrame and BagFrame.PassesSearchFilter then + local matches = BagFrame:PassesSearchFilter(button.itemData) + button:SetAlpha(matches and 1.0 or 0.25) + else + button:SetAlpha(1.0) + end + end + end end -- Highlight a specific bag button in the toolbar diff --git a/UI/BankFrame.lua b/UI/BankFrame.lua index 0f9d0d3..81f8941 100644 --- a/UI/BankFrame.lua +++ b/UI/BankFrame.lua @@ -1270,46 +1270,49 @@ end -- Highlight all item slots belonging to a specific bank bag by dimming others function Guda_BankFrame_HighlightBagSlots(bagID) - local itemContainer = getglobal("Guda_BankFrame_ItemContainer") - if not itemContainer then - return - end + -- Buttons are parented under per-bag parents, not directly under the item container + local highlightCount, dimCount = 0, 0 - local highlightCount = 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() and not button.isBagSlot 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 + for _, bankBagParent in pairs(bankBagParents) do + if bankBagParent then + local children = { bankBagParent:GetChildren() } + for _, button in ipairs(children) 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 - 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 -- Clear all highlighting by restoring full opacity to all slots function Guda_BankFrame_ClearHighlightedSlots() - local itemContainer = getglobal("Guda_BankFrame_ItemContainer") - if not itemContainer then return end + -- Restore alpha to search-filter state (pfUI style). If no search, full opacity. + local searchActive = BankFrame and BankFrame.IsSearchActive and BankFrame:IsSearchActive() - -- 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() and not button.isBagSlot then - -- Restore full opacity - button:SetAlpha(1.0) + for _, bankBagParent in pairs(bankBagParents) do + if bankBagParent then + local children = { bankBagParent:GetChildren() } + for _, button in ipairs(children) do + if button and button:IsShown() and button.hasItem ~= nil and not button.isBagSlot then + if searchActive and BankFrame and BankFrame.PassesSearchFilter then + 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