@cc-component/cc-ex-component 1.4.2 → 1.4.3
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.
|
@@ -225,19 +225,19 @@ export class ReferenceComponent extends Component {
|
|
|
225
225
|
let name = key[0].toLowerCase() + key.substring(1);
|
|
226
226
|
const type = this.getPropertyType(data.com)
|
|
227
227
|
let bind_pix = `@Bind`
|
|
228
|
-
let event = `,{ event: (
|
|
228
|
+
let event = `,{ event: (this:${className}) => { } }`
|
|
229
229
|
if (type === "YXCollectionView") {
|
|
230
230
|
event = `, {
|
|
231
|
-
layout: (
|
|
231
|
+
layout: (this:${className}) => {
|
|
232
232
|
const layout = new YXFlowLayout();
|
|
233
233
|
layout.horizontalSpacing = 10;
|
|
234
234
|
layout.verticalSpacing = 20;
|
|
235
235
|
layout.itemSize = () => math.size(100, 100);
|
|
236
236
|
return layout;
|
|
237
237
|
},
|
|
238
|
-
cellForItemAt: (
|
|
238
|
+
cellForItemAt: (this:${className}, indexPath, collectionView) => {
|
|
239
239
|
const node = collectionView.dequeueReusableCell("cell", indexPath);
|
|
240
|
-
//node.getComponent(TableVIewItem).refreshUI(
|
|
240
|
+
//node.getComponent(TableVIewItem).refreshUI(this.viewModel.${name}[indexPath.row])
|
|
241
241
|
return node;
|
|
242
242
|
},
|
|
243
243
|
}`
|
|
@@ -246,9 +246,9 @@ export class ReferenceComponent extends Component {
|
|
|
246
246
|
} else if (type === "TableView") {
|
|
247
247
|
event = `, {
|
|
248
248
|
itemSize: () => math.size(100, 100),
|
|
249
|
-
cellForItemAt: (
|
|
249
|
+
cellForItemAt: (this:${className}, indexPath, collectionView) => {
|
|
250
250
|
const node = collectionView.dequeueReusableCell("cell", indexPath)
|
|
251
|
-
//node.getComponent(TableVIewItem).refreshUI(
|
|
251
|
+
//node.getComponent(TableVIewItem).refreshUI(this.viewModel.${name}[indexPath.row])
|
|
252
252
|
return node
|
|
253
253
|
},
|
|
254
254
|
}`
|
|
@@ -432,7 +432,7 @@ export class ${className} extends ViewModel(${this.baseWindowName}) {${sx.text}\
|
|
|
432
432
|
const typeMap: Record<string, string> = {
|
|
433
433
|
'Label': 'string',
|
|
434
434
|
'RichText': 'string',
|
|
435
|
-
'Sprite': 'SpriteFrame',
|
|
435
|
+
'Sprite': 'SpriteFrame | { bundle: string, path: string }',
|
|
436
436
|
'Button': 'boolean', // Button 通常绑定激活状态(true/false)
|
|
437
437
|
'ProgressBar': 'number', // 进度条应为 number (0~1)
|
|
438
438
|
'Skeleton': 'sp.SkeletonData',
|
package/assets/core/ViewModel.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { math } from 'cc';
|
|
|
17
17
|
import { YXCollectionView, YXIndexPath } from '../lib/collectView/lib_collect/yx-collection-view';
|
|
18
18
|
import { EventTouch } from 'cc';
|
|
19
19
|
import { YXPagelayout } from '../lib/collectView/lib_collect/yx-page-layout';
|
|
20
|
+
import { SpriteFrame } from 'cc';
|
|
20
21
|
|
|
21
22
|
interface IBindingData extends ITableViewEvents, IBindingDataEvents {
|
|
22
23
|
dataPath: string;
|
|
@@ -28,32 +29,35 @@ interface IBindingData extends ITableViewEvents, IBindingDataEvents {
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
interface IBindingDataEvents {
|
|
31
|
-
reset?: (
|
|
32
|
-
event?: (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
reset?: (this: any, value: any, com: Component) => void;
|
|
33
|
+
event?: (this: any) => void;
|
|
34
|
+
/**动态加载spine的 sp.SkeletonData完成 */
|
|
35
|
+
spineFinish?: (this: any) => void;
|
|
36
|
+
touchStart?: (this: any, event: EventTouch) => void;
|
|
37
|
+
touchMove?: (this: any, event: EventTouch) => void;
|
|
38
|
+
touchEnd?: (this: any, event: EventTouch) => void;
|
|
39
|
+
touchCancel?: (this: any, event: EventTouch) => void;
|
|
40
|
+
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
|
|
40
44
|
interface ITableViewEvents {
|
|
41
45
|
/**列表相关 */
|
|
42
|
-
itemSize: (
|
|
43
|
-
cellForItemAt: (
|
|
44
|
-
onTouchCellAt?: (
|
|
45
|
-
numberOfItems?: (
|
|
46
|
-
moveFinish?: (
|
|
46
|
+
itemSize: (this: any) => Size,
|
|
47
|
+
cellForItemAt: (this: any, indexPath: IIndexPath, collectionView: ListView) => Node,
|
|
48
|
+
onTouchCellAt?: (this: any, indexPath: YXIndexPath) => void
|
|
49
|
+
numberOfItems?: (this: any) => number;
|
|
50
|
+
moveFinish?: (this: any, indexPath: IIndexPath) => void
|
|
47
51
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
interface ICollectViewEvents {
|
|
51
55
|
/**列表相关 */
|
|
52
|
-
layout: (
|
|
53
|
-
cellForItemAt: (
|
|
54
|
-
itemSize?: ((
|
|
55
|
-
onTouchCellAt?: (
|
|
56
|
-
numberOfItems?: ((
|
|
56
|
+
layout: (this: any) => YXFlowLayout,
|
|
57
|
+
cellForItemAt: (this: any, indexPath: YXIndexPath, collectionView: YXCollectionView) => Node
|
|
58
|
+
itemSize?: ((this: any, indexPath: YXIndexPath, layout: YXFlowLayout, collectionView: YXCollectionView) => math.Size),
|
|
59
|
+
onTouchCellAt?: (this: any, indexPath: YXIndexPath) => void
|
|
60
|
+
numberOfItems?: ((this: any, section: number, collectionView: YXCollectionView) => number);
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// 全局存储绑定关系: { className -> { uiProp: dataPath } }
|
|
@@ -135,6 +139,7 @@ export function Bind<T extends Component>(path?: string, param?: IBindingDataEve
|
|
|
135
139
|
itemSize: null,
|
|
136
140
|
cellForItemAt: null,
|
|
137
141
|
numberOfItems: null,
|
|
142
|
+
spineFinish: param?.spineFinish,
|
|
138
143
|
touchStart: param?.touchStart,
|
|
139
144
|
touchMove: param?.touchMove,
|
|
140
145
|
touchEnd: param?.touchEnd,
|
|
@@ -281,10 +286,12 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
281
286
|
|
|
282
287
|
protected onLoad(): void {
|
|
283
288
|
super.onLoad()
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
289
|
+
if (this.config) {
|
|
290
|
+
const module = this.config.module;
|
|
291
|
+
const name = this.config.name.replace('Window', '');
|
|
292
|
+
const manager: any = (js.getClassByName(`${module}Manager`))
|
|
293
|
+
manager.Ins[`${name}Data`] = this.viewModel
|
|
294
|
+
}
|
|
288
295
|
}
|
|
289
296
|
// 在 withDataBinding 返回的 class 中
|
|
290
297
|
protected onDestroy(): void {
|
|
@@ -370,7 +377,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
370
377
|
const btnCall = (btn) => {
|
|
371
378
|
tempData.value = btn.node.active
|
|
372
379
|
self.viewModel[sx] = tempData
|
|
373
|
-
data.event?.(self)
|
|
380
|
+
data.event?.call(self)
|
|
374
381
|
self[`onClick_${sx}`]?.(btn)
|
|
375
382
|
}
|
|
376
383
|
com_btn[touch_click] = btnCall
|
|
@@ -381,7 +388,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
381
388
|
if (data.touchStart && !com_btn[touch_start]) {
|
|
382
389
|
com_btn.node.off(Node.EventType.TOUCH_START, com_btn[touch_start]);
|
|
383
390
|
const call_start = (btn) => {
|
|
384
|
-
data.touchStart?.(self, btn)
|
|
391
|
+
data.touchStart?.call(self, btn)
|
|
385
392
|
}
|
|
386
393
|
com_btn[touch_start] = call_start
|
|
387
394
|
com_btn.node.on(Node.EventType.TOUCH_START, com_btn[touch_start]);
|
|
@@ -390,7 +397,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
390
397
|
if (data.touchMove && !com_btn[touch_start]) {
|
|
391
398
|
com_btn.node.off(Node.EventType.TOUCH_MOVE, com_btn[touch_start]);
|
|
392
399
|
const call_start = (btn) => {
|
|
393
|
-
data.touchMove?.(self, btn)
|
|
400
|
+
data.touchMove?.call(self, btn)
|
|
394
401
|
}
|
|
395
402
|
com_btn[touch_start] = call_start
|
|
396
403
|
com_btn.node.on(Node.EventType.TOUCH_MOVE, com_btn[touch_start]);
|
|
@@ -399,7 +406,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
399
406
|
if (data.touchEnd && !com_btn[touch_start]) {
|
|
400
407
|
com_btn.node.off(Node.EventType.TOUCH_END, com_btn[touch_start]);
|
|
401
408
|
const call_start = (btn) => {
|
|
402
|
-
data.touchEnd?.(self, btn)
|
|
409
|
+
data.touchEnd?.call(self, btn)
|
|
403
410
|
}
|
|
404
411
|
com_btn[touch_start] = call_start
|
|
405
412
|
com_btn.node.on(Node.EventType.TOUCH_END, com_btn[touch_start]);
|
|
@@ -408,7 +415,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
408
415
|
if (data.touchCancel && !com_btn[touch_start]) {
|
|
409
416
|
com_btn.node.off(Node.EventType.TOUCH_CANCEL, com_btn[touch_start]);
|
|
410
417
|
const call_start = (btn) => {
|
|
411
|
-
data.touchCancel?.(self, btn)
|
|
418
|
+
data.touchCancel?.call(self, btn)
|
|
412
419
|
}
|
|
413
420
|
com_btn[touch_start] = call_start
|
|
414
421
|
com_btn.node.on(Node.EventType.TOUCH_CANCEL, com_btn[touch_start]);
|
|
@@ -425,7 +432,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
425
432
|
const slideCall = (slider) => {
|
|
426
433
|
tempData.value = slider.progress
|
|
427
434
|
self.viewModel[sx] = tempData
|
|
428
|
-
data.event?.(self)
|
|
435
|
+
data.event?.call(self)
|
|
429
436
|
self[`onClick_${sx}`]?.(slider)
|
|
430
437
|
}
|
|
431
438
|
com_btn[touch_click] = slideCall
|
|
@@ -443,7 +450,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
443
450
|
const toggleCall = (toggle) => {
|
|
444
451
|
tempData.value = toggle.isChecked
|
|
445
452
|
self.viewModel[sx] = tempData
|
|
446
|
-
data.event?.(self)
|
|
453
|
+
data.event?.call(self)
|
|
447
454
|
self[`onClick_${sx}`]?.(toggle)
|
|
448
455
|
}
|
|
449
456
|
com_btn[touch_click] = toggleCall
|
|
@@ -461,7 +468,7 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
461
468
|
const ebCall = (editbox: EditBox) => {
|
|
462
469
|
tempData.value = editbox.textLabel.string
|
|
463
470
|
self.viewModel[sx] = tempData
|
|
464
|
-
data.event?.(self)
|
|
471
|
+
data.event?.call(self)
|
|
465
472
|
self[`onClick_${sx}`]?.(editbox)
|
|
466
473
|
}
|
|
467
474
|
com_btn[touch_click] = ebCall
|
|
@@ -480,14 +487,14 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
480
487
|
switch (data.type) {
|
|
481
488
|
case 'cc.Label':
|
|
482
489
|
if (data.reset) {
|
|
483
|
-
data.reset(self, value, com);
|
|
490
|
+
data.reset.call(self, value, com);
|
|
484
491
|
} else {
|
|
485
492
|
if (value != undefined && value !== null) (com as Label).string = value?.toString() || '';
|
|
486
493
|
}
|
|
487
494
|
break;
|
|
488
495
|
case 'cc.RichText':
|
|
489
496
|
if (data.reset) {
|
|
490
|
-
data.reset(self, value, com);
|
|
497
|
+
data.reset.call(self, value, com);
|
|
491
498
|
} else
|
|
492
499
|
if (value != undefined && value !== null)
|
|
493
500
|
(com as RichText).string = value?.toString() || '';
|
|
@@ -496,34 +503,59 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
496
503
|
// 假设 value 是 SpriteFrame 路径或资源
|
|
497
504
|
// 需要额外处理资源加载逻辑
|
|
498
505
|
if (data.reset) {
|
|
499
|
-
data.reset(self, value, com);
|
|
506
|
+
data.reset.call(self, value, com);
|
|
500
507
|
} else
|
|
501
|
-
if (value != undefined && value !== null)
|
|
508
|
+
if (value != undefined && value !== null) {
|
|
509
|
+
if (value instanceof SpriteFrame)
|
|
510
|
+
(com as Sprite).spriteFrame = value;
|
|
511
|
+
else {
|
|
512
|
+
const data = ExComponentModule.EmitGetSprite(value)
|
|
513
|
+
if (data) (com as Sprite).spriteFrame = data;
|
|
514
|
+
else {
|
|
515
|
+
ExComponentModule.EmitLoadSprite(value).then(sprite => { if (com && com.isValid) (com as Sprite).spriteFrame = sprite; }).catch(() => { });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
502
519
|
break;
|
|
503
520
|
case 'cc.Button':
|
|
504
521
|
const com_btn = (com as Button);
|
|
505
522
|
if (data.reset) {
|
|
506
|
-
data.reset(self, value, com);
|
|
523
|
+
data.reset.call(self, value, com);
|
|
507
524
|
} else
|
|
508
525
|
com_btn.node.active = value ?? true;
|
|
509
526
|
break;
|
|
510
527
|
case 'cc.ProgressBar':
|
|
511
528
|
if (data.reset) {
|
|
512
|
-
data.reset(self, value, com);
|
|
529
|
+
data.reset.call(self, value, com);
|
|
513
530
|
} else
|
|
514
531
|
if (value != undefined && value !== null) (com as ProgressBar).progress = Number(value) || 0;
|
|
515
532
|
break;
|
|
516
|
-
case '
|
|
533
|
+
case 'sp.Skeleton':
|
|
517
534
|
if (data.reset) {
|
|
518
|
-
data.reset(self, value, com);
|
|
535
|
+
data.reset.call(self, value, com);
|
|
519
536
|
} else
|
|
520
|
-
if (value != undefined && value !== null)
|
|
537
|
+
if (value != undefined && value !== null)
|
|
538
|
+
if (value instanceof sp.SkeletonData)
|
|
539
|
+
(com as sp.Skeleton).skeletonData = value
|
|
540
|
+
else {
|
|
541
|
+
const dataSpine = ExComponentModule.EmitGetSpine(value)
|
|
542
|
+
if (dataSpine) {
|
|
543
|
+
(com as sp.Skeleton).skeletonData = value;
|
|
544
|
+
data.spineFinish.call(self)
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
ExComponentModule.EmitLoadSpine(value).then(sprite => {
|
|
548
|
+
if (sprite) { if (com && com.isValid) (com as sp.Skeleton).skeletonData = sprite; }
|
|
549
|
+
data.spineFinish.call(self)
|
|
550
|
+
}).catch(() => { });
|
|
551
|
+
}
|
|
552
|
+
}
|
|
521
553
|
break;
|
|
522
554
|
case 'cc.Slider':
|
|
523
555
|
{
|
|
524
556
|
const com_sld = (com as Slider);
|
|
525
557
|
if (data.reset) {
|
|
526
|
-
data.reset(self, value, com);
|
|
558
|
+
data.reset.call(self, value, com);
|
|
527
559
|
} else
|
|
528
560
|
if (value != undefined && value !== null) com_sld.progress = Number(value) || 0;
|
|
529
561
|
}
|
|
@@ -532,7 +564,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
532
564
|
{
|
|
533
565
|
const com_tg = (com as Toggle);
|
|
534
566
|
if (data.reset) {
|
|
535
|
-
data.reset(self, value, com);
|
|
567
|
+
data.reset.call(self, value, com);
|
|
536
568
|
} else
|
|
537
569
|
if (value != undefined && value !== null) com_tg.isChecked = Boolean(value);
|
|
538
570
|
}
|
|
@@ -541,7 +573,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
541
573
|
{
|
|
542
574
|
const com_eb = (com as EditBox);
|
|
543
575
|
if (data.reset) {
|
|
544
|
-
data.reset(self, value, com);
|
|
576
|
+
data.reset.call(self, value, com);
|
|
545
577
|
} else
|
|
546
578
|
if (value != undefined && value !== null) com_eb.string = value?.toString() || '';
|
|
547
579
|
}
|
|
@@ -550,7 +582,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
550
582
|
{
|
|
551
583
|
const com_tgc = (com as ToggleContainer);
|
|
552
584
|
if (data.reset) {
|
|
553
|
-
data.reset(self, value, com);
|
|
585
|
+
data.reset.call(self, value, com);
|
|
554
586
|
}
|
|
555
587
|
//事件
|
|
556
588
|
if (com_tgc.checkEvents.length <= 0) {
|
|
@@ -564,7 +596,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
564
596
|
tempData.skip = true;
|
|
565
597
|
tempData.value = com_tgc.toggleItems.indexOf(toggle)
|
|
566
598
|
self.viewModel[sx] = tempData
|
|
567
|
-
data.event?.(self)
|
|
599
|
+
data.event?.call(self)
|
|
568
600
|
self[`onClick_${sx}`]?.(toggle)
|
|
569
601
|
}
|
|
570
602
|
com_tgc.checkEvents.push(clickEventHandler);
|
|
@@ -580,7 +612,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
580
612
|
{
|
|
581
613
|
|
|
582
614
|
const com_list = (com as TableView);
|
|
583
|
-
if (data.reset) { data.reset(self, value, com); }
|
|
615
|
+
if (data.reset) { data.reset.call(self, value, com); }
|
|
584
616
|
|
|
585
617
|
// ✅ 关键:不要缓存 count,而是通过 dataPath 动态取值
|
|
586
618
|
const getLatestDataLength = () => {
|
|
@@ -592,19 +624,19 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
592
624
|
com_list.reload()
|
|
593
625
|
} else {
|
|
594
626
|
const cellForItemAt = (indexPath: IIndexPath, collectionView: ListView) => {
|
|
595
|
-
return data.cellForItemAt(self, indexPath, collectionView);
|
|
627
|
+
return data.cellForItemAt.call(self, indexPath, collectionView);
|
|
596
628
|
}
|
|
597
629
|
const numberOfItems = () => {
|
|
598
630
|
return getLatestDataLength()
|
|
599
631
|
}
|
|
600
632
|
const itemSize = () => {
|
|
601
|
-
return data.itemSize(self)
|
|
633
|
+
return data.itemSize.call(self)
|
|
602
634
|
}
|
|
603
635
|
const moveFinish = (indexPath: IIndexPath) => {
|
|
604
|
-
data.moveFinish?.(self, indexPath)
|
|
636
|
+
data.moveFinish?.call(self, indexPath)
|
|
605
637
|
}
|
|
606
638
|
const onTouchCellAt = (indexPath: IIndexPath) => {
|
|
607
|
-
data.onTouchCellAt?.(self, indexPath)
|
|
639
|
+
data.onTouchCellAt?.call(self, indexPath)
|
|
608
640
|
}
|
|
609
641
|
|
|
610
642
|
const classView = { cellForItemAt, numberOfItems, itemSize, moveFinish, onTouchCellAt }
|
|
@@ -643,7 +675,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
643
675
|
// 确定列表内一共需要显示多少条内容
|
|
644
676
|
// table_collection.isCenterShow = false;//少于宽度,居中显示
|
|
645
677
|
table_collection.numberOfItems = () => {
|
|
646
|
-
const count = data.numberOfItems ? data.numberOfItems(self) : getLatestDataLength()
|
|
678
|
+
const count = data.numberOfItems ? data.numberOfItems.call(self) : getLatestDataLength()
|
|
647
679
|
if (table_collection.layout instanceof YXPagelayout) {
|
|
648
680
|
table_collection.layout.dataCount = count
|
|
649
681
|
return count * 3
|
|
@@ -652,13 +684,13 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
652
684
|
}
|
|
653
685
|
}
|
|
654
686
|
table_collection.cellForItemAt = (indexPath, collectionView) => {
|
|
655
|
-
return data.cellForItemAt(self, indexPath, collectionView as any) // 返回这个节点给列表显示
|
|
687
|
+
return data.cellForItemAt.call(self, indexPath, collectionView as any) // 返回这个节点给列表显示
|
|
656
688
|
}
|
|
657
689
|
|
|
658
690
|
table_collection.onTouchCellAt = (indexPath, collectionView) => {
|
|
659
691
|
// 通过 getVisibleNode 获取到点击的节点
|
|
660
692
|
//const cell = collectionView.getVisibleCellNode(indexPath)
|
|
661
|
-
data.onTouchCellAt?.(self, indexPath)
|
|
693
|
+
data.onTouchCellAt?.call(self, indexPath)
|
|
662
694
|
}
|
|
663
695
|
table_collection.onCellDisplay = (cell, indexPath) => { }
|
|
664
696
|
table_collection.onCellEndDisplay = (cell, indexPath) => { }
|
|
@@ -687,3 +719,4 @@ export function Ref(target: any, propertyKey: string) {
|
|
|
687
719
|
const refList = refMap.get(target)
|
|
688
720
|
refList.push(propertyKey)
|
|
689
721
|
}
|
|
722
|
+
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { sp } from "cc";
|
|
2
|
+
import { SpriteFrame } from "cc";
|
|
1
3
|
import { Button } from "cc";
|
|
2
4
|
|
|
3
5
|
|
|
@@ -11,6 +13,9 @@ export class ExComponentModule {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
param: { click: (comp: Button) => void }
|
|
16
|
+
paramSprite: { loadSprite: (param: { bundle: string, path: string }) => Promise<SpriteFrame>, getSprite: (param: { bundle: string, path: string }) => SpriteFrame }
|
|
17
|
+
paramSpine: { loadSpine: (param: { bundle: string, path: string }) => Promise<sp.SkeletonData>, getSpine: (param: { bundle: string, path: string }) => sp.SkeletonData }
|
|
18
|
+
|
|
14
19
|
ResetBaseWindow: string = "BaseWindow";
|
|
15
20
|
static Init() {
|
|
16
21
|
|
|
@@ -19,16 +24,38 @@ export class ExComponentModule {
|
|
|
19
24
|
static OnButtonClick(param: { click: (comp: Button) => void }) {
|
|
20
25
|
ExComponentModule.Ins.param = param
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
ExComponentModule.Ins.param.click(btn)
|
|
24
|
-
}
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
static ResetBaseWindow(name?: string, isGet?: boolean) {
|
|
27
30
|
if (!isGet) ExComponentModule.Ins.ResetBaseWindow = name
|
|
28
31
|
return ExComponentModule.Ins.ResetBaseWindow
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
static OnLoadSprite(param: { loadSprite: (param: { bundle: string, path: string }) => Promise<SpriteFrame>, getSprite: (param: { bundle: string, path: string }) => SpriteFrame }) {
|
|
35
|
+
ExComponentModule.Ins.paramSprite = param
|
|
36
|
+
}
|
|
37
|
+
static OnLoadSpine(param: { loadSpine: (param: { bundle: string, path: string }) => Promise<sp.SkeletonData>, getSpine: (param: { bundle: string, path: string }) => sp.SkeletonData }) {
|
|
38
|
+
ExComponentModule.Ins.paramSpine = param
|
|
39
|
+
}
|
|
31
40
|
|
|
41
|
+
|
|
42
|
+
static Emit(btn: Button) {
|
|
43
|
+
ExComponentModule.Ins.param.click(btn)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static async EmitLoadSprite(param: any): Promise<SpriteFrame> {
|
|
47
|
+
return ExComponentModule.Ins.paramSprite.loadSprite(param)
|
|
48
|
+
}
|
|
49
|
+
static EmitGetSprite(param: any): SpriteFrame {
|
|
50
|
+
return ExComponentModule.Ins.paramSprite.getSprite(param)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static async EmitLoadSpine(param: any): Promise<sp.SkeletonData> {
|
|
54
|
+
return ExComponentModule.Ins.paramSpine.loadSpine(param)
|
|
55
|
+
}
|
|
56
|
+
static EmitGetSpine(param: any): sp.SkeletonData {
|
|
57
|
+
return ExComponentModule.Ins.paramSpine.getSpine(param)
|
|
58
|
+
}
|
|
32
59
|
}
|
|
33
60
|
window.ExComponentModule = ExComponentModule;
|
|
34
61
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SpriteFrame } from "cc";
|
|
2
|
+
import { sp } from "cc";
|
|
3
|
+
import { Sprite } from "cc";
|
|
1
4
|
import { Button } from "cc";
|
|
2
5
|
declare global {
|
|
3
6
|
namespace ExComponentModule {
|
|
@@ -5,9 +8,18 @@ declare global {
|
|
|
5
8
|
function Init();
|
|
6
9
|
/**监听所有按钮的点击事件 */
|
|
7
10
|
function OnButtonClick(param: { click: (comp: Button) => void });
|
|
11
|
+
/**监听加载图片 */
|
|
12
|
+
function OnLoadSprite(param: { loadSprite: (param: { bundle: string, path: string }) => Promise<SpriteFrame>, getSprite: (param: { bundle: string, path: string }) => SpriteFrame });
|
|
13
|
+
function OnLoadSpine(param: { loadSpine: (param: { bundle: string, path: string }) => Promise<sp.SkeletonData>, getSpine: (param: { bundle: string, path: string }) => sp.SkeletonData });
|
|
14
|
+
/**重置基础窗口 */
|
|
8
15
|
function ResetBaseWindow(name?: string, isGet?: boolean);
|
|
9
16
|
/**组件:内部使用方法 */
|
|
10
17
|
function Emit(btn: Button);
|
|
11
18
|
|
|
19
|
+
//#region 组件:内部使用方法----------------
|
|
20
|
+
function EmitLoadSprite(param: any): Promise<SpriteFrame>;
|
|
21
|
+
function EmitGetSprite(param: any): SpriteFrame;
|
|
22
|
+
function EmitLoadSpine(param: any): Promise<sp.SkeletonData>;
|
|
23
|
+
function EmitGetSpine(param: any): sp.SkeletonData;
|
|
12
24
|
}
|
|
13
25
|
}
|