feat: 根据唯一标识符获取ui

This commit is contained in:
unanmed 2023-09-29 18:06:52 +08:00
parent 17633b094d
commit 3b8232a9d9

View File

@ -18,7 +18,7 @@ export class Focus<T = any> extends EventEmitter<FocusEvent<T>> {
stack: T[];
focused: T | null = null;
/** ui是否平等在平等时关闭ui不再会将其之后的ui全部删除,而是保留 */
/** 聚焦目标是否平等,在平等时,关闭聚焦目标不再会将其之后的目标全部删除,而是保留 */
readonly equal: boolean;
constructor(react: boolean = false, equal: boolean = false) {
@ -83,7 +83,7 @@ export class Focus<T = any> extends EventEmitter<FocusEvent<T>> {
}
/**
* ui平ui全部删
*
* @param item
*/
splice(item: T) {
@ -249,8 +249,16 @@ export class UiController extends Focus<IndexedGameUi> {
* @param num ui的唯一标识符
*/
focusByNum(num: number) {
const ui = this.stack.find(v => v.num === num);
const ui = this.getByNum(num);
if (!ui) return;
this.focus(ui);
}
/**
* ui
* @param num ui的唯一标识符
*/
getByNum(num: number) {
return this.stack.find(v => v.num === num);
}
}