Fix grid placement logic

This commit is contained in:
2025-01-09 15:39:08 +01:00
parent c16e5f1e47
commit 939ca47e3c

View File

@@ -230,18 +230,24 @@ StaticGridFrame = {
---@param rowspan number
---@param colspan number
Add = function(self, frame, rowspan, colspan)
if rowspan > self.rows or colspan > self.columns then
print("Rowspan or colspan exceeds grid dimensions.")
return
end
for row = 1, self.rows do
for col = 1, self.columns do
if not self.occupancy[row][col] then
local canPlace = true
for r = row, row + rowspan - 1 do
for c = col, col + colspan - 1 do
if not self.occupancy[r] or self.occupancy[r][c] then
-- Check if r or c is out of bounds or if the cell is occupied
if r > self.rows or c > self.columns or self.occupancy[r][c] then
canPlace = false
break
end
if not canPlace then break end
end
if not canPlace then break end
end
if canPlace then
local x = (col - 1) * self.cellWidth