Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion components/itemFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,25 @@ function ItemFrame:Layout()
local revBags, revSlots = profile.reverseBags, profile.reverseSlots
local x, y = 0,0

-- Calculate offset
local totalSlots = 0
for j = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
totalSlots = totalSlots + GetContainerNumSlots(j)
end
local offset = self:calcOffset(columns,totalSlots)

if profile.emptyOnTop and not self:BagBreak() then
x = offset
end

for k = revBags and #self.bags or 1, revBags and 1 or #self.bags, revBags and -1 or 1 do
local bag = self.bags[k]
local slots = self.bagSlots[bag]

if profile.emptyOnTop and self:BagBreak() then
x = self:calcOffset(columns,GetContainerNumSlots(k-1))
end

if slots then
local numSlots = self:NumSlots(bag)
for slot = revSlots and numSlots or 1, revSlots and 1 or numSlots, revSlots and -1 or 1 do
Expand All @@ -162,7 +177,11 @@ function ItemFrame:Layout()

if self:BagBreak() and x > 0 then
y = y + 1
x = 0
if profile.emptyOnTop and self:BagBreak() then
x = self:calcOffset(columns,GetContainerNumSlots(k-1))
else
x = 0
end
end
end
end
Expand All @@ -177,6 +196,14 @@ function ItemFrame:Layout()
self:SendFrameSignal('ITEM_FRAME_RESIZED')
end

function ItemFrame:calcOffset(columns,slots)
local offset = columns - (slots % columns)
if offset == columns then
offset = 0
end
return offset
end

function ItemFrame:ForAll(method, ...)
if not self:PendingLayout() then
for i, button in ipairs(self.buttons) do
Expand Down
1 change: 1 addition & 0 deletions config/panels.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Addon.FrameOptions = Addon.Options:NewPanel(ADDON, L.FrameSettings, L.FrameSetti
row:CreateCheck('reverseBags')
row:CreateCheck('reverseSlots')
row:CreateCheck('bagBreak')
row:CreateCheck('emptyOnTop')

if REAGENTBANK_CONTAINER and self.frameID == 'bank' then
row:CreateCheck('exclusiveReagent')
Expand Down
1 change: 1 addition & 0 deletions localization/config/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ L.Layer = 'Layer'
L.BagBreak = 'Bag Break'
L.ReverseBags = 'Reverse Bag Order'
L.ReverseSlots = 'Reverse Slot Order'
L.EmptyOnTop = 'Empty Slots On Top'

L.Color = 'Background Color'
L.BorderColor = 'Border Color'
Expand Down