Skip to content

Commit

Permalink
界面暂存
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed May 20, 2024
1 parent b298d01 commit d1adff2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/customDefine/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class UI extends BaseDefine {
});
}

private _uiCache?: Node[];
private _uiCache?: {
预设: Node[];
};

get watchPattern() {
if (!env.mapUri) {
Expand Down Expand Up @@ -57,7 +59,9 @@ export class UI extends BaseDefine {
}

private async loadUI() {
let nodes: Node[] = [];
let nodes = {
预设: [] as Node[],
};
try {
if (!env.mapUri) {
return nodes;
Expand All @@ -68,12 +72,15 @@ export class UI extends BaseDefine {
if (fileType !== vscode.FileType.File) {
continue;
};
if (fileName === 'SceneUI.json') {
continue;
};
if (!fileName.endsWith('.json')) {
continue;
};
let node = await this.loadUIFile(vscode.Uri.joinPath(dir, fileName));
if (node) {
nodes.push(node);
nodes.预设.push(node);
}
}
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/mainMenu/mainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let mainNode = new TreeNode('主菜单', {
new 功能,
new 单位属性,
new 玩家属性,
//new 界面,
new 界面,
new 自定义事件,
new 环境,
new TreeNode('重新选择Y3地图路径', {
Expand Down
35 changes: 32 additions & 3 deletions src/mainMenu/pages/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@ import * as vscode from 'vscode';
import { define } from "../../customDefine";
import { env } from "../../env";

type Node = {
name: string,
uid: string,
type: number,
childs: Node[],
};

let icons: Map<number, vscode.ThemeIcon> = new Map();
icons.set(1, new vscode.ThemeIcon('inspect')); // Button
icons.set(3, new vscode.ThemeIcon('text-size')); // TextLabel
icons.set(4, new vscode.ThemeIcon('graph-line')); // Image
icons.set(7, new vscode.ThemeIcon('symbol-number')); // Layout
icons.set(10, new vscode.ThemeIcon('list-unordered')); // ScrollView
icons.set(27, new vscode.ThemeIcon('settings-gear')); // Chat_Box

class UINode extends TreeNode {
constructor(ui: Node) {
super(ui.name, {
update: async (node) => {
node.iconPath = icons.get(ui.type);
node.childs = ui.childs.length > 0
? ui.childs.map(ui => new UINode(ui))
: undefined;
}
});
}
}

export class 界面 extends TreeNode {
constructor() {
super('界面', {
Expand All @@ -13,7 +41,7 @@ export class 界面 extends TreeNode {
},

childs: [
new TreeNode('画板', {
new TreeNode('预设', {
iconPath: new vscode.ThemeIcon('layout-statusbar'),

show: async () => {
Expand All @@ -25,8 +53,9 @@ export class 界面 extends TreeNode {
return;
}

node.childs = (await define.画板.getUI()).map(ui => new TreeNode(ui.name, {
}));
node.childs = (await define.画板.getUI())
.预设
.map(ui => new UINode(ui));
}
})
],
Expand Down

0 comments on commit d1adff2

Please sign in to comment.