Lists duplicate, rename and edit values right in their rows
game-maker / gate (push) Successful in 2m20s
game-maker / suite (push) Successful in 8m25s

Name, opacity and Z each sat in a separate field below or beside
the list. You had to select a row first and then look elsewhere to
change it. Duplicating was a separate button or not possible at all.
Now the row itself carries everything.

- SortableList gets three optional callbacks. onDuplicate shows a
  copy button between the eye and the delete button. onRename opens
  a text field on double click, Enter or a click outside commits,
  Esc cancels, an empty name is ignored. value puts a NumberField
  into the row.
- Dragging on the number changes the value and never moves the row.
  A whole drag is one undo step, the canvas follows live.
- Copy and delete only show on the hovered and the selected row.
  Their space stays reserved, so nothing jumps on hover.
- Pixel layers: copy right above with the same pixels on all
  frames, rename, opacity in percent. The Name and Opacity fields
  below the list are gone.
- Pixel frames: copy right after, replaces the Duplicate button.
- Tilemap layers: copy with cells, Z and visibility, rename, Z in
  the row. The Name and Z fields in the panel are gone.
- Vector shapes: copy at the same place and select it, rename.
- New in core: DuplicateVectorShapeCommand,
  DuplicateTilemapLayerCommand, withLayerDuplicated and copyName
  ("X copy", "X copy 2"). copyName lives in src/core/util/names.ts
  because the model never imports from commands/.

Findings:

- Double clicking a shape that is not selected yet only selects it.
  The first click moves the list up, so the second click misses the
  name. Module 47 selects the row first.

Tests:

- ./check.sh: 138 files, 2055 tests, CHECK EXIT 0 (before 2052).
- GM_STEPS=47,48 (fresh, twice): ALL PASSED, 91 checks (before 86).
- GM_STEPS=39,40,47,48: module 40 green, 47 died on the rename
  check, which was a test fault and is fixed.
- Counter probes: a constant copyName fails the shape and pixel
  layer tests. A dead copy hit fails the copy check in 47.
- Check total 1272 in README and wiki, computed (1266 + 6).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-22 06:02:47 +02:00
1 parent ae0247d86f
commit bbbf34109b
19 files changed
+747 -153

No files matched your search

+21
View File
@@ -6,6 +6,7 @@
* one that cannot do what is asked throws a `PixelEditError` with the reason in words.
*/
import type { PixelArtAsset, PixelFrame, PixelLayer } from './Asset';
import { copyName } from '../util/names';
import { PIXEL_CANVAS_MAX } from './pixelCel';
export interface PixelArtState {
@@ -83,6 +84,26 @@ export function withLayerAdded(state: PixelArtState, id: string, aboveId = ''):
return next;
}
/**
* A copy of a layer right above it, named after it, with its cels on every frame. The cels are files
* named by their content, so the copy names the same files and costs no upload.
*/
export function withLayerDuplicated(state: PixelArtState, id: string, sourceId: string): PixelArtState {
const next = cloneState(state);
const index = layerIndex(next, sourceId);
const source = next.layers[index]!;
const name = copyName(
next.layers.map((layer) => layer.name),
source.name,
);
next.layers.splice(index + 1, 0, { ...source, id, name });
for (const frame of next.frames) {
const cel = frame.cels[sourceId];
if (cel) frame.cels[id] = cel;
}
return next;
}
/** Takes a layer out, with its cels on every frame. The last layer stays: there would be nothing to paint on. */
export function withLayerRemoved(state: PixelArtState, layerId: string): PixelArtState {
const next = cloneState(state);