refreshNodeId when save tree
This commit is contained in:
1 parent
db709a28ec
commit
c30c81d53b
4 files changed
+22
-6
No files matched your search
@@ -56,8 +56,7 @@ npm run dist # 编译exe可执行文件
|
|||||||
## TODO
|
## TODO
|
||||||
+ 右键菜单
|
+ 右键菜单
|
||||||
+ 面板拖拽新建节点
|
+ 面板拖拽新建节点
|
||||||
+ 未保存的行为树标星号
|
+ 变量自动补全
|
||||||
+ 异步加载界面
|
|
||||||
|
|
||||||
## About
|
## About
|
||||||
目前编辑器还处于非常简陋的阶段,有问题可以联系作者(QQ1013299930),本项目将长期维护,望前端大佬们多提点~
|
目前编辑器还处于非常简陋的阶段,有问题可以联系作者(QQ1013299930),本项目将长期维护,望前端大佬们多提点~
|
||||||
@@ -364,7 +364,7 @@ export default class AppMenu {
|
|||||||
submenu: serverItems,
|
submenu: serverItems,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "处理脚本",
|
label: "批处理脚本",
|
||||||
click: () => {
|
click: () => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const res = await dialog.showOpenDialog({
|
const res = await dialog.showOpenDialog({
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7",
|
||||||
"description": "行为树编辑器",
|
"description": "行为树编辑器",
|
||||||
"main": "./dist/main.js",
|
"main": "./dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
private treeModel: BehaviorTreeModel;
|
private treeModel: BehaviorTreeModel;
|
||||||
private settings: Settings;
|
private settings: Settings;
|
||||||
private data: GraphNodeModel;
|
private data: GraphNodeModel;
|
||||||
|
private unsave: boolean = false;
|
||||||
|
|
||||||
constructor(props: EditorProps) {
|
constructor(props: EditorProps) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -336,11 +337,17 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
this.graph.set("animate", true);
|
this.graph.set("animate", true);
|
||||||
|
|
||||||
this.props.onChangeSaveState(true);
|
this.props.onChangeSaveState(true);
|
||||||
|
this.unsave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
|
if(!this.unsave) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { filepath } = this.props;
|
const { filepath } = this.props;
|
||||||
const root = Utils.createFileData(this.graph.findDataById("1") as GraphNodeModel);
|
const data = this.graph.findDataById("1") as GraphNodeModel;
|
||||||
|
this.autoId = Utils.refreshNodeId(data);
|
||||||
|
const root = Utils.createFileData(data);
|
||||||
const treeModel = {
|
const treeModel = {
|
||||||
name: path.basename(filepath).slice(0, -5),
|
name: path.basename(filepath).slice(0, -5),
|
||||||
root,
|
root,
|
||||||
@@ -348,9 +355,17 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
} as BehaviorTreeModel;
|
} as BehaviorTreeModel;
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
filepath,
|
filepath,
|
||||||
JSON.stringify(treeModel)
|
JSON.stringify(treeModel, null, 2)
|
||||||
);
|
);
|
||||||
this.props.onChangeSaveState(false);
|
this.props.onChangeSaveState(false);
|
||||||
|
this.unsave = false;
|
||||||
|
|
||||||
|
this.graph.set("animate", false);
|
||||||
|
this.graph.changeData(Utils.createTreeData(root, this.settings));
|
||||||
|
this.graph.layout();
|
||||||
|
this.graph.fitCenter();
|
||||||
|
this.graph.set("animate", true);
|
||||||
|
|
||||||
return treeModel;
|
return treeModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,6 +415,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
this.graph.set("animate", true);
|
this.graph.set("animate", true);
|
||||||
|
|
||||||
this.props.onChangeSaveState(true);
|
this.props.onChangeSaveState(true);
|
||||||
|
this.unsave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pushUndoStack(keepRedo?: boolean) {
|
pushUndoStack(keepRedo?: boolean) {
|
||||||
@@ -460,6 +476,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
const item = this.graph.findById(id);
|
const item = this.graph.findById(id);
|
||||||
item.draw();
|
item.draw();
|
||||||
this.props.onChangeSaveState(true);
|
this.props.onChangeSaveState(true);
|
||||||
|
this.unsave = true;
|
||||||
}}
|
}}
|
||||||
pushUndoStack={() => {
|
pushUndoStack={() => {
|
||||||
this.pushUndoStack();
|
this.pushUndoStack();
|
||||||
|
|||||||
Reference in new issue
Block a user