@gongxh/bit-ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +243 -0
- package/dist/bit-ui.cjs +1749 -0
- package/dist/bit-ui.d.ts +478 -0
- package/dist/bit-ui.min.cjs +1 -0
- package/dist/bit-ui.min.mjs +1 -0
- package/dist/bit-ui.mjs +1743 -0
- package/package.json +57 -0
package/dist/bit-ui.d.ts
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { GComponent } from 'fairygui-cc';
|
|
2
|
+
import { Component } from 'cc';
|
|
3
|
+
|
|
4
|
+
/** 窗口显示时,对其他窗口的隐藏处理类型 */
|
|
5
|
+
declare enum WindowType {
|
|
6
|
+
/** 不做任何处理 */
|
|
7
|
+
Normal = 0,
|
|
8
|
+
/** 关闭所有 */
|
|
9
|
+
CloseAll = 1,
|
|
10
|
+
/** 关闭上一个 */
|
|
11
|
+
CloseOne = 2,
|
|
12
|
+
/** 隐藏所有 */
|
|
13
|
+
HideAll = 4,
|
|
14
|
+
/** 隐藏上一个 */
|
|
15
|
+
HideOne = 8
|
|
16
|
+
}
|
|
17
|
+
/** 窗口适配类型,默认全屏 */
|
|
18
|
+
declare enum AdapterType {
|
|
19
|
+
/** 全屏适配 */
|
|
20
|
+
Full = 0,
|
|
21
|
+
/** 空出刘海 */
|
|
22
|
+
Bang = 1,
|
|
23
|
+
/** 固定的 不适配 */
|
|
24
|
+
Fixed = 2
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @Author: Gongxh
|
|
29
|
+
* @Date: 2024-12-08
|
|
30
|
+
* @Description: 窗口顶边资源栏
|
|
31
|
+
*/
|
|
32
|
+
interface IHeader {
|
|
33
|
+
/** 资源栏名称 */
|
|
34
|
+
name: string;
|
|
35
|
+
/** 窗口适配类型 */
|
|
36
|
+
adapterType: AdapterType;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @Author: Gongxh
|
|
41
|
+
* @Date: 2025-01-10
|
|
42
|
+
* @Description: 窗口顶部资源栏信息
|
|
43
|
+
*/
|
|
44
|
+
declare class WindowHeaderInfo {
|
|
45
|
+
/** header名字 */
|
|
46
|
+
name: string;
|
|
47
|
+
/**
|
|
48
|
+
* 创建 WindowHeaderInfo
|
|
49
|
+
* @param {string} name header窗口名
|
|
50
|
+
* @param {*} [userdata] 自定义数据
|
|
51
|
+
* @returns {WindowHeaderInfo}
|
|
52
|
+
*/
|
|
53
|
+
static create(name: string, userdata?: any): WindowHeaderInfo;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @Author: Gongxh
|
|
58
|
+
* @Date: 2024-12-08
|
|
59
|
+
* @Description:
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
interface IWindow {
|
|
63
|
+
/** 窗口类型 */
|
|
64
|
+
type: WindowType;
|
|
65
|
+
/** 窗口适配类型 */
|
|
66
|
+
adapterType: AdapterType;
|
|
67
|
+
/** 底部遮罩的透明度 */
|
|
68
|
+
bgAlpha: number;
|
|
69
|
+
/**
|
|
70
|
+
* 窗口是否显示
|
|
71
|
+
*/
|
|
72
|
+
isShowing(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* 窗口是否被遮挡了
|
|
75
|
+
*/
|
|
76
|
+
isCover(): boolean;
|
|
77
|
+
/** 获取资源栏数据 */
|
|
78
|
+
getHeaderInfo(): WindowHeaderInfo;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @Author: Gongxh
|
|
83
|
+
* @Date: 2025-01-11
|
|
84
|
+
* @Description: 窗口顶边栏
|
|
85
|
+
* 窗口顶边资源栏 同组中只会有一个显示
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
declare abstract class UIHeader extends GComponent implements IHeader {
|
|
89
|
+
/** 窗口适配类型 */
|
|
90
|
+
adapterType: AdapterType;
|
|
91
|
+
protected abstract onInit(): void;
|
|
92
|
+
protected abstract onShow(window: IWindow, userdata?: any): void;
|
|
93
|
+
protected abstract onClose(): void;
|
|
94
|
+
protected onHide(): void;
|
|
95
|
+
protected onAdapted(): void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @Author: Gongxh
|
|
100
|
+
* @Date: 2024-12-11
|
|
101
|
+
* @Description: UI 装饰器
|
|
102
|
+
*/
|
|
103
|
+
declare namespace _uidecorator {
|
|
104
|
+
interface IUIInfoBase {
|
|
105
|
+
/** 构造函数 */
|
|
106
|
+
ctor: any;
|
|
107
|
+
/** 属性 */
|
|
108
|
+
props: Record<string, 1>;
|
|
109
|
+
/** 方法 */
|
|
110
|
+
callbacks: Record<string, Function>;
|
|
111
|
+
/** 控制器 */
|
|
112
|
+
controls: Record<string, 1>;
|
|
113
|
+
/** 动画 */
|
|
114
|
+
transitions: Record<string, 1>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 窗口属性注册数据结构
|
|
118
|
+
*/
|
|
119
|
+
interface UIWindowInfo extends IUIInfoBase {
|
|
120
|
+
/** 配置信息 */
|
|
121
|
+
res: {
|
|
122
|
+
/** 窗口组名称 */
|
|
123
|
+
group: string;
|
|
124
|
+
/** fgui包名 */
|
|
125
|
+
pkg: string;
|
|
126
|
+
/** 窗口名 */
|
|
127
|
+
name: string;
|
|
128
|
+
/** 窗口bundle名 */
|
|
129
|
+
bundle: string;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** 获取窗口注册信息 */
|
|
133
|
+
export function getWindowMaps(): Map<any, UIWindowInfo>;
|
|
134
|
+
/**
|
|
135
|
+
* 窗口装饰器
|
|
136
|
+
* @param {string} groupName 窗口组名称
|
|
137
|
+
* @param {string} pkgName fgui包名
|
|
138
|
+
* @param {string} name 窗口名 (与fgui中的组件名一一对应)
|
|
139
|
+
*/
|
|
140
|
+
export function uiclass(groupName: string, pkgName: string, name: string, bundle?: string): Function;
|
|
141
|
+
/**
|
|
142
|
+
* 组件属性注册数据结构
|
|
143
|
+
*/
|
|
144
|
+
interface IUIComInfo extends IUIInfoBase {
|
|
145
|
+
/** 配置信息 */
|
|
146
|
+
res: {
|
|
147
|
+
/** fgui包名 */
|
|
148
|
+
pkg: string;
|
|
149
|
+
/** 组件名 */
|
|
150
|
+
name: string;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** 获取组件注册信息 */
|
|
154
|
+
export function getComponentMaps(): Map<any, IUIComInfo>;
|
|
155
|
+
/**
|
|
156
|
+
* UI组件装饰器
|
|
157
|
+
* @param {string} pkg 包名
|
|
158
|
+
* @param {string} name 组件名
|
|
159
|
+
*/
|
|
160
|
+
export function uicom(pkg: string, name: string): Function;
|
|
161
|
+
/** header属性注册数据结构 */
|
|
162
|
+
interface IUIHeaderInfo extends IUIInfoBase {
|
|
163
|
+
/** 配置信息 */
|
|
164
|
+
res: {
|
|
165
|
+
/** fgui包名 */
|
|
166
|
+
pkg: string;
|
|
167
|
+
/** 组件名 */
|
|
168
|
+
name: string;
|
|
169
|
+
/** headerbundle名 */
|
|
170
|
+
bundle: string;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** 获取header注册信息 */
|
|
174
|
+
export function getHeaderMaps(): Map<any, IUIHeaderInfo>;
|
|
175
|
+
/**
|
|
176
|
+
* UI header装饰器
|
|
177
|
+
* @param {string} pkg 包名
|
|
178
|
+
* @param {string} name 组件名
|
|
179
|
+
*/
|
|
180
|
+
export function uiheader(pkg: string, name: string, bundle?: string): Function;
|
|
181
|
+
/**
|
|
182
|
+
* UI属性装饰器
|
|
183
|
+
* @param {Object} target 实例成员的类的原型
|
|
184
|
+
* @param {string} name 属性名
|
|
185
|
+
*
|
|
186
|
+
* example: @uiprop node: GObject
|
|
187
|
+
*/
|
|
188
|
+
export function uiprop(target: Object, name: string): any;
|
|
189
|
+
/**
|
|
190
|
+
* UI控制器装饰器
|
|
191
|
+
* @param {Object} target 实例成员的类的原型
|
|
192
|
+
* @param {string} name 属性名
|
|
193
|
+
*
|
|
194
|
+
* example: @uicontrol node: GObject
|
|
195
|
+
*/
|
|
196
|
+
export function uicontrol(target: Object, name: string): any;
|
|
197
|
+
/**
|
|
198
|
+
* UI动画装饰器
|
|
199
|
+
* @param {Object} target 实例成员的类的原型
|
|
200
|
+
* @param {string} name 属性名
|
|
201
|
+
*
|
|
202
|
+
* example: @uitransition node: GObject
|
|
203
|
+
*/
|
|
204
|
+
export function uitransition(target: Object, name: string): any;
|
|
205
|
+
/**
|
|
206
|
+
* 方法装饰器 (给点击事件用)
|
|
207
|
+
* @param {Object} target 实例成员的类的原型
|
|
208
|
+
* @param {string} name 方法名
|
|
209
|
+
*/
|
|
210
|
+
export function uiclick(target: Object, name: string, descriptor: PropertyDescriptor): void;
|
|
211
|
+
/** 首次UI注册完成 */
|
|
212
|
+
export function setRegisterFinish(): void;
|
|
213
|
+
export {};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @Author: Gongxh
|
|
218
|
+
* @Date: 2025-02-25
|
|
219
|
+
* @Description: 包配置格式
|
|
220
|
+
*/
|
|
221
|
+
interface IPackageConfig {
|
|
222
|
+
/** UI所在resources中的路径 */
|
|
223
|
+
uiPath: string;
|
|
224
|
+
/** 如果UI不在 resources 中,则需要配置 所在bundle下的路径名*/
|
|
225
|
+
bundlePaths?: {
|
|
226
|
+
[bundleName: string]: string;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* 手动管理资源的包
|
|
230
|
+
* 1. 用于基础UI包, 提供一些最基础的组件,所有其他包都可能引用其中的内容
|
|
231
|
+
* 2. 资源header所在的包
|
|
232
|
+
* 3. 用于一些特殊场景, 比如需要和其他资源一起加载, 并且显示进度条的包
|
|
233
|
+
*/
|
|
234
|
+
manualPackages: string[];
|
|
235
|
+
/**
|
|
236
|
+
* 不推荐配置 只是提供一种特殊需求的实现方式
|
|
237
|
+
* 窗口引用到其他包中的资源 需要的配置信息
|
|
238
|
+
*/
|
|
239
|
+
linkPackages: {
|
|
240
|
+
[windowName: string]: string[];
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* 关闭界面后,需要立即释放资源的包名(建议尽量少)
|
|
244
|
+
* 一般不建议包进行频繁装载卸载,因为每次装载卸载必然是要消耗CPU时间(意味着耗电)和产生大量GC的。UI系统占用的内存是可以精确估算的,你可以按照包的使用频率设定哪些包是需要立即释放的。
|
|
245
|
+
* 不包括手动管理的包
|
|
246
|
+
*/
|
|
247
|
+
imReleasePackages: string[];
|
|
248
|
+
}
|
|
249
|
+
interface IPackageConfigRes {
|
|
250
|
+
/** 配置信息 */
|
|
251
|
+
config: IPackageConfig;
|
|
252
|
+
/** 显示加载等待窗 */
|
|
253
|
+
showWaitWindow: () => void;
|
|
254
|
+
/** 隐藏加载等待窗 */
|
|
255
|
+
hideWaitWindow: () => void;
|
|
256
|
+
/** 打开窗口时UI包加载失败 */
|
|
257
|
+
fail: (windowName: string, errmsg: string, pkgs: string[]) => void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @Author: Gongxh
|
|
262
|
+
* @Date: 2024-12-13
|
|
263
|
+
* @Description:
|
|
264
|
+
*/
|
|
265
|
+
interface WindowInfo {
|
|
266
|
+
/** 类的构造函数 */
|
|
267
|
+
ctor: any;
|
|
268
|
+
/** 窗口组名 */
|
|
269
|
+
group: string;
|
|
270
|
+
/** fgui包名 */
|
|
271
|
+
pkg: string;
|
|
272
|
+
/** 窗口名 */
|
|
273
|
+
name: string;
|
|
274
|
+
/** bundle名 */
|
|
275
|
+
bundle: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* @Author: Gongxh
|
|
280
|
+
* @Date: 2024-12-08
|
|
281
|
+
* @Description: 窗口组 (在同一个窗口容器的上的窗口)
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
declare class WindowGroup {
|
|
285
|
+
/**
|
|
286
|
+
* 获取窗口组的名称。
|
|
287
|
+
* @returns {string} 窗口组的名称。
|
|
288
|
+
*/
|
|
289
|
+
get name(): string;
|
|
290
|
+
/**
|
|
291
|
+
* 获取当前窗口组中窗口的数量。
|
|
292
|
+
* @returns 窗口数量
|
|
293
|
+
*/
|
|
294
|
+
get size(): number;
|
|
295
|
+
/**
|
|
296
|
+
* 获取是否忽略查询的状态。
|
|
297
|
+
* @returns {boolean} 如果忽略查询,则返回 true,否则返回 false。
|
|
298
|
+
*/
|
|
299
|
+
get isIgnore(): boolean;
|
|
300
|
+
showWindow(info: WindowInfo, userdata?: any): void;
|
|
301
|
+
hasWindow(name: string): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* 获取窗口组中顶部窗口的名称。
|
|
304
|
+
* @returns {string} 顶部窗口的名称。
|
|
305
|
+
*/
|
|
306
|
+
getTopWindowName(): string;
|
|
307
|
+
/**
|
|
308
|
+
* 关闭窗口组中的所有窗口
|
|
309
|
+
*/
|
|
310
|
+
closeAllWindow(): void;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @Author: Gongxh
|
|
315
|
+
* @Date: 2024-12-07
|
|
316
|
+
* @Description: 窗口管理类
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
declare class UIManager {
|
|
320
|
+
/** 配置UI包的一些信息 (可以不配置 完全手动管理) */
|
|
321
|
+
static initPackageConfig(res: IPackageConfigRes): void;
|
|
322
|
+
/**
|
|
323
|
+
* 异步打开一个窗口 (如果UI包的资源未加载, 会自动加载 配合 UIManager.initPackageConfig一起使用)
|
|
324
|
+
* @param windowName 窗口名
|
|
325
|
+
* @param userdata 用户数据
|
|
326
|
+
*/
|
|
327
|
+
static showWindow(windowName: string, userdata?: any): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* 显示指定名称的窗口,并传递可选的用户数据。(用于已加载过资源的窗口)
|
|
330
|
+
* @param windowName - 窗口的名称。
|
|
331
|
+
* @param userdata - 可选参数,用于传递给窗口的用户数据。
|
|
332
|
+
*/
|
|
333
|
+
static showWindowIm(windowName: string, userdata?: any): void;
|
|
334
|
+
/**
|
|
335
|
+
* 关闭窗口
|
|
336
|
+
* @param windowName 窗口名
|
|
337
|
+
*/
|
|
338
|
+
static closeWindow(windowName: string): void;
|
|
339
|
+
/**
|
|
340
|
+
* 关闭所有窗口
|
|
341
|
+
* @param ignoreNames 忽略关闭的窗口名
|
|
342
|
+
*/
|
|
343
|
+
static closeAllWindow(ignoreNames?: string[]): void;
|
|
344
|
+
/**
|
|
345
|
+
* 获取当前最顶层的窗口实例。
|
|
346
|
+
* @template T - 窗口实例的类型,必须继承自 IWindow 接口。
|
|
347
|
+
* @returns {T | null} - 返回最顶层的窗口实例,如果没有找到则返回 null。
|
|
348
|
+
* @description 该方法会遍历所有窗口组,找到最顶层的窗口并返回其实例。
|
|
349
|
+
*/
|
|
350
|
+
static getTopWindow<T extends IWindow>(): T | null;
|
|
351
|
+
/**
|
|
352
|
+
* 根据窗口名称获取窗口实例。
|
|
353
|
+
* @template T 窗口类型,必须继承自IWindow接口。
|
|
354
|
+
* @param name 窗口的名称。
|
|
355
|
+
* @returns 如果找到窗口,则返回对应类型的窗口实例;否则返回null。
|
|
356
|
+
*/
|
|
357
|
+
static getWindow<T extends IWindow>(name: string): T | null;
|
|
358
|
+
/**
|
|
359
|
+
* 检查是否存在指定名称的窗口。
|
|
360
|
+
* @param name 窗口的名称。
|
|
361
|
+
* @returns 如果存在指定名称的窗口,则返回 true,否则返回 false。
|
|
362
|
+
*/
|
|
363
|
+
static hasWindow(name: string): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* 根据给定的组名获取窗口组。如果组不存在,则抛出错误。
|
|
366
|
+
* @param groupName 窗口组的名称。
|
|
367
|
+
* @returns 返回找到的窗口组。
|
|
368
|
+
*/
|
|
369
|
+
static getWindowGroup(groupName: string): WindowGroup;
|
|
370
|
+
/**
|
|
371
|
+
* 获取当前顶层窗口组的名称。
|
|
372
|
+
* 返回第一个包含至少一个窗口的窗口组名称。(该方法只检查不忽略查询的窗口组)
|
|
373
|
+
* 如果没有找到任何包含窗口的组,则返回空字符串。
|
|
374
|
+
*/
|
|
375
|
+
static getTopGroupName(): string;
|
|
376
|
+
/** 动态注册窗口到资源池中 */
|
|
377
|
+
static dynamicRegisterWindow(ctor: any, group: string, pkg: string, name: string, bundle: string): void;
|
|
378
|
+
/** 动态注册窗口header到资源池中 */
|
|
379
|
+
static dynamicRegisterHeader(ctor: any, pkg: string, name: string, bundle: string): void;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @Author: Gongxh
|
|
384
|
+
* @Date: 2024-12-14
|
|
385
|
+
* @Description: 窗口基类和fgui组件对接
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
declare abstract class UIWindow extends GComponent implements IWindow {
|
|
389
|
+
/** 窗口类型 */
|
|
390
|
+
type: WindowType;
|
|
391
|
+
/** 窗口适配类型 */
|
|
392
|
+
adapterType: AdapterType;
|
|
393
|
+
/** 底部遮罩的透明度 */
|
|
394
|
+
bgAlpha: number;
|
|
395
|
+
isShowing(): boolean;
|
|
396
|
+
isCover(): boolean;
|
|
397
|
+
/**
|
|
398
|
+
* 获取窗口顶部资源栏数据 默认返回空数组
|
|
399
|
+
* @returns {WindowHeaderInfo[]}
|
|
400
|
+
*/
|
|
401
|
+
getHeaderInfo(): WindowHeaderInfo;
|
|
402
|
+
getHeader<T extends UIHeader>(): T | null;
|
|
403
|
+
protected abstract onAdapted(): void;
|
|
404
|
+
protected abstract onInit(): void;
|
|
405
|
+
protected abstract onClose(): void;
|
|
406
|
+
protected abstract onShow(userdata?: any): void;
|
|
407
|
+
protected abstract onShowFromHide(): void;
|
|
408
|
+
protected abstract onHide(): void;
|
|
409
|
+
protected abstract onCover(): void;
|
|
410
|
+
protected abstract onRecover(): void;
|
|
411
|
+
protected abstract onEmptyAreaClick(): void;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @Author: Gongxh
|
|
416
|
+
* @Date: 2024-12-14
|
|
417
|
+
* @Description:
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
declare abstract class Window extends UIWindow {
|
|
421
|
+
protected onAdapted(): void;
|
|
422
|
+
/**
|
|
423
|
+
* 初始化窗口时调用的方法。
|
|
424
|
+
* 子类必须实现的方法,用来设置窗口的属性。
|
|
425
|
+
*/
|
|
426
|
+
protected abstract onInit(): void;
|
|
427
|
+
/**
|
|
428
|
+
* 窗口关闭时的处理逻辑。
|
|
429
|
+
* 子类可以重写此方法以实现自定义的关闭行为。
|
|
430
|
+
*/
|
|
431
|
+
protected onClose(): void;
|
|
432
|
+
/**
|
|
433
|
+
* 窗口显示时的回调函数。
|
|
434
|
+
* @param userdata 可选参数,传递给窗口显示时的用户数据。
|
|
435
|
+
*/
|
|
436
|
+
protected onShow(userdata?: any): void;
|
|
437
|
+
/**
|
|
438
|
+
* 隐藏窗口时的处理逻辑。
|
|
439
|
+
* 重写此方法以实现自定义的隐藏行为。
|
|
440
|
+
*/
|
|
441
|
+
protected onHide(): void;
|
|
442
|
+
/**
|
|
443
|
+
* 当窗口从隐藏状态变为显示状态时调用。
|
|
444
|
+
* 这个方法可以被子类重写以实现特定的显示逻辑。
|
|
445
|
+
*/
|
|
446
|
+
protected onShowFromHide(): void;
|
|
447
|
+
/**
|
|
448
|
+
* 当窗口被覆盖时触发的事件处理函数。
|
|
449
|
+
* 子类可以重写此方法以添加自定义行为。
|
|
450
|
+
*/
|
|
451
|
+
protected onCover(): void;
|
|
452
|
+
/**
|
|
453
|
+
* 恢复窗口状态时的处理逻辑。
|
|
454
|
+
* 此方法在窗口从隐藏或最小化状态恢复时被调用。
|
|
455
|
+
*/
|
|
456
|
+
protected onRecover(): void;
|
|
457
|
+
/**
|
|
458
|
+
* 空白区域点击事件处理函数。
|
|
459
|
+
* 当用户点击窗口的空白区域时触发此方法。
|
|
460
|
+
*/
|
|
461
|
+
protected onEmptyAreaClick(): void;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @Author: Gongxh
|
|
466
|
+
* @Date: 2024-12-07
|
|
467
|
+
* @Description: cocos UI模块
|
|
468
|
+
*/
|
|
469
|
+
|
|
470
|
+
declare class UIModule extends Component {
|
|
471
|
+
/** 模块名称 */
|
|
472
|
+
moduleName: string;
|
|
473
|
+
/** 模块初始化完成后调用的函数 */
|
|
474
|
+
protected onInit(): void;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export { AdapterType, UIHeader, UIManager, UIModule, Window, WindowGroup, WindowHeaderInfo, WindowType, _uidecorator };
|
|
478
|
+
export type { IPackageConfigRes };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,i=require("@gongxh/bit-core"),s=require("fairygui-cc"),o=require("cc");exports.WindowType=void 0,(e=exports.WindowType||(exports.WindowType={}))[e.Normal=0]="Normal",e[e.CloseAll=1]="CloseAll",e[e.CloseOne=2]="CloseOne",e[e.HideAll=4]="HideAll",e[e.HideOne=8]="HideOne",exports.AdapterType=void 0,(t=exports.AdapterType||(exports.AdapterType={}))[t.Full=0]="Full",t[t.Bang=1]="Bang",t[t.Fixed=2]="Fixed";class n extends s.GComponent{constructor(){super(...arguments),this.adapterType=exports.AdapterType.Full,this._refCount=0}onHide(){}onAdapted(){}_init(){this.onInit()}_adapted(){switch(this.setPosition(.5*i.Screen.ScreenWidth,.5*i.Screen.ScreenHeight),this.setPivot(.5,.5,!0),this.adapterType){case exports.AdapterType.Full:this.setSize(i.Screen.ScreenWidth,i.Screen.ScreenHeight,!0);break;case exports.AdapterType.Bang:this.setSize(i.Screen.SafeWidth,i.Screen.SafeHeight,!0)}this.onAdapted()}_show(e){var t;this.visible=!0,this.onShow(e,null===(t=e.getHeaderInfo())||void 0===t?void 0:t.userdata)}_hide(){this.visible=!1,this.onHide()}_close(){this.onClose(),this.dispose()}_addRef(){this._refCount++}_decRef(){return--this._refCount}_screenResize(){this._adapted()}}class r{static setConfig(e){this._config=e}static serializeProps(e,t,i){if(!this._config)return;const s=this._config[t];if(!s)return;const o=s[i=i||e.name];if(!o)return;const n=o.props;this.serializationPropsNode(e,n);const r=o.callbacks;this.serializationCallbacksNode(e,r);const a=o.controls;this.serializationControlsNode(e,a);const h=o.transitions;this.serializationTransitionsNode(e,h)}static serializationPropsNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s++],o=s+t[s];let n=e;for(;++s<=o;)if(n=n.getChildAt(t[s]),!n){console.warn(`无法对UI类(${e.name})属性(${i})赋值,请检查节点配置是否正确`);break}e[i]=n==e?null:n}}static serializationCallbacksNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s++],o=s+t[s];let n=e;for(;++s<=o;)if(n=n.getChildAt(t[s]),!n){console.warn(`无法对UI类(${e.name})的(${i})设置回调,请检查节点配置是否正确`);break}n!=e&&n.onClick(e[i],e)}}static serializationControlsNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s],o=t[s+1],n=e.getController(o);if(!n){console.warn(`无法对UI类(${e.name})的(${i})设置控制器,请检查配置是否正确`);break}e[i]=n,s+=2}}static serializationTransitionsNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s],o=t[s+1],n=e.getTransition(o);if(!n){console.warn(`无法对UI类(${e.name})的(${i})设置动画,请检查配置是否正确`);break}e[i]=n,s+=2}}}r._config={};class a{static register(){for(const{ctor:e,res:t}of exports._uidecorator.getComponentMaps().values()){const i=`${t.pkg}/${t.name}`;this._registeredComponents.has(i)?console.debug(`自定义组件已注册,跳过 组件名:${t.name} 包名:${t.pkg}`):(console.debug(`自定义组件注册 组件名:${t.name} 包名:${t.pkg}`),this.registerComponent(e,t.pkg,t.name),this._registeredComponents.add(i))}}static dynamicRegister(e,t,s){const o=`${t}/${s}`;this._registeredComponents.has(o)?console.debug(`自定义组件已注册,跳过 组件名:${s} 包名:${t}`):(i.debug(`自定义组件注册 组件名:${s} 包名:${t}`),this.registerComponent(e,t,s),this._registeredComponents.add(o))}static registerComponent(e,t,i){e.prototype.onConstruct=function(){r.serializeProps(this,t,i),this.onInit&&this.onInit()},s.UIObjectFactory.setExtension(`ui://${t}/${i}`,e)}}a._registeredComponents=new Set;class h{static initPackageConfig(e){this._resPool.initPackageConfig(e)}static showWindow(e,t){return new Promise((i,s)=>{this._resPool.loadWindowRes(e,{complete:()=>{this.showWindowIm(e,t),i()},fail:e=>{s(e)}})})}static showWindowIm(e,t){const i=this._resPool.get(e),s=this.getWindowGroup(i.group);this._resPool.addResRef(e),s.showWindow(i,t)}static closeWindow(e){if(!this._windows.has(e))return void console.warn(`窗口不存在 ${e} 不需要关闭`);let t=this._resPool.get(e);const i=this.getWindowGroup(t.group);if(i._removeWindow(e),0==i.size){let e=this._queryGroupNames.indexOf(i.name);if(e>0&&i.name==this.getTopGroupName())do{const t=this._queryGroupNames[--e];let i=this.getWindowGroup(t);if(i.size>0){this.getWindow(i.getTopWindowName())._recover();break}}while(e>=0)}}static closeAllWindow(e=[]){let t=e.length>0;this._windows.forEach((i,s)=>{t&&e.includes(s)||this.closeWindow(s)}),t||this._windows.clear()}static getTopWindow(){for(let e=this._queryGroupNames.length;e>0;){let t=this.getWindowGroup(this._queryGroupNames[--e]);if(t.size>0)return this.getWindow(t.getTopWindowName())}return null}static getWindow(e){return this._windows.get(e)}static hasWindow(e){return this._windows.has(e)}static getWindowGroup(e){if(this._groups.has(e))return this._groups.get(e);throw new Error(`UIManager.getWindowGroup: window group 【${e}】 not found`)}static getTopGroupName(){for(let e=this._queryGroupNames.length-1;e>=0;e--){let t=this._queryGroupNames[e];if(this._groups.get(t).size>0)return t}return""}static _init(e){this._resPool=e}static _addWindow(e,t){this._windows.set(e,t)}static _removeWindow(e){this.hasWindow(e)&&(this._windows.get(e)._close(),this._windows.delete(e),this._resPool.releaseWindowRes(e))}static registerUI(){for(const{ctor:e,res:t}of exports._uidecorator.getWindowMaps().values())i.debug(`窗口注册 窗口名:${t.name} 包名:${t.pkg} 组名:${t.group}`),this._resPool.add(e,t.group,t.pkg,t.name,t.bundle);for(const{ctor:e,res:t}of exports._uidecorator.getHeaderMaps().values())i.debug(`header注册 header名:${t.name} 包名:${t.pkg}`),this._resPool.addHeader(e,t.pkg,t.name,t.bundle);a.register()}static dynamicRegisterWindow(e,t,s,o,n){i.debug(`窗口注册 窗口名:${o} 包名:${s} 组名:${t}`),this._resPool.add(e,t,s,o,n)}static dynamicRegisterHeader(e,t,s,o){i.debug(`header注册 header名:${s} 包名:${t}`),this._resPool.addHeader(e,t,s,o)}static _addWindowGroup(e){if(this._groups.has(e.name))throw new Error(`UIManager._addWindowGroup: window group 【${e.name}】 already exists`);this._groups.set(e.name,e),!e.isIgnore&&this._queryGroupNames.push(e.name)}static _screenResize(){this._windows.forEach(e=>{e.screenResize()}),this._groups.forEach(e=>{e._screenResize()})}static _getResPool(){return this._resPool}}h._groups=new Map,h._queryGroupNames=[],h._windows=new Map,exports._uidecorator=void 0,function(e){const t="__uipropmeta__",i="__uicbmeta__",s="__uicontrolmeta__",o="__uitransitionmeta__",n=new Map;function r(e,t){return e.hasOwnProperty(t)?e[t]:e[t]=Object.assign({},e[t])}e.getWindowMaps=function(){return n},e.uiclass=function(e,r,a,d){return function(l){const p=l;return n.set(p,{ctor:l,props:l[t]||null,callbacks:l[i]||null,controls:l[s]||null,transitions:l[o]||null,res:{group:e,pkg:r,name:a,bundle:d||""}}),c&&h.dynamicRegisterWindow(l,e,r,a,d||""),l}};let d=new Map;e.getComponentMaps=function(){return d},e.uicom=function(e,n){return function(r){const h=r;return d.set(h,{ctor:r,props:r[t]||null,callbacks:r[i]||null,controls:r[s]||null,transitions:r[o]||null,res:{pkg:e,name:n}}),c&&a.dynamicRegister(r,e,n),r}};let l=new Map;e.getHeaderMaps=function(){return l},e.uiheader=function(e,n,r){return function(a){const d=a;return l.set(d,{ctor:a,props:a[t]||null,callbacks:a[i]||null,controls:a[s]||null,transitions:a[o]||null,res:{pkg:e,name:n,bundle:r||""}}),c&&h.dynamicRegisterHeader(a,e,n,r||""),a}},e.uiprop=function(e,i){r(e.constructor,t)[i]=1},e.uicontrol=function(e,t){r(e.constructor,s)[t]=1},e.uitransition=function(e,t){r(e.constructor,o)[t]=1},e.uiclick=function(e,t,s){r(e.constructor,i)[t]=s.value};let c=!1;e.setRegisterFinish=function(){c=!0}}(exports._uidecorator||(exports._uidecorator={}));const d=globalThis||window||global;d.getKunpoRegisterWindowMaps=function(){return exports._uidecorator.getWindowMaps()},d.getKunpoRegisterComponentMaps=function(){return exports._uidecorator.getComponentMaps()},d.getKunpoRegisterHeaderMaps=function(){return exports._uidecorator.getHeaderMaps()};class l extends s.GComponent{constructor(){super(...arguments),this.type=exports.WindowType.Normal,this.adapterType=exports.AdapterType.Full,this._header=null,this._isCover=!1,this._swallowComponent=null}_init(e,t){if(e){let t=new s.GComponent;t.name="swallow",t.setSize(i.Screen.ScreenWidth,i.Screen.ScreenHeight,!0),t.setPivot(.5,.5,!0),t.setPosition(.5*this.width,.5*this.height),this.addChild(t),t.parent.setChildIndex(t,0),t.onClick(this.onEmptyAreaClick,this),t.opaque=e,this._swallowComponent=t}this.opaque=e,this.bgAlpha=t,this.onInit()}_adapted(){var e,t;switch(this.setPosition(.5*i.Screen.ScreenWidth,.5*i.Screen.ScreenHeight),this.setPivot(.5,.5,!0),this.adapterType){case exports.AdapterType.Full:this.setSize(i.Screen.ScreenWidth,i.Screen.ScreenHeight,!0);break;case exports.AdapterType.Bang:this.setSize(i.Screen.SafeWidth,i.Screen.SafeHeight,!0)}null===(e=this._swallowComponent)||void 0===e||e.setSize(i.Screen.ScreenWidth,i.Screen.ScreenHeight,!0),null===(t=this._swallowComponent)||void 0===t||t.setPosition(.5*this.width,.5*+this.height),this.onAdapted()}_close(){this.onClose(),this.dispose()}_show(e){this.visible=!0,this.onShow(e)}_hide(){this.visible=!1,this.onHide()}_showFromHide(){this.visible=!0,this.onShowFromHide()}_cover(){this._isCover=!0,this.onCover()}_recover(){this._isCover=!1,this.onRecover()}_setDepth(e){this.parent.setChildIndex(this,e)}isShowing(){return this.visible}isCover(){return this._isCover}screenResize(){this._adapted()}getHeaderInfo(){return null}getHeader(){return this._header}_setHeader(e){this._header=e}}class c{get name(){return this._name}get size(){return this._windowNames.length}get isIgnore(){return this._ignoreQuery}constructor(e,t,i,n,r){this._name="",this._ignoreQuery=!1,this._swallowTouch=!1,this._windowNames=[],this._headers=new Map,this._bgAlpha=0,this._color=new o.Color(0,0,0,255),this._name=e,this._root=t,this._ignoreQuery=i,this._swallowTouch=n,this._bgAlpha=r;const a=new s.GGraph;a.touchable=!1,a.name="bgAlpha",a.setPosition(.5*t.width,.5*t.height),a.setSize(t.width,t.height,!0),a.setPivot(.5,.5,!0),t.addChild(a),this._alphaGraph=a}_createWindow(e,t){let i=s.UIPackage.createObject(e,t);return i.name=t,r.serializeProps(i,e),i._init(this._swallowTouch,this._bgAlpha),i._adapted(),this._createHeader(i),this._addWindow(i),i}_addWindow(e){this._root.addChild(e),h._addWindow(e.name,e)}showWindow(e,t){let i=e.name,s=h.getWindow(i);s||(s=this._createWindow(e.pkg,i),this._processWindowCloseStatus(s),this._windowNames.push(i)),s._show(t),this._moveWindowToTop(i),this._processHeaderStatus(),this._root.visible=!0}_removeWindow(e){let t=this._windowNames.lastIndexOf(e),i=this.size-1;if(t<0)return void console.warn(`窗口组${this._name}中未找到窗口${e} 删除失败`);let s=h.getWindow(e).getHeader();if(s&&this._removeHeader(s),this._windowNames.splice(t,1),h._removeWindow(e),this._processWindowHideStatus(this.size-1,!0),0==this.size)this._root.visible=!1;else if(i==t&&t>0){let e=this.getTopWindowName(),t=h.getWindow(e);this._adjustAlphaGraph(t),t._setDepth(this._root.numChildren-1)}this._processHeaderStatus()}_moveWindowToTop(e){let t=!1;if(0==this.size)return console.warn(`WindowGroup.moveWindowToTop: window group 【${this._name}】 is empty`),!1;if(this._windowNames[this.size-1]==e);else{const i=this._windowNames.indexOf(e);if(-1==i)return console.warn(`WindowGroup.moveWindowToTop: window 【${e}】 not found in window group 【${this._name}】`),!1;i<this._windowNames.length-1&&(this._windowNames.splice(i,1),this._windowNames.push(e),t=!0)}let i=h.getWindow(e);return this._adjustAlphaGraph(i),i._setDepth(this._root.numChildren-1),this._processWindowHideStatus(this.size-1,t),!0}_processWindowHideStatus(e,t=!0){if(e<0)return;let i=this._windowNames[e],s=h.getWindow(i);if(e!=this.size-1||s.isShowing()||s._showFromHide(),0==e)return;let o=s.type;if(o!=exports.WindowType.HideAll){if(o==exports.WindowType.HideOne){let t=this._windowNames[e-1],i=h.getWindow(t);i.isShowing()&&i._hide()}else{let t=this._windowNames[e-1],i=h.getWindow(t);!i.isShowing()&&i._showFromHide()}t&&this._processWindowHideStatus(e-1,t)}else for(let t=e-1;t>=0;--t){let e=this._windowNames[t];const i=h.getWindow(e);i.isShowing()&&i._hide()}}_processWindowCloseStatus(e){if(e.type==exports.WindowType.CloseOne){let e=this.size;for(;e>0;){let e=this._windowNames.pop(),t=h.getWindow(e).getHeader();t&&this._removeHeader(t),h._removeWindow(e);break}}else if(e.type==exports.WindowType.CloseAll){for(let e=this.size;e>0;){let t=this._windowNames[--e],i=h.getWindow(t).getHeader();i&&this._removeHeader(i),h._removeWindow(t)}this._windowNames.length=0}}_processHeaderStatus(){let e=null,t=null,i=this.size-1;for(let s=this.size-1;s>=0;--s){let o=this._windowNames[s],n=h.getWindow(o);if(n.isShowing()&&n.getHeader()){t=n,e=n.getHeader(),i=s;break}}this._headers.forEach((i,s)=>{this._root.setChildIndex(i,0),!e&&i.visible?i._hide():e&&(e.name!=s||i.visible?e.name!=s&&i.visible&&i._hide():i._show(t))}),e&&(i==this.size-1?this._root.setChildIndex(e,this._root.numChildren-1):this._root.setChildIndex(e,this._root.numChildren-this.size+i-1))}_adjustAlphaGraph(e){this._root.setChildIndex(this._alphaGraph,this._root.numChildren-1),this._color.a=255*e.bgAlpha,this._alphaGraph.clearGraphics(),this._alphaGraph.drawRect(0,this._color,this._color)}hasWindow(e){return this._windowNames.indexOf(e)>=0}getTopWindowName(){return this.size>0?this._windowNames[this.size-1]:(console.warn(`WindowGroup.getTopWindowName: window group 【${this._name}】 is empty`),"")}_createHeader(e){let t=e.getHeaderInfo();if(!t)return;let i=t.name,o=this._getHeader(i);if(o)e._setHeader(o),o._addRef();else{let{pkg:t}=h._getResPool().getHeader(i),o=s.UIPackage.createObject(t,i);o.name=i,o.opaque=!1,e._setHeader(o),o.visible=!1,r.serializeProps(o,t),o._init(),o._adapted(),this._root.addChild(o),o._addRef(),this._headers.set(o.name,o)}}_removeHeader(e){if(this._headers.has(e.name)){e._decRef()<=0&&(this._headers.delete(e.name),e._close())}}_getHeader(e){return this._headers.get(e)}_screenResize(){this._headers.forEach(e=>{e._screenResize()}),this._alphaGraph.setPosition(.5*i.Screen.ScreenWidth,.5*i.Screen.ScreenHeight),this._alphaGraph.setSize(i.Screen.ScreenWidth,i.Screen.ScreenHeight,!0),this._alphaGraph.setPivot(.5,.5,!0)}closeAllWindow(){for(;this.size>0;){let e=this.getTopWindowName();h.closeWindow(e)}}}class p{static create(e,t){const i=new p;return i.name=e,i.userdata=t,i}}function u(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(n<3?o(r):n>3?o(t,i,r):o(t,i))||r);return n>3&&r&&Object.defineProperty(t,i,r),r}"function"==typeof SuppressedError&&SuppressedError;class w{constructor(){this._windowInfos=new Map,this._headerInfos=new Map,this._pkgBundles=new Map,this._isInit=!1,this._windowPkgs=new Map,this._pkgRefs={},this._uiPaths={},this._manualPackages=new Set,this._imReleasePackages=new Set,this._showWaitWindow=null,this._hideWaitWindow=null,this._fail=null,this._waitRef=0}add(e,t,i,o,n){this.has(o)||(this._windowInfos.set(o,{ctor:e,group:t,pkg:i,name:o,bundle:n}),this._pkgBundles.set(i,n||"resources"),this.addWindowPkg(o,i),s.UIObjectFactory.setExtension(`ui://${i}/${o}`,e))}has(e){return this._windowInfos.has(e)}get(e){if(!this.has(e))throw new Error(`窗口【${e}】未注册,请使用 _uidecorator.uiclass 注册窗口`);return this._windowInfos.get(e)}addHeader(e,t,i,o){this.hasHeader(i)||(this._headerInfos.set(i,{ctor:e,pkg:t,bundle:o}),this._pkgBundles.set(t,o||"resources"),s.UIObjectFactory.setExtension(`ui://${t}/${i}`,e))}hasHeader(e){return this._headerInfos.has(e)}getHeader(e){if(!this.hasHeader(e))throw new Error(`窗口header【${e}】未注册,请使用 _uidecorator.uiheader 注册窗口header`);return this._headerInfos.get(e)}initPackageConfig(e){var t,i;if(!e||!e.config)return;if(this._isInit)throw new Error("资源配置已初始化,请勿重复设置");this._isInit=!0,this._showWaitWindow=null==e?void 0:e.showWaitWindow,this._hideWaitWindow=null==e?void 0:e.hideWaitWindow,this._fail=null==e?void 0:e.fail,this._uiPaths=(null===(t=e.config)||void 0===t?void 0:t.bundlePaths)||{},this._uiPaths.resources=(null===(i=e.config)||void 0===i?void 0:i.uiPath)||"";for(const e in this._uiPaths)""==this._uiPaths[e]||this._uiPaths[e].endsWith("/")||(this._uiPaths[e]+="/");this._manualPackages=new Set(e.config.manualPackages||[]),this._imReleasePackages=new Set(e.config.imReleasePackages||[]);let s=e.config.linkPackages||{};for(const e in s){let t=s[e];for(const i of t||[])this.addWindowPkg(e,i)}this._windowPkgs.forEach((e,t)=>{for(let t=e.length-1;t>=0;t--)this._manualPackages.has(e[t])&&e.splice(t,1);e.length<=0&&this._windowPkgs.delete(t)})}addWindowPkg(e,t){this._windowPkgs.has(e)?this._windowPkgs.get(e).push(t):this._windowPkgs.set(e,[t])}loadWindowRes(e,t){var i;if(!this._isInit)return console.warn("UI包信息未配置 将手动管理所有UI包资源的加载,如果需要配置,请使用 【UIManager.initPackageConfig】接口"),void t.complete();this.hasWindowPkg(e)?(this._waitRef++<=0&&(null===(i=this._showWaitWindow)||void 0===i||i.call(this)),this.loadPackages({pkgs:this.getWindowPkgs(e),complete:()=>{var e;--this._waitRef<=0&&(t.complete(),null===(e=this._hideWaitWindow)||void 0===e||e.call(this))},fail:i=>{var s,o;console.warn(`界面${e}打开失败`),t.fail(i),null===(s=this._fail)||void 0===s||s.call(this,e,"UI包加载失败",i),--this._waitRef<=0&&(null===(o=this._hideWaitWindow)||void 0===o||o.call(this))}})):t.complete()}addResRef(e){if(!this._isInit)return;if(!this.hasWindowPkg(e))return;let t=this.getWindowPkgs(e);for(const e of t)this.addRef(e)}releaseWindowRes(e){if(!this._isInit||!this.hasWindowPkg(e))return;let t=this.getWindowPkgs(e);for(const e of t)this.decRef(e)}loadPackages(e){let t=e.pkgs.filter(e=>this.getRef(e)<=0),i=[],n=[],r=t.length;if(r<=0)e.complete();else for(const a of t){let t=this.getPkgBundle(a),h="resources"===t?o.resources:o.assetManager.getBundle(t);if(!h)throw new Error(`UI包【${a}】所在的bundle【${t}】未加载`);s.UIPackage.loadPackage(h,this.getPkgPath(a),t=>{r--,t?n.push(a):i.push(a),r>0||(n.length>0?e.fail(n):e.complete())})}}getPkgBundle(e){return this._pkgBundles.get(e)||"resources"}getPkgPath(e){let t=this._pkgBundles.get(e);return this._uiPaths[t]+e}getWindowPkgs(e){return this._windowPkgs.has(e)?this._windowPkgs.get(e):[]}hasWindowPkg(e){return this._windowPkgs.has(e)}getRef(e){return this._pkgRefs[e]?this._pkgRefs[e]:0}addRef(e){this._pkgRefs[e]=this.getRef(e)+1}decRef(e){this._pkgRefs[e]=this.getRef(e)-1,this.getRef(e)<=0&&(delete this._pkgRefs[e],this._imReleasePackages.has(e)&&s.UIPackage.removePackage(e))}}const{ccclass:_,property:g,menu:f}=o._decorator;let m=class extends o.Component{constructor(){super(...arguments),this.ignoreQuery=!1,this.swallowTouch=!1,this.bgAlpha=.75}init(){let e=this.node.name;i.debug(`\tUIContainer name:${e} 忽略顶部窗口查询:${this.ignoreQuery} 吞噬触摸事件:${this.swallowTouch}`);const t=new s.GComponent;t.name=e,t.node.name=e,t.visible=!1,t.opaque=this.swallowTouch,t.setSize(i.Screen.ScreenWidth,i.Screen.ScreenHeight,!0),s.GRoot.inst.addChild(t),h._addWindowGroup(new c(e,t,this.ignoreQuery,this.swallowTouch,this.bgAlpha))}};u([g({displayName:"忽略顶部窗口查询",tooltip:"当通过窗口管理器获取顶部窗口时,是否忽略查询"})],m.prototype,"ignoreQuery",void 0),u([g({displayName:"吞噬触摸事件",tooltip:"窗口组是否会吞噬触摸事件,防止层级下的窗口接收触摸事件"})],m.prototype,"swallowTouch",void 0),u([g({displayName:"底部遮罩透明度",tooltip:"底部半透明遮罩的默认透明度",min:0,max:1,step:.01})],m.prototype,"bgAlpha",void 0),m=u([_("CocosWindowContainer"),f("kunpo/UI/UIContainer")],m);const{ccclass:W,menu:k,property:P}=o._decorator;exports.UIModule=class extends o.Component{constructor(){super(...arguments),this.moduleName="UI模块"}init(){h._init(new w),s.GRoot.create(),i.debug("初始化 WindowContainers");for(const e of this.node.children){const t=e.getComponent(m);null==t||t.init()}this.node.destroyAllChildren(),h.registerUI(),exports._uidecorator.setRegisterFinish(),this.onInit()}onInit(){i.debug("UIModule init complete")}},exports.UIModule=u([W("UIModule"),k("kunpo/UIModule")],exports.UIModule),exports.UIHeader=n,exports.UIManager=h,exports.Window=class extends l{onAdapted(){}onClose(){}onShow(e){}onHide(){}onShowFromHide(){}onCover(){}onRecover(){}onEmptyAreaClick(){}},exports.WindowGroup=c,exports.WindowHeaderInfo=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Screen as e,debug as t}from"@gongxh/bit-core";import{GComponent as i,UIObjectFactory as s,GGraph as o,UIPackage as n,GRoot as r}from"fairygui-cc";import{Color as a,resources as h,assetManager as d,_decorator as l,Component as c}from"cc";var u,w,_;!function(e){e[e.Normal=0]="Normal",e[e.CloseAll=1]="CloseAll",e[e.CloseOne=2]="CloseOne",e[e.HideAll=4]="HideAll",e[e.HideOne=8]="HideOne"}(u||(u={})),function(e){e[e.Full=0]="Full",e[e.Bang=1]="Bang",e[e.Fixed=2]="Fixed"}(w||(w={}));class g extends i{constructor(){super(...arguments),this.adapterType=w.Full,this._refCount=0}onHide(){}onAdapted(){}_init(){this.onInit()}_adapted(){switch(this.setPosition(.5*e.ScreenWidth,.5*e.ScreenHeight),this.setPivot(.5,.5,!0),this.adapterType){case w.Full:this.setSize(e.ScreenWidth,e.ScreenHeight,!0);break;case w.Bang:this.setSize(e.SafeWidth,e.SafeHeight,!0)}this.onAdapted()}_show(e){var t;this.visible=!0,this.onShow(e,null===(t=e.getHeaderInfo())||void 0===t?void 0:t.userdata)}_hide(){this.visible=!1,this.onHide()}_close(){this.onClose(),this.dispose()}_addRef(){this._refCount++}_decRef(){return--this._refCount}_screenResize(){this._adapted()}}class p{static setConfig(e){this._config=e}static serializeProps(e,t,i){if(!this._config)return;const s=this._config[t];if(!s)return;const o=s[i=i||e.name];if(!o)return;const n=o.props;this.serializationPropsNode(e,n);const r=o.callbacks;this.serializationCallbacksNode(e,r);const a=o.controls;this.serializationControlsNode(e,a);const h=o.transitions;this.serializationTransitionsNode(e,h)}static serializationPropsNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s++],o=s+t[s];let n=e;for(;++s<=o;)if(n=n.getChildAt(t[s]),!n){console.warn(`无法对UI类(${e.name})属性(${i})赋值,请检查节点配置是否正确`);break}e[i]=n==e?null:n}}static serializationCallbacksNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s++],o=s+t[s];let n=e;for(;++s<=o;)if(n=n.getChildAt(t[s]),!n){console.warn(`无法对UI类(${e.name})的(${i})设置回调,请检查节点配置是否正确`);break}n!=e&&n.onClick(e[i],e)}}static serializationControlsNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s],o=t[s+1],n=e.getController(o);if(!n){console.warn(`无法对UI类(${e.name})的(${i})设置控制器,请检查配置是否正确`);break}e[i]=n,s+=2}}static serializationTransitionsNode(e,t){const i=t.length;let s=0;for(;s<i;){const i=t[s],o=t[s+1],n=e.getTransition(o);if(!n){console.warn(`无法对UI类(${e.name})的(${i})设置动画,请检查配置是否正确`);break}e[i]=n,s+=2}}}p._config={};class f{static register(){for(const{ctor:e,res:t}of _.getComponentMaps().values()){const i=`${t.pkg}/${t.name}`;this._registeredComponents.has(i)?console.debug(`自定义组件已注册,跳过 组件名:${t.name} 包名:${t.pkg}`):(console.debug(`自定义组件注册 组件名:${t.name} 包名:${t.pkg}`),this.registerComponent(e,t.pkg,t.name),this._registeredComponents.add(i))}}static dynamicRegister(e,i,s){const o=`${i}/${s}`;this._registeredComponents.has(o)?console.debug(`自定义组件已注册,跳过 组件名:${s} 包名:${i}`):(t(`自定义组件注册 组件名:${s} 包名:${i}`),this.registerComponent(e,i,s),this._registeredComponents.add(o))}static registerComponent(e,t,i){e.prototype.onConstruct=function(){p.serializeProps(this,t,i),this.onInit&&this.onInit()},s.setExtension(`ui://${t}/${i}`,e)}}f._registeredComponents=new Set;class m{static initPackageConfig(e){this._resPool.initPackageConfig(e)}static showWindow(e,t){return new Promise((i,s)=>{this._resPool.loadWindowRes(e,{complete:()=>{this.showWindowIm(e,t),i()},fail:e=>{s(e)}})})}static showWindowIm(e,t){const i=this._resPool.get(e),s=this.getWindowGroup(i.group);this._resPool.addResRef(e),s.showWindow(i,t)}static closeWindow(e){if(!this._windows.has(e))return void console.warn(`窗口不存在 ${e} 不需要关闭`);let t=this._resPool.get(e);const i=this.getWindowGroup(t.group);if(i._removeWindow(e),0==i.size){let e=this._queryGroupNames.indexOf(i.name);if(e>0&&i.name==this.getTopGroupName())do{const t=this._queryGroupNames[--e];let i=this.getWindowGroup(t);if(i.size>0){this.getWindow(i.getTopWindowName())._recover();break}}while(e>=0)}}static closeAllWindow(e=[]){let t=e.length>0;this._windows.forEach((i,s)=>{t&&e.includes(s)||this.closeWindow(s)}),t||this._windows.clear()}static getTopWindow(){for(let e=this._queryGroupNames.length;e>0;){let t=this.getWindowGroup(this._queryGroupNames[--e]);if(t.size>0)return this.getWindow(t.getTopWindowName())}return null}static getWindow(e){return this._windows.get(e)}static hasWindow(e){return this._windows.has(e)}static getWindowGroup(e){if(this._groups.has(e))return this._groups.get(e);throw new Error(`UIManager.getWindowGroup: window group 【${e}】 not found`)}static getTopGroupName(){for(let e=this._queryGroupNames.length-1;e>=0;e--){let t=this._queryGroupNames[e];if(this._groups.get(t).size>0)return t}return""}static _init(e){this._resPool=e}static _addWindow(e,t){this._windows.set(e,t)}static _removeWindow(e){this.hasWindow(e)&&(this._windows.get(e)._close(),this._windows.delete(e),this._resPool.releaseWindowRes(e))}static registerUI(){for(const{ctor:e,res:i}of _.getWindowMaps().values())t(`窗口注册 窗口名:${i.name} 包名:${i.pkg} 组名:${i.group}`),this._resPool.add(e,i.group,i.pkg,i.name,i.bundle);for(const{ctor:e,res:i}of _.getHeaderMaps().values())t(`header注册 header名:${i.name} 包名:${i.pkg}`),this._resPool.addHeader(e,i.pkg,i.name,i.bundle);f.register()}static dynamicRegisterWindow(e,i,s,o,n){t(`窗口注册 窗口名:${o} 包名:${s} 组名:${i}`),this._resPool.add(e,i,s,o,n)}static dynamicRegisterHeader(e,i,s,o){t(`header注册 header名:${s} 包名:${i}`),this._resPool.addHeader(e,i,s,o)}static _addWindowGroup(e){if(this._groups.has(e.name))throw new Error(`UIManager._addWindowGroup: window group 【${e.name}】 already exists`);this._groups.set(e.name,e),!e.isIgnore&&this._queryGroupNames.push(e.name)}static _screenResize(){this._windows.forEach(e=>{e.screenResize()}),this._groups.forEach(e=>{e._screenResize()})}static _getResPool(){return this._resPool}}m._groups=new Map,m._queryGroupNames=[],m._windows=new Map,function(e){const t="__uipropmeta__",i="__uicbmeta__",s="__uicontrolmeta__",o="__uitransitionmeta__",n=new Map;function r(e,t){return e.hasOwnProperty(t)?e[t]:e[t]=Object.assign({},e[t])}e.getWindowMaps=function(){return n},e.uiclass=function(e,r,a,h){return function(l){const c=l;return n.set(c,{ctor:l,props:l[t]||null,callbacks:l[i]||null,controls:l[s]||null,transitions:l[o]||null,res:{group:e,pkg:r,name:a,bundle:h||""}}),d&&m.dynamicRegisterWindow(l,e,r,a,h||""),l}};let a=new Map;e.getComponentMaps=function(){return a},e.uicom=function(e,n){return function(r){const h=r;return a.set(h,{ctor:r,props:r[t]||null,callbacks:r[i]||null,controls:r[s]||null,transitions:r[o]||null,res:{pkg:e,name:n}}),d&&f.dynamicRegister(r,e,n),r}};let h=new Map;e.getHeaderMaps=function(){return h},e.uiheader=function(e,n,r){return function(a){const l=a;return h.set(l,{ctor:a,props:a[t]||null,callbacks:a[i]||null,controls:a[s]||null,transitions:a[o]||null,res:{pkg:e,name:n,bundle:r||""}}),d&&m.dynamicRegisterHeader(a,e,n,r||""),a}},e.uiprop=function(e,i){r(e.constructor,t)[i]=1},e.uicontrol=function(e,t){r(e.constructor,s)[t]=1},e.uitransition=function(e,t){r(e.constructor,o)[t]=1},e.uiclick=function(e,t,s){r(e.constructor,i)[t]=s.value};let d=!1;e.setRegisterFinish=function(){d=!0}}(_||(_={}));const W=globalThis||window||global;W.getKunpoRegisterWindowMaps=function(){return _.getWindowMaps()},W.getKunpoRegisterComponentMaps=function(){return _.getComponentMaps()},W.getKunpoRegisterHeaderMaps=function(){return _.getHeaderMaps()};class k extends i{constructor(){super(...arguments),this.type=u.Normal,this.adapterType=w.Full,this._header=null,this._isCover=!1,this._swallowComponent=null}_init(t,s){if(t){let s=new i;s.name="swallow",s.setSize(e.ScreenWidth,e.ScreenHeight,!0),s.setPivot(.5,.5,!0),s.setPosition(.5*this.width,.5*this.height),this.addChild(s),s.parent.setChildIndex(s,0),s.onClick(this.onEmptyAreaClick,this),s.opaque=t,this._swallowComponent=s}this.opaque=t,this.bgAlpha=s,this.onInit()}_adapted(){var t,i;switch(this.setPosition(.5*e.ScreenWidth,.5*e.ScreenHeight),this.setPivot(.5,.5,!0),this.adapterType){case w.Full:this.setSize(e.ScreenWidth,e.ScreenHeight,!0);break;case w.Bang:this.setSize(e.SafeWidth,e.SafeHeight,!0)}null===(t=this._swallowComponent)||void 0===t||t.setSize(e.ScreenWidth,e.ScreenHeight,!0),null===(i=this._swallowComponent)||void 0===i||i.setPosition(.5*this.width,.5*+this.height),this.onAdapted()}_close(){this.onClose(),this.dispose()}_show(e){this.visible=!0,this.onShow(e)}_hide(){this.visible=!1,this.onHide()}_showFromHide(){this.visible=!0,this.onShowFromHide()}_cover(){this._isCover=!0,this.onCover()}_recover(){this._isCover=!1,this.onRecover()}_setDepth(e){this.parent.setChildIndex(this,e)}isShowing(){return this.visible}isCover(){return this._isCover}screenResize(){this._adapted()}getHeaderInfo(){return null}getHeader(){return this._header}_setHeader(e){this._header=e}}class P extends k{onAdapted(){}onClose(){}onShow(e){}onHide(){}onShowFromHide(){}onCover(){}onRecover(){}onEmptyAreaClick(){}}class v{get name(){return this._name}get size(){return this._windowNames.length}get isIgnore(){return this._ignoreQuery}constructor(e,t,i,s,n){this._name="",this._ignoreQuery=!1,this._swallowTouch=!1,this._windowNames=[],this._headers=new Map,this._bgAlpha=0,this._color=new a(0,0,0,255),this._name=e,this._root=t,this._ignoreQuery=i,this._swallowTouch=s,this._bgAlpha=n;const r=new o;r.touchable=!1,r.name="bgAlpha",r.setPosition(.5*t.width,.5*t.height),r.setSize(t.width,t.height,!0),r.setPivot(.5,.5,!0),t.addChild(r),this._alphaGraph=r}_createWindow(e,t){let i=n.createObject(e,t);return i.name=t,p.serializeProps(i,e),i._init(this._swallowTouch,this._bgAlpha),i._adapted(),this._createHeader(i),this._addWindow(i),i}_addWindow(e){this._root.addChild(e),m._addWindow(e.name,e)}showWindow(e,t){let i=e.name,s=m.getWindow(i);s||(s=this._createWindow(e.pkg,i),this._processWindowCloseStatus(s),this._windowNames.push(i)),s._show(t),this._moveWindowToTop(i),this._processHeaderStatus(),this._root.visible=!0}_removeWindow(e){let t=this._windowNames.lastIndexOf(e),i=this.size-1;if(t<0)return void console.warn(`窗口组${this._name}中未找到窗口${e} 删除失败`);let s=m.getWindow(e).getHeader();if(s&&this._removeHeader(s),this._windowNames.splice(t,1),m._removeWindow(e),this._processWindowHideStatus(this.size-1,!0),0==this.size)this._root.visible=!1;else if(i==t&&t>0){let e=this.getTopWindowName(),t=m.getWindow(e);this._adjustAlphaGraph(t),t._setDepth(this._root.numChildren-1)}this._processHeaderStatus()}_moveWindowToTop(e){let t=!1;if(0==this.size)return console.warn(`WindowGroup.moveWindowToTop: window group 【${this._name}】 is empty`),!1;if(this._windowNames[this.size-1]==e);else{const i=this._windowNames.indexOf(e);if(-1==i)return console.warn(`WindowGroup.moveWindowToTop: window 【${e}】 not found in window group 【${this._name}】`),!1;i<this._windowNames.length-1&&(this._windowNames.splice(i,1),this._windowNames.push(e),t=!0)}let i=m.getWindow(e);return this._adjustAlphaGraph(i),i._setDepth(this._root.numChildren-1),this._processWindowHideStatus(this.size-1,t),!0}_processWindowHideStatus(e,t=!0){if(e<0)return;let i=this._windowNames[e],s=m.getWindow(i);if(e!=this.size-1||s.isShowing()||s._showFromHide(),0==e)return;let o=s.type;if(o!=u.HideAll){if(o==u.HideOne){let t=this._windowNames[e-1],i=m.getWindow(t);i.isShowing()&&i._hide()}else{let t=this._windowNames[e-1],i=m.getWindow(t);!i.isShowing()&&i._showFromHide()}t&&this._processWindowHideStatus(e-1,t)}else for(let t=e-1;t>=0;--t){let e=this._windowNames[t];const i=m.getWindow(e);i.isShowing()&&i._hide()}}_processWindowCloseStatus(e){if(e.type==u.CloseOne){let e=this.size;for(;e>0;){let e=this._windowNames.pop(),t=m.getWindow(e).getHeader();t&&this._removeHeader(t),m._removeWindow(e);break}}else if(e.type==u.CloseAll){for(let e=this.size;e>0;){let t=this._windowNames[--e],i=m.getWindow(t).getHeader();i&&this._removeHeader(i),m._removeWindow(t)}this._windowNames.length=0}}_processHeaderStatus(){let e=null,t=null,i=this.size-1;for(let s=this.size-1;s>=0;--s){let o=this._windowNames[s],n=m.getWindow(o);if(n.isShowing()&&n.getHeader()){t=n,e=n.getHeader(),i=s;break}}this._headers.forEach((i,s)=>{this._root.setChildIndex(i,0),!e&&i.visible?i._hide():e&&(e.name!=s||i.visible?e.name!=s&&i.visible&&i._hide():i._show(t))}),e&&(i==this.size-1?this._root.setChildIndex(e,this._root.numChildren-1):this._root.setChildIndex(e,this._root.numChildren-this.size+i-1))}_adjustAlphaGraph(e){this._root.setChildIndex(this._alphaGraph,this._root.numChildren-1),this._color.a=255*e.bgAlpha,this._alphaGraph.clearGraphics(),this._alphaGraph.drawRect(0,this._color,this._color)}hasWindow(e){return this._windowNames.indexOf(e)>=0}getTopWindowName(){return this.size>0?this._windowNames[this.size-1]:(console.warn(`WindowGroup.getTopWindowName: window group 【${this._name}】 is empty`),"")}_createHeader(e){let t=e.getHeaderInfo();if(!t)return;let i=t.name,s=this._getHeader(i);if(s)e._setHeader(s),s._addRef();else{let{pkg:t}=m._getResPool().getHeader(i),s=n.createObject(t,i);s.name=i,s.opaque=!1,e._setHeader(s),s.visible=!1,p.serializeProps(s,t),s._init(),s._adapted(),this._root.addChild(s),s._addRef(),this._headers.set(s.name,s)}}_removeHeader(e){if(this._headers.has(e.name)){e._decRef()<=0&&(this._headers.delete(e.name),e._close())}}_getHeader(e){return this._headers.get(e)}_screenResize(){this._headers.forEach(e=>{e._screenResize()}),this._alphaGraph.setPosition(.5*e.ScreenWidth,.5*e.ScreenHeight),this._alphaGraph.setSize(e.ScreenWidth,e.ScreenHeight,!0),this._alphaGraph.setPivot(.5,.5,!0)}closeAllWindow(){for(;this.size>0;){let e=this.getTopWindowName();m.closeWindow(e)}}}class C{static create(e,t){const i=new C;return i.name=e,i.userdata=t,i}}function H(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(n<3?o(r):n>3?o(t,i,r):o(t,i))||r);return n>3&&r&&Object.defineProperty(t,i,r),r}"function"==typeof SuppressedError&&SuppressedError;class R{constructor(){this._windowInfos=new Map,this._headerInfos=new Map,this._pkgBundles=new Map,this._isInit=!1,this._windowPkgs=new Map,this._pkgRefs={},this._uiPaths={},this._manualPackages=new Set,this._imReleasePackages=new Set,this._showWaitWindow=null,this._hideWaitWindow=null,this._fail=null,this._waitRef=0}add(e,t,i,o,n){this.has(o)||(this._windowInfos.set(o,{ctor:e,group:t,pkg:i,name:o,bundle:n}),this._pkgBundles.set(i,n||"resources"),this.addWindowPkg(o,i),s.setExtension(`ui://${i}/${o}`,e))}has(e){return this._windowInfos.has(e)}get(e){if(!this.has(e))throw new Error(`窗口【${e}】未注册,请使用 _uidecorator.uiclass 注册窗口`);return this._windowInfos.get(e)}addHeader(e,t,i,o){this.hasHeader(i)||(this._headerInfos.set(i,{ctor:e,pkg:t,bundle:o}),this._pkgBundles.set(t,o||"resources"),s.setExtension(`ui://${t}/${i}`,e))}hasHeader(e){return this._headerInfos.has(e)}getHeader(e){if(!this.hasHeader(e))throw new Error(`窗口header【${e}】未注册,请使用 _uidecorator.uiheader 注册窗口header`);return this._headerInfos.get(e)}initPackageConfig(e){var t,i;if(!e||!e.config)return;if(this._isInit)throw new Error("资源配置已初始化,请勿重复设置");this._isInit=!0,this._showWaitWindow=null==e?void 0:e.showWaitWindow,this._hideWaitWindow=null==e?void 0:e.hideWaitWindow,this._fail=null==e?void 0:e.fail,this._uiPaths=(null===(t=e.config)||void 0===t?void 0:t.bundlePaths)||{},this._uiPaths.resources=(null===(i=e.config)||void 0===i?void 0:i.uiPath)||"";for(const e in this._uiPaths)""==this._uiPaths[e]||this._uiPaths[e].endsWith("/")||(this._uiPaths[e]+="/");this._manualPackages=new Set(e.config.manualPackages||[]),this._imReleasePackages=new Set(e.config.imReleasePackages||[]);let s=e.config.linkPackages||{};for(const e in s){let t=s[e];for(const i of t||[])this.addWindowPkg(e,i)}this._windowPkgs.forEach((e,t)=>{for(let t=e.length-1;t>=0;t--)this._manualPackages.has(e[t])&&e.splice(t,1);e.length<=0&&this._windowPkgs.delete(t)})}addWindowPkg(e,t){this._windowPkgs.has(e)?this._windowPkgs.get(e).push(t):this._windowPkgs.set(e,[t])}loadWindowRes(e,t){var i;if(!this._isInit)return console.warn("UI包信息未配置 将手动管理所有UI包资源的加载,如果需要配置,请使用 【UIManager.initPackageConfig】接口"),void t.complete();this.hasWindowPkg(e)?(this._waitRef++<=0&&(null===(i=this._showWaitWindow)||void 0===i||i.call(this)),this.loadPackages({pkgs:this.getWindowPkgs(e),complete:()=>{var e;--this._waitRef<=0&&(t.complete(),null===(e=this._hideWaitWindow)||void 0===e||e.call(this))},fail:i=>{var s,o;console.warn(`界面${e}打开失败`),t.fail(i),null===(s=this._fail)||void 0===s||s.call(this,e,"UI包加载失败",i),--this._waitRef<=0&&(null===(o=this._hideWaitWindow)||void 0===o||o.call(this))}})):t.complete()}addResRef(e){if(!this._isInit)return;if(!this.hasWindowPkg(e))return;let t=this.getWindowPkgs(e);for(const e of t)this.addRef(e)}releaseWindowRes(e){if(!this._isInit||!this.hasWindowPkg(e))return;let t=this.getWindowPkgs(e);for(const e of t)this.decRef(e)}loadPackages(e){let t=e.pkgs.filter(e=>this.getRef(e)<=0),i=[],s=[],o=t.length;if(o<=0)e.complete();else for(const r of t){let t=this.getPkgBundle(r),a="resources"===t?h:d.getBundle(t);if(!a)throw new Error(`UI包【${r}】所在的bundle【${t}】未加载`);n.loadPackage(a,this.getPkgPath(r),t=>{o--,t?s.push(r):i.push(r),o>0||(s.length>0?e.fail(s):e.complete())})}}getPkgBundle(e){return this._pkgBundles.get(e)||"resources"}getPkgPath(e){let t=this._pkgBundles.get(e);return this._uiPaths[t]+e}getWindowPkgs(e){return this._windowPkgs.has(e)?this._windowPkgs.get(e):[]}hasWindowPkg(e){return this._windowPkgs.has(e)}getRef(e){return this._pkgRefs[e]?this._pkgRefs[e]:0}addRef(e){this._pkgRefs[e]=this.getRef(e)+1}decRef(e){this._pkgRefs[e]=this.getRef(e)-1,this.getRef(e)<=0&&(delete this._pkgRefs[e],this._imReleasePackages.has(e)&&n.removePackage(e))}}const{ccclass:b,property:S,menu:I}=l;let $=class extends c{constructor(){super(...arguments),this.ignoreQuery=!1,this.swallowTouch=!1,this.bgAlpha=.75}init(){let s=this.node.name;t(`\tUIContainer name:${s} 忽略顶部窗口查询:${this.ignoreQuery} 吞噬触摸事件:${this.swallowTouch}`);const o=new i;o.name=s,o.node.name=s,o.visible=!1,o.opaque=this.swallowTouch,o.setSize(e.ScreenWidth,e.ScreenHeight,!0),r.inst.addChild(o),m._addWindowGroup(new v(s,o,this.ignoreQuery,this.swallowTouch,this.bgAlpha))}};H([S({displayName:"忽略顶部窗口查询",tooltip:"当通过窗口管理器获取顶部窗口时,是否忽略查询"})],$.prototype,"ignoreQuery",void 0),H([S({displayName:"吞噬触摸事件",tooltip:"窗口组是否会吞噬触摸事件,防止层级下的窗口接收触摸事件"})],$.prototype,"swallowTouch",void 0),H([S({displayName:"底部遮罩透明度",tooltip:"底部半透明遮罩的默认透明度",min:0,max:1,step:.01})],$.prototype,"bgAlpha",void 0),$=H([b("CocosWindowContainer"),I("kunpo/UI/UIContainer")],$);const{ccclass:y,menu:N,property:z}=l;let G=class extends c{constructor(){super(...arguments),this.moduleName="UI模块"}init(){m._init(new R),r.create(),t("初始化 WindowContainers");for(const e of this.node.children){const t=e.getComponent($);null==t||t.init()}this.node.destroyAllChildren(),m.registerUI(),_.setRegisterFinish(),this.onInit()}onInit(){t("UIModule init complete")}};G=H([y("UIModule"),N("kunpo/UIModule")],G);export{w as AdapterType,g as UIHeader,m as UIManager,G as UIModule,P as Window,v as WindowGroup,C as WindowHeaderInfo,u as WindowType,_ as _uidecorator};
|