@ives_xxz/framework 1.6.6 → 2.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/Framework.ts +9 -13
- package/FrameworkAutoInitialize.ts +58 -0
- package/{CC.d.ts.meta → FrameworkAutoInitialize.ts.meta} +1 -1
- package/FrameworkBase.ts +35 -36
- package/animation/FWSkeleton.ts +5 -6
- package/component/FWVirtualViewComponent.ts +42 -45
- package/config/FWAssetConfig.ts +2 -2
- package/controller/FWLayerController.ts +3 -7
- package/data/FWData.ts +2 -3
- package/define/FWEventDefine.ts +24 -21
- package/define/FWSystemDefine.ts +127 -132
- package/define/FWSystemDefine.ts.meta +1 -1
- package/entry/FWEntry.ts +2 -3
- package/expand/FWDecorator.ts +56 -114
- package/expand/FWRollingViewNesting.ts +3 -5
- package/item/FWVirtualListItem.ts +1 -1
- package/language/FWLanguage.ts +15 -19
- package/layer/FWLayer.ts +1 -1
- package/log/FWLog.ts +30 -35
- package/logic/FWLogic.ts +2 -4
- package/machine/FWStateMachine.ts +1 -2
- package/manager/FWAnimationManager.ts +6 -8
- package/manager/FWAssetManager.ts +22 -23
- package/manager/FWAudioManager.ts +30 -52
- package/manager/FWBundleManager.ts +2 -4
- package/manager/FWComponentManager.ts +0 -1
- package/manager/FWEngineManager.ts +9 -12
- package/manager/FWEventManager.ts +4 -7
- package/manager/FWHotUpdateManager.ts +32 -33
- package/manager/FWLanguageManager.ts +1 -2
- package/manager/FWLayerManager.ts +88 -138
- package/manager/FWManager.ts +1 -3
- package/manager/FWObjectManager.ts +7 -9
- package/manager/FWPerformanceManager.ts +2 -3
- package/manager/FWPromiseManager.ts +29 -28
- package/manager/FWResManager.ts +1 -3
- package/manager/FWSocketManager.ts +2 -5
- package/manager/FWStateManager.ts +2 -4
- package/manager/FWTimeManager.ts +14 -15
- package/manager/FWUiManager.ts +3 -4
- package/package.json +1 -1
- package/{register → registry}/FWRegistry.ts +8 -8
- package/service/http/FWHttp.ts +5 -7
- package/service/socket/FWSocket.ts +28 -43
- package/service/socket/FWSocketHandle.ts +3 -6
- package/service/socket/FWSocketSender.ts +5 -9
- package/types/Creator.d.ts.meta +6 -0
- package/{FW.d.ts → types/FW.d.ts} +407 -153
- package/types/Global.d.ts +21 -0
- package/{render/FWAssembler.ts.meta → types/Global.d.ts.meta} +1 -1
- package/types.meta +13 -0
- package/utils/FWObjectPool.ts +5 -7
- package/utils/FWTask.ts +18 -22
- package/render/FWAssembler.ts +0 -11
- /package/{register → registry}/FWRegistry.ts.meta +0 -0
- /package/{register.meta → registry.meta} +0 -0
- /package/{CC.d.ts → types/Creator.d.ts} +0 -0
- /package/{FW.d.ts.meta → types/FW.d.ts.meta} +0 -0
package/expand/FWDecorator.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import FWLog from "../log/FWLog";
|
|
1
|
+
import 'reflect-metadata';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
$class: Record<string, any>,
|
|
6
|
-
$propertyKey: string | symbol,
|
|
7
|
-
$descriptorOrInitializer?: any
|
|
8
|
-
) => void;
|
|
9
|
-
|
|
10
|
-
export const searchChild = function (node: cc.Node, name: string) {
|
|
3
|
+
export function searchChild(node: cc.Node, name: string) {
|
|
11
4
|
let ret = node.getChildByName(name);
|
|
12
5
|
if (ret) return ret;
|
|
13
6
|
for (let i = 0; i < node.children.length; i++) {
|
|
@@ -17,57 +10,49 @@ export const searchChild = function (node: cc.Node, name: string) {
|
|
|
17
10
|
if (ret) return ret;
|
|
18
11
|
}
|
|
19
12
|
return null;
|
|
20
|
-
}
|
|
13
|
+
}
|
|
21
14
|
|
|
22
15
|
const CookDecoratorKey = ($desc: string) => `__ccc_decorator_${$desc}__`;
|
|
23
16
|
|
|
24
|
-
const KeyChild = CookDecoratorKey(
|
|
17
|
+
const KeyChild = CookDecoratorKey('child_cache');
|
|
25
18
|
|
|
26
19
|
type ParamType = {
|
|
27
20
|
path?: string;
|
|
28
21
|
};
|
|
29
22
|
|
|
30
|
-
export function FWPropertyNode($opt?: ParamType): PropertyDecorator {
|
|
23
|
+
export function FWPropertyNode($opt?: ParamType): FW.PropertyDecorator {
|
|
31
24
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
25
|
return ($target, $propertyKey: string, $descriptorOrInitializer) => {
|
|
33
|
-
const cache: { propertyKey: string; childName: string }[] = ($target[
|
|
34
|
-
KeyChild
|
|
35
|
-
] ??= []);
|
|
26
|
+
const cache: { propertyKey: string; childName: string }[] = ($target[KeyChild] ??= []);
|
|
36
27
|
if (!cache.some(($vo) => $vo.propertyKey === $propertyKey)) {
|
|
37
28
|
cache.push({
|
|
38
29
|
propertyKey: $propertyKey,
|
|
39
30
|
childName: $opt?.path || $propertyKey,
|
|
40
31
|
});
|
|
41
32
|
} else {
|
|
42
|
-
throw new Error(
|
|
43
|
-
`child 装饰器重复绑定属性:${$propertyKey},class:${$target?.name}`
|
|
44
|
-
);
|
|
33
|
+
throw new Error(`child 装饰器重复绑定属性:${$propertyKey},class:${$target?.name}`);
|
|
45
34
|
}
|
|
46
35
|
if (cache.length === 1) {
|
|
47
36
|
const oldOnLoad: () => void = $target.onLoad || undefined;
|
|
48
37
|
$target.onLoad = function () {
|
|
49
|
-
cache.forEach(
|
|
50
|
-
($vo) =>
|
|
51
|
-
(this[$vo.propertyKey] = searchChild(this.node, $vo.childName))
|
|
52
|
-
);
|
|
38
|
+
cache.forEach(($vo) => (this[$vo.propertyKey] = searchChild(this.node, $vo.childName)));
|
|
53
39
|
oldOnLoad && oldOnLoad.apply(this);
|
|
54
40
|
};
|
|
55
41
|
}
|
|
56
42
|
};
|
|
57
43
|
}
|
|
58
44
|
|
|
59
|
-
const KeyChildMulti = CookDecoratorKey(
|
|
45
|
+
const KeyChildMulti = CookDecoratorKey('child_cache_multi'); // 重新定义 Key,避免冲突
|
|
60
46
|
|
|
61
47
|
/** 查找多个节点,并存储为数组 */
|
|
62
|
-
export function FWPropertyNodes(...paths: string[]): PropertyDecorator {
|
|
48
|
+
export function FWPropertyNodes(...paths: string[]): FW.PropertyDecorator {
|
|
63
49
|
return ($target: any, $propertyKey: string) => {
|
|
64
50
|
// 确保 $target[KeyChild] 是数组
|
|
65
51
|
if (!$target[KeyChildMulti]) {
|
|
66
52
|
$target[KeyChildMulti] = [];
|
|
67
53
|
}
|
|
68
54
|
|
|
69
|
-
const cache: { propertyKey: string; childNames: string[] }[] =
|
|
70
|
-
$target[KeyChildMulti];
|
|
55
|
+
const cache: { propertyKey: string; childNames: string[] }[] = $target[KeyChildMulti];
|
|
71
56
|
|
|
72
57
|
// 查找是否已经存在该属性的绑定
|
|
73
58
|
const existingEntry = cache.find(($vo) => $vo.propertyKey === $propertyKey);
|
|
@@ -80,7 +65,7 @@ export function FWPropertyNodes(...paths: string[]): PropertyDecorator {
|
|
|
80
65
|
});
|
|
81
66
|
} else {
|
|
82
67
|
throw new Error(
|
|
83
|
-
`child 装饰器重复绑定属性:${$propertyKey}, class:${$target.constructor.name}
|
|
68
|
+
`child 装饰器重复绑定属性:${$propertyKey}, class:${$target.constructor.name}`,
|
|
84
69
|
);
|
|
85
70
|
}
|
|
86
71
|
|
|
@@ -123,13 +108,13 @@ interface INewable<T = any> extends Function {
|
|
|
123
108
|
new (...args: any[]): T;
|
|
124
109
|
}
|
|
125
110
|
|
|
126
|
-
const KeyComp = CookDecoratorKey(
|
|
111
|
+
const KeyComp = CookDecoratorKey('comp_cache');
|
|
127
112
|
|
|
128
113
|
export function FWPropertyComponent(
|
|
129
114
|
$componentClass: INewable<cc.Component>,
|
|
130
115
|
$childName?: string,
|
|
131
|
-
$mute = false
|
|
132
|
-
): PropertyDecorator {
|
|
116
|
+
$mute = false,
|
|
117
|
+
): FW.PropertyDecorator {
|
|
133
118
|
return ($target, $propertyKey: string, $descriptorOrInitializer) => {
|
|
134
119
|
const cache: {
|
|
135
120
|
propertyKey: string;
|
|
@@ -144,9 +129,7 @@ export function FWPropertyComponent(
|
|
|
144
129
|
});
|
|
145
130
|
} else {
|
|
146
131
|
if (!$mute) {
|
|
147
|
-
throw new Error(
|
|
148
|
-
`component装饰器重复绑定属性:${$propertyKey},class:${$target.name}`
|
|
149
|
-
);
|
|
132
|
+
throw new Error(`component装饰器重复绑定属性:${$propertyKey},class:${$target.name}`);
|
|
150
133
|
}
|
|
151
134
|
return;
|
|
152
135
|
}
|
|
@@ -154,21 +137,18 @@ export function FWPropertyComponent(
|
|
|
154
137
|
const oldOnLoad: () => void = $target.onLoad || undefined; //$target.onLoad也可以拿到父类的实现
|
|
155
138
|
$target.onLoad = function () {
|
|
156
139
|
cache.forEach(($vo) => {
|
|
157
|
-
const node = $vo.childName
|
|
158
|
-
? searchChild(this.node, $vo.childName)
|
|
159
|
-
: this.node;
|
|
140
|
+
const node = $vo.childName ? searchChild(this.node, $vo.childName) : this.node;
|
|
160
141
|
if (!node) {
|
|
161
142
|
if (!$mute) {
|
|
162
143
|
throw new Error(
|
|
163
|
-
`component装饰器没有找到适合的node节点:class:${$target?.name},组件:${$componentClass?.name},childName:${$childName}
|
|
144
|
+
`component装饰器没有找到适合的node节点:class:${$target?.name},组件:${$componentClass?.name},childName:${$childName}`,
|
|
164
145
|
);
|
|
165
146
|
} else {
|
|
166
147
|
return;
|
|
167
148
|
}
|
|
168
149
|
}
|
|
169
150
|
this[$vo.propertyKey] =
|
|
170
|
-
node.getComponent($vo.compClass) ||
|
|
171
|
-
node.addComponent($vo.compClass);
|
|
151
|
+
node.getComponent($vo.compClass) || node.addComponent($vo.compClass);
|
|
172
152
|
});
|
|
173
153
|
oldOnLoad && oldOnLoad.apply(this);
|
|
174
154
|
};
|
|
@@ -178,8 +158,8 @@ export function FWPropertyComponent(
|
|
|
178
158
|
|
|
179
159
|
export function FWPropertyComponents(
|
|
180
160
|
$componentClass: INewable<cc.Component>,
|
|
181
|
-
$childName?: string
|
|
182
|
-
): PropertyDecorator {
|
|
161
|
+
$childName?: string,
|
|
162
|
+
): FW.PropertyDecorator {
|
|
183
163
|
return ($target, $propertyKey: string, $descriptorOrInitializer) => {
|
|
184
164
|
const componentName = $childName || $propertyKey;
|
|
185
165
|
const oldOnLoad: () => void = $target.onLoad || undefined; //$target.onLoad也可以拿到父类的实现
|
|
@@ -223,11 +203,7 @@ export function isNull(message?: string) {
|
|
|
223
203
|
}
|
|
224
204
|
|
|
225
205
|
export function FWSocketAutoProcessPause() {
|
|
226
|
-
return function (
|
|
227
|
-
target: any,
|
|
228
|
-
propertyKey: string,
|
|
229
|
-
descriptor: PropertyDescriptor
|
|
230
|
-
) {
|
|
206
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
231
207
|
const originalMethod = descriptor.value;
|
|
232
208
|
|
|
233
209
|
descriptor.value = async function (...args: any[]) {
|
|
@@ -235,7 +211,7 @@ export function FWSocketAutoProcessPause() {
|
|
|
235
211
|
const result = await originalMethod.apply(this, args);
|
|
236
212
|
return result;
|
|
237
213
|
} finally {
|
|
238
|
-
|
|
214
|
+
FW.Log.debug('暂停socket消息处理');
|
|
239
215
|
FW.Entry.socketMgr.resumeMessageHandle();
|
|
240
216
|
}
|
|
241
217
|
};
|
|
@@ -245,25 +221,17 @@ export function FWSocketAutoProcessPause() {
|
|
|
245
221
|
}
|
|
246
222
|
|
|
247
223
|
export function FWDeprecated(description?: string) {
|
|
248
|
-
return function (
|
|
249
|
-
target: any,
|
|
250
|
-
propertyKey: string,
|
|
251
|
-
descriptor: PropertyDescriptor
|
|
252
|
-
) {
|
|
224
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
253
225
|
const originalMethod = descriptor.value;
|
|
254
226
|
descriptor.value = async function (...args: any[]) {
|
|
255
|
-
|
|
227
|
+
FW.Log.warn(`${propertyKey}方法已弃用!${description || ''}`);
|
|
256
228
|
originalMethod.apply(this, args);
|
|
257
229
|
};
|
|
258
230
|
return descriptor;
|
|
259
231
|
};
|
|
260
232
|
}
|
|
261
233
|
export function FWSocketAutoProcessResume() {
|
|
262
|
-
return function (
|
|
263
|
-
target: any,
|
|
264
|
-
propertyKey: string,
|
|
265
|
-
descriptor: PropertyDescriptor
|
|
266
|
-
) {
|
|
234
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
267
235
|
const originalMethod = descriptor.value;
|
|
268
236
|
|
|
269
237
|
descriptor.value = async function (...args: any[]) {
|
|
@@ -271,7 +239,7 @@ export function FWSocketAutoProcessResume() {
|
|
|
271
239
|
const result = await originalMethod.apply(this, args);
|
|
272
240
|
return result;
|
|
273
241
|
} finally {
|
|
274
|
-
|
|
242
|
+
FW.Log.debug('恢复socket消息处理');
|
|
275
243
|
FW.Entry.socketMgr.resumeMessageHandle();
|
|
276
244
|
}
|
|
277
245
|
};
|
|
@@ -281,11 +249,7 @@ export function FWSocketAutoProcessResume() {
|
|
|
281
249
|
}
|
|
282
250
|
|
|
283
251
|
export function RegisterEvents(events: FW.RegisterEventArgs[]) {
|
|
284
|
-
return function (
|
|
285
|
-
target: any,
|
|
286
|
-
propertyKey: string,
|
|
287
|
-
descriptor: PropertyDescriptor
|
|
288
|
-
) {
|
|
252
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
289
253
|
const originalMethod = descriptor.value;
|
|
290
254
|
|
|
291
255
|
descriptor.value = function (...args: any[]) {
|
|
@@ -300,11 +264,7 @@ export function RegisterEvents(events: FW.RegisterEventArgs[]) {
|
|
|
300
264
|
}
|
|
301
265
|
|
|
302
266
|
export function AutoRegisterCCEvent(nodePath: string, eventName?: string) {
|
|
303
|
-
return function (
|
|
304
|
-
target: any,
|
|
305
|
-
propertyKey: string,
|
|
306
|
-
descriptor: PropertyDescriptor
|
|
307
|
-
) {
|
|
267
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
308
268
|
const originalMethod = descriptor.value;
|
|
309
269
|
const originalOnInit = target.onInit;
|
|
310
270
|
const evt = eventName || cc.Node.EventType.TOUCH_END;
|
|
@@ -315,9 +275,7 @@ export function AutoRegisterCCEvent(nodePath: string, eventName?: string) {
|
|
|
315
275
|
let targetNode: cc.Node | null = null;
|
|
316
276
|
|
|
317
277
|
const cachedNodes = this[KeyChild] || [];
|
|
318
|
-
const cachedNode = cachedNodes.find(
|
|
319
|
-
(vo: any) => vo.childName === nodePath
|
|
320
|
-
);
|
|
278
|
+
const cachedNode = cachedNodes.find((vo: any) => vo.childName === nodePath);
|
|
321
279
|
|
|
322
280
|
if (cachedNode && this[cachedNode.propertyKey]) {
|
|
323
281
|
targetNode = this[cachedNode.propertyKey];
|
|
@@ -325,7 +283,7 @@ export function AutoRegisterCCEvent(nodePath: string, eventName?: string) {
|
|
|
325
283
|
targetNode = searchChild(this.layer?.node || this.node, nodePath);
|
|
326
284
|
|
|
327
285
|
if (targetNode && !cachedNode) {
|
|
328
|
-
const cacheKey = `_cached_${nodePath.replace(/\//g,
|
|
286
|
+
const cacheKey = `_cached_${nodePath.replace(/\//g, '_')}`;
|
|
329
287
|
this[cacheKey] = targetNode;
|
|
330
288
|
if (!this[KeyChild]) this[KeyChild] = [];
|
|
331
289
|
this[KeyChild].push({
|
|
@@ -336,53 +294,45 @@ export function AutoRegisterCCEvent(nodePath: string, eventName?: string) {
|
|
|
336
294
|
}
|
|
337
295
|
|
|
338
296
|
if (targetNode) {
|
|
339
|
-
this.registerEvent({
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
});
|
|
348
|
-
|
|
297
|
+
this.registerEvent({
|
|
298
|
+
CCEvent: [
|
|
299
|
+
{
|
|
300
|
+
eventName: evt,
|
|
301
|
+
cb: originalMethod.bind(this),
|
|
302
|
+
target: targetNode,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
});
|
|
306
|
+
FW.Log.debug(`自动注册事件: ${nodePath} -> ${propertyKey}`);
|
|
349
307
|
} else {
|
|
350
|
-
|
|
308
|
+
FW.Log.warn(`自动注册事件失败: 未找到节点 ${nodePath}`);
|
|
351
309
|
}
|
|
352
310
|
};
|
|
353
311
|
};
|
|
354
312
|
}
|
|
355
313
|
|
|
356
314
|
export function AutoRegisterFWEvent(eventName: any) {
|
|
357
|
-
return function (
|
|
358
|
-
target: any,
|
|
359
|
-
propertyKey: string,
|
|
360
|
-
descriptor: PropertyDescriptor
|
|
361
|
-
) {
|
|
315
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
362
316
|
const originalMethod = descriptor.value;
|
|
363
317
|
const originalOnInit = target.onInit;
|
|
364
318
|
|
|
365
319
|
target.onInit = function (...args) {
|
|
366
320
|
originalOnInit?.call(this, args);
|
|
367
|
-
this.registerEvent({
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
});
|
|
321
|
+
this.registerEvent({
|
|
322
|
+
CCEvent: [
|
|
323
|
+
{
|
|
324
|
+
eventName: eventName,
|
|
325
|
+
cb: originalMethod.bind(this),
|
|
326
|
+
target: this,
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
});
|
|
376
330
|
};
|
|
377
331
|
};
|
|
378
332
|
}
|
|
379
333
|
|
|
380
334
|
export function PerformanceMonitor(operationName?: string) {
|
|
381
|
-
return function (
|
|
382
|
-
target: any,
|
|
383
|
-
propertyKey: string,
|
|
384
|
-
descriptor: PropertyDescriptor
|
|
385
|
-
) {
|
|
335
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
386
336
|
const originalMethod = descriptor.value;
|
|
387
337
|
|
|
388
338
|
descriptor.value = async function (...args: any[]) {
|
|
@@ -400,24 +350,16 @@ export function PerformanceMonitor(operationName?: string) {
|
|
|
400
350
|
const result = await originalMethod.apply(this, args);
|
|
401
351
|
const duration = Date.now() - startTime;
|
|
402
352
|
|
|
403
|
-
FW.Entry.performanceMgr?.recordOperationMetric(
|
|
404
|
-
moduleName,
|
|
405
|
-
methodName,
|
|
406
|
-
duration
|
|
407
|
-
);
|
|
353
|
+
FW.Entry.performanceMgr?.recordOperationMetric(moduleName, methodName, duration);
|
|
408
354
|
|
|
409
355
|
if (duration > 100) {
|
|
410
|
-
|
|
356
|
+
FW.Log.warn(`[${moduleName}] ${methodName} took ${duration}ms`);
|
|
411
357
|
}
|
|
412
358
|
|
|
413
359
|
return result;
|
|
414
360
|
} catch (error) {
|
|
415
361
|
const duration = Date.now() - startTime;
|
|
416
|
-
FW.Entry.performanceMgr?.recordOperationMetric(
|
|
417
|
-
moduleName,
|
|
418
|
-
`${methodName}_error`,
|
|
419
|
-
duration
|
|
420
|
-
);
|
|
362
|
+
FW.Entry.performanceMgr?.recordOperationMetric(moduleName, `${methodName}_error`, duration);
|
|
421
363
|
throw error;
|
|
422
364
|
}
|
|
423
365
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import FWLog from '../log/FWLog';
|
|
2
|
-
|
|
3
1
|
const { ccclass, property, menu } = cc._decorator;
|
|
4
2
|
|
|
5
3
|
interface EventTouch extends cc.Event.EventTouch {
|
|
@@ -59,9 +57,9 @@ export default class FWRollingViewNesting extends cc.Component {
|
|
|
59
57
|
let touch = event.touch;
|
|
60
58
|
if (viewGroup.content) {
|
|
61
59
|
if (viewGroup instanceof cc.PageView) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
viewGroup['_touchEndPosition'] = touch.getLocation();
|
|
61
|
+
}
|
|
62
|
+
viewGroup._handleReleaseLogic(touch);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
if (
|
|
@@ -52,7 +52,7 @@ export default class FWVirtualListItem extends FWObject {
|
|
|
52
52
|
|
|
53
53
|
_registerEvent() {
|
|
54
54
|
if (!this._eventReg) {
|
|
55
|
-
if (this.btnCom && this.list.selectedMode > 0) {
|
|
55
|
+
if (this.btnCom && (this.list.selectedMode as number) > 0) {
|
|
56
56
|
this.btnCom.clickEvents.unshift(this.createEvt(this, 'onClickThis'));
|
|
57
57
|
}
|
|
58
58
|
if (this.adaptiveSize) {
|
package/language/FWLanguage.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FWLodash } from "../utils/FWLodash";
|
|
1
|
+
import { FWLodash } from '../utils/FWLodash';
|
|
3
2
|
|
|
4
3
|
const { ccclass, property, executeInEditMode } = cc._decorator;
|
|
5
4
|
|
|
@@ -10,11 +9,8 @@ export default abstract class FWLanguage extends cc.Component {
|
|
|
10
9
|
protected _language: number = 0;
|
|
11
10
|
|
|
12
11
|
@property({
|
|
13
|
-
type: FWLodash.CCEnum([
|
|
14
|
-
|
|
15
|
-
...FW.Entry.languageMgr.getSupportedLanguages(),
|
|
16
|
-
]),
|
|
17
|
-
displayName: "language",
|
|
12
|
+
type: FWLodash.CCEnum(['请选择语言', ...FW.Entry.languageMgr.getSupportedLanguages()]),
|
|
13
|
+
displayName: 'language',
|
|
18
14
|
visible: true,
|
|
19
15
|
serializable: true,
|
|
20
16
|
})
|
|
@@ -34,21 +30,21 @@ export default abstract class FWLanguage extends cc.Component {
|
|
|
34
30
|
|
|
35
31
|
private refreshInspector() {
|
|
36
32
|
//@ts-ignore
|
|
37
|
-
Editor.Utils.refreshSelectedInspector(
|
|
33
|
+
Editor.Utils.refreshSelectedInspector('node', this.node.uuid);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
protected onLoad(): void {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
37
|
+
FW.Entry.uiMgr.register({
|
|
38
|
+
FWEvent: [
|
|
39
|
+
{
|
|
40
|
+
eventName: FW.EventDefine.LanguageEvent.LANGUAGE_CHANGE,
|
|
41
|
+
cb: () => {
|
|
42
|
+
this._language = FW.Entry.languageMgr.getLanguageIndex();
|
|
43
|
+
this.onLanguageChange();
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
protected onEnable(): void {
|
package/layer/FWLayer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { ccclass, property } = cc._decorator;
|
|
2
2
|
|
|
3
3
|
@ccclass
|
|
4
|
-
export
|
|
4
|
+
export class FWLayer extends cc.Component implements FW.Layer {
|
|
5
5
|
public readonly entry: FW.Entry = FW.Entry;
|
|
6
6
|
public ctr: FW.LayerController;
|
|
7
7
|
public onLoad(): void {}
|
package/log/FWLog.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
class FWLog {
|
|
1
|
+
export class FWLog {
|
|
2
|
+
FWLogColorMap: Map<FW.SystemDefine.FWLogType, string> = new Map<
|
|
3
|
+
FW.SystemDefine.FWLogType,
|
|
4
|
+
string
|
|
5
|
+
>([
|
|
6
|
+
[FW.SystemDefine.FWLogType.DEBUG, '#FFFFFF'],
|
|
7
|
+
[FW.SystemDefine.FWLogType.SOCKET_SEND, '#50BBE4'],
|
|
8
|
+
[FW.SystemDefine.FWLogType.SOCKET_RECEIVE, '#F423DF'],
|
|
9
|
+
[FW.SystemDefine.FWLogType.REQUEST, '#23F4C6'],
|
|
10
|
+
[FW.SystemDefine.FWLogType.RESPONSE, '#FF8A00'],
|
|
11
|
+
[FW.SystemDefine.FWLogType.WARN, '#FFC107'],
|
|
12
|
+
[FW.SystemDefine.FWLogType.ERROR, '#DC3545'],
|
|
13
|
+
[FW.SystemDefine.FWLogType.SYSTEM, '#9b1eeeff'],
|
|
14
|
+
]);
|
|
18
15
|
private static instance: FWLog;
|
|
19
16
|
public static getInstance() {
|
|
20
17
|
if (!this.instance) {
|
|
@@ -30,8 +27,8 @@ class FWLog {
|
|
|
30
27
|
return window.console.log.bind(
|
|
31
28
|
window.console,
|
|
32
29
|
`%c[debug]:${FW.Entry.timeMgr.getTime()}`,
|
|
33
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
34
|
-
|
|
30
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
31
|
+
FW.SystemDefine.FWLogType.DEBUG,
|
|
35
32
|
)}; font-weight: bold; font-size: 10;`,
|
|
36
33
|
);
|
|
37
34
|
|
|
@@ -43,8 +40,8 @@ class FWLog {
|
|
|
43
40
|
return window.console.log.bind(
|
|
44
41
|
window.console,
|
|
45
42
|
`%c[sendMsg]:${FW.Entry.timeMgr.getTime()}`,
|
|
46
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
47
|
-
|
|
43
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
44
|
+
FW.SystemDefine.FWLogType.SOCKET_SEND,
|
|
48
45
|
)}; font-weight: bold; font-size: 10;`,
|
|
49
46
|
);
|
|
50
47
|
return console.log;
|
|
@@ -55,8 +52,8 @@ class FWLog {
|
|
|
55
52
|
return window.console.log.bind(
|
|
56
53
|
window.console,
|
|
57
54
|
`%c[receiveMsg]:${FW.Entry.timeMgr.getTime()}`,
|
|
58
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
59
|
-
|
|
55
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
56
|
+
FW.SystemDefine.FWLogType.SOCKET_RECEIVE,
|
|
60
57
|
)}; font-weight: bold; font-size: 10;`,
|
|
61
58
|
);
|
|
62
59
|
return console.log;
|
|
@@ -67,8 +64,8 @@ class FWLog {
|
|
|
67
64
|
return window.console.log.bind(
|
|
68
65
|
window.console,
|
|
69
66
|
`%c[request]:${FW.Entry.timeMgr.getTime()}`,
|
|
70
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
71
|
-
|
|
67
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
68
|
+
FW.SystemDefine.FWLogType.REQUEST,
|
|
72
69
|
)}; font-weight: bold; font-size: 10;`,
|
|
73
70
|
);
|
|
74
71
|
return console.log;
|
|
@@ -79,8 +76,8 @@ class FWLog {
|
|
|
79
76
|
return window.console.log.bind(
|
|
80
77
|
window.console,
|
|
81
78
|
`%c[response]:${FW.Entry.timeMgr.getTime()}`,
|
|
82
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
83
|
-
|
|
79
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
80
|
+
FW.SystemDefine.FWLogType.RESPONSE,
|
|
84
81
|
)}; font-weight: bold; font-size: 10;`,
|
|
85
82
|
);
|
|
86
83
|
return console.log;
|
|
@@ -91,8 +88,8 @@ class FWLog {
|
|
|
91
88
|
return window.console.log.bind(
|
|
92
89
|
window.console,
|
|
93
90
|
`%c[system]:${FW.Entry.timeMgr.getTime()}`,
|
|
94
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
95
|
-
|
|
91
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
92
|
+
FW.SystemDefine.FWLogType.SYSTEM,
|
|
96
93
|
)}; font-weight: bold; font-size: 10;`,
|
|
97
94
|
);
|
|
98
95
|
return console.log;
|
|
@@ -103,8 +100,8 @@ class FWLog {
|
|
|
103
100
|
return window.console.warn.bind(
|
|
104
101
|
window.console,
|
|
105
102
|
`%c[warn]:${FW.Entry.timeMgr.getTime()}`,
|
|
106
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
107
|
-
|
|
103
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
104
|
+
FW.SystemDefine.FWLogType.WARN,
|
|
108
105
|
)}; font-weight: bold; font-size: 10;`,
|
|
109
106
|
);
|
|
110
107
|
return console.warn;
|
|
@@ -115,8 +112,8 @@ class FWLog {
|
|
|
115
112
|
return window.console.error.bind(
|
|
116
113
|
window.console,
|
|
117
114
|
`%c[error]:${FW.Entry.timeMgr.getTime()}`,
|
|
118
|
-
`color: black; background-color: ${FWLogColorMap.get(
|
|
119
|
-
|
|
115
|
+
`color: black; background-color: ${this.FWLogColorMap.get(
|
|
116
|
+
FW.SystemDefine.FWLogType.ERROR,
|
|
120
117
|
)}; font-weight: bold; font-size: 10;`,
|
|
121
118
|
);
|
|
122
119
|
return console.error;
|
|
@@ -128,5 +125,3 @@ if (!CC_DEBUG && !CC_DEV && !CC_BUILD) {
|
|
|
128
125
|
window.console.warn = () => {};
|
|
129
126
|
window.console.error = () => {};
|
|
130
127
|
}
|
|
131
|
-
|
|
132
|
-
export default FWLog.getInstance();
|
package/logic/FWLogic.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { injectable } from
|
|
2
|
-
import { FrameworkBase } from "../FrameworkBase";
|
|
3
|
-
import { FWSystemDefine } from "../define/FWSystemDefine";
|
|
1
|
+
import { injectable } from 'inversify';
|
|
4
2
|
@injectable()
|
|
5
|
-
export
|
|
3
|
+
export class FWLogic extends FW.FrameworkBase {
|
|
6
4
|
public initialize?(): void;
|
|
7
5
|
public onDestroy?(): void;
|
|
8
6
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import FWLog from '../log/FWLog';
|
|
2
1
|
import { FWState } from '../state/FWState';
|
|
3
2
|
|
|
4
3
|
export default class FWStateMachine implements FW.StateMachine {
|
|
@@ -17,7 +16,7 @@ export default class FWStateMachine implements FW.StateMachine {
|
|
|
17
16
|
/** 进入状态 */
|
|
18
17
|
enter(stateType: number, ...args: any): void {
|
|
19
18
|
if (this.stateMap.size == 0) {
|
|
20
|
-
|
|
19
|
+
FW.Log.error('stateMachine is not register!');
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { FWSkeleton } from '../animation/FWSkeleton';
|
|
2
2
|
import { FWTween } from '../animation/FWTween';
|
|
3
3
|
import { FWManager } from './FWManager';
|
|
4
|
-
import { FWSystemDefine } from '../define/FWSystemDefine';
|
|
5
|
-
import FWLog from '../log/FWLog';
|
|
6
4
|
import { FWAnimationMachine } from '../machine/FWAnimationMachine';
|
|
7
5
|
|
|
8
6
|
export default class FWAnimationManager extends FWManager {
|
|
@@ -10,9 +8,9 @@ export default class FWAnimationManager extends FWManager {
|
|
|
10
8
|
public initialize(): void {
|
|
11
9
|
this.animationMachineMap = new Map<string, FWAnimationMachine>();
|
|
12
10
|
|
|
13
|
-
this.createAnimationMachine(
|
|
14
|
-
this.createAnimationMachine(
|
|
15
|
-
this.createAnimationMachine(
|
|
11
|
+
this.createAnimationMachine(FW.SystemDefine.FWAnimationMachineType.TWEEN);
|
|
12
|
+
this.createAnimationMachine(FW.SystemDefine.FWAnimationMachineType.SKELETON);
|
|
13
|
+
this.createAnimationMachine(FW.SystemDefine.FWAnimationMachineType.ANIMATION);
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -22,7 +20,7 @@ export default class FWAnimationManager extends FWManager {
|
|
|
22
20
|
*/
|
|
23
21
|
createTween(args?: FW.TweenArgs) {
|
|
24
22
|
const t = new FWTween();
|
|
25
|
-
const machine = this.animationMachineMap.get(
|
|
23
|
+
const machine = this.animationMachineMap.get(FW.SystemDefine.FWAnimationMachineType.TWEEN);
|
|
26
24
|
t.animationName = args?.tag || '';
|
|
27
25
|
t.animation = cc.tween(args?.target);
|
|
28
26
|
t.timeScale(args?.timeScale || 1);
|
|
@@ -37,7 +35,7 @@ export default class FWAnimationManager extends FWManager {
|
|
|
37
35
|
*/
|
|
38
36
|
createSkeleton(skeleton: sp.Skeleton) {
|
|
39
37
|
const s = new FWSkeleton();
|
|
40
|
-
const machine = this.animationMachineMap.get(
|
|
38
|
+
const machine = this.animationMachineMap.get(FW.SystemDefine.FWAnimationMachineType.SKELETON);
|
|
41
39
|
s.animationName = skeleton.name;
|
|
42
40
|
s.animation = skeleton;
|
|
43
41
|
machine.addAnimation(s);
|
|
@@ -63,7 +61,7 @@ export default class FWAnimationManager extends FWManager {
|
|
|
63
61
|
*/
|
|
64
62
|
private createAnimationMachine(animationMachineName: string) {
|
|
65
63
|
if (this.animationMachineMap.has(animationMachineName)) {
|
|
66
|
-
|
|
64
|
+
FW.Log.warn(`已创建动画机:${animationMachineName},请勿重复注册!`);
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
67
|
const machine = new FWAnimationMachine();
|