Skip to content

Commit

Permalink
feat: Added right-click "New Event" command to the Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-coster committed Jul 13, 2023
1 parent 9cff684 commit eb358b5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
{
"command": "stitch.assets.newEvent",
"title": "New Event...",
"enablement": "stitch.projectCount > 0 && (view == bscotch-stitch-resources || view == bscotch-stitch-inspector)"
"enablement": "stitch.projectCount > 0"
},
{
"command": "stitch.openIde",
Expand Down Expand Up @@ -327,7 +327,7 @@
},
{
"command": "stitch.assets.newEvent",
"when": "stitch.projectCount > 0 && (view == bscotch-stitch-resources || view == bscotch-stitch-inspector) && viewItem == asset-objects",
"when": "(view == bscotch-stitch-resources && viewItem == asset-objects) || (view == bscotch-stitch-inspector && viewItem == inspector-object-events)",
"group": "navigation@1"
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode/src/inspector.mts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ObjectItem extends StitchTreeItemBase<'asset-objects'> {
class ObjectEvents extends StitchTreeItemBase<'inspector-object-events'> {
override readonly kind = 'inspector-object-events';
parent = undefined;
constructor() {
constructor(readonly asset: Asset<'objects'>) {
super('Events');
this.contextValue = this.kind;
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
Expand Down Expand Up @@ -147,7 +147,7 @@ export class GameMakerInspectorProvider
return [
new ObjectParentFolder(),
new ObjectSpriteFolder(),
new ObjectEvents(),
new ObjectEvents(this.asset),
new ObjectChildren(),
];
} else if (element instanceof ObjectParentFolder && this.asset.parent) {
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode/src/manifest.commands.mts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export const commands = {
'stitch.assets.newEvent': {
command: 'stitch.assets.newEvent',
title: 'New Event...',
enablement: `${when.hasProjects} && (${when.assetTreeFocused} || ${when.inspectorFocused})`,
enablement: when.hasProjects,
[$showInViewItemContextMenu]: {
when: `${when.hasProjects} && (${when.assetTreeFocused} || ${when.inspectorFocused}) && ${when.viewItemIsObject}`,
when: `(${when.assetTreeFocused} && ${when.viewItemIsObject}) || (${when.inspectorFocused} && ${when.viewItemIsInspectorEvents})`,
group: 'navigation@1',
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/vscode/src/manifest.when.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export const when = {
viewItemIsFolder: 'viewItem == folder',
viewItemIsAsset: 'viewItem =~ /^asset-/',
viewItemIsObject: 'viewItem == asset-objects',
viewItemIsInspectorEvents: 'viewItem == inspector-object-events',
} as const;

0 comments on commit eb358b5

Please sign in to comment.