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

@ -391,6 +391,21 @@ test("WASD room browsing changes view without moving players", function()
currentRoom, setEditorRoomName = oldCurrentRoom, oldSetEditorRoomName
end)
test("screen-to-cell mapping uses the neighbourhood render transform", function()
local oldWidth, oldHeight, oldGridWidth, oldGridHeight = width, height, gridWidth, gridHeight
width, height, gridWidth, gridHeight = 110, 110, 11, 11
local room = {name = "a"}
local world = setmetatable({}, {__index = World})
world.roomNeighborhoodTransform = function()
return {zoom = 0.78, originX = 22, originY = 22, cameraX = 0, cameraY = 0}
end
local cell = world:screenCellInRoom(room,
22 + width * 0.78 * (4.5 / 11), 22 + height * 0.78 * (7.5 / 11))
assertTrue(cell.x == 5 and cell.y == 8, "rendered cell did not map back to itself")
assertTrue(world:screenCellInRoom(room, 1, 1) == nil, "preview margin mapped into active room")
width, height, gridWidth, gridHeight = oldWidth, oldHeight, oldGridWidth, oldGridHeight
end)
test("one run cannot terminate at two different switches", function()
local second = switch("red", 1, 2)
local world, _, roomB = makeWorld(second)