mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 20:59:37 +08:00
feat: UiController.holdOn
This commit is contained in:
parent
7a235b2349
commit
f79cd57f75
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭一个ui,注意如果不是平等模式,在其之后的ui都会同时关闭掉
|
* 关闭一个ui,注意如果不是平等模式,在其之后的ui都会同时关闭掉
|
||||||
* @param num 要关闭的ui的唯一标识符
|
* @param num 要关闭的ui的唯一标识符
|
||||||
|
Loading…
Reference in New Issue
Block a user