Add a Container tab and propagate template edits
The Container tab reuses SceneViewport against any object holder, so a container template is edited exactly like a scene. Right-click no longer changes the selection, which previously made nesting impossible: opening the menu on a container loaded it, and "Place in container" then targeted itself. Template edits (move, rename, override) now reach already-placed instances per slot, through a shared templateSync used by both the apply path and the plain object commands. Copies the user has touched keep their own value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6bedc948be
commit
9d93020bd8
35 files changed
+1452
-363
No files matched your search
@@ -9,7 +9,13 @@ import { CreateContainerCommand } from '../../src/core/commands/containerCommand
|
||||
import { SetOverrideCommand } from '../../src/core/commands/sceneObjectCommands';
|
||||
import { RemoveVariableCommand, RenameVariableCommand } from '../../src/core/commands/variableCommands';
|
||||
import type { ContainerAsset } from '../../src/core/model/Asset';
|
||||
import { findAsset, findUsages, objectHolders } from '../../src/core/model/Project';
|
||||
import {
|
||||
findAsset,
|
||||
findObjectHolder,
|
||||
findUsages,
|
||||
listContainers,
|
||||
objectHolders,
|
||||
} from '../../src/core/model/Project';
|
||||
import { makeBehavior, makeSpriteScene, place } from '../helpers';
|
||||
|
||||
/** A behavior with a `speed` variable, placed and overridden to 42, then wrapped in a container. */
|
||||
@@ -21,7 +27,7 @@ function containerWithOverride() {
|
||||
const container = new CreateContainerCommand(f.sceneId, [objectId]);
|
||||
f.stack.execute(container);
|
||||
const template = () => (findAsset(f.project, container.assetId) as ContainerAsset).objects[0]!;
|
||||
return { ...f, behaviorId: behavior.id, objectId, template };
|
||||
return { ...f, behaviorId: behavior.id, containerId: container.assetId, objectId, template };
|
||||
}
|
||||
|
||||
describe('object holders', () => {
|
||||
@@ -34,6 +40,20 @@ describe('object holders', () => {
|
||||
).toEqual(['container', 'scene']);
|
||||
});
|
||||
|
||||
it('resolves a scene or a container by id, but no other asset', () => {
|
||||
const { project, sceneId, containerId, spriteId, behaviorId } = containerWithOverride();
|
||||
expect(findObjectHolder(project, sceneId)?.type).toBe('scene');
|
||||
expect(findObjectHolder(project, containerId)?.type).toBe('container');
|
||||
expect(findObjectHolder(project, spriteId)).toBeUndefined();
|
||||
expect(findObjectHolder(project, behaviorId)).toBeUndefined();
|
||||
expect(findObjectHolder(project, 'nope')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('lists the container assets on their own', () => {
|
||||
const { project, containerId } = containerWithOverride();
|
||||
expect(listContainers(project).map((c) => c.id)).toEqual([containerId]);
|
||||
});
|
||||
|
||||
it('finds usages inside container templates, not just in scenes', () => {
|
||||
const { project, behaviorId, template } = containerWithOverride();
|
||||
// The placed object and the template copy the container was built from.
|
||||
|
||||
Reference in new issue
Block a user