Skip to content

Commit

Permalink
Revert "Fix stack splitting near top of screen"
Browse files Browse the repository at this point in the history
This reverts commit 16997df.
  • Loading branch information
veechs committed Jan 25, 2025
1 parent d819f50 commit 1f5a8cf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Components/Inventory.Layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ function Inventory:AssignItemsToSlots(

-- Ensure parentage of item slot button is set to current group frame.
-- This is required to get the layering right -- without it, stuff can end up behind groups.
button.bagshuiData.parent:SetParent(groupFrame)
button:SetParent(groupFrame)

-- Record details of this button's assignments so we can access
-- them during UI events.
Expand Down Expand Up @@ -1501,7 +1501,7 @@ function Inventory:ShowFrameInNextPosition(

-- Display the frame.
self:SizeAndShowFrame(
(frame.bagshuiData and frame.bagshuiData.parent) or frame,
frame,
positioningTable.anchorPoint,
positioningTable.anchorToFrame,
positioningTable.anchorToPoint,
Expand Down
37 changes: 21 additions & 16 deletions Components/Inventory.Ui.ItemButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,11 @@ function InventoryUi:CreateInventoryItemSlotButton(buttonNum)
function(elementNum)
-- The button is created normally, then customized for Inventory use.
local slotButton = ui:CreateItemSlotButton(
"Item" .. elementNum,
"Item"..elementNum,
inventory.uiFrame
)
ui.buttons.itemSlots[elementNum] = slotButton

-- Wrap the button in another frame so GetParent() in
-- ContainerFrameItemButton_OnClick() / ContainerFrameItemButton_OnEnter()
-- will work. This is updated in `Ui:AssignItemToItemButton()`.
slotButton.bagshuiData.parent = _G.CreateFrame(
"Frame",
"ItemParent" .. elementNum,
-- Even though the parentage is going to be changed in `Inventory:AssignItemsToSlots()`,
-- things *will not work* unless the initial parent is set here.
inventory.uiFrame
)
slotButton:SetParent(slotButton.bagshuiData.parent)
-- We'll be sizing and positioning using the parent in `Inventory:ShowFrameInNextPosition()`,
-- so this will force the item button to match.
slotButton:SetAllPoints(slotButton.bagshuiData.parent)

-- Used by OnUpdate to manage real-time stock badge fading.
slotButton.bagshuiData.lastStockStateRefresh = _G.GetTime()

Expand Down Expand Up @@ -145,6 +130,12 @@ function Inventory:ItemButton_OnEnter(itemButton)
local buttonInfo = itemButton.bagshuiData
local item = itemButton.bagshuiData.item or self.inventory[buttonInfo.bagNum][buttonInfo.slotNum]

-- Update IDs so ContainerFrameItemButton_OnEnter() will work.
-- Disabled because we're currently not actually calling ContainerFrameItemButton_OnEnter,
-- but this could probably be added in the future if it's found to be necessary for compatibility
-- with other addons.
self:UpdateItemButtonIDs(itemButton, item)

-- Record that the mouse has moved over this button (used by OnUpdate to determine
-- whether the tooltip should be shown when the Edit Mode cursor puts down an item).
-- This is used instead of MouseIsOver() because that function returns true even
Expand Down Expand Up @@ -768,6 +759,9 @@ function Inventory:ItemButton_OnClick(mouseButton, isDrag)
local buttonInfo = itemButton.bagshuiData
local item = self.inventory[buttonInfo.bagNum][buttonInfo.slotNum]

-- Update IDs so ContainerFrameItemButton_OnClick() will work.
self:UpdateItemButtonIDs(itemButton, item)

-- Nothing normal should happen in Edit Mode.
if self.editMode then

Expand Down Expand Up @@ -999,6 +993,17 @@ end



--- Set item slot button and parent frame ID to the given item's bagNum and slotNum, respectively.
--- This provides compatibility with Blizzard's ContainerFrameItemButton_OnClick(), etc.
---@param button table Item slot button.
---@param item table Bagshui item.
function Inventory:UpdateItemButtonIDs(button, item)
button:SetID(item and item.slotNum or -99)
button:GetParent():SetID(item and item.bagNum or -99)
end



--- Return the appropriate empty slot texture (generic or profession-specific).
---@param emptySlot table Bagshui item table for the empty slot.
---@return string texturePath
Expand Down
4 changes: 0 additions & 4 deletions Components/Ui.ItemButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,6 @@ function Ui:AssignItemToItemButton(button, item, groupId)
buttonInfo.item = item
buttonInfo.itemId = item.id

-- Update IDs so ContainerFrameItemButton_OnClick()/ContainerFrameItemButton_OnEnter() will work.
button:SetID(item and item.slotNum or -99)
button:GetParent():SetID(item and item.bagNum or -99)

-- Store group ID so `UpdateItemButtonStockState()` can pull per-group settings.
buttonInfo.groupId = groupId

Expand Down

0 comments on commit 1f5a8cf

Please sign in to comment.