@cc-component/cc-ex-component 1.3.1 → 1.3.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.
- package/assets/core/BaseWindow.ts +11 -1
- package/assets/core/ReferenceComponent.ts +5 -3
- package/assets/ex/ExCommon.ts +12 -0
- package/assets/interface/ExComponentModule.ts +38 -0
- package/assets/interface/ExComponentModule.ts.meta +9 -0
- package/assets/interface/Interface.ts +13 -0
- package/assets/interface/Interface.ts.meta +9 -0
- package/assets/interface.meta +9 -0
- package/index.ts +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UIOpacity, tween, Vec3 } from 'cc';
|
|
2
2
|
import { _decorator, Component, Node } from 'cc';
|
|
3
3
|
import { BaseReference } from './BaseReference';
|
|
4
|
+
import { Button } from 'cc';
|
|
4
5
|
const { ccclass, property } = _decorator;
|
|
5
6
|
|
|
6
7
|
@ccclass('BaseWindow')
|
|
@@ -29,13 +30,22 @@ export class BaseWindow extends BaseReference {
|
|
|
29
30
|
if (!this.root || !this.maskOpacity) { return }
|
|
30
31
|
this.showAnim()
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* 关闭界面
|
|
35
|
+
* @param param
|
|
36
|
+
* @param param.is_anim 是否有动画
|
|
37
|
+
* @param param.param 关闭参数
|
|
38
|
+
* @param param.finish 关闭完成回调
|
|
39
|
+
* @param param.comp 关闭的按钮组件
|
|
40
|
+
* @param param.time 关闭的按钮的时间
|
|
41
|
+
*/
|
|
32
42
|
public close(param?: { is_anim?: boolean, param?: any, finish?: Function }) {
|
|
33
43
|
this.paramClose = param;
|
|
34
44
|
this.param?.callBack?.(param?.param)//回调方法
|
|
35
45
|
if (param?.is_anim && this.root && this.maskOpacity) {
|
|
36
46
|
this.hideAnim()
|
|
37
47
|
} else {
|
|
38
|
-
param?.finish()
|
|
48
|
+
param?.finish?.()
|
|
39
49
|
this.destroyWindow()
|
|
40
50
|
}
|
|
41
51
|
}
|
|
@@ -27,7 +27,6 @@ export class ReferenceComponent extends Component {
|
|
|
27
27
|
@property({ displayName: "复制属性" })
|
|
28
28
|
private get refresh() { return this._refresh; }
|
|
29
29
|
private set refresh(val: boolean) {
|
|
30
|
-
console.error('打印了')
|
|
31
30
|
if (EDITOR_NOT_IN_PREVIEW) {
|
|
32
31
|
this.initNodeList();
|
|
33
32
|
this.genCode();
|
|
@@ -85,6 +84,8 @@ export class ReferenceComponent extends Component {
|
|
|
85
84
|
comList2 = ["YXCollectionView", "TableView"]
|
|
86
85
|
comList_base = ["EditBox", "Toggle", "ToggleContainer", "Slider", "Button", "ProgressBar"]
|
|
87
86
|
|
|
87
|
+
/** 生成代码基础窗口名称 */
|
|
88
|
+
public baseWindowName = "BaseWindow"
|
|
88
89
|
skipList = ["Button"]//跳过按钮类型
|
|
89
90
|
protected onLoad(): void {
|
|
90
91
|
if (EDITOR_NOT_IN_PREVIEW) {//处理编辑器逻辑
|
|
@@ -343,9 +344,10 @@ ${sx_this}
|
|
|
343
344
|
/** 生成引用节点的获取代码 并复制到剪切板 */
|
|
344
345
|
private genCodeVmDataAll() {
|
|
345
346
|
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
347
|
+
this.baseWindowName = ExComponentModule.ResetBaseWindow('', true)
|
|
346
348
|
let importStr = `
|
|
347
349
|
import { Label, RichText, ProgressBar, Sprite, EditBox, Toggle, Slider, ToggleContainer, Button, math, SpriteFrame, _decorator , Node} from 'cc';
|
|
348
|
-
import { ViewModel, BindViewModel, BindTable, BindCollect, Bind, Ref, BaseViewModelData, YXCollectionView, YXFlowLayout, TableView,
|
|
350
|
+
import { ViewModel, BindViewModel, BindTable, BindCollect, Bind, Ref, BaseViewModelData, YXCollectionView, YXFlowLayout, TableView, BaseWindow } from 'db://assets/pkg-export/@cc-component/cc-ex-component';
|
|
349
351
|
const { ccclass, property } = _decorator;`
|
|
350
352
|
|
|
351
353
|
if (this.isComDebug) {
|
|
@@ -378,7 +380,7 @@ const { ccclass, property } = _decorator;
|
|
|
378
380
|
const classView = `
|
|
379
381
|
@BindViewModel(${className}Data)
|
|
380
382
|
@ccclass('${className}')
|
|
381
|
-
export class ${className} extends ViewModel(
|
|
383
|
+
export class ${className} extends ViewModel(${this.baseWindowName}) {${sx.text}\n${onload}\n\n${sx.event}\n}`
|
|
382
384
|
|
|
383
385
|
text += classView
|
|
384
386
|
|
package/assets/ex/ExCommon.ts
CHANGED
|
@@ -627,6 +627,18 @@ sp.Skeleton.prototype.fromHEX = function (this: sp.Skeleton, hex: string): void
|
|
|
627
627
|
const label = this;
|
|
628
628
|
label.color = (new Color()).fromHEX(hex)
|
|
629
629
|
};
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
// 保存原始方法
|
|
633
|
+
const originalOnTouchEnded = Button.prototype["_onTouchEnded"];
|
|
634
|
+
// 重写 _onTouchEnded
|
|
635
|
+
Button.prototype["_onTouchEnded"] = function (...args: any[]) {
|
|
636
|
+
// 播放点击音效
|
|
637
|
+
ExComponentModule.Emit(this);
|
|
638
|
+
// 调用原始逻辑
|
|
639
|
+
return originalOnTouchEnded.apply(this, args);
|
|
640
|
+
};
|
|
641
|
+
|
|
630
642
|
export { };
|
|
631
643
|
|
|
632
644
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Button } from "cc";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class ExComponentModule {
|
|
5
|
+
static _instance: ExComponentModule;
|
|
6
|
+
static get Ins() {
|
|
7
|
+
if (!this._instance) {
|
|
8
|
+
this._instance = new ExComponentModule();
|
|
9
|
+
}
|
|
10
|
+
return this._instance;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
param: { click: (comp: Button) => void }
|
|
14
|
+
ResetBaseWindow: string = "BaseWindow";
|
|
15
|
+
static Init() {
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static OnButtonClick(param: { click: (comp: Button) => void }) {
|
|
20
|
+
ExComponentModule.Ins.param = param
|
|
21
|
+
}
|
|
22
|
+
static Emit(btn: Button) {
|
|
23
|
+
ExComponentModule.Ins.param.click(btn)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static ResetBaseWindow(name?: string, isGet?: boolean) {
|
|
27
|
+
if (!isGet) ExComponentModule.Ins.ResetBaseWindow = name
|
|
28
|
+
return ExComponentModule.Ins.ResetBaseWindow
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
window.ExComponentModule = ExComponentModule;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export function ResetBaseWindow(path?: string) {
|
|
37
|
+
return function (target: any) { ExComponentModule.ResetBaseWindow(path) }
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Button } from "cc";
|
|
2
|
+
declare global {
|
|
3
|
+
namespace ExComponentModule {
|
|
4
|
+
/**初始化 */
|
|
5
|
+
function Init();
|
|
6
|
+
/**监听所有按钮的点击事件 */
|
|
7
|
+
function OnButtonClick(param: { click: (comp: Button) => void });
|
|
8
|
+
function ResetBaseWindow(name?: string, isGet?: boolean);
|
|
9
|
+
/**组件:内部使用方法 */
|
|
10
|
+
function Emit(btn: Button);
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
}
|
package/index.ts
CHANGED
|
@@ -5,7 +5,8 @@ export * from './assets/core/ViewModel';
|
|
|
5
5
|
export * from './assets/core/ReferenceComponent';
|
|
6
6
|
export * from './assets/core/BaseReference';
|
|
7
7
|
export * from './assets/core/BaseViewModelData';
|
|
8
|
-
|
|
8
|
+
export * from './assets/interface/Interface';
|
|
9
|
+
export * from './assets/interface/ExComponentModule';
|
|
9
10
|
|
|
10
11
|
export * from './assets/lib/tableView/TableView';
|
|
11
12
|
export * from './assets/lib/collectView/lib_collect/yx-collection-view';
|