Fix grid placement logic
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user