Let a container sort its content with its parent (#243)
A container is not drawn, so it had no place in the draw order. The chain from its content to the parent of the container broke there, and a container under a character could not be drawn together with it. - A container gets the switch Sort with parent under Z. It defaults to off, also for new containers, so projects draw as they did. - With the switch on, the whole content is drawn in the slot of the container's parent. The content's own switch does not count there. - Containers in a row pass the content on as long as each has the switch on. On the top level or under a tilemap it has no effect. - drawSlots follows the new sortsWith field of a draw item. Scene view, game and picking all use drawSlots, so all three agree. Found on the way: a scene object hung directly under a container spells the container out, and its template content is dropped. That is the existing spelledOut rule, the tests now keep both cases apart. Tests: - ./check.sh: 178 files, 2573 tests, CHECK EXIT 0 - 7 new unit tests in sort-with-parent.test.ts: the switch, template content, override per container, a chain, top level and tilemap, game and picking - e2e 5b-iii: a real click on the switch in the inspector, with undo - 4 counter-probes over #242 and #243 bite (2 unit, 2 browser) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
074bda2247
commit
3abb6894a7
5 files changed
+188
-15
No files matched your search
@@ -85,6 +85,42 @@ export async function drawing(t) {
|
||||
objs.splice(objs.findIndex(o => o.id === 'o-sort'), 1);
|
||||
__gm.state.select(null)`);
|
||||
|
||||
// 5b-iii. A container sorted with its parent (#243): a container under o1 holds a crate on -1 in
|
||||
// its template, a third crate stands before o1. Off, as a new container starts, the crate
|
||||
// inside drops behind everything on 0; the container's own switch draws it right behind o1.
|
||||
const INSIDE = 'o-cont~sort-in';
|
||||
await mutate(`
|
||||
const p = __gm.state.project;
|
||||
const objs = __gm.state.activeScene.objects;
|
||||
const make = (id, assetId, parentId, z) => ({ id, assetId, name: '', position: { x: 0, y: 0, z }, editorOffset: { x: 0, y: 0 }, overrides: {}, parentId, instanceEdits: {} });
|
||||
p.assets.push({ id: 'sort-box', type: 'container', name: 'sort-box', props: { enabled: true }, objects: [make('sort-in', 'crate', '', -1)] });
|
||||
objs.splice(objs.findIndex(o => o.id === 'o1'), 0, make('o-sort', 'crate', '', 0));
|
||||
objs.push(make('o-cont', 'sort-box', 'o1', 0));`);
|
||||
const boxOrder = () =>
|
||||
json(`__gm.drawOrder().filter(id => ['o-sort', 'o1', ${JSON.stringify(INSIDE)}].includes(id))`);
|
||||
const boxOff = await boxOrder();
|
||||
await select({ kind: 'object', holderId: 'scene1', objectId: 'o-cont' });
|
||||
const boxRow = await json("__gm.inspectorField('Sort with parent')");
|
||||
if (boxRow) await click(boxRow.x, boxRow.y);
|
||||
const boxOverride = (await object('o-cont')).overrides.sortWithParent;
|
||||
const boxOn = await boxOrder();
|
||||
await undo();
|
||||
const boxUndone = await boxOrder();
|
||||
check(
|
||||
'Sort with parent on a container draws its content right behind the parent of the container, and undo takes it back',
|
||||
JSON.stringify(boxOff) === `["${INSIDE}","o-sort","o1"]` &&
|
||||
boxOverride === true &&
|
||||
JSON.stringify(boxOn) === `["o-sort","${INSIDE}","o1"]` &&
|
||||
JSON.stringify(boxUndone) === JSON.stringify(boxOff),
|
||||
JSON.stringify({ boxRow, boxOff, boxOverride, boxOn, boxUndone }),
|
||||
);
|
||||
await mutate(`
|
||||
const p = __gm.state.project;
|
||||
const scene = __gm.state.activeScene;
|
||||
scene.objects = scene.objects.filter(o => o.id !== 'o-sort' && o.id !== 'o-cont');
|
||||
p.assets = p.assets.filter(a => a.id !== 'sort-box');
|
||||
__gm.state.select(null)`);
|
||||
|
||||
// 5c. The symbols are the asset panel's icons, white in a dark outline and without a plate
|
||||
// behind them: one of each in a lane of its own, the pixels read on a grid over each icon
|
||||
// (±12 world units round its centre). Each must show white and the outline, and none of the
|
||||
|
||||
Reference in new issue
Block a user