Unify editor input with room preview transform

This commit is contained in:
Your Name 2026-08-12 02:58:01 -04:00
parent 3c5e6daf06
commit 8fae34b803
5 changed files with 82 additions and 29 deletions

View file

@ -58,21 +58,14 @@ local boxPaletteSections = {}
-- erase that tile more than once.
local function roomCellAt(x, y)
if x < 0 or x >= width or y < 0 or y >= height then return nil end
local cell = currentRoom:getCellFromMousePos(x, y)
cell.x = constrain(cell.x, 1, gridWidth)
cell.y = constrain(cell.y, 1, gridHeight)
return cell
return currentRoom:getCellFromMousePos(x, y)
end
local function paintRoomCell(cell, button)
-- Use the centre of the cell so Room's existing pointer-based edit helpers
-- perform the same operation as a normal click.
local x = (cell.x - .5) * width / gridWidth
local y = (cell.y - .5) * height / gridHeight
if button == 1 and selectedAsset then
currentRoom:attemptPlace(selectedAsset, gameAssets[selectedAsset], x, y, selectedColor)
currentRoom:attemptPlaceAtCell(selectedAsset, gameAssets[selectedAsset], cell, selectedColor)
elseif button == 2 then
currentRoom:attemptDelete(x, y, selectedColor)
currentRoom:attemptDeleteAtCell(cell, selectedColor)
end
end