The tilemap panel gains Fill and Pick: Fill floods the connected cells of the active layer that carry the same tile (edge neighbours only, bounded by the grid) as one undo step, Pick takes the tile of the clicked cell on the active layer, and holding Alt picks while any tool is active (#133)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c2fd536aaf
commit
0b32d3cbf3
9 files changed
+350
-20
No files matched your search
@@ -317,6 +317,62 @@ export async function tilemap(t) {
|
||||
await undo();
|
||||
await settle();
|
||||
|
||||
// 40n. Fill and pick (#133). The 3 × 3 block sits in the corner of the 6 × 4 grid, so the empty
|
||||
// cells around it are one region of 15: a click fills exactly those, in one undo step.
|
||||
await clickInPanel(t, '__gm.tilemap.toolAt("fill")');
|
||||
await settle();
|
||||
const empty = await json(`__gm.tilemap.cellAt(${JSON.stringify(MAP_OBJECT)}, 5, 3)`);
|
||||
await click(empty.x, empty.y);
|
||||
await settle();
|
||||
cells = await painted();
|
||||
check(
|
||||
'the fill tool fills the connected empty cells up to the edge of the grid',
|
||||
Object.keys(cells).length === COLUMNS * ROWS && Object.values(cells).every((id) => id === 'at-grass'),
|
||||
JSON.stringify(Object.keys(cells).sort()),
|
||||
);
|
||||
await undo();
|
||||
await settle();
|
||||
check(
|
||||
'and the whole fill is one undo step',
|
||||
Object.keys(await painted()).length === 9,
|
||||
JSON.stringify(Object.keys(await painted()).sort()),
|
||||
);
|
||||
// With no tile chosen, whatever tile the paint state holds afterwards came from the map.
|
||||
await evaluate("__gm.state.setTilemapPaint({ tileId: '' })");
|
||||
await clickInPanel(t, '__gm.tilemap.toolAt("pick")');
|
||||
await settle();
|
||||
const inBlock = await json(`__gm.tilemap.cellAt(${JSON.stringify(MAP_OBJECT)}, 1, 1)`);
|
||||
await click(inBlock.x, inBlock.y);
|
||||
await settle();
|
||||
const picked = await json('__gm.tilemap.paint()');
|
||||
check(
|
||||
'the pick tool takes the tile of the cell and hands it back to the tool before it',
|
||||
picked.tileId === 'at-grass' && picked.tool === 'fill' && Object.keys(await painted()).length === 9,
|
||||
JSON.stringify(picked),
|
||||
);
|
||||
// Held Alt: Pick for as long as it is down, the brush again once it is up.
|
||||
await clickInPanel(t, '__gm.tilemap.toolAt("brush")');
|
||||
await evaluate("__gm.state.setTilemapPaint({ tileId: '' })");
|
||||
await settle();
|
||||
await t.keyDown('Alt');
|
||||
await settle();
|
||||
const holding = await json('__gm.tilemap.paint()');
|
||||
await click(inBlock.x, inBlock.y, 'left', { alt: true });
|
||||
const whileHeld = await json('__gm.tilemap.paint()');
|
||||
await t.keyUp('Alt');
|
||||
await settle();
|
||||
const released = await json('__gm.tilemap.paint()');
|
||||
check(
|
||||
'holding Alt picks, and letting go of it brings the brush back',
|
||||
holding.tool === 'pick' &&
|
||||
whileHeld.tool === 'pick' &&
|
||||
whileHeld.tileId === 'at-grass' &&
|
||||
released.tool === 'brush' &&
|
||||
released.tileId === 'at-grass' &&
|
||||
Object.keys(await painted()).length === 9,
|
||||
JSON.stringify({ holding, whileHeld, released }),
|
||||
);
|
||||
|
||||
// 40h. A second layer draws above the first, and hiding it leaves its cells alone.
|
||||
await clickInPanel(t, '__gm.tilemap.addLayerAt()');
|
||||
await settle();
|
||||
|
||||
@@ -43,6 +43,7 @@ const KEYS = {
|
||||
ArrowRight: { key: 'ArrowRight', code: 'ArrowRight', windowsVirtualKeyCode: 39 },
|
||||
ArrowDown: { key: 'ArrowDown', code: 'ArrowDown', windowsVirtualKeyCode: 40 },
|
||||
Delete: { key: 'Delete', code: 'Delete', windowsVirtualKeyCode: 46 },
|
||||
Alt: { key: 'Alt', code: 'AltLeft', windowsVirtualKeyCode: 18 },
|
||||
a: { key: 'a', code: 'KeyA', windowsVirtualKeyCode: 65 },
|
||||
c: { key: 'c', code: 'KeyC', windowsVirtualKeyCode: 67 },
|
||||
d: { key: 'd', code: 'KeyD', windowsVirtualKeyCode: 68 },
|
||||
|
||||
Reference in new issue
Block a user