mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
ui控制器添加根据num聚焦的方法
This commit is contained in:
parent
df98da5d67
commit
e6d96f6e2a
3
idea.md
3
idea.md
@ -78,7 +78,7 @@ dam4.png ---- 存档 59
|
|||||||
[] 优化开头动画
|
[] 优化开头动画
|
||||||
[x] 玩家可以设置字体大小
|
[x] 玩家可以设置字体大小
|
||||||
[] 完全删除 functions.js
|
[] 完全删除 functions.js
|
||||||
[x] 优化插件加载系统
|
[] 优化插件加载系统
|
||||||
[] 优化 Scroll 组件
|
[] 优化 Scroll 组件
|
||||||
[] 重写技能控制系统
|
[] 重写技能控制系统
|
||||||
[] 自定义快捷键
|
[] 自定义快捷键
|
||||||
@ -102,3 +102,4 @@ dam4.png ---- 存档 59
|
|||||||
[x] 着色器特效
|
[x] 着色器特效
|
||||||
[] 完全删除 core.plugin?(待定)
|
[] 完全删除 core.plugin?(待定)
|
||||||
[] 通用 Addon 接口
|
[] 通用 Addon 接口
|
||||||
|
[] 完善加载系统
|
||||||
|
@ -423,6 +423,13 @@ export class ShaderEffect extends EventEmitter<ShaderEvent> {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface GameCanvasReplacer {
|
||||||
|
recover(): void;
|
||||||
|
append(): void;
|
||||||
|
remove(): void;
|
||||||
|
update(compile?: boolean): void;
|
||||||
|
}
|
||||||
|
|
||||||
function floorPower2(value: number) {
|
function floorPower2(value: number) {
|
||||||
return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
|
return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
|
||||||
}
|
}
|
||||||
@ -484,7 +491,16 @@ export function setTickerFor(effect: ShaderEffect) {
|
|||||||
return ticker;
|
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;
|
let zIndex = 0;
|
||||||
canvas.forEach(v => {
|
canvas.forEach(v => {
|
||||||
const canvas = core.canvas[v].canvas;
|
const canvas = core.canvas[v].canvas;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, h, shallowReactive } from 'vue';
|
import { Component, shallowReactive } from 'vue';
|
||||||
import { EmitableEvent, EventEmitter } from '../../common/eventEmitter';
|
import { EmitableEvent, EventEmitter } from '../../common/eventEmitter';
|
||||||
import { KeyCode } from '../../../plugin/keyCodes';
|
import { KeyCode } from '../../../plugin/keyCodes';
|
||||||
import { Hotkey } from './hotkey';
|
import { Hotkey } from './hotkey';
|
||||||
@ -212,7 +212,7 @@ export class UiController extends Focus<IndexedGameUi> {
|
|||||||
*/
|
*/
|
||||||
open(id: string, vOn?: UiVOn, vBind?: UiVBind) {
|
open(id: string, vOn?: UiVOn, vBind?: UiVBind) {
|
||||||
const ui = this.get(id);
|
const ui = this.get(id);
|
||||||
if (!ui) return;
|
if (!ui) return -1;
|
||||||
const num = this.num++;
|
const num = this.num++;
|
||||||
this.add({ num, ...ui.with(vOn, vBind) });
|
this.add({ num, ...ui.with(vOn, vBind) });
|
||||||
return num;
|
return num;
|
||||||
@ -223,18 +223,34 @@ export class UiController extends Focus<IndexedGameUi> {
|
|||||||
* @param id ui的id
|
* @param id ui的id
|
||||||
* @param ui 对应的GameUi实例
|
* @param ui 对应的GameUi实例
|
||||||
*/
|
*/
|
||||||
resgister(id: string, ui: GameUi) {
|
register(...ui: GameUi[]) {
|
||||||
if (id in this.list) {
|
ui.forEach(v => {
|
||||||
console.warn(`已存在id为'${id}'的ui,已将其覆盖`);
|
const id = v.id;
|
||||||
}
|
if (id in this.list) {
|
||||||
this.list[id] = ui;
|
console.warn(`已存在id为'${id}'的ui,已将其覆盖`);
|
||||||
|
}
|
||||||
|
this.list[id] = v;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消注册一个ui
|
* 取消注册一个ui
|
||||||
* @param id 要取消注册的ui的id
|
* @param id 要取消注册的ui的id
|
||||||
*/
|
*/
|
||||||
unregister(id: string) {
|
unregister(...id: string[]) {
|
||||||
delete this.list[id];
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,4 +62,4 @@ fixedUi.register(
|
|||||||
new GameUi('completeAchi', CompleteAchi)
|
new GameUi('completeAchi', CompleteAchi)
|
||||||
);
|
);
|
||||||
|
|
||||||
mainUi.focus(mainUi.get('start'), true);
|
mainUi.focusByNum(mainUi.open('start'));
|
||||||
|
Loading…
Reference in New Issue
Block a user