specify output directory when build
This commit is contained in:
1 parent
8e43285089
commit
95689ec712
4 files changed
+49
-34
No files matched your search
+12
-2
@@ -20,6 +20,7 @@ export default class AppMenu {
|
|||||||
private mainWindow: BrowserWindow;
|
private mainWindow: BrowserWindow;
|
||||||
private webContents: WebContents;
|
private webContents: WebContents;
|
||||||
private settings: Settings;
|
private settings: Settings;
|
||||||
|
private buildDir?: string;
|
||||||
|
|
||||||
constructor(mainProcess: MainProcess) {
|
constructor(mainProcess: MainProcess) {
|
||||||
this.mainProcess = mainProcess;
|
this.mainProcess = mainProcess;
|
||||||
@@ -139,8 +140,17 @@ export default class AppMenu {
|
|||||||
{
|
{
|
||||||
label: "构建",
|
label: "构建",
|
||||||
accelerator: "CommandOrControl+b",
|
accelerator: "CommandOrControl+b",
|
||||||
click: () => {
|
click: async () => {
|
||||||
this.webContents.send(MainEventType.BUILD);
|
if (!this.buildDir) {
|
||||||
|
const res = await dialog.showOpenDialog({
|
||||||
|
properties: ["openDirectory"],
|
||||||
|
});
|
||||||
|
if (res.canceled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.buildDir = res.filePaths[0];
|
||||||
|
}
|
||||||
|
this.webContents.send(MainEventType.BUILD, this.buildDir);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"description": "行为树编辑器",
|
"description": "行为树编辑器",
|
||||||
"main": "./dist/main.js",
|
"main": "./dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { Tabs, message } from "antd";
|
|||||||
import { ipcRenderer } from "electron";
|
import { ipcRenderer } from "electron";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as Utils from "../common/Utils";
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
|
import * as Utils from "../common/Utils";
|
||||||
import Editor from "./Editor";
|
import Editor from "./Editor";
|
||||||
|
|
||||||
import "antd/dist/antd.dark.css";
|
import "antd/dist/antd.dark.css";
|
||||||
@@ -72,7 +72,7 @@ export default class TreeTabs extends Component<TreeTabsProps, TreeTabsState> {
|
|||||||
message.success("已保存所有行为树");
|
message.success("已保存所有行为树");
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on(MainEventType.BUILD, () => {
|
ipcRenderer.on(MainEventType.BUILD, async (event, buildDir) => {
|
||||||
for (let k in this.editors) {
|
for (let k in this.editors) {
|
||||||
let editor = this.editors[k];
|
let editor = this.editors[k];
|
||||||
editor.save();
|
editor.save();
|
||||||
@@ -80,21 +80,16 @@ export default class TreeTabs extends Component<TreeTabsProps, TreeTabsState> {
|
|||||||
|
|
||||||
const settings = Utils.getRemoteSettings();
|
const settings = Utils.getRemoteSettings();
|
||||||
const workdir = settings.workdir;
|
const workdir = settings.workdir;
|
||||||
if (!fs.existsSync(workdir)) {
|
|
||||||
console.log("workdir not found:", workdir);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const files = fs.readdirSync(workdir).filter((f) => {
|
const files = fs.readdirSync(workdir).filter((f) => {
|
||||||
return f.endsWith(".json");
|
return f.endsWith(".json");
|
||||||
});
|
});
|
||||||
for (const path of files) {
|
for (const path of files) {
|
||||||
const builddir = fs.realpathSync(workdir + "/../build", "utf-8");
|
const buildpath = buildDir + "/" + path;
|
||||||
fs.mkdirSync(builddir, { recursive: true });
|
|
||||||
const buildpath = builddir + "/" + path;
|
|
||||||
console.log("build:", buildpath);
|
console.log("build:", buildpath);
|
||||||
const treeModel = Utils.createBuildData(path, settings);
|
const treeModel = Utils.createBuildData(path, settings);
|
||||||
fs.writeFileSync(buildpath, JSON.stringify(treeModel, null, 2));
|
fs.writeFileSync(buildpath, JSON.stringify(treeModel, null, 2));
|
||||||
}
|
}
|
||||||
|
message.success("已构建所有行为树");
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on(MainEventType.UNDO, () => {
|
ipcRenderer.on(MainEventType.UNDO, () => {
|
||||||
|
|||||||
+32
-22
@@ -5,7 +5,7 @@ import { Layout, message, Tabs } from "antd";
|
|||||||
import * as Utils from "../common/Utils";
|
import * as Utils from "../common/Utils";
|
||||||
import MainEventType from "../common/MainEventType";
|
import MainEventType from "../common/MainEventType";
|
||||||
import Settings from "../main-process/Settings";
|
import Settings from "../main-process/Settings";
|
||||||
import {ipcRenderer} from "electron";
|
import { ipcRenderer } from "electron";
|
||||||
import "antd/dist/antd.dark.css";
|
import "antd/dist/antd.dark.css";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import RegisterNode from "./RegisterNode";
|
import RegisterNode from "./RegisterNode";
|
||||||
@@ -53,20 +53,20 @@ export default class Main extends Component {
|
|||||||
}
|
}
|
||||||
SyncRequest("POST", serverModel.host, {
|
SyncRequest("POST", serverModel.host, {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
cmd:"btree.reload",
|
cmd: "btree.reload",
|
||||||
data: {
|
data: {
|
||||||
trees: this.tabs.getOpenTreesModel()
|
trees: this.tabs.getOpenTreesModel(),
|
||||||
},
|
},
|
||||||
session: this.session++,
|
session: this.session++,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
message.success("服务器已更新");
|
message.success("服务器已更新");
|
||||||
})
|
});
|
||||||
|
|
||||||
ipcRenderer.on(MainEventType.BATCH_EXEC, (event: any, path: string)=>{
|
ipcRenderer.on(MainEventType.BATCH_EXEC, (event: any, path: string) => {
|
||||||
BatchExec(path, this.state.workdir);
|
BatchExec(path, this.state.workdir);
|
||||||
})
|
});
|
||||||
|
|
||||||
console.log("workdir", this.settings.curWorkspace.getWorkdir());
|
console.log("workdir", this.settings.curWorkspace.getWorkdir());
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -113,7 +113,7 @@ export default class Main extends Component {
|
|||||||
sider.style.maxWidth = width + "px";
|
sider.style.maxWidth = width + "px";
|
||||||
sider.style.minWidth = "0px";
|
sider.style.minWidth = "0px";
|
||||||
sider.style.flex = "";
|
sider.style.flex = "";
|
||||||
reSizer.style.left = (width - 5) + "px";
|
reSizer.style.left = width - 5 + "px";
|
||||||
content.style.width = window.innerWidth - width + "px";
|
content.style.width = window.innerWidth - width + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,16 +122,27 @@ export default class Main extends Component {
|
|||||||
document.documentElement.removeEventListener("mouseup", stopDrag, false);
|
document.documentElement.removeEventListener("mouseup", stopDrag, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
reSizer.addEventListener("mouseover", function() {
|
reSizer.addEventListener(
|
||||||
reSizer.style.opacity = "1";
|
"mouseover",
|
||||||
reSizer.addEventListener("mousedown", initDrag, false);
|
function () {
|
||||||
reSizer.addEventListener("mouseout", function init() {
|
reSizer.style.opacity = "1";
|
||||||
reSizer.style.opacity = "0";
|
reSizer.addEventListener("mousedown", initDrag, false);
|
||||||
}, false);
|
reSizer.addEventListener(
|
||||||
}, false);
|
"mouseout",
|
||||||
|
function init() {
|
||||||
|
reSizer.style.opacity = "0";
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
window.addEventListener("resize", function() {
|
window.addEventListener("resize", function () {
|
||||||
const currentWidth = parseInt(document.defaultView.getComputedStyle(reSizerParent).width, 10);
|
const currentWidth = parseInt(
|
||||||
|
document.defaultView.getComputedStyle(reSizerParent).width,
|
||||||
|
10
|
||||||
|
);
|
||||||
setWidth(currentWidth);
|
setWidth(currentWidth);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -147,7 +158,7 @@ export default class Main extends Component {
|
|||||||
const { workdir, workspace } = this.state;
|
const { workdir, workspace } = this.state;
|
||||||
document.title = `行为树编辑器 - ${workspace}`;
|
document.title = `行为树编辑器 - ${workspace}`;
|
||||||
return (
|
return (
|
||||||
<Layout className="body" style={{flexDirection: "column"}}>
|
<Layout className="body" style={{ flexDirection: "column" }}>
|
||||||
<Sider className="sider" width={250}>
|
<Sider className="sider" width={250}>
|
||||||
{workdir !== "" ? (
|
{workdir !== "" ? (
|
||||||
<Explorer
|
<Explorer
|
||||||
@@ -166,16 +177,15 @@ export default class Main extends Component {
|
|||||||
"Please Open Workspace"
|
"Please Open Workspace"
|
||||||
)}
|
)}
|
||||||
</Sider>
|
</Sider>
|
||||||
<div id="sizer-hint-bar"/>
|
<div id="sizer-hint-bar" />
|
||||||
<Content className="content">
|
<Content className="content">
|
||||||
<TreeTabs
|
<TreeTabs
|
||||||
ref={(ref) => {
|
ref={(ref) => {
|
||||||
this.tabs = ref;
|
this.tabs = ref;
|
||||||
}}
|
}}
|
||||||
onTabSelected={(path)=>{
|
onTabSelected={(path) => {
|
||||||
this.explorer.selectNode(path);
|
this.explorer.selectNode(path);
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Content>
|
</Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
Reference in new issue
Block a user