Skip to content

Commit

Permalink
支持切换地图
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Nov 6, 2024
1 parent bd050fe commit bab0c7b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@
"title": "打开插件",
"enablement": "viewItem == 插件",
"category": "Y3开发助手"
},
{
"command": "y3-helper.changeMap",
"title": "切换地图",
"category": "Y3开发助手"
}
],
"configuration": {
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class Env {
await this.updateEditor(askUser);
}

private updateCurrentMap(map: Map) {
public updateCurrentMap(map: Map) {
if (this.currentMap === map) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/mainMenu/mainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { 自定义事件 } from './pages/events';
import { 界面 } from './pages/ui';
import { 时间轴动画 } from './pages/uiAnim';
import { 插件 } from './pages/plugin';
import { 地图管理 } from './pages/mapManager';
import { 跳字 } from './pages/jumpword';
import { 字体 } from './pages/font';

Expand All @@ -31,6 +32,7 @@ let mainNode = new TreeNode('主菜单', {
]
}),
new 插件,
new 地图管理,
new 环境,
new TreeNode('重新选择Y3地图路径', {
command: {
Expand Down
41 changes: 41 additions & 0 deletions src/mainMenu/pages/mapManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { TreeNode } from "../treeNode";
import * as vscode from 'vscode';
import { env } from "../../env";

export class 地图管理 extends TreeNode {
constructor() {
super('地图管理', {
iconPath: new vscode.ThemeIcon('repo-clone'),

update: async (node) => {
await env.mapReady();
let entryMap = env.project?.entryMap;
let currentMap = env.currentMap;
node.childs = env.project?.maps.map(map => {
return new TreeNode(map.name, {
iconPath: map === entryMap ? new vscode.ThemeIcon('star-full') : new vscode.ThemeIcon('star-empty'),
description: map === currentMap ? '当前地图' : undefined,
tooltip: `id: ${String(map.id)}\n\n点击切换至此地图`,
command: {
command: "y3-helper.changeMap",
title: "切换地图",
arguments: [map.name],
}
});
});
},
});

env.onDidChange(() => {
this.refresh();
});
}
};

vscode.commands.registerCommand('y3-helper.changeMap', async (name: string) => {
let map = env.project?.maps.find(map => map.name === name);
if (!map) {
return;
}
env.updateCurrentMap(map);
});

0 comments on commit bab0c7b

Please sign in to comment.