diff --git a/common/BehaviorTreeModel.ts b/common/BehaviorTreeModel.ts index 89e0e31..8906c70 100644 --- a/common/BehaviorTreeModel.ts +++ b/common/BehaviorTreeModel.ts @@ -11,7 +11,7 @@ export interface BehaviorNodeTypeModel { desc?: string; args?: ArgsDefType[]; input?: string[]; - output?: string; + output?: string[]; doc?: string; } @@ -21,7 +21,7 @@ export interface BehaviorNodeModel { desc?: string; args?: {[key: string]: any}; input?: string[]; - output?: string; + output?: string[]; children?: BehaviorNodeModel[]; debug?: boolean; } @@ -36,7 +36,7 @@ export interface GraphNodeModel extends TreeGraphData { desc?: string; args?: {[key: string]: any}; input?: string[]; - output?: string; + output?: string[]; children?: GraphNodeModel[]; size?: number[]; diff --git a/render-process/Editor/NodePanel.tsx b/render-process/Editor/NodePanel.tsx index 202bd70..f820894 100644 --- a/render-process/Editor/NodePanel.tsx +++ b/render-process/Editor/NodePanel.tsx @@ -23,6 +23,7 @@ export default class NodePanel extends React.Component { componentDidUpdate() { const { model, settings } = this.props; + this.formRef.current.resetFields(); this.formRef.current.setFieldsValue(this.getInitialValues()); } @@ -36,9 +37,19 @@ export default class NodePanel extends React.Component { }; if (model.args) { for (let k in model.args) { - initialValues[`args.${k}`] = model.args[k] + initialValues[`args.${k}`] = model.args[k]; } } + if (model.input) { + model.input.forEach((v, i) => { + initialValues[`input.${i}`] = v; + }) + } + if (model.output) { + model.output.forEach((v, i) => { + initialValues[`output.${i}`] = v; + }) + } return initialValues; } @@ -113,15 +124,15 @@ export default class NodePanel extends React.Component { - {this.renderInputs(model, conf)} - {this.renderArgs(model, conf)} - {this.renderOutputs(model, conf)} + {this.renderInputs(conf)} + {this.renderArgs(conf)} + {this.renderOutputs(conf)} ) } - renderArgs(model: BehaviorNodeModel, conf: BehaviorNodeTypeModel) { + renderArgs(conf: BehaviorNodeTypeModel) { if (!conf || !conf.args || conf.args.length == 0) { return null; } @@ -158,12 +169,16 @@ export default class NodePanel extends React.Component {

常量参数

{conf && conf.args && conf.args.map((e, i: number) => { + const required = e.type.indexOf("?") == -1; return ( = 0 ? 'checked' : undefined} + rules={[ + { required, message: `${e.desc}(${e.name})为必填字段` } + ]} > {normalArgs(e)} @@ -175,18 +190,49 @@ export default class NodePanel extends React.Component { } - renderInputs(model: BehaviorNodeModel, conf: BehaviorNodeTypeModel) { + renderInputs(conf: BehaviorNodeTypeModel) { + if (!conf.input || !conf.input || conf.input.length == 0) { + return null; + } + return (

输入变量

+ { + conf.input.map((e, i) => { + return ( + + + + ) + }) + }
) } - renderOutputs(model: BehaviorNodeModel, conf: BehaviorNodeTypeModel) { + renderOutputs(conf: BehaviorNodeTypeModel) { + if (!conf.output || !conf.output || conf.output.length == 0) { + return null; + } return (

输出变量

+ { + conf.output.map((e, i) => { + return ( + + + + ) + }) + }
) } diff --git a/render-process/RegisterNode.ts b/render-process/RegisterNode.ts index 318edb5..a111d7f 100644 --- a/render-process/RegisterNode.ts +++ b/render-process/RegisterNode.ts @@ -34,8 +34,8 @@ export default function (settings: Settings) { stateStyles: { selected: { 'main-box': { - stroke: 'black', - lineWidth: 3, + stroke: 'yellow', + lineWidth: 5, }, }, hover: {