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
@@ -7,7 +7,7 @@ import { describe, expect, it } from 'vitest';
|
||||
import { CreateAssetCommand } from '../../src/core/commands/assetCommands';
|
||||
import { PlaceAssetCommand } from '../../src/core/commands/sceneObjectCommands';
|
||||
import { createEmptyProject } from '../../src/core/model/Project';
|
||||
import { paintedTilemap } from '../../src/editor/panels/TilemapPanel';
|
||||
import { chooseTool, holdPick, paintedTilemap, pickTile } from '../../src/editor/panels/TilemapPanel';
|
||||
import { EditorState, objectSelection } from '../../src/editor/state';
|
||||
|
||||
function setup() {
|
||||
@@ -61,6 +61,55 @@ describe('the painted tilemap', () => {
|
||||
expect(paintedTilemap(state)?.objectId).toBe(map);
|
||||
});
|
||||
|
||||
it('picks with the Pick tool and hands the tile to the painting tool before it (#133)', () => {
|
||||
const { state, sceneId, tilemapId, place } = setup();
|
||||
state.select(objectSelection(sceneId, [place(sceneId, tilemapId)]));
|
||||
chooseTool(state, 'rect');
|
||||
chooseTool(state, 'pick');
|
||||
pickTile(state, 'grass');
|
||||
expect(state.tilemapPaint).toMatchObject({ tool: 'rect', tileId: 'grass' });
|
||||
// From a tool that does not paint with a tile, the pick goes to the brush.
|
||||
chooseTool(state, 'erase');
|
||||
chooseTool(state, 'pick');
|
||||
pickTile(state, 'wall');
|
||||
expect(state.tilemapPaint).toMatchObject({ tool: 'brush', tileId: 'wall' });
|
||||
});
|
||||
|
||||
it('picks while Alt is held and goes back to the tool before it on release', () => {
|
||||
const { state, sceneId, tilemapId, place } = setup();
|
||||
state.select(objectSelection(sceneId, [place(sceneId, tilemapId)]));
|
||||
chooseTool(state, 'fill');
|
||||
expect(holdPick(state, true)).toBe(true);
|
||||
expect(state.tilemapPaint.tool).toBe('pick');
|
||||
pickTile(state, 'grass');
|
||||
expect(state.tilemapPaint).toMatchObject({ tool: 'pick', tileId: 'grass' });
|
||||
expect(holdPick(state, false)).toBe(true);
|
||||
expect(state.tilemapPaint).toMatchObject({ tool: 'fill', tileId: 'grass' });
|
||||
// Held from Select, too: the release brings Select back.
|
||||
chooseTool(state, 'select');
|
||||
holdPick(state, true);
|
||||
holdPick(state, false);
|
||||
expect(state.tilemapPaint.tool).toBe('select');
|
||||
});
|
||||
|
||||
it('leaves Alt alone without a map, and a tool chosen while holding it stays', () => {
|
||||
const { state, sceneId, tilemapId, place } = setup();
|
||||
expect(holdPick(state, true)).toBe(false);
|
||||
expect(state.tilemapPaint.tool).toBe('select');
|
||||
const map = place(sceneId, tilemapId);
|
||||
state.select(objectSelection(sceneId, [map]));
|
||||
chooseTool(state, 'brush');
|
||||
holdPick(state, true);
|
||||
chooseTool(state, 'rect');
|
||||
expect(holdPick(state, false)).toBe(false);
|
||||
expect(state.tilemapPaint.tool).toBe('rect');
|
||||
// Released after the map was deselected: nothing to paint on, so Select.
|
||||
holdPick(state, true);
|
||||
state.select(null);
|
||||
holdPick(state, false);
|
||||
expect(state.tilemapPaint.tool).toBe('select');
|
||||
});
|
||||
|
||||
it('is none for a map in a scene that is not the one showing', () => {
|
||||
const { state, tilemapId, create, place } = setup();
|
||||
const otherScene = create('scene', 'Elsewhere');
|
||||
|
||||
Reference in new issue
Block a user