Files
oops-plugin-framework/assets/core/gui/layer/LayerDialog.ts
dgflash f2fe9d47b6 1. 存储模块全面优化,修复跨平台兼容性问题,完美支持所有Unicode字符
2. 存储模块性能提升,添加LRU缓存、批量操作支持,优化内存使用
3. 多语言模块性能与内存管理优化,组件查询性能提升
4. 时间模块类型安全与性能优化,使用泛型替代any,对象池机制减少内存分配
5. 事件系统修复双重注册、重复注册等严重问题,实现EventData对象池减少GC压力
6. RandomManager修复4个逻辑BUG,包括边界问题和越界问题
7. 音频模块内存与性能优化,避免重复加载,优化数据结构,添加完整清理机制
8. CCView与CCViewVM合并,支持按需启用MVVM
9. Collection模块优化,AsyncQueue添加队列容量限制,Collection查询性能提升
10. ECS系统全面优化,对象池复用减少内存分配,循环性能提升
11. 优化MVVM组件性能
2026-01-09 21:54:05 +08:00

76 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* @Author: dgflash
* @Date: 2021-07-03 16:13:17
* @LastEditors: dgflash
* @LastEditTime: 2023-07-24 17:14:57
*/
import type { Node } from 'cc';
import { LayerPopUp } from './LayerPopup';
import type { UIParam, UIState } from './LayerUIElement';
import type { UIConfig } from './UIConfig';
/** 模式弹窗数据 */
type DialogParam = {
/** 弹窗唯一编号 */
uiid: string;
/** 窗口配置 */
config: UIConfig;
/** 窗口附加参数 */
params?: UIParam;
}
/*
* 模式弹窗层,该层的窗口同时只能显示一个,删除以后会自动从队列当中取一个弹窗,直到队列为空
*/
export class LayerDialog extends LayerPopUp {
/** 窗口调用参数队列 */
private params: Array<DialogParam> = [];
/** 当前打开的界面 */
private current: Node = null!;
/**
* 添加模式窗口
* 1. 同时添加多个模式窗口时,第一个之后的窗口会先队列起来,在第一个关闭后在加载与显示第二个;同时方法返回节点保持只返回当前显示的界面节点
*/
add(uiid: string, config: UIConfig, params?: UIParam): Promise<Node> {
return new Promise<Node>(async (resolve, reject) => {
// 控制同一时间只能显示一个模式窗口
if (this.ui_nodes.size > 0) {
this.params.push({ uiid: uiid, config: config, params: params });
resolve(this.current);
}
else {
this.current = await this.showDialog(uiid, config, params);
resolve(this.current);
}
});
}
/** 显示模式弹窗 */
private showDialog(uiid: string, config: UIConfig, param?: UIParam): Promise<Node> {
return new Promise<Node>(async (resolve, reject) => {
const state = this.initUIConfig(uiid, config, param);
const node = await this.load(state);
resolve(node);
});
}
protected closeUi(state: UIState) {
super.closeUi(state);
// 使用 Promise 微任务代替 setTimeout性能更好且更可靠
Promise.resolve().then(() => this.next());
}
protected closeBlack() {
if (this.params.length == 0) {
super.closeBlack();
}
}
private next() {
if (this.params.length > 0) {
const param = this.params.shift()!;
this.showDialog(param.uiid, param.config, param.params);
}
}
}