Skip to content

Commit

Permalink
Remove bag highlight lock on unequip
Browse files Browse the repository at this point in the history
Fix #70
  • Loading branch information
veechs committed Feb 9, 2025
1 parent 210fc50 commit d5d9bc1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Components/Inventory.Ui.BagButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ function InventoryUi:CreateBagSlotButtons()
bagSlotButton:SetScript("OnUpdate", function(elapsed)
onUpdate_refreshTooltip = false

-- Remove item highlighting if there's no longer a container in the slot.
if
inventory.highlightItemsInContainerLocked == _G.this.bagshuiData.bagNum
and not inventory:BagSlotButtonHasBag(_G.this)
then
inventory:PrintDebug("Clearing highlight")
inventory.highlightItemsInContainerLocked = nil
inventory.highlightItemsInContainerId = nil
inventory:UpdateBagBar()
inventory:UpdateItemSlotColors()
end

-- Safeguard to prevent tooltips from popping up when the mouse has already left.
if not _G.this.bagshuiData.mouseIsOver then
_G.this.bagshuiData.tooltipCooldownUpdate = nil
Expand Down Expand Up @@ -213,9 +225,11 @@ function InventoryUi:CreateBagSlotButtons()
local this = _G.this
local bagNum = this.bagshuiData.bagNum

local hasBag = inventory:BagSlotButtonHasBag(this)

-- Alt-click highlight lock.
if
inventory:BagSlotButtonHasBag(this)
hasBag
and (
_G.IsAltKeyDown()
-- Normal clicking needs to remove the highlight lock since the bag might be getting picked up.
Expand Down Expand Up @@ -271,6 +285,12 @@ function InventoryUi:CreateBagSlotButtons()
oldOnClick()
end

-- Equipping a new bag should highlight slots immediately.
if not hasBag then
-- Need a short delay for inventory cache to update.
Bagshui:QueueEvent(this:GetScript("OnEnter"), 0.25, nil, this)
end

end)

-- OnDragStart -- just use the original OnDragStart, but block it when offline or in Edit Mode.
Expand Down

0 comments on commit d5d9bc1

Please sign in to comment.