Replace the five variable nodes with one Variables node
A single node now lists any number of variables. Every entry is an output that reads the current value whenever it is pulled; an entry switched to Set is also an input and is written when the flow arrives. Exec pins only exist while at least one entry writes, and all inputs are read before any write, so one node can swap two variables. Get/Set variable, Get/Set variables and Variable are gone. Old project files are converted on load: each old node becomes a Variables node with the same variables, edges and typed values. A written port without a typed value now shows the zero of its kind on the node body, matching what the inspector shows and what the run writes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
854ae2e756
commit
7c63c884ef
40 files changed
+895
-590
No files matched your search
@@ -15,7 +15,6 @@ import {
|
||||
type PortType,
|
||||
type Value,
|
||||
} from '../../core/graph';
|
||||
import type { BehaviorAsset } from '../../core/model/Asset';
|
||||
import type { Project } from '../../core/model/Project';
|
||||
import { isList, type PropertyValue } from '../../core/model/Properties';
|
||||
import { assetRefLabel } from '../../core/properties/assetRef';
|
||||
@@ -114,7 +113,7 @@ export class NodeView extends Widget {
|
||||
this.def = def;
|
||||
this.cursor = 'grab';
|
||||
this.addChild(this.box, this.ports);
|
||||
this.sync(node, { nodes: [node], edges: [] }, null, null, def);
|
||||
this.sync(node, { nodes: [node], edges: [] }, null, def);
|
||||
}
|
||||
|
||||
/** Ports sit on the left/right edges; widen the hit area so they can be grabbed. */
|
||||
@@ -127,7 +126,6 @@ export class NodeView extends Widget {
|
||||
sync(
|
||||
node: GraphNode,
|
||||
graph: Graph,
|
||||
asset: BehaviorAsset | null,
|
||||
project: Project | null,
|
||||
def: NodeDef,
|
||||
problem: string | null = null,
|
||||
@@ -141,10 +139,10 @@ export class NodeView extends Widget {
|
||||
.filter((p) => !hidden.has(p.key))
|
||||
.map((p) => ({
|
||||
label: p.label,
|
||||
value: formatParam(p, node.params[p.key] ?? p.default, asset, project),
|
||||
value: formatParam(p, node.params[p.key] ?? p.default, project),
|
||||
}))
|
||||
// A title made from a setting states it ("Behavior: Double" under "Double", "Variable: speed"
|
||||
// under "Get speed"). A dangling reference keeps its row: "speed?" is not in the title.
|
||||
// A title made from a setting states it ("Behavior: Double" under "Double"). A dangling
|
||||
// reference keeps its row: "Double?" is not in the title.
|
||||
.filter((p) => !derived || (p.value !== title && !title.endsWith(` ${p.value}`)))
|
||||
.map((p) => `${p.label}: ${p.value}`);
|
||||
this.connected = new Set(
|
||||
@@ -200,6 +198,15 @@ export class NodeView extends Widget {
|
||||
return [...this.paramLines];
|
||||
}
|
||||
|
||||
get inputLines(): string[] {
|
||||
return this.def.inputs.map((input) => this.inputText(input));
|
||||
}
|
||||
|
||||
private inputText(input: PortDef): string {
|
||||
const inline = this.inlineTexts.get(input.key);
|
||||
return inline === undefined ? input.label : `${input.label} ${inline}`;
|
||||
}
|
||||
|
||||
/** Everything above the first port row. The problem line sits in here, so ports move down with it. */
|
||||
private headerHeight(): number {
|
||||
const lines = this.paramLines.length + (this.problem ? 1 : 0);
|
||||
@@ -276,10 +283,8 @@ export class NodeView extends Widget {
|
||||
const output = this.def.outputs[i];
|
||||
const rowTop = y + i * ROW_HEIGHT + 2;
|
||||
if (input) {
|
||||
const inline = this.inlineTexts.get(input.key);
|
||||
const label = inline === undefined ? input.label : `${input.label} ${inline}`;
|
||||
add(
|
||||
label,
|
||||
this.inputText(input),
|
||||
input.type === 'exec' ? 'body' : 'muted',
|
||||
PAD + PORT_RADIUS + 4,
|
||||
rowTop,
|
||||
@@ -368,21 +373,8 @@ export class NodeView extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
/** The value of a setting as shown on the node; references that no longer resolve get a "?". */
|
||||
function formatParam(
|
||||
param: PropertyDef,
|
||||
value: PropertyValue | undefined,
|
||||
asset: BehaviorAsset | null,
|
||||
project: Project | null,
|
||||
): string {
|
||||
function formatParam(param: PropertyDef, value: PropertyValue | undefined, project: Project | null): string {
|
||||
if (value === undefined || value === '') return '—';
|
||||
if (
|
||||
param.kind === 'enum' &&
|
||||
param.key === 'variable' &&
|
||||
asset &&
|
||||
!asset.variables.some((v) => v.key === value)
|
||||
)
|
||||
return `${asString(value)}?`;
|
||||
return formatField(param, value, project);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user