Skip to content

Commit

Permalink
When removing items from your inventory, the bags will not redraw unt…
Browse files Browse the repository at this point in the history
…il the bag is closed.
  • Loading branch information
Cidan committed Dec 6, 2023
1 parent 97da798 commit daf2303
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 8 additions & 1 deletion frames/bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ local Window = LibStub('LibWindow-1.1')
---@field freeBagSlotsButton Item The free bag slots button.
---@field freeReagentBagSlotsButton Item The free reagent bag slots button.
---@field itemsByBagAndSlot table<number, table<number, Item|ItemRow>>
---@field currentItemCount number
---@field sections table<string, Section>
---@field slots bagSlots
---@field isReagentBank boolean
---@field decorator Texture
---@field bg Texture
---@field moneyFrame Money
---@field resizeHandle Button
---@field drawOnClose boolean
local bagProto = {}

function bagProto:Show()
Expand All @@ -91,6 +93,10 @@ function bagProto:Hide()
end
PlaySound(self.kind == const.BAG_KIND.BANK and SOUNDKIT.IG_MAINMENU_CLOSE or SOUNDKIT.IG_BACKPACK_CLOSE)
self.frame:Hide()
if self.drawOnClose then
print("drawing on close")
self:Refresh()
end
end

function bagProto:Toggle()
Expand Down Expand Up @@ -268,7 +274,8 @@ function bagFrame:Create(kind)
---@class Bag
local b = {}
setmetatable(b, { __index = bagProto })

b.currentItemCount = 0
b.drawOnClose = false
b.isReagentBank = false
b.itemsByBagAndSlot = {}
b.sections = {}
Expand Down
14 changes: 11 additions & 3 deletions views/gridview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function views:GridView(bag, dirtyItems)
bag:WipeFreeSlots()
local freeSlotsData = {count = 0, bagid = 0, slotid = 0}
local freeReagentSlotsData = {count = 0, bagid = 0, slotid = 0}
local itemCount = 0
bag.content.compactStyle = database:GetBagCompaction(bag.kind)
for _, data in pairs(dirtyItems) do
local bagid, slotid = data.bagid, data.slotid
Expand All @@ -41,6 +42,8 @@ function views:GridView(bag, dirtyItems)
freeSlotsData.bagid = bagid
freeSlotsData.slotid = slotid
end
else
itemCount = itemCount + 1
end

local oldFrame = bag.itemsByBagAndSlot[bagid][slotid] --[[@as Item]]
Expand Down Expand Up @@ -145,10 +148,15 @@ function views:GridView(bag, dirtyItems)

bag.recentItems:SetMaxCellWidth(sizeInfo.itemsPerRow)
-- Loop through each section and draw it's size.
for _, section in pairs(bag.sections) do
section:SetMaxCellWidth(sizeInfo.itemsPerRow)
section:Draw(bag.kind, database:GetBagView(bag.kind))
if bag.currentItemCount <= itemCount then
for _, section in pairs(bag.sections) do
section:SetMaxCellWidth(sizeInfo.itemsPerRow)
section:Draw(bag.kind, database:GetBagView(bag.kind))
end
else
bag.drawOnClose = true
end
bag.currentItemCount = itemCount
bag.freeSlots:SetMaxCellWidth(sizeInfo.itemsPerRow)
bag.freeSlots:Draw(bag.kind, database:GetBagView(bag.kind))

Expand Down

0 comments on commit daf2303

Please sign in to comment.