diff --git a/idea.md b/idea.md index 0e6ae66..1e9e938 100644 --- a/idea.md +++ b/idea.md @@ -78,7 +78,7 @@ dam4.png ---- 存档 59 [] 优化开头动画 [x] 玩家可以设置字体大小 [] 完全删除 functions.js -[x] 优化插件加载系统 +[] 优化插件加载系统 [] 优化 Scroll 组件 [] 重写技能控制系统 [] 自定义快捷键 @@ -102,3 +102,4 @@ dam4.png ---- 存档 59 [x] 着色器特效 [] 完全删除 core.plugin?(待定) [] 通用 Addon 接口 +[] 完善加载系统 diff --git a/src/core/fx/shader.ts b/src/core/fx/shader.ts index 269efec..7abc261 100644 --- a/src/core/fx/shader.ts +++ b/src/core/fx/shader.ts @@ -423,6 +423,13 @@ export class ShaderEffect extends EventEmitter { `; } +interface GameCanvasReplacer { + recover(): void; + append(): void; + remove(): void; + update(compile?: boolean): void; +} + function floorPower2(value: number) { return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2)); } @@ -484,7 +491,16 @@ export function setTickerFor(effect: ShaderEffect) { return ticker; } -export function replaceGameCanvas(effect: ShaderEffect, canvas: string[]) { +/** + * 用着色器特效画布替换样板画布 + * @param effect 着色器特效实例 + * @param canvas 要替换的画布列表 + * @returns 特效控制器,用于控制特效的显示 + */ +export function replaceGameCanvas( + effect: ShaderEffect, + canvas: string[] +): GameCanvasReplacer { let zIndex = 0; canvas.forEach(v => { const canvas = core.canvas[v].canvas; diff --git a/src/core/main/custom/ui.ts b/src/core/main/custom/ui.ts index ea3d714..8ae26ea 100644 --- a/src/core/main/custom/ui.ts +++ b/src/core/main/custom/ui.ts @@ -1,4 +1,4 @@ -import { Component, h, shallowReactive } from 'vue'; +import { Component, shallowReactive } from 'vue'; import { EmitableEvent, EventEmitter } from '../../common/eventEmitter'; import { KeyCode } from '../../../plugin/keyCodes'; import { Hotkey } from './hotkey'; @@ -212,7 +212,7 @@ export class UiController extends Focus { */ open(id: string, vOn?: UiVOn, vBind?: UiVBind) { const ui = this.get(id); - if (!ui) return; + if (!ui) return -1; const num = this.num++; this.add({ num, ...ui.with(vOn, vBind) }); return num; @@ -223,18 +223,34 @@ export class UiController extends Focus { * @param id ui的id * @param ui 对应的GameUi实例 */ - resgister(id: string, ui: GameUi) { - if (id in this.list) { - console.warn(`已存在id为'${id}'的ui,已将其覆盖`); - } - this.list[id] = ui; + register(...ui: GameUi[]) { + ui.forEach(v => { + const id = v.id; + if (id in this.list) { + console.warn(`已存在id为'${id}'的ui,已将其覆盖`); + } + this.list[id] = v; + }); } /** * 取消注册一个ui * @param id 要取消注册的ui的id */ - unregister(id: string) { - delete this.list[id]; + unregister(...id: string[]) { + id.forEach(v => { + delete this.list[v]; + }); + return this; + } + + /** + * 根据ui的唯一标识符进行聚焦 + * @param num 要聚焦于的ui的唯一标识符 + */ + focusByNum(num: number, add?: boolean) { + const ui = this.stack.find(v => v.num === num); + if (!ui) return; + this.focus(ui); } } diff --git a/src/core/main/init/ui.ts b/src/core/main/init/ui.ts index 9a76be2..e0b5565 100644 --- a/src/core/main/init/ui.ts +++ b/src/core/main/init/ui.ts @@ -62,4 +62,4 @@ fixedUi.register( new GameUi('completeAchi', CompleteAchi) ); -mainUi.focus(mainUi.get('start'), true); +mainUi.focusByNum(mainUi.open('start'));