From 4bb083f7363f34a87a52ac67554e60055eb44929 Mon Sep 17 00:00:00 2001 From: zhandouxiaojiji Date: Thu, 5 Nov 2020 16:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main-process/AppMenu.ts | 34 ++++++++++++------- main-process/Settings.ts | 4 ++- .../node-config.json | 0 sample/workdir/boss101.json | 1 + sample/workdir/monster101.json | 1 + sample/workdir/monster102.json | 1 + sample/workdir/monster103.json | 1 + sample/workdir/monster104.json | 1 + sample/workdir/monster106.json | 1 + sample/workspace.json | 4 +++ 10 files changed, 34 insertions(+), 14 deletions(-) rename sample-node-config.json => sample/node-config.json (100%) create mode 100644 sample/workdir/boss101.json create mode 100644 sample/workdir/monster101.json create mode 100644 sample/workdir/monster102.json create mode 100644 sample/workdir/monster103.json create mode 100644 sample/workdir/monster104.json create mode 100644 sample/workdir/monster106.json create mode 100644 sample/workspace.json diff --git a/main-process/AppMenu.ts b/main-process/AppMenu.ts index f828185..28b5280 100644 --- a/main-process/AppMenu.ts +++ b/main-process/AppMenu.ts @@ -94,6 +94,20 @@ export default class AppMenu { this.mainProcess.rebuildMenu(); this.webContents.send(MainEventType.OPEN_DIR, this.settings.curWorkspace.getWorkdir()); }; + const saveToNewPath = () => { + (async () => { + const res = await dialog.showSaveDialog({ + properties: ['showOverwriteConfirmation'], + filters: [ + { name: "Json", extensions: ['json'] } + ] + }); + if (!res.canceled) { + this.settings.curWorkspace.setFilepath(res.filePath); + this.settings.curWorkspace.save(); + } + })(); + } const recentItems: MenuItemConstructorOptions[] = []; for (let path of this.settings.recentWorkspaces) { recentItems.push({ @@ -129,22 +143,16 @@ export default class AppMenu { if (this.settings.curWorkspace.getFilepath()) { this.settings.curWorkspace.save(); } else { - (async () => { - const res = await dialog.showSaveDialog({ - properties: ['showOverwriteConfirmation'], - filters: [ - { name: "Json", extensions: ['json'] } - ] - }); - if (!res.canceled) { - this.settings.curWorkspace.setFilepath(res.filePath); - this.settings.curWorkspace.save(); - - } - })(); + saveToNewPath(); } } }, + { + label: '另存为', + click: () => { + saveToNewPath(); + }, + }, { label: "最近打开", submenu: recentItems, diff --git a/main-process/Settings.ts b/main-process/Settings.ts index 50dccbd..e6c967f 100644 --- a/main-process/Settings.ts +++ b/main-process/Settings.ts @@ -14,7 +14,6 @@ export interface SettingsModel { } const settingPath = 'settings.json'; -const sampleNodeConfig = 'sample-node-config.json'; const sampleNodeClassify: BehaviorNodeClassify[] = [ { classify: "Composite", desc: "复合节点" }, { classify: "Decorator", desc: "修饰节点" }, @@ -83,6 +82,9 @@ export default class Settings { pushRecentWorkspace(path: string) { if (this.settings.recentWorkspaces.indexOf(path) < 0) { this.settings.recentWorkspaces.unshift(path); + console.log("push", path); + } else { + console.log("already in path", this.settings.recentWorkspaces, path); } this.save(); } diff --git a/sample-node-config.json b/sample/node-config.json similarity index 100% rename from sample-node-config.json rename to sample/node-config.json diff --git a/sample/workdir/boss101.json b/sample/workdir/boss101.json new file mode 100644 index 0000000..58f3abf --- /dev/null +++ b/sample/workdir/boss101.json @@ -0,0 +1 @@ +{"name":"boss101","root":{"id":1,"name":"Selector","desc":"Boss105","children":[{"id":2,"name":"Sequence","desc":"攻击范围内的敌人","children":[{"id":3,"name":"FindEnemyCanAttack","args":{},"output":["enemy1"]},{"id":4,"name":"LaunchSkillWithWeight","desc":"按权重放技能","args":{},"input":["enemy"]}]},{"id":5,"name":"Sequence","desc":"移动","children":[{"id":6,"name":"MonsterFindEnemy","desc":"寻找敌人","args":{},"output":["enemy"]},{"id":7,"name":"MoveToAtkPos","args":{"offset":160},"input":["enemy"]}]},{"id":8,"name":"Sequence","desc":"巡逻 ","args":{},"children":[{"id":9,"name":"NotMoving"},{"id":10,"name":"MonsterPatrol","desc":"巡逻"}]}]},"desc":"Boss105"} \ No newline at end of file diff --git a/sample/workdir/monster101.json b/sample/workdir/monster101.json new file mode 100644 index 0000000..7eda249 --- /dev/null +++ b/sample/workdir/monster101.json @@ -0,0 +1 @@ +{"root":{"name":"Selector","desc":"主动小怪","args":{},"debug":false,"id":1,"children":[{"name":"Sequence","desc":"攻击范围内的敌人","id":2,"children":[{"name":"FindEnemyCanAttack","desc":"","args":{},"output":["enemy"],"debug":false,"id":3},{"name":"NormalAttack","desc":"","args":{},"input":["enemy"],"debug":false,"id":4},{"name":"Wait","desc":"等待","args":{"time":"math.random(36)"},"debug":false,"id":5},{"name":"MoveRandom","desc":"","args":{"range":70},"id":6}]},{"name":"Sequence","desc":"移动","id":7,"children":[{"name":"MonsterFindEnemy","desc":"寻找敌人","args":{},"output":["enemy"],"debug":false,"id":8},{"name":"FloorMove","desc":"移动到目标","args":{"rand":70},"input":["enemy"],"debug":false,"id":9}]},{"name":"Sequence","desc":"巡逻","id":10,"children":[{"name":"NotMoving","desc":"","args":{},"debug":false,"id":11},{"name":"MonsterPatrol","desc":"巡逻","args":{},"debug":false,"id":12},{"name":"Wait","desc":"","args":{"time":"math.random(36)"},"debug":false,"id":13}]}]},"name":"monster101","server":true,"desc":"主动小怪"} \ No newline at end of file diff --git a/sample/workdir/monster102.json b/sample/workdir/monster102.json new file mode 100644 index 0000000..086d8e4 --- /dev/null +++ b/sample/workdir/monster102.json @@ -0,0 +1 @@ +{"root":{"name":"Selector","desc":"102","id":1,"children":[{"name":"ListenUnderAttack","desc":"监听被攻击","input":["enemy"],"id":2},{"name":"Sequence","desc":"攻击敌人","id":3,"children":[{"name":"NormalAttack","input":["enemy"],"id":4},{"name":"Wait","desc":"等待","args":{"time":30},"id":5}]},{"name":"Wait","desc":"等待","args":{"time":30},"id":6}]},"name":"monster102","server":true,"desc":"102"} \ No newline at end of file diff --git a/sample/workdir/monster103.json b/sample/workdir/monster103.json new file mode 100644 index 0000000..2026c19 --- /dev/null +++ b/sample/workdir/monster103.json @@ -0,0 +1 @@ +{"root":{"name":"Selector","desc":"103","id":1,"children":[]},"name":"monster103","server":true,"desc":"103"} \ No newline at end of file diff --git a/sample/workdir/monster104.json b/sample/workdir/monster104.json new file mode 100644 index 0000000..7dbdbc3 --- /dev/null +++ b/sample/workdir/monster104.json @@ -0,0 +1 @@ +{"root":{"name":"Parallel","desc":"被动小怪","args":{},"id":1,"children":[{"name":"ListenUnderAttack","desc":"监听被攻击","input":["enemy"],"id":2},{"name":"Wait","desc":"","args":{"time":12},"id":3},{"name":"Selector","id":4,"children":[{"name":"Sequence","desc":"攻击","id":5,"children":[{"name":"NotNull","input":["enemy"],"id":6,"children":[]},{"name":"Selector","id":7,"children":[{"name":"Sequence","id":8,"children":[{"name":"CanNormalAttack","desc":"","args":{},"debug":false,"id":9},{"name":"NormalAttack","args":{"rand":100},"input":["enemy"],"id":10},{"name":"Wait","desc":"","args":{"time":"math.random(36)"},"id":11}]},{"name":"Sequence","desc":"移动","id":12,"children":[{"name":"InAlertRange","desc":"在警戒范围内","args":{},"input":["enemy"],"debug":false,"id":13},{"name":"FloorMove","desc":"","args":{},"input":["enemy"],"id":14}]}]}]},{"name":"Sequence","desc":"巡逻","id":15,"children":[{"name":"MonsterPatrol","desc":"巡逻","id":16},{"name":"SetNull","input":["enemy"],"id":17,"children":[]}]}]},{"name":"Wait","desc":"","args":{"time":"math.random(36)"},"id":18}]},"name":"monster104","server":true,"desc":"被动小怪"} \ No newline at end of file diff --git a/sample/workdir/monster106.json b/sample/workdir/monster106.json new file mode 100644 index 0000000..86ecbe4 --- /dev/null +++ b/sample/workdir/monster106.json @@ -0,0 +1 @@ +{"root":{"name":"Sequence","desc":"塔防小怪","args":{},"id":1,"children":[{"name":"Once","desc":"","args":{},"id":2,"children":[{"name":"ListenUnderAttack","desc":"监听被击","args":{},"input":[null],"id":3,"children":[{"name":"SetNull","desc":"","args":{},"input":["path"],"id":4}]}]},{"name":"Selector","desc":"","args":{},"id":5,"children":[{"name":"Sequence","desc":"","args":{},"id":6,"children":[{"name":"NotNull","desc":"","args":{},"input":["path"],"id":7,"children":[]},{"name":"MovePath","desc":"","args":{},"input":["path"],"id":8}]},{"name":"MonsterFindDefendPath","desc":"","args":{},"output":["path"],"id":9}]}]},"name":"monster106","server":true,"desc":"塔防小怪"} \ No newline at end of file diff --git a/sample/workspace.json b/sample/workspace.json new file mode 100644 index 0000000..db61182 --- /dev/null +++ b/sample/workspace.json @@ -0,0 +1,4 @@ +{ + "nodeConfPath": "sample\\node-config.json", + "workdir": "sample\\workdir" +} \ No newline at end of file