Skip to content

Commit

Permalink
Internal cleanup release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cidan committed Mar 18, 2024
1 parent f31fcb3 commit 04ed21c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions data/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ function items:BackpackLoadFunction()
for bagid, bag in pairs(items.itemsByBagAndSlot) do
local freeSlots = C_Container.GetContainerNumFreeSlots(bagid)
local name = ""
if bagid == -2 then
elseif bagid == 0 then
if bagid == Enum.BagIndex.Keyring then
elseif bagid == Enum.BagIndex.Backpack then
name = GetItemSubClassInfo(Enum.ItemClass.Container, 0)
extraSlotInfo.emptySlots[name] = extraSlotInfo.emptySlots[name] or 0
extraSlotInfo.emptySlots[name] = extraSlotInfo.emptySlots[name] + freeSlots
Expand Down
10 changes: 9 additions & 1 deletion frames/section.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ function sectionProto:SetFillWidth(fill)
self.fillWidth = fill
end

---@return boolean
function sectionProto:GetFillWidth()
return self.fillWidth
end

function sectionProto:GetContent()
return self.content
end
Expand Down Expand Up @@ -158,9 +163,12 @@ function sectionProto:Grid(kind, view, freeSpaceShown)
self.frame:Hide()
return 0, 0
end
if self.fillWidth then
w = math.max(w, self.title:GetTextWidth())
end
self.frame:SetSize(w + 12, h + self.title:GetHeight() + 6)
self.frame:Show()
return w+12, h + self.title:GetHeight() + 6
return w + 12, h + self.title:GetHeight() + 6
end

-------
Expand Down
9 changes: 9 additions & 0 deletions util/sort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function sort.SortSectionsAlphabetically(a, b)
if a.title:GetText() == L:G("Recent Items") then return true end
if b.title:GetText() == L:G("Recent Items") then return false end

if a:GetFillWidth() then return false end
if b:GetFillWidth() then return true end

if a.title:GetText() == L:G("Free Space") then return false end
if b.title:GetText() == L:G("Free Space") then return true end
return a.title:GetText() < b.title:GetText()
Expand All @@ -85,6 +88,9 @@ function sort.SortSectionsBySizeDescending(a, b)
if a.title:GetText() == L:G("Recent Items") then return true end
if b.title:GetText() == L:G("Recent Items") then return false end

if a:GetFillWidth() then return false end
if b:GetFillWidth() then return true end

if a.title:GetText() == L:G("Free Space") then return false end
if b.title:GetText() == L:G("Free Space") then return true end
local aSize, bSize = a:GetCellCount(), b:GetCellCount()
Expand All @@ -101,6 +107,9 @@ function sort.SortSectionsBySizeAscending(a, b)
if a.title:GetText() == L:G("Recent Items") then return true end
if b.title:GetText() == L:G("Recent Items") then return false end

if a:GetFillWidth() then return false end
if b:GetFillWidth() then return true end

if a.title:GetText() == L:G("Free Space") then return false end
if b.title:GetText() == L:G("Free Space") then return true end
local aSize, bSize = a:GetCellCount(), b:GetCellCount()
Expand Down
6 changes: 2 additions & 4 deletions views/gridview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ local function GridView(view, bag, slotInfo)
if button == nil then
debug:Log("RemoveCell", "Removed because not in itemsByBagAndSlot", slotkey)
section:RemoveCell(slotkey)
elseif slotkey ~= 'freeSlot' and slotkey ~= 'freeReagentSlot' then
else
-- Remove item buttons that are empty or don't match the category.
if data.isItemEmpty or data.stackedOn ~= nil then
if view.defer and not data.forceClear then
Expand Down Expand Up @@ -187,10 +187,8 @@ local function GridView(view, bag, slotInfo)
end
end

-- Draw the free slots section.
freeSlotsSection:SetMaxCellWidth(sizeInfo.itemsPerRow)
freeSlotsSection:SetMaxCellWidth(2)
freeSlotsSection:Draw(bag.kind, database:GetBagView(bag.kind), false)

view.content.maxCellWidth = sizeInfo.columnCount
-- Sort the sections.
view.content:Sort(sort:GetSectionSortFunction(bag.kind, const.BAG_VIEW.SECTION_GRID))
Expand Down

0 comments on commit 04ed21c

Please sign in to comment.