From 4b5b91eaaa0b527488a6e67595064c5aacdc20bd Mon Sep 17 00:00:00 2001 From: MelekTaus Date: Sun, 20 Sep 2026 10:16:37 +0200 Subject: [PATCH] Open asset in the scene object menu: the context menu of a scene object row has an Open asset entry below Select asset that does the same as a double click on the asset in the asset panel, so it selects the asset and opens its tab; kinds without an editor of their own (sprite, camera, text, collider) are only selected, just like the double click there; e2e 01 right clicks a behavior row and checks the open tab (#176) Co-Authored-By: Claude Opus 5 --- README.md | 2 +- src/editor/panels/HierarchyPanel.ts | 5 +++++ tools/e2e/01-hierarchy.mjs | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eeb3b6af..c2432bb1 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ npm run build # writes dist/ and regenerates index.html; the folder is wh The browser suite and the three example games need a machine with a GPU: ```bash -node tools/seed-e2e.mjs && node tools/e2e.mjs # the editor, 1102 checks (GM_STEPS=20 for one step) +node tools/seed-e2e.mjs && node tools/e2e.mjs # the editor, 1103 checks (GM_STEPS=20 for one step) node tools/seed-jumprun.mjs && node tools/smoke-jumprun.mjs node tools/seed-tetris.mjs && node tools/smoke-tetris.mjs node tools/seed-actor.mjs && node tools/smoke-actor.mjs diff --git a/src/editor/panels/HierarchyPanel.ts b/src/editor/panels/HierarchyPanel.ts index ef698c77..574f6265 100644 --- a/src/editor/panels/HierarchyPanel.ts +++ b/src/editor/panels/HierarchyPanel.ts @@ -174,6 +174,11 @@ export class HierarchyPanel extends Panel { label: 'Select asset', onSelect: () => object && state.select({ kind: 'asset', assetId: object.assetId }), }, + { + // The same as double-clicking the asset in the asset panel: selects it and opens its tab. + label: 'Open asset', + onSelect: () => object && state.openAsset(object.assetId), + }, { label: 'Add collider', disabled: !object || !source || many || !canAddCollider(state.project, source, object), diff --git a/tools/e2e/01-hierarchy.mjs b/tools/e2e/01-hierarchy.mjs index 02ea61dc..14c60eb8 100644 --- a/tools/e2e/01-hierarchy.mjs +++ b/tools/e2e/01-hierarchy.mjs @@ -6,7 +6,7 @@ import { same } from '../lib/harness.mjs'; * without touching the selection, and selecting a nested object unfolds the way down to it. */ export async function hierarchy(t) { - const { check, evaluate, json, click, doubleClick, select, state, shot } = t; + const { check, evaluate, json, click, clickText, doubleClick, select, state, shot } = t; const rowIds = () => json('__gm.hierarchyOrder()'); const rows = async () => JSON.stringify(await rowIds()); const selectionBefore = (await state()).selection; @@ -55,4 +55,20 @@ export async function hierarchy(t) { ); await evaluate('__gm.state.select(null); __gm.hierarchyCollapseAll()'); check('Collapse all folds everything back', same(await rowIds(), ['o1', 'o2', 'o3', 'o5']), await rows()); + + // Open asset in the row's menu does what a double-click in the asset panel does. + const spawnerRow = await json(`__gm.hierarchyRow('o5')`); + await click(spawnerRow.x, spawnerRow.y, 'right'); + await clickText('Open asset'); + const opened = await json('__gm.documents()'); + const openedSelection = (await state()).selection; + check( + 'Open asset in the row menu selects the asset and opens its tab', + opened.active === 'asset:spawner' && + opened.docs.includes('asset:spawner') && + openedSelection?.kind === 'asset' && + openedSelection.assetId === 'spawner', + JSON.stringify({ opened, openedSelection }), + ); + await evaluate(`__gm.closeDocument('asset:spawner'); __gm.state.select(null)`); }