change node name
This commit is contained in:
1 parent
cad9a2c4d6
commit
a4810121d1
4 files changed
+21
-7
No files matched your search
@@ -22,6 +22,12 @@ const sampleNodeClassify: BehaviorNodeClassify[] = [
|
|||||||
{ classify: "Action", desc: "行为节点" },
|
{ classify: "Action", desc: "行为节点" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const unknowNodeType: BehaviorNodeTypeModel = {
|
||||||
|
name: 'unknow',
|
||||||
|
desc: '新建节点',
|
||||||
|
type: 'Action',
|
||||||
|
}
|
||||||
|
|
||||||
export default class Settings {
|
export default class Settings {
|
||||||
private settings: SettingsModel;
|
private settings: SettingsModel;
|
||||||
private name2conf: { [name: string]: BehaviorNodeTypeModel } = {};
|
private name2conf: { [name: string]: BehaviorNodeTypeModel } = {};
|
||||||
@@ -79,6 +85,6 @@ export default class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNodeConf(name: string) {
|
getNodeConf(name: string) {
|
||||||
return this.name2conf[name];
|
return this.name2conf[name] || unknowNodeType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ const { Item } = Form;
|
|||||||
interface NodePanelProps {
|
interface NodePanelProps {
|
||||||
model: BehaviorNodeModel;
|
model: BehaviorNodeModel;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
updateNode: (id: string) => void;
|
updateNode: (id: string, forceUpdate:boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NodePanelState {
|
interface NodePanelState {
|
||||||
@@ -109,10 +109,10 @@ export default class NodePanel extends React.Component<NodePanelProps> {
|
|||||||
model.output = null;
|
model.output = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNode(model.id.toString());
|
|
||||||
if (forceUpdate) {
|
if (forceUpdate) {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
|
updateNode(model.id.toString(), forceUpdate);
|
||||||
};
|
};
|
||||||
|
|
||||||
onFinishFailed = (errorInfo: any) => {
|
onFinishFailed = (errorInfo: any) => {
|
||||||
|
|||||||
@@ -306,7 +306,15 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
<NodePanel
|
<NodePanel
|
||||||
model={curNode}
|
model={curNode}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
updateNode={id => {
|
updateNode={(id, forceUpdate) => {
|
||||||
|
if (forceUpdate) {
|
||||||
|
const data: any = this.graph.findDataById(id);
|
||||||
|
data.conf = settings.getNodeConf(data.name);
|
||||||
|
data.size = Utils.calcTreeNodeSize(data);
|
||||||
|
this.graph.changeData();
|
||||||
|
this.graph.layout();
|
||||||
|
}
|
||||||
|
|
||||||
const item = this.graph.findById(id);
|
const item = this.graph.findById(id);
|
||||||
item.draw();
|
item.draw();
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ export default function (settings: Settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const args: any = cfg.args;
|
const args: any = cfg.args;
|
||||||
if (args && Object.keys(args).length > 0) {
|
if (nodeConf.args && args && Object.keys(args).length > 0) {
|
||||||
y += 20;
|
y += 20;
|
||||||
group.addShape('text', {
|
group.addShape('text', {
|
||||||
attrs: {
|
attrs: {
|
||||||
@@ -181,7 +181,7 @@ export default function (settings: Settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const input: [] = cfg.input ? cfg.input as [] : [];
|
const input: [] = cfg.input ? cfg.input as [] : [];
|
||||||
if (input.length > 0) {
|
if (nodeConf.input && input.length > 0) {
|
||||||
y += 20;
|
y += 20;
|
||||||
group.addShape('text', {
|
group.addShape('text', {
|
||||||
attrs: {
|
attrs: {
|
||||||
@@ -197,7 +197,7 @@ export default function (settings: Settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const output: [] = cfg.output ? cfg.output as [] : [];
|
const output: [] = cfg.output ? cfg.output as [] : [];
|
||||||
if (output.length > 0) {
|
if (nodeConf.output && output.length > 0) {
|
||||||
y += 20;
|
y += 20;
|
||||||
group.addShape('text', {
|
group.addShape('text', {
|
||||||
attrs: {
|
attrs: {
|
||||||
|
|||||||
Reference in new issue
Block a user