Add Get/Set properties nodes and a breadcrumb for opened sub-behaviors
Get properties / Set properties work like their variable counterparts:
one port per chosen property, an unconnected input writes its inline
value. A port chosen from the built-in list keeps that property's field
and default (height starts at 100, color is a colour field). "object" is
reserved for the fixed input, checked by the command and on load.
The property picker names the owning type ("Sprite width"), and text
fields can now carry a suggestion list; Get/Set property use it.
Double-clicking a call node shows the path of opened behaviors under the
graph header. Clicking an entry jumps back and trims the path; choosing
a behavior any other way hides it. Reopening a behavior already on the
path steps back to it instead of repeating it. The bar shows before the
graph switches, otherwise it clips the graph that was just fitted.
The "Add node..." header button is gone; nodes come from the context menu.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9fa592078
commit
854ae2e756
35 files changed
+1044
-101
No files matched your search
@@ -1,9 +1,11 @@
|
||||
import { CanvasTextMetrics, Graphics, Rectangle, Text } from 'pixi.js';
|
||||
import {
|
||||
asNumber,
|
||||
asString,
|
||||
edgesInto,
|
||||
type Graph,
|
||||
type GraphNode,
|
||||
inlineInputDef,
|
||||
inlineInputs,
|
||||
inlineValue,
|
||||
type NodeCategory,
|
||||
@@ -15,10 +17,11 @@ import {
|
||||
} from '../../core/graph';
|
||||
import type { BehaviorAsset } from '../../core/model/Asset';
|
||||
import type { Project } from '../../core/model/Project';
|
||||
import { isList, type PropertyValue, textOf } from '../../core/model/Properties';
|
||||
import { isList, type PropertyValue } from '../../core/model/Properties';
|
||||
import { assetRefLabel } from '../../core/properties/assetRef';
|
||||
import type { PropertyDef } from '../../core/properties/PropertySchema';
|
||||
import { formatNumber, Theme, textStyle, type TextStyleToken, truncate, Widget } from '../../ui';
|
||||
import { textureRefLabel } from '../../core/properties/textureRef';
|
||||
import { formatNumber, Theme, textStyle, type TextStyleToken, toHex, truncate, Widget } from '../../ui';
|
||||
import { keyLabel } from '../inspector/fieldFactory';
|
||||
import { collapsedNodeWidth } from './folding';
|
||||
|
||||
@@ -93,6 +96,7 @@ export class NodeView extends Widget {
|
||||
targetPort: { port: string; isOutput: boolean } | null = null;
|
||||
/** Data inputs that currently have a connection (their inline value is hidden). */
|
||||
private connected = new Set<string>();
|
||||
private inlineTexts = new Map<string, string>();
|
||||
/** Which sides carry a link – a collapsed node marks those with one dot each. */
|
||||
private linked = { inputs: false, outputs: false };
|
||||
|
||||
@@ -148,6 +152,12 @@ export class NodeView extends Widget {
|
||||
.filter((p) => edgesInto(graph, node.id, p.key).length > 0)
|
||||
.map((p) => p.key),
|
||||
);
|
||||
this.inlineTexts = new Map();
|
||||
for (const port of inlineInputs(this.def)) {
|
||||
const value = inlineValue(node, port);
|
||||
if (!this.connected.has(port.key) && value !== null && value !== '')
|
||||
this.inlineTexts.set(port.key, formatField(inlineInputDef(port), value, project));
|
||||
}
|
||||
this.linked = {
|
||||
inputs: graph.edges.some((e) => e.to.node === node.id),
|
||||
outputs: graph.edges.some((e) => e.from.node === node.id),
|
||||
@@ -266,11 +276,8 @@ export class NodeView extends Widget {
|
||||
const output = this.def.outputs[i];
|
||||
const rowTop = y + i * ROW_HEIGHT + 2;
|
||||
if (input) {
|
||||
let label = input.label;
|
||||
if (input.type !== 'exec' && input.type !== 'object' && !this.connected.has(input.key)) {
|
||||
const value = inlineValue(this.node, input);
|
||||
if (value !== null && value !== '') label += ` ${formatValue(value)}`;
|
||||
}
|
||||
const inline = this.inlineTexts.get(input.key);
|
||||
const label = inline === undefined ? input.label : `${input.label} ${inline}`;
|
||||
add(
|
||||
label,
|
||||
input.type === 'exec' ? 'body' : 'muted',
|
||||
@@ -369,8 +376,6 @@ function formatParam(
|
||||
project: Project | null,
|
||||
): string {
|
||||
if (value === undefined || value === '') return '—';
|
||||
if (param.kind === 'key') return keyLabel(textOf(value));
|
||||
if (param.kind === 'asset') return assetRefLabel(project, textOf(value));
|
||||
if (
|
||||
param.kind === 'enum' &&
|
||||
param.key === 'variable' &&
|
||||
@@ -378,6 +383,15 @@ function formatParam(
|
||||
!asset.variables.some((v) => v.key === value)
|
||||
)
|
||||
return `${asString(value)}?`;
|
||||
return formatField(param, value, project);
|
||||
}
|
||||
|
||||
/** A value in the words of the field that edits it: a key's name, a color's hex, a texture's name. */
|
||||
function formatField(def: PropertyDef, value: Value, project: Project | null): string {
|
||||
if (def.kind === 'key') return keyLabel(asString(value));
|
||||
if (def.kind === 'asset') return assetRefLabel(project, asString(value));
|
||||
if (def.kind === 'texture') return textureRefLabel(project, asString(value));
|
||||
if (def.kind === 'color') return toHex(asNumber(value));
|
||||
return formatValue(value);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user