@cc-component/cc-ex-component 1.2.6 → 1.2.8
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/ReferenceComponent.ts +24 -17
- package/assets/core/ViewModel.ts +50 -6
- package/package.json +1 -1
- package/assets/platform/Interface.ts +0 -80
- package/assets/platform/Interface.ts.meta +0 -9
- package/assets/platform/android/AndroidModule.ts +0 -12
- package/assets/platform/android/AndroidModule.ts.meta +0 -9
- package/assets/platform/android/AndroidSDK.ts +0 -186
- package/assets/platform/android/AndroidSDK.ts.meta +0 -1
- package/assets/platform/android/AnyThinkAds/ATBanner.ts +0 -266
- package/assets/platform/android/AnyThinkAds/ATBanner.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATInterstitial.ts +0 -185
- package/assets/platform/android/AnyThinkAds/ATInterstitial.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATInterstitialAuto.ts +0 -180
- package/assets/platform/android/AnyThinkAds/ATInterstitialAuto.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATNative.ts +0 -256
- package/assets/platform/android/AnyThinkAds/ATNative.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATRewardedAutoVideo.ts +0 -175
- package/assets/platform/android/AnyThinkAds/ATRewardedAutoVideo.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATRewardedVideo.ts +0 -243
- package/assets/platform/android/AnyThinkAds/ATRewardedVideo.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATSDK.ts +0 -222
- package/assets/platform/android/AnyThinkAds/ATSDK.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/ATSplash.ts +0 -155
- package/assets/platform/android/AnyThinkAds/ATSplash.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidBannerTS.ts +0 -71
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidBannerTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialAutoTS.ts +0 -52
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialAutoTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialTS.ts +0 -41
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidNativeTS.ts +0 -47
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidNativeTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoAutoTS.ts +0 -52
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoAutoTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoTS.ts +0 -41
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidSplashTS.ts +0 -42
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidSplashTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidTS.ts +0 -73
- package/assets/platform/android/AnyThinkAds/Android/ATAndroidTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/Android.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSBannerTS.ts +0 -66
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSBannerTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitiaAutolTS.ts +0 -54
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitiaAutolTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitialTS.ts +0 -43
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitialTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSNativeTS.ts +0 -47
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSNativeTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedAutoVideoTS.ts +0 -55
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedAutoVideoTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedVideoTS.ts +0 -43
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedVideoTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSSplashTS.ts +0 -47
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSSplashTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSTS.ts +0 -76
- package/assets/platform/android/AnyThinkAds/iOS/ATiOSTS.ts.meta +0 -9
- package/assets/platform/android/AnyThinkAds/iOS.meta +0 -9
- package/assets/platform/android/AnyThinkAds.meta +0 -9
- package/assets/platform/android/iOSSDK.ts +0 -14
- package/assets/platform/android/iOSSDK.ts.meta +0 -1
- package/assets/platform/android.meta +0 -11
- package/assets/platform/base/EditorSDK.ts +0 -30
- package/assets/platform/base/EditorSDK.ts.meta +0 -1
- package/assets/platform/base/PlatfprmModule.ts +0 -152
- package/assets/platform/base/PlatfprmModule.ts.meta +0 -9
- package/assets/platform/base/SDKBase.ts +0 -59
- package/assets/platform/base/SDKBase.ts.meta +0 -9
- package/assets/platform/base/SDKEnum.ts +0 -127
- package/assets/platform/base/SDKEnum.ts.meta +0 -9
- package/assets/platform/base/TTSDK.ts +0 -366
- package/assets/platform/base/TTSDK.ts.meta +0 -9
- package/assets/platform/base/WXSDK.ts +0 -149
- package/assets/platform/base/WXSDK.ts.meta +0 -1
- package/assets/platform/base.meta +0 -9
- package/assets/platform/wx/MiniSDK.ts +0 -1039
- package/assets/platform/wx/MiniSDK.ts.meta +0 -9
- package/assets/platform/wx/lib.douyin.d.ts +0 -168
- package/assets/platform/wx/lib.douyin.d.ts.meta +0 -9
- package/assets/platform/wx/wxmini.d.ts +0 -2452
- package/assets/platform/wx/wxmini.d.ts.meta +0 -9
- package/assets/platform/wx.meta +0 -9
- package/assets/platform.meta +0 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Sprite } from "cc";
|
|
2
|
+
import { assetManager } from "cc";
|
|
2
3
|
import { Enum } from "cc";
|
|
3
4
|
import { _decorator, Component, js, Node } from "cc";
|
|
4
5
|
import { EDITOR_NOT_IN_PREVIEW } from "cc/env";
|
|
@@ -25,6 +26,7 @@ export class ReferenceComponent extends Component {
|
|
|
25
26
|
@property({ displayName: "复制属性" })
|
|
26
27
|
private get refresh() { return this._refresh; }
|
|
27
28
|
private set refresh(val: boolean) {
|
|
29
|
+
console.error('打印了')
|
|
28
30
|
if (EDITOR_NOT_IN_PREVIEW) {
|
|
29
31
|
this.initNodeList();
|
|
30
32
|
this.genCode();
|
|
@@ -187,6 +189,7 @@ export class ReferenceComponent extends Component {
|
|
|
187
189
|
text += line;
|
|
188
190
|
});
|
|
189
191
|
Editor.Clipboard.write("text", text);
|
|
192
|
+
|
|
190
193
|
console.log("已复制到剪切板");
|
|
191
194
|
}
|
|
192
195
|
|
|
@@ -194,8 +197,8 @@ export class ReferenceComponent extends Component {
|
|
|
194
197
|
private genCodeBind(isCopy: boolean = true, isClass: boolean = false) {
|
|
195
198
|
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
196
199
|
let text = "";
|
|
197
|
-
let eventStr: string = " //#region
|
|
198
|
-
let pix = "onClick_"
|
|
200
|
+
let eventStr: string = " //#region ⚠️ ------------方法事件"
|
|
201
|
+
let pix = "private onClick_"
|
|
199
202
|
// const com = this.node.components.find(v => { return v.reference })
|
|
200
203
|
// const match = com.name.match(/<([^>]+)>/);
|
|
201
204
|
// const className = match && match[1] ? match[1] : "any"
|
|
@@ -203,15 +206,16 @@ export class ReferenceComponent extends Component {
|
|
|
203
206
|
let data = `${className}Data`
|
|
204
207
|
let iinterface = `I${className}Data`
|
|
205
208
|
//console.error("[MLogger Error]", className)
|
|
206
|
-
const viewModel =
|
|
209
|
+
const viewModel =
|
|
210
|
+
`\n //#region ⚠️ ------------自动生成属性
|
|
207
211
|
// ✅ 外部界面调用,刷新UI
|
|
208
212
|
public refreshUI(data: ${iinterface}) { super.refreshUI(data); }
|
|
209
213
|
|
|
210
|
-
|
|
214
|
+
// ✅ 使用新装饰器(自动响应式 + 路径推导)
|
|
211
215
|
@BindViewModel(${className}Data)
|
|
212
216
|
viewModel: ${className}Data;`
|
|
213
217
|
text += viewModel + "\n\n"
|
|
214
|
-
text += `
|
|
218
|
+
text += ` // ✅ UI属性`
|
|
215
219
|
//生成get属性
|
|
216
220
|
this.nodes.forEach(data => {
|
|
217
221
|
let key = data.key;
|
|
@@ -250,7 +254,7 @@ export class ReferenceComponent extends Component {
|
|
|
250
254
|
}
|
|
251
255
|
|
|
252
256
|
let bind = `${bind_pix}("${name}"${this.comList.includes(type) ? event : ""})`
|
|
253
|
-
if (
|
|
257
|
+
if (true) {
|
|
254
258
|
bind = `${bind_pix}("${name}"${this.comList2.includes(type) ? event : ""})`
|
|
255
259
|
}
|
|
256
260
|
if (this.comList_base.includes(type)) {
|
|
@@ -265,12 +269,16 @@ export class ReferenceComponent extends Component {
|
|
|
265
269
|
let line = ` ${bind} @Ref ${name}: ${type};`
|
|
266
270
|
text += line;
|
|
267
271
|
});
|
|
272
|
+
text += `\n //#endregion END`
|
|
268
273
|
|
|
274
|
+
text += `\n\n //#region ⚠️ ------------自定义属性`
|
|
275
|
+
text += `\n\n //#endregion END`
|
|
269
276
|
|
|
270
277
|
if (isCopy) {
|
|
271
278
|
Editor.Clipboard.write("text", text);
|
|
272
279
|
console.log("已复制到剪切板");
|
|
273
280
|
}
|
|
281
|
+
eventStr += `\n //#endregion END`
|
|
274
282
|
return { text: text, event: eventStr }
|
|
275
283
|
|
|
276
284
|
}
|
|
@@ -280,33 +288,33 @@ export class ReferenceComponent extends Component {
|
|
|
280
288
|
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
281
289
|
let text = ""
|
|
282
290
|
let sx_this = ''
|
|
283
|
-
let sx = '
|
|
291
|
+
let sx = ''
|
|
284
292
|
const className = this.node.name
|
|
285
293
|
|
|
286
294
|
let data = `${className}Data`
|
|
287
295
|
let iinterface = `I${className}Data`
|
|
288
296
|
|
|
289
297
|
//生成get属性
|
|
290
|
-
this.nodes.forEach(data => {
|
|
298
|
+
this.nodes.forEach((data, index) => {
|
|
291
299
|
let key = data.key;
|
|
292
300
|
let name = key[0].toLowerCase() + key.substring(1);
|
|
293
301
|
const type = this.getPropertyType(data.com)
|
|
294
302
|
//@ts-ignore
|
|
295
303
|
let line = ` ${name}: ${this.getDataTypeByComponentType(type)};`//`private get ${name}() { return this.rc.get("${key}", ${this.getPropertyType(data.node)}); }`;
|
|
296
|
-
sx += line + "\n";
|
|
304
|
+
sx += line + "" + (index < this.nodes.length - 1 ? "\n" : "");
|
|
297
305
|
|
|
298
306
|
let line_sx = ` this.${name} = ${this.getDataTypeByComponentTypeValue(type)}`
|
|
299
|
-
sx_this += line_sx +
|
|
307
|
+
sx_this += line_sx + (index < this.nodes.length - 1 ? "\n" : "");
|
|
300
308
|
});
|
|
301
309
|
|
|
302
310
|
text = `
|
|
303
|
-
//#region
|
|
311
|
+
//#region ⚠️ ------------数据接口
|
|
304
312
|
export interface ${iinterface} {
|
|
305
313
|
${sx}
|
|
306
314
|
}
|
|
307
|
-
|
|
315
|
+
//#endregion END`;
|
|
308
316
|
text += `
|
|
309
|
-
//#region
|
|
317
|
+
//#region ⚠️ ------------数据对象
|
|
310
318
|
class ${data} extends BaseViewModelData implements ${iinterface} {
|
|
311
319
|
${sx}
|
|
312
320
|
|
|
@@ -315,7 +323,7 @@ ${sx}
|
|
|
315
323
|
${sx_this}
|
|
316
324
|
}
|
|
317
325
|
}
|
|
318
|
-
|
|
326
|
+
//#endregion END`;
|
|
319
327
|
if (isCopy) {
|
|
320
328
|
Editor.Clipboard.write("text", text);
|
|
321
329
|
console.log("已复制到剪切板");
|
|
@@ -331,7 +339,7 @@ ${sx_this}
|
|
|
331
339
|
private genCodeVmDataAll() {
|
|
332
340
|
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
333
341
|
let importStr = `
|
|
334
|
-
import { Label, RichText, ProgressBar, Sprite, EditBox, Toggle, Slider, ToggleContainer, Button, math, SpriteFrame, _decorator } from 'cc';
|
|
342
|
+
import { Label, RichText, ProgressBar, Sprite, EditBox, Toggle, Slider, ToggleContainer, Button, math, SpriteFrame, _decorator , Node} from 'cc';
|
|
335
343
|
import { ViewModel, BindViewModel, BindTable, BindCollect, Bind, Ref, BaseViewModelData, YXCollectionView, YXFlowLayout, TableView, BaseReference } from 'db://assets/pkg-export/@cc-component/cc-ex-component';
|
|
336
344
|
const { ccclass, property } = _decorator;`
|
|
337
345
|
|
|
@@ -354,7 +362,7 @@ const { ccclass, property } = _decorator;
|
|
|
354
362
|
|
|
355
363
|
let iinterface = `I${className}Data`
|
|
356
364
|
const onload = `
|
|
357
|
-
//#region
|
|
365
|
+
//#region ⚠️ ------------初始化
|
|
358
366
|
onLoad(): void {
|
|
359
367
|
|
|
360
368
|
}
|
|
@@ -446,5 +454,4 @@ export class ${className} extends ViewModel(BaseReference) {${sx.text}\n${onload
|
|
|
446
454
|
};
|
|
447
455
|
return typeMap[compType] ?? 'any'; // 默认 fallback
|
|
448
456
|
}
|
|
449
|
-
|
|
450
457
|
}
|
package/assets/core/ViewModel.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { TableView } from '../lib/tableView/TableView';
|
|
|
15
15
|
import { YXFlowLayout } from '../lib/collectView/lib_collect/yx-flow-layout';
|
|
16
16
|
import { math } from 'cc';
|
|
17
17
|
import { YXCollectionView, YXIndexPath } from '../lib/collectView/lib_collect/yx-collection-view';
|
|
18
|
+
import { EventTouch } from 'cc';
|
|
18
19
|
|
|
19
20
|
interface IBindingData extends ITableViewEvents, IBindingDataEvents {
|
|
20
21
|
dataPath: string;
|
|
@@ -25,8 +26,12 @@ interface IBindingData extends ITableViewEvents, IBindingDataEvents {
|
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
interface IBindingDataEvents {
|
|
28
|
-
reset?:
|
|
29
|
-
event?:
|
|
29
|
+
reset?: (self: any, value: any, com: Component) => void;
|
|
30
|
+
event?: (self: any) => void;
|
|
31
|
+
touchStart?: (self: any, event: EventTouch) => void;
|
|
32
|
+
touchMove?: (self: any, event: EventTouch) => void;
|
|
33
|
+
touchEnd?: (self: any, event: EventTouch) => void;
|
|
34
|
+
touchCancel?: (self: any, event: EventTouch) => void;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
|
|
@@ -310,8 +315,9 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
310
315
|
} else
|
|
311
316
|
com_btn.node.active = value ?? true;
|
|
312
317
|
|
|
313
|
-
|
|
314
|
-
|
|
318
|
+
//事件点击
|
|
319
|
+
const touch_click = 'CallClick'
|
|
320
|
+
com_btn.node.off(Button.EventType.CLICK, com_btn[touch_click]);
|
|
315
321
|
tempData.skip = true;
|
|
316
322
|
const btnCall = (btn) => {
|
|
317
323
|
tempData.value = btn.node.active
|
|
@@ -319,8 +325,46 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
319
325
|
data.event?.(self)
|
|
320
326
|
self[`onClick_${sx}`]?.(btn)
|
|
321
327
|
}
|
|
322
|
-
com_btn[
|
|
323
|
-
com_btn.node.on(Button.EventType.CLICK, com_btn[
|
|
328
|
+
com_btn[touch_click] = btnCall
|
|
329
|
+
com_btn.node.on(Button.EventType.CLICK, com_btn[touch_click]);
|
|
330
|
+
|
|
331
|
+
//touch
|
|
332
|
+
if (data.touchStart) {
|
|
333
|
+
const touch_start = 'CALL_TOUCH_START'
|
|
334
|
+
com_btn.node.off(Node.EventType.TOUCH_START, com_btn[touch_start]);
|
|
335
|
+
const call_start = (btn) => {
|
|
336
|
+
data.touchStart?.(self, btn)
|
|
337
|
+
}
|
|
338
|
+
com_btn[touch_start] = call_start
|
|
339
|
+
com_btn.node.on(Node.EventType.TOUCH_START, com_btn[touch_start]);
|
|
340
|
+
}
|
|
341
|
+
if (data.touchMove) {
|
|
342
|
+
const touch_start = 'CALL_TOUCH_MOVE'
|
|
343
|
+
com_btn.node.off(Node.EventType.TOUCH_MOVE, com_btn[touch_start]);
|
|
344
|
+
const call_start = (btn) => {
|
|
345
|
+
data.touchMove?.(self, btn)
|
|
346
|
+
}
|
|
347
|
+
com_btn[touch_start] = call_start
|
|
348
|
+
com_btn.node.on(Node.EventType.TOUCH_MOVE, com_btn[touch_start]);
|
|
349
|
+
}
|
|
350
|
+
if (data.touchEnd) {
|
|
351
|
+
const touch_start = 'CALL_TOUCH_END'
|
|
352
|
+
com_btn.node.off(Node.EventType.TOUCH_END, com_btn[touch_start]);
|
|
353
|
+
const call_start = (btn) => {
|
|
354
|
+
data.touchEnd?.(self, btn)
|
|
355
|
+
}
|
|
356
|
+
com_btn[touch_start] = call_start
|
|
357
|
+
com_btn.node.on(Node.EventType.TOUCH_END, com_btn[touch_start]);
|
|
358
|
+
}
|
|
359
|
+
if (data.touchCancel) {
|
|
360
|
+
const touch_start = 'CALL_TOUCH_CANCEL'
|
|
361
|
+
com_btn.node.off(Node.EventType.TOUCH_CANCEL, com_btn[touch_start]);
|
|
362
|
+
const call_start = (btn) => {
|
|
363
|
+
data.touchCancel?.(self, btn)
|
|
364
|
+
}
|
|
365
|
+
com_btn[touch_start] = call_start
|
|
366
|
+
com_btn.node.on(Node.EventType.TOUCH_CANCEL, com_btn[touch_start]);
|
|
367
|
+
}
|
|
324
368
|
break;
|
|
325
369
|
case 'cc.ProgressBar':
|
|
326
370
|
if (data.reset) {
|
package/package.json
CHANGED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { _decorator, Node } from 'cc';
|
|
2
|
-
import { AdsCall, AdsData, ButtonTouch, PositonData, SDKBuyParam, SDKLoginData, SDKStatus, TTBaseData, TTData, UserInfoData } from './base/SDKEnum';
|
|
3
|
-
import { ICreateUserInfoButton } from './wx/MiniSDK';
|
|
4
|
-
import { SDKBase } from './base/SDKBase';
|
|
5
|
-
declare global {
|
|
6
|
-
namespace PlatfprmModule {
|
|
7
|
-
/**小游戏:按钮触摸 需要在按钮onTouchEnd中调用的方法 使用这个属性*/
|
|
8
|
-
const buttonTouch: ButtonTouch;
|
|
9
|
-
//#region 通用==============
|
|
10
|
-
/**模块初始化 */
|
|
11
|
-
export function Init(): Promise<boolean>
|
|
12
|
-
/**登录 */
|
|
13
|
-
export function Login(data?: string): Promise<SDKLoginData>
|
|
14
|
-
/**抖音:打开侧边栏
|
|
15
|
-
* callBack: 从侧边栏点击进入 游戏回调
|
|
16
|
-
*/
|
|
17
|
-
export function NavigateToScene(param?: { scene?: string; callBack?: () => void })
|
|
18
|
-
/**cocos node坐标转换为原生坐标 */
|
|
19
|
-
export function ToPosition(node: Node): PositonData
|
|
20
|
-
/**添加到桌面 */
|
|
21
|
-
export function AddShortcut(): Promise<boolean>
|
|
22
|
-
/**激励视频初始化 */
|
|
23
|
-
export function InitRewardedVideo(param: AdsData);
|
|
24
|
-
/**激励视频显示 */
|
|
25
|
-
export function ShowRewardedVideo(param: AdsCall): Promise<boolean>
|
|
26
|
-
//开放数据域
|
|
27
|
-
export function InitOpenDataLayout(node: Node)
|
|
28
|
-
export function SendMessageToOpenData(params: { type: string, event: string })
|
|
29
|
-
/** 更新开放数据榜单数据 */
|
|
30
|
-
export function UpdateCloudRank(key: string, score: number): Promise<boolean>
|
|
31
|
-
export function ShowRank(keyList: string[], openId?: string)
|
|
32
|
-
|
|
33
|
-
//#region 安卓相关===========
|
|
34
|
-
/**退出登录 */
|
|
35
|
-
export function Logout(): Promise<SDKStatus>
|
|
36
|
-
/**支付--目前只有安卓接入了 */
|
|
37
|
-
export function Pay(param: SDKBuyParam): Promise<SDKStatus>
|
|
38
|
-
|
|
39
|
-
//#region 微信相关===========
|
|
40
|
-
/**创建游戏圈按钮 */
|
|
41
|
-
export function CreateGameClubButton(): any
|
|
42
|
-
/**创建用户信息按钮 */
|
|
43
|
-
export function CreateUserInfoButton(param: ICreateUserInfoButton, callBack: (userInfo: UserInfoData) => void)
|
|
44
|
-
/**检查是否显示隐私条约 */
|
|
45
|
-
export function CheckShowPrivacy(): any
|
|
46
|
-
/**打开隐私条约 */
|
|
47
|
-
export function OpenPrivacyCUrl(): any
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//#region 抖音相关===========
|
|
51
|
-
/**初始化视频流场景 */
|
|
52
|
-
export function InitTTFeedScene()
|
|
53
|
-
/**抖音订阅视频流回调 */
|
|
54
|
-
export function RequestFeedSubscribe(call: (success: boolean) => void);
|
|
55
|
-
/**抖音:上报抖音场景 */
|
|
56
|
-
export function ReportScene()
|
|
57
|
-
export function ReportFeed(data: TTBaseData)
|
|
58
|
-
/**抖音:上报抖音订阅视频流数据 */
|
|
59
|
-
export function StoreFeedData(data: TTData): Promise<boolean>
|
|
60
|
-
/**抖音:获取抖音订阅视频流数据 */
|
|
61
|
-
export function GetFeedData(data: TTBaseData): Promise<boolean>
|
|
62
|
-
/**抖音:检查抖音订阅视频流状态 */
|
|
63
|
-
export function CheckFeedSubscribeStatus(): Promise<boolean>
|
|
64
|
-
/**抖音:检查抖音场景状态 默认:scene=sidebar*/
|
|
65
|
-
export function CheckScene(scene?: string): Promise<boolean>
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
namespace AndroidModule {
|
|
70
|
-
export function Init()
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//暂时不用这种方式
|
|
76
|
-
// declare module "cc" {
|
|
77
|
-
// namespace PlatfprmModule {
|
|
78
|
-
// function ToSideBar(): void;
|
|
79
|
-
// }
|
|
80
|
-
// }
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { _decorator, Component, Node } from 'cc';
|
|
2
|
-
import { SDKBase } from '../base/SDKBase';
|
|
3
|
-
import { AdsCall, AdsData, PositonData, SDKBuyParam, SDKEnum, SDKInitParam, SDKLoginData, SDKStatus } from '../base/SDKEnum';
|
|
4
|
-
import { native } from 'cc';
|
|
5
|
-
import { sys } from 'cc';
|
|
6
|
-
import { ATRewardedVideoAutoAdSDK } from './AnyThinkAds/ATRewardedAutoVideo';
|
|
7
|
-
import { ATSDK } from './AnyThinkAds/ATSDK';
|
|
8
|
-
import { assetManager } from 'cc';
|
|
9
|
-
const { ccclass, property } = _decorator;
|
|
10
|
-
|
|
11
|
-
@ccclass('AndroidSDK')
|
|
12
|
-
export class AndroidSDK extends SDKBase {
|
|
13
|
-
|
|
14
|
-
private _loginResolve: ((value: [boolean, string] | PromiseLike<[boolean, string]>) => void) | null = null;
|
|
15
|
-
private _logoutResolve: ((value: SDKStatus | PromiseLike<SDKStatus>) => void) | null = null;
|
|
16
|
-
private _showAdResolve: ((value: SDKStatus | PromiseLike<SDKStatus>) => void) | null = null;
|
|
17
|
-
private _buyResolve: ((value: SDKStatus | PromiseLike<SDKStatus>) => void) | null = null;
|
|
18
|
-
|
|
19
|
-
initParam: SDKInitParam = {
|
|
20
|
-
gameId: '',
|
|
21
|
-
deviceId: '',
|
|
22
|
-
deviceOs: '',
|
|
23
|
-
region: '',
|
|
24
|
-
mac: '',
|
|
25
|
-
oaid: '',
|
|
26
|
-
idfa: '',
|
|
27
|
-
androidid: '',
|
|
28
|
-
ip: '',
|
|
29
|
-
gameRoleID: '',
|
|
30
|
-
userId: ''
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//广告
|
|
34
|
-
// ads_id = "a68897c135273e"
|
|
35
|
-
// ads_key = "a3f3913b21437f71fe9c55b1656963ffd"
|
|
36
|
-
// ads_placement_id = "b68897c26d1c09"
|
|
37
|
-
// ads_scenario = "your scenario id"
|
|
38
|
-
ads_load_resolve: any = null
|
|
39
|
-
|
|
40
|
-
adsParam: AdsData;
|
|
41
|
-
adsCall: AdsCall;
|
|
42
|
-
|
|
43
|
-
init(): Promise<boolean> {
|
|
44
|
-
native.bridge.onNative = (func: string, param?: string | null): void => {
|
|
45
|
-
switch (func) {
|
|
46
|
-
case SDKEnum.Init:
|
|
47
|
-
console.log('初始化成功')
|
|
48
|
-
break;
|
|
49
|
-
case SDKEnum.Login:
|
|
50
|
-
break;
|
|
51
|
-
case SDKEnum.Logout:
|
|
52
|
-
this._logoutResolve?.(SDKStatus.success);
|
|
53
|
-
break;
|
|
54
|
-
case SDKEnum.DeviceInfo:
|
|
55
|
-
const data = JSON.parse(param);
|
|
56
|
-
this.initParam.deviceId = data._deviceId || "";
|
|
57
|
-
this.initParam.region = data._region || "";
|
|
58
|
-
this.initParam.mac = data._mac || "";
|
|
59
|
-
this.initParam.oaid = data._oaid || "";
|
|
60
|
-
this.initParam.idfa = data._idfa || "";
|
|
61
|
-
this.initParam.androidid = data._androidid || "";
|
|
62
|
-
this.initParam.ip = data._ip || "";
|
|
63
|
-
console.log(SDKEnum.DeviceInfo, param);
|
|
64
|
-
break;
|
|
65
|
-
case SDKEnum.LoginSuccess:
|
|
66
|
-
this._loginResolve?.([true, param]);
|
|
67
|
-
break;
|
|
68
|
-
case SDKEnum.LoginFailed:
|
|
69
|
-
break;
|
|
70
|
-
case SDKEnum.PseudoID:
|
|
71
|
-
this.initParam.deviceId = param;
|
|
72
|
-
break
|
|
73
|
-
case SDKEnum.Buy:
|
|
74
|
-
this._buyResolve?.(Number(param));
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
native.bridge.sendToNative(SDKEnum.DeviceInfo);
|
|
79
|
-
return new Promise<boolean>((resolve, reject) => {
|
|
80
|
-
assetManager.loadBundle('android', (error, bundle) => {
|
|
81
|
-
if (error) {
|
|
82
|
-
console.error('加载bundle android 失败', error)
|
|
83
|
-
resolve(false)
|
|
84
|
-
} else {
|
|
85
|
-
resolve(true)
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
public async login(data?: string): Promise<SDKLoginData> {
|
|
91
|
-
return new Promise<SDKLoginData>(async (resolve, reject) => {
|
|
92
|
-
if (this._loginResolve != null) {
|
|
93
|
-
this._loginResolve([false, "登录请求未完成"]);
|
|
94
|
-
}
|
|
95
|
-
let [success, code] = await new Promise<[boolean, string]>((resolve, reject) => {
|
|
96
|
-
this._loginResolve = resolve;
|
|
97
|
-
native.bridge.sendToNative(SDKEnum.Init, data);
|
|
98
|
-
});
|
|
99
|
-
this._loginResolve = null;
|
|
100
|
-
resolve({ success, code });
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
public async logout(): Promise<SDKStatus> {
|
|
104
|
-
const status = await new Promise<SDKStatus>((resolve) => {
|
|
105
|
-
native.bridge.sendToNative(SDKEnum.Logout);
|
|
106
|
-
this._logoutResolve = resolve;
|
|
107
|
-
});
|
|
108
|
-
this._logoutResolve = null;
|
|
109
|
-
return status;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public async pay(param: SDKBuyParam): Promise<SDKStatus> {
|
|
113
|
-
// param.description = "安卓sdk"
|
|
114
|
-
// param.userId = this.initParam.userId
|
|
115
|
-
// param.gameRoleID = this.initParam.gameRoleID
|
|
116
|
-
const status = await new Promise<SDKStatus>((resolve) => {
|
|
117
|
-
native.bridge.sendToNative(SDKEnum.Buy, JSON.stringify(param));
|
|
118
|
-
this._buyResolve = resolve;
|
|
119
|
-
});
|
|
120
|
-
this._buyResolve = null;
|
|
121
|
-
return status;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
//#region 广告======================================
|
|
125
|
-
public initRewardedVideo(param: AdsData) {
|
|
126
|
-
this.adsParam = param;
|
|
127
|
-
ATSDK.initSDK(param.appId, param.appKey);
|
|
128
|
-
// ATSDK.setLogDebug(true);
|
|
129
|
-
// ATSDK.showDebuggerUI(this.ads_key);
|
|
130
|
-
//ATRewardedVideoSDK.setAdListener(this.RewardedVideoListener);
|
|
131
|
-
ATRewardedVideoAutoAdSDK.setAdListener(this.AutoRewardedVideoListener);
|
|
132
|
-
ATRewardedVideoAutoAdSDK.addPlacementIds([this.adsParam.adUnitId]);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public showRewardedVideo(param: AdsCall) {
|
|
136
|
-
this.adsCall = param;
|
|
137
|
-
ATRewardedVideoAutoAdSDK.entryAdScenario(this.adsParam.adUnitId, "your scenario id")
|
|
138
|
-
if (ATRewardedVideoAutoAdSDK.hasAdReady(this.adsParam.adUnitId)) {
|
|
139
|
-
ATRewardedVideoAutoAdSDK.showAdInScenario(this.adsParam.adUnitId, "your scenario id");
|
|
140
|
-
} else {
|
|
141
|
-
param.error?.('视频没有准备好,请重试!')
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private AutoRewardedVideoListener = {
|
|
146
|
-
onRewardedVideoAdLoaded: (placementId: any) => {
|
|
147
|
-
console.log("已加载", placementId)
|
|
148
|
-
this.ads_load_resolve?.(true)
|
|
149
|
-
},
|
|
150
|
-
onRewardedVideoAdFailed: (placementId: any, errorInfo: any) => {
|
|
151
|
-
this.ads_load_resolve?.(false)
|
|
152
|
-
console.log("加载失败", placementId, errorInfo)
|
|
153
|
-
this.adsCall?.error?.(errorInfo);
|
|
154
|
-
},
|
|
155
|
-
onRewardedVideoAdPlayStart: (placementId: any, callbackInfo: any) => {
|
|
156
|
-
console.log("开始播放", placementId, callbackInfo)
|
|
157
|
-
},
|
|
158
|
-
onRewardedVideoAdPlayEnd: (placementId: any, callbackInfo: any) => {
|
|
159
|
-
console.log("播放结束", placementId, callbackInfo)
|
|
160
|
-
this.adsCall?.show?.();
|
|
161
|
-
},
|
|
162
|
-
onRewardedVideoAdPlayFailed: (placementId: any, errorInfo: any, callbackInfo: any) => {
|
|
163
|
-
console.log("播放失败", placementId, callbackInfo, errorInfo)
|
|
164
|
-
this.adsCall?.fail?.(errorInfo);
|
|
165
|
-
},
|
|
166
|
-
onRewardedVideoAdClosed: (placementId: any, callbackInfo: any) => {
|
|
167
|
-
console.log("关闭视频", placementId, callbackInfo)
|
|
168
|
-
this.adsCall?.close?.();
|
|
169
|
-
},
|
|
170
|
-
onRewardedVideoAdPlayClicked: (placementId: any, callbackInfo: any) => {
|
|
171
|
-
console.log("点击视频", placementId)
|
|
172
|
-
this.adsCall?.click?.();
|
|
173
|
-
// this.adsStatus = AdsStatus.click;
|
|
174
|
-
},
|
|
175
|
-
onReward: (placementId: any, callbackInfo: any) => {
|
|
176
|
-
console.log("奖励", placementId, callbackInfo)
|
|
177
|
-
this.adsCall?.success?.();
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
public toPosition(node: Node): PositonData {
|
|
182
|
-
return null
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"937d378e-b39e-4175-a7c6-52c526c9593b","files":[],"subMetas":{},"userData":{}}
|