diff --git a/render-process/Editor/Editor.css b/render-process/Editor/Editor.css index 523d59c..fd8dd6c 100644 --- a/render-process/Editor/Editor.css +++ b/render-process/Editor/Editor.css @@ -17,4 +17,4 @@ width : 100%; height : 100%; display: flex; -} \ No newline at end of file +} diff --git a/render-process/Editor/Properties.tsx b/render-process/Editor/Properties.tsx index 9a13251..4df6ae1 100644 --- a/render-process/Editor/Properties.tsx +++ b/render-process/Editor/Properties.tsx @@ -1,6 +1,7 @@ import React, { Component } from "react"; import { Menu, Input } from "antd"; import * as fs from 'fs'; +import * as path from 'path'; import { BehaviorTreeModel } from "../../common/BehaviorTreeModel"; import { remote } from 'electron'; import { MainProcess } from "../../main-process/MainProcess"; @@ -8,28 +9,60 @@ import Settings from "../../main-process/Settings"; const { Search } = Input; +interface TreeFile { + name: string; + path: string; +} + export interface PropertiesProps { workspace: string; onOpenTree: (path: string) => void; - trees: BehaviorTreeModel[]; } interface PropertiesState { - + treeList: TreeFile[] } export default class Properties extends Component { state: PropertiesState = { - + treeList: [] }; componentDidMount() { + var workspace = this.props.workspace; + if (workspace == '') { + workspace = this.getLastWorkspace(); + } + this.setState({ treeList: this.getTreeList(workspace) }); + } + + getLastWorkspace() { const settings: Settings = remote.getGlobal("settings"); - const lastWorkspace = settings.recentWorkspaces[0]; - console.log("&&&&&& last workspace", lastWorkspace); + return settings.recentWorkspaces[0]; + } + + getTreeList(workspace: string) { + if (workspace == '' || !fs.existsSync(workspace)) { + console.log("workspace not exist", workspace); + return; + } + + const files = fs.readdirSync(workspace); + const list: TreeFile[] = []; + files.forEach((filename) => { + const stat = fs.statSync(path.join(workspace, filename)) + if (stat.isFile()) { + list.push({ + name: filename.slice(0, -5), + path: workspace + '/' + name + '.json' + }); + } + }) + return list; } render() { + const { treeList } = this.state; return (
{ }} /> - - test + {treeList.map((tree) => ( + + {tree.name} + + ))}
) diff --git a/render-process/Editor/index.tsx b/render-process/Editor/index.tsx index 18be383..0d7eb74 100644 --- a/render-process/Editor/index.tsx +++ b/render-process/Editor/index.tsx @@ -34,10 +34,8 @@ export default class Editor extends Component { ipcRenderer.on(MainEventType.OPEN_WORKSPACE, (event: any, workspace: any) => { console.log("on open workspace", workspace); this.setState({ workspace }); - this.loadAllTrees(); }); - this.loadAllTrees(); } loadAllTrees() { @@ -89,7 +87,6 @@ export default class Editor extends Component { onOpenTree={(path) => { console.log("open tree", path); }} - trees={trees} /> diff --git a/render-process/index.css b/render-process/index.css index 67e31af..6fec35b 100644 --- a/render-process/index.css +++ b/render-process/index.css @@ -1,4 +1,20 @@ body { background-color: #242424; padding: 0px; +} + +::-webkit-scrollbar +{ + background-color: #a0a0a0; +} + +::-webkit-scrollbar-track +{ + background-color:#1d1d1d; +} + +::-webkit-scrollbar-thumb +{ + height:50px; + background-color:#818181; } \ No newline at end of file