feat: UiController.holdOn

This commit is contained in:
unanmed 2023-10-21 22:36:47 +08:00
parent 7a235b2349
commit f79cd57f75

View File

@ -158,6 +158,8 @@ export class UiController extends Focus<IndexedGameUi> {
list: Record<string, GameUi> = {}; list: Record<string, GameUi> = {};
num: number = 0; num: number = 0;
private hold: boolean = false;
constructor(equal?: boolean) { constructor(equal?: boolean) {
super(true, equal); super(true, equal);
UiController.list.push(this); UiController.list.push(this);
@ -165,7 +167,8 @@ export class UiController extends Focus<IndexedGameUi> {
spliced.forEach(v => { spliced.forEach(v => {
v.ui.emit('close'); v.ui.emit('close');
if (this.stack.length === 0) { if (this.stack.length === 0) {
this.emit('end'); if (!this.hold) this.emit('end');
this.hold = false;
} }
}); });
}); });
@ -194,6 +197,17 @@ export class UiController extends Focus<IndexedGameUi> {
return this.list[id]; return this.list[id];
} }
/**
* ui不会导致ui整体被关闭ui背景闪烁
* holdOn使 app:
* ```txt
* hold on -> close -> use item -> hook -> stack.length === 0 ? hide app : no action
* ```
*/
holdOn() {
this.hold = true;
}
/** /**
* uiui都会同时关闭掉 * uiui都会同时关闭掉
* @param num ui的唯一标识符 * @param num ui的唯一标识符