mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-06-19 19:17:21 +08:00
ModuleUtil.addGui支持自定义窗口动画参数
This commit is contained in:
@@ -24,7 +24,7 @@ export class LayerUIElement extends Component {
|
||||
/** 界面关闭回调 - 包括关闭动画播放完(辅助框架内存业务流程使用) */
|
||||
private onCloseWindow: Function = null!;
|
||||
|
||||
/** 窗口添加 */
|
||||
/** 添加界面且界面设置到父节点之前 */
|
||||
add(): Promise<boolean> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// 触发窗口组件上添加到父节点后的事件
|
||||
|
||||
@@ -46,7 +46,7 @@ export abstract class CCComp extends GameComponent implements ecs.IComp {
|
||||
remove(params?: UIRemove) {
|
||||
const cct = ECSModel.compCtors[this.tid];
|
||||
if (this.ent) {
|
||||
ModuleUtil.remove(this.ent, cct, params);
|
||||
ModuleUtil.removeGui(this.ent, cct, params);
|
||||
}
|
||||
else {
|
||||
console.error(`组件 ${this.name} 移除失败,实体不存在`);
|
||||
|
||||
@@ -58,7 +58,7 @@ export abstract class CCVMParentComp extends VMParent implements ecs.IComp {
|
||||
remove(params?: UIRemove) {
|
||||
const cct = ECSModel.compCtors[this.tid];
|
||||
if (this.ent) {
|
||||
ModuleUtil.remove(this.ent, cct, params);
|
||||
ModuleUtil.removeGui(this.ent, cct, params);
|
||||
}
|
||||
else {
|
||||
console.error(`组件 ${this.name} 移除失败,实体不存在`);
|
||||
|
||||
@@ -20,15 +20,17 @@ export class ModuleUtil {
|
||||
* @param uiArgs 界面参数
|
||||
* @returns 界面节点
|
||||
*/
|
||||
static add<T extends CCVMParentComp | CCComp>(ent: ecs.Entity, ctor: ECSCtor<T>, uiArgs: any = null): Promise<Node | null> {
|
||||
static addGui<T extends CCVMParentComp | CCComp>(ent: ecs.Entity, ctor: ECSCtor<T>, uiArgs?: any, anim?: UICallbacks): Promise<Node | null> {
|
||||
return new Promise<Node | null>((resolve, reject) => {
|
||||
const uic: UICallbacks = {
|
||||
onAdded: (node: Node, params: any) => {
|
||||
const comp = node.getComponent(ctor) as ecs.Comp;
|
||||
ent.add(comp);
|
||||
if (anim && anim.onAdded) anim.onAdded(node, params);
|
||||
resolve(node);
|
||||
},
|
||||
onLoadFailure: () => {
|
||||
if (anim && anim.onLoadFailure) anim.onLoadFailure();
|
||||
resolve(null);
|
||||
}
|
||||
};
|
||||
@@ -51,7 +53,7 @@ export class ModuleUtil {
|
||||
* @param isDestroy 是否释放界面缓存(默认为释放界面缓存)
|
||||
* @param onRemoved 窗口关闭完成事件
|
||||
*/
|
||||
static remove(ent: ecs.Entity, ctor: CompType<ecs.IComp>, params?: UIRemove) {
|
||||
static removeGui(ent: ecs.Entity, ctor: CompType<ecs.IComp>, params?: UIRemove) {
|
||||
if (params == null) {
|
||||
params = { isDestroy: true };
|
||||
}
|
||||
@@ -98,6 +100,7 @@ export class ModuleUtil {
|
||||
node.parent = parent;
|
||||
}
|
||||
|
||||
//#region deprecated
|
||||
/**
|
||||
* 添加界面组件
|
||||
* @param ent 模块实体
|
||||
@@ -168,4 +171,5 @@ export class ModuleUtil {
|
||||
oops.gui.remove(uiId, isDestroy);
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user