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