drgame-cc 1.0.45 → 1.0.46
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/drres/focus/focus_1/gesture.atlas +34 -0
- package/drres/focus/focus_1/gesture.atlas.meta +6 -0
- package/drres/focus/focus_1/gesture.json +1 -0
- package/drres/focus/focus_1/gesture.json.meta +10 -0
- package/drres/focus/focus_1/gesture.png +0 -0
- package/drres/{icons/pointer-yellow-60.png.meta → focus/focus_1/gesture.png.meta} +14 -14
- package/drres/focus/focus_1.meta +13 -0
- package/drres/focus/focus_2/gesture.atlas +41 -0
- package/drres/focus/focus_2/gesture.atlas.meta +6 -0
- package/drres/focus/focus_2/gesture.json +1 -0
- package/drres/focus/focus_2/gesture.json.meta +10 -0
- package/drres/focus/focus_2/gesture.png +0 -0
- package/drres/{icons/pointer-blue-60.png.meta → focus/focus_2/gesture.png.meta} +13 -13
- package/drres/focus/focus_2.meta +13 -0
- package/drres/focus/focus_3/gesture.atlas +34 -0
- package/drres/focus/focus_3/gesture.atlas.meta +6 -0
- package/drres/focus/focus_3/gesture.json +1 -0
- package/drres/focus/focus_3/gesture.json.meta +10 -0
- package/drres/focus/focus_3/gesture.png +0 -0
- package/drres/{icons/pointer-pink-60.png.meta → focus/focus_3/gesture.png.meta} +12 -12
- package/drres/focus/focus_3.meta +13 -0
- package/drres/focus/focus_4/gesture.atlas +20 -0
- package/drres/focus/focus_4/gesture.atlas.meta +6 -0
- package/drres/focus/focus_4/gesture.json +1 -0
- package/drres/focus/focus_4/gesture.json.meta +10 -0
- package/drres/focus/focus_4/gesture.png +0 -0
- package/drres/focus/focus_4/gesture.png.meta +38 -0
- package/drres/focus/focus_4.meta +13 -0
- package/drres/focus.meta +13 -0
- package/drres/prefab/ExitWin.prefab +2 -2
- package/drres/prefab/Toast.prefab +378 -378
- package/drscript/{ad/AdManager.ts.meta → BtnExtra.ts.meta} +1 -1
- package/drscript/Define.ts +17 -2
- package/drscript/{ad/AdSlot.ts.meta → Define.ts.meta} +1 -1
- package/drscript/{ad/AggregateAdProvider.ts.meta → ExitWin.ts.meta} +1 -1
- package/drscript/GameAnalytics.ts +37 -118
- package/drscript/{ad/IAdProvider.ts.meta → GameAnalytics.ts.meta} +1 -1
- package/drscript/HelperWin.ts.meta +10 -0
- package/drscript/Info.ts.meta +10 -0
- package/drscript/InternalUitl.ts.meta +10 -0
- package/drscript/KeyAdapter.ts +133 -0
- package/drscript/KeyAdapter.ts.meta +10 -0
- package/drscript/Loader.ts.meta +10 -0
- package/drscript/PlatformAdapter.ts +178 -192
- package/drscript/PlatformAdapter.ts.meta +10 -0
- package/drscript/README.md +91 -805
- package/drscript/README.md.meta +6 -0
- package/drscript/UIAdapter.ts +324 -0
- package/drscript/UIAdapter.ts.meta +10 -0
- package/drscript/WebBridge.ts +1 -1
- package/drscript/WebBridge.ts.meta +10 -0
- package/drscript/ad-sdk/reporters/superset-lewo.js +6 -0
- package/drscript/ad-sdk/types/enums.d.ts +1 -0
- package/drscript/ad-sdk.meta +13 -0
- package/drscript/ad.meta +13 -0
- package/drscript/component/AlertTip.ts +25 -0
- package/drscript/component/AlertTip.ts.meta +10 -0
- package/drscript/component/BtnExtra.ts +17 -0
- package/drscript/component/BtnExtra.ts.meta +10 -0
- package/drscript/{ExitWin.ts → component/ExitWin.ts} +6 -8
- package/drscript/component/ExitWin.ts.meta +10 -0
- package/drscript/{HelperWin.ts → component/HelperWin.ts} +5 -19
- package/drscript/component/HelperWin.ts.meta +10 -0
- package/drscript/component.meta +13 -0
- package/drscript/config.meta +13 -0
- package/drscript/core.meta +13 -0
- package/drscript/focus/FocusItem.ts +1 -19
- package/drscript/focus/FocusManager.ts +132 -170
- package/drscript/focus/FocusVisualLayer.ts +74 -163
- package/drscript/focus.meta +13 -0
- package/drscript/input/KeyboardMove.ts +40 -11
- package/drscript/input/KeyboardMove.ts.meta +10 -0
- package/drscript/input.meta +13 -0
- package/drscript/interface.meta +13 -0
- package/drscript/pinyin.meta +13 -0
- package/drscript/toast.meta +13 -0
- package/drscript/virtualgamepad.meta +13 -0
- package/package.json +1 -1
- package/drres/config/default.json +0 -108
- package/drres/config/default.json.meta +0 -6
- package/drres/icons/pointer-blue-60.png +0 -0
- package/drres/icons/pointer-pink-60.png +0 -0
- package/drres/icons/pointer-white-60.png +0 -0
- package/drres/icons/pointer-yellow-60.png +0 -0
- package/drscript/Info.ts +0 -78
- package/drscript/InternalUitl.ts +0 -65
- package/drscript/ad/AdManager.ts +0 -174
- package/drscript/ad/AdSlot.ts +0 -44
- package/drscript/ad/AggregateAdProvider.ts +0 -149
- package/drscript/ad/IAdProvider.ts +0 -39
- package/drscript/ad/MockAdProvider.ts +0 -36
- package/drscript/ad/MockAdProvider.ts.meta +0 -10
- package/drscript/ad/SelfAdProvider.ts +0 -41
- package/drscript/ad/SelfAdProvider.ts.meta +0 -10
- package/drscript/config/TvUiConfig.ts +0 -155
- package/drscript/config/TvUiConfig.ts.meta +0 -10
- package/drscript/config/TvUiConfigManager.ts +0 -133
- package/drscript/config/TvUiConfigManager.ts.meta +0 -10
- package/drscript/core/BackManager.ts +0 -38
- package/drscript/core/BackManager.ts.meta +0 -10
- package/drscript/core/NativeBridge.ts +0 -137
- package/drscript/core/NativeBridge.ts.meta +0 -10
- package/drscript/core/TvUi.ts +0 -69
- package/drscript/core/TvUi.ts.meta +0 -10
- package/drscript/core/TvUiRoot.ts +0 -137
- package/drscript/core/TvUiRoot.ts.meta +0 -10
- package/drscript/icon/IconConfig.ts +0 -7
- package/drscript/icon/IconConfig.ts.meta +0 -10
- package/drscript/icon/IconManager.ts +0 -97
- package/drscript/icon/IconManager.ts.meta +0 -10
- package/drscript/input/KeyCodeAdapter.ts +0 -23
- package/drscript/input/RemoteInputManager.ts +0 -105
- package/drscript/interface/ILobbyBridge.ts +0 -5
- package/drscript/toast/ToastComponent.ts +0 -35
- package/drscript/toast/ToastComponent.ts.meta +0 -10
- package/drscript/toast/ToastManager.ts +0 -66
- package/drscript/toast/ToastManager.ts.meta +0 -10
- package/drscript/toast/TvExitConfirmDialog.ts +0 -334
- package/drscript/toast/TvExitConfirmDialog.ts.meta +0 -10
- package/drscript/toast/UIFunctions.ts +0 -150
- package/drscript/toast/UIFunctions.ts.meta +0 -10
|
@@ -1,96 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
import { BtnExtra } from "./BtnExtra";
|
|
3
|
-
import
|
|
4
|
-
import { EVideoScene,
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { AdEvent, AdPlatform, AdSdk, AdType } from "./ad-sdk/ad-sdk";
|
|
2
|
+
import { BtnExtra } from "./component/BtnExtra";
|
|
3
|
+
import HelperWin from "./component/HelperWin";
|
|
4
|
+
import { AnalyticsAction, AnalyticsEvent, EVideoScene, FingerStyle } from "./Define";
|
|
5
|
+
import FocusVisualLayer from "./focus/FocusVisualLayer";
|
|
6
|
+
import GameAnalytics from "./GameAnalytics";
|
|
7
7
|
import { Loader } from "./Loader";
|
|
8
|
-
import
|
|
9
|
-
import { InternalUitl } from "./InternalUitl";
|
|
8
|
+
import { UIAdapter } from "./UIAdapter";
|
|
10
9
|
import { WebBridge } from "./WebBridge";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** 平台适配器,名字有点长防止和Platform,Adapter冲突 */
|
|
10
|
+
|
|
11
|
+
/** 平台适配器,公共 API 入口 */
|
|
14
12
|
export class PlatformAdapter {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
/** 焦点管理 */
|
|
14
|
+
public static focus = UIAdapter.focus;
|
|
15
|
+
/** 返回键管理 */
|
|
16
|
+
public static back = UIAdapter.back;
|
|
17
|
+
/** WebBridge */
|
|
18
|
+
public static get webBridge() { return UIAdapter.webBridge; }
|
|
19
|
+
|
|
20
|
+
private static contentId: string = "";
|
|
21
|
+
|
|
22
|
+
// ========================================================================
|
|
23
|
+
// 初始化
|
|
24
|
+
// ========================================================================
|
|
25
|
+
|
|
22
26
|
/** 初始化
|
|
23
27
|
* @param cnName 中文名称
|
|
24
|
-
* @param minigameID 小游戏ID
|
|
28
|
+
* @param minigameID 小游戏ID
|
|
25
29
|
*/
|
|
26
|
-
public static async init(cnName: string, minigameID: number, focusIcon:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var platform =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
enableCursor: true,
|
|
39
|
-
configPath: "drres/config/default",
|
|
40
|
-
focus: {
|
|
41
|
-
enabled: true,
|
|
42
|
-
defaultIconKey: focusIcon
|
|
43
|
-
},
|
|
44
|
-
adSdk: {
|
|
45
|
-
platform: platform
|
|
46
|
-
},
|
|
47
|
-
ads: {
|
|
48
|
-
reward: {
|
|
49
|
-
enabled: true,
|
|
50
|
-
mode: "reward",
|
|
51
|
-
channels: [
|
|
52
|
-
{ type: "aggregate", priority: 1, reward_type: "reward" },
|
|
53
|
-
{ type: "mock", priority: 100 }
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
popup: {
|
|
57
|
-
enabled: true,
|
|
58
|
-
mode: "popup",
|
|
59
|
-
channels: [
|
|
60
|
-
{ type: "aggregate", priority: 1 },
|
|
61
|
-
{ type: "mock", priority: 100 }
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
game: {
|
|
65
|
-
enabled: true,
|
|
66
|
-
mode: "popup",
|
|
67
|
-
channels: [
|
|
68
|
-
{ type: "aggregate", priority: 1 },
|
|
69
|
-
{ type: "mock", priority: 100 }
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
30
|
+
public static async init(cnName: string, minigameID: number, focusIcon: FingerStyle) {
|
|
31
|
+
FocusVisualLayer.setStyle(focusIcon);
|
|
32
|
+
UIAdapter._zhName = cnName;
|
|
33
|
+
var platform: AdPlatform = AdPlatform.None;
|
|
34
|
+
UIAdapter.webBridge = new WebBridge();
|
|
35
|
+
if (UIAdapter.webBridge.isAvailable()) {
|
|
36
|
+
} else if (this.isXiaomi) {
|
|
37
|
+
platform = AdPlatform.Xiaomi;
|
|
38
|
+
}
|
|
39
|
+
this.contentId = minigameID.toString();
|
|
40
|
+
console.log(`[sdk-version] ${UIAdapter.version}`);
|
|
41
|
+
UIAdapter.init({ focusEnabled: true });
|
|
74
42
|
|
|
75
43
|
GameAnalytics.init({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
content_title: cnName, // 游戏名(具体的乐窝游戏名)
|
|
44
|
+
app_item: "25",
|
|
45
|
+
content_type: "游戏",
|
|
46
|
+
content_id: this.contentId,
|
|
47
|
+
content_title: cnName,
|
|
81
48
|
});
|
|
82
|
-
if (
|
|
83
|
-
|
|
49
|
+
if (PlatformAdapter.isCocos) {
|
|
50
|
+
UIAdapter.toastPool = new cc.NodePool();
|
|
51
|
+
UIAdapter.prefab = await UIAdapter.loadPrefab('drres/prefab/Toast');
|
|
52
|
+
}
|
|
84
53
|
let adapters: any = {};
|
|
85
|
-
adapters[platform] = { cpId: contentId };
|
|
86
|
-
await AdSdk.init({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
54
|
+
adapters[platform] = { cpId: this.contentId };
|
|
55
|
+
await AdSdk.init({ platform: AdPlatform.Xiaomi, adapters: adapters });
|
|
56
|
+
AdSdk.onGameReady(UIAdapter.version);
|
|
57
|
+
if (this.canWatchVideo) {
|
|
58
|
+
AdSdk.on(AdEvent.Closed, (data: any) => {
|
|
59
|
+
if (!data.isCompleted) {
|
|
60
|
+
PlatformAdapter.showTip("必须看完视频,才能获取奖励");
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
// 监听失败
|
|
64
|
+
AdSdk.on(AdEvent.Error, (data: any) => {
|
|
65
|
+
PlatformAdapter.showTip(`广告暂不可用,请稍后再试(${data.message})`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// 预加载激励视频广告,让 native 侧提前准备,减少首次拉取失败率
|
|
69
|
+
UIAdapter.hookLoadScene();
|
|
70
|
+
UIAdapter.back.setFallback(() => UIAdapter.backHandler());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private static get isXiaomi() {
|
|
74
|
+
if (typeof window === 'undefined') return null;
|
|
75
|
+
return window['AppBridge'] || null;
|
|
92
76
|
}
|
|
93
77
|
|
|
78
|
+
// ========================================================================
|
|
79
|
+
// Toast
|
|
80
|
+
// ========================================================================
|
|
81
|
+
|
|
82
|
+
public static showTip(text: string, dur = 1500) {
|
|
83
|
+
return UIAdapter.showTip(text, dur);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ========================================================================
|
|
87
|
+
// 广告
|
|
88
|
+
// ========================================================================
|
|
89
|
+
|
|
94
90
|
/**
|
|
95
91
|
* 显示奖励视频
|
|
96
92
|
* @param scene 视频场景
|
|
@@ -98,116 +94,124 @@ export class PlatformAdapter {
|
|
|
98
94
|
* @param callback 回调函数
|
|
99
95
|
* @param target 回调函数的this指向
|
|
100
96
|
*/
|
|
101
|
-
public static showRewardVideo(scene: EVideoScene, rewardType: string, callback: Function, target?: any) {
|
|
102
|
-
|
|
97
|
+
public static async showRewardVideo(scene: EVideoScene, rewardType: string, callback: Function, target?: any) {
|
|
98
|
+
let finishFired = false;
|
|
99
|
+
let fireFinish = () => {
|
|
100
|
+
if (finishFired) return;
|
|
101
|
+
finishFired = true;
|
|
102
|
+
};
|
|
103
|
+
let onSuccess = () => {
|
|
104
|
+
try {
|
|
105
|
+
PlatformAdapter.report(AnalyticsEvent.RewardVideoAd, AnalyticsAction.Exposure);
|
|
106
|
+
callback && callback.call(target);
|
|
107
|
+
} finally {
|
|
108
|
+
fireFinish();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
if (PlatformAdapter.canWatchVideo) {
|
|
113
|
+
// 监听奖励(用户完整看完广告触发)
|
|
114
|
+
try {
|
|
115
|
+
const result = await AdSdk.requestAd({
|
|
116
|
+
adType: AdType.RewardVideo,
|
|
117
|
+
cpId: this.contentId,
|
|
118
|
+
rewardType: rewardType || "reward",
|
|
119
|
+
triggerScene: scene || "reward",
|
|
120
|
+
extra: {}
|
|
121
|
+
});
|
|
122
|
+
if (result && result.isCompleted === true) {
|
|
123
|
+
onSuccess();
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
onSuccess();
|
|
127
|
+
return false;
|
|
128
|
+
} catch (error: any) {
|
|
129
|
+
console.log("广告请求失败", error.code, error.message);
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
callback && callback.call(target);
|
|
133
|
+
}
|
|
103
134
|
}
|
|
135
|
+
|
|
136
|
+
// ========================================================================
|
|
137
|
+
// 按钮注册
|
|
138
|
+
// ========================================================================
|
|
139
|
+
|
|
104
140
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param button
|
|
141
|
+
* 注册按钮事件,有 BtnExtra 组件会自动切换按钮图片
|
|
142
|
+
* @param button 按钮节点
|
|
107
143
|
*/
|
|
108
144
|
public static registerButton(button: cc.Node) {
|
|
109
145
|
var sprite = button.getComponent(cc.Sprite);
|
|
110
146
|
var btnExtra = button.getComponent(BtnExtra);
|
|
111
|
-
var onFocus = () => {
|
|
112
|
-
|
|
113
|
-
};
|
|
114
|
-
var onRomove = () => {
|
|
115
|
-
sprite.spriteFrame = btnExtra.normalSprite;
|
|
116
|
-
};
|
|
117
|
-
TvUi.focus.register(button, {
|
|
118
|
-
onFocus: onFocus,
|
|
119
|
-
onBlur: onRomove,
|
|
120
|
-
});
|
|
147
|
+
var onFocus = () => { sprite.spriteFrame = btnExtra.hoverSprite; };
|
|
148
|
+
var onRomove = () => { sprite.spriteFrame = btnExtra.normalSprite; };
|
|
149
|
+
UIAdapter.focus.register(button, { onFocus: onFocus, onBlur: onRomove });
|
|
121
150
|
}
|
|
122
151
|
|
|
123
152
|
/**
|
|
124
|
-
*
|
|
153
|
+
* 按名称注册按钮
|
|
125
154
|
* @param name 按钮名称
|
|
126
|
-
* @param parent
|
|
127
|
-
* @returns
|
|
155
|
+
* @param parent 查找的父节点,默认场景节点
|
|
128
156
|
*/
|
|
129
157
|
public static registerButtonByName(name: string, parent: cc.Node = null) {
|
|
130
158
|
if (!parent) parent = cc.director.getScene();
|
|
131
|
-
let button =
|
|
132
|
-
|
|
133
|
-
this.registerButton(button);
|
|
159
|
+
let button = PlatformAdapter.findChildByName(parent, name);
|
|
160
|
+
PlatformAdapter.registerButton(button);
|
|
134
161
|
}
|
|
135
162
|
|
|
136
163
|
/**
|
|
137
|
-
*
|
|
164
|
+
* 导航到指定名称的按钮
|
|
138
165
|
* @param name 按钮名称
|
|
139
|
-
* @param parent
|
|
140
|
-
* @returns
|
|
166
|
+
* @param parent 查找的父节点,默认场景节点
|
|
141
167
|
*/
|
|
142
168
|
public static focusButtonByName(name: string, parent: cc.Node = null) {
|
|
143
169
|
if (!parent) parent = cc.director.getScene();
|
|
144
|
-
let button =
|
|
145
|
-
|
|
170
|
+
let button = PlatformAdapter.findChildByName(parent, name);
|
|
171
|
+
UIAdapter.focus.focus(button);
|
|
146
172
|
}
|
|
147
173
|
|
|
174
|
+
/** 导航到指定按钮 */
|
|
148
175
|
public static focusButton(btn: cc.Node) {
|
|
149
|
-
|
|
176
|
+
UIAdapter.focus.focus(btn);
|
|
150
177
|
}
|
|
151
178
|
|
|
152
179
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @param parent
|
|
180
|
+
* 递归查找指定名称的子节点
|
|
181
|
+
* @param parent 父节点
|
|
155
182
|
* @param name 子节点名称
|
|
156
|
-
* @param name 子节点名称
|
|
157
|
-
* @returns
|
|
158
183
|
*/
|
|
159
184
|
public static findChildByName(parent: cc.Node, name: string): cc.Node | null {
|
|
160
|
-
if (parent.name === name)
|
|
161
|
-
return parent;
|
|
162
|
-
}
|
|
163
|
-
|
|
185
|
+
if (parent.name === name) return parent;
|
|
164
186
|
for (let i = 0; i < parent.children.length; i++) {
|
|
165
|
-
let result =
|
|
166
|
-
if (result)
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
187
|
+
let result = PlatformAdapter.findChildByName(parent.children[i], name);
|
|
188
|
+
if (result) return result;
|
|
169
189
|
}
|
|
170
190
|
return null;
|
|
171
191
|
}
|
|
172
192
|
|
|
193
|
+
// ========================================================================
|
|
194
|
+
// 场景 / 窗口 栈
|
|
195
|
+
// ========================================================================
|
|
173
196
|
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
public static refreshWindow(window: cc.Node) {
|
|
189
|
-
TvUi.focus.registerButtons(window);
|
|
190
|
-
this.findBtnExtra(window);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
public static async showExitWin() {
|
|
194
|
-
let exitPfb = await Loader.loadRes('drres/prefab/ExitWin', cc.Prefab);
|
|
195
|
-
let exitWin = cc.instantiate(exitPfb);
|
|
196
|
-
exitWin.parent = cc.director.getScene();
|
|
197
|
-
exitWin.setPosition(cc.v2(cc.winSize.width / 2, cc.winSize.height / 2));
|
|
198
|
-
}
|
|
197
|
+
/** 显示预制体场景(压入场景栈,返回键可回溯)
|
|
198
|
+
* @param onBack 自定义返回处理,返回 false 表示不关闭,保留当前场景
|
|
199
|
+
*/
|
|
200
|
+
public static showScene(scene: cc.Node, onBack?: () => boolean | void) { UIAdapter.showScene(scene, onBack); }
|
|
201
|
+
/** 关闭预制体场景(从栈中移除,不销毁) */
|
|
202
|
+
public static hideScene(scene: cc.Node) { UIAdapter.hideScene(scene); }
|
|
203
|
+
/** 打开界面
|
|
204
|
+
* @param onBack 自定义返回处理,返回 false 表示不关闭,保留当前窗口
|
|
205
|
+
*/
|
|
206
|
+
public static showWindow(window: cc.Node, onBack?: () => boolean | void) { UIAdapter.showWindow(window, onBack); }
|
|
207
|
+
/** 关闭界面 */
|
|
208
|
+
public static hideWindow(window: cc.Node) { UIAdapter.hideWindow(window); }
|
|
209
|
+
/** 刷新导航按钮 */
|
|
210
|
+
public static refreshFocus(window: cc.Node) { UIAdapter.refreshFocus(window); }
|
|
199
211
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (child.isValid === false || !child.activeInHierarchy) continue;
|
|
204
|
-
let btnExtra = child.getComponent(BtnExtra);
|
|
205
|
-
if (btnExtra) {
|
|
206
|
-
this.registerButton(child);
|
|
207
|
-
}
|
|
208
|
-
this.findBtnExtra(child);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
212
|
+
// ========================================================================
|
|
213
|
+
// 进度 / 加载
|
|
214
|
+
// ========================================================================
|
|
211
215
|
|
|
212
216
|
/** 设置启动页进度条 */
|
|
213
217
|
public static setProgress(progress: number, tip: string) {
|
|
@@ -219,59 +223,41 @@ export class PlatformAdapter {
|
|
|
219
223
|
if (window["closeLoading"]) window["closeLoading"]();
|
|
220
224
|
}
|
|
221
225
|
|
|
226
|
+
// ========================================================================
|
|
227
|
+
// 上报
|
|
228
|
+
// ========================================================================
|
|
229
|
+
|
|
222
230
|
/**
|
|
223
|
-
*
|
|
231
|
+
* 上报事件(缓存)
|
|
224
232
|
* @param event 事件类型
|
|
225
|
-
* @param action
|
|
233
|
+
* @param action 操作类型,默认点击
|
|
226
234
|
* @param adRequestId 广告请求ID
|
|
227
235
|
*/
|
|
228
236
|
public static report(event: AnalyticsEvent, action: AnalyticsAction = AnalyticsAction.Click, adRequestId?: string) {
|
|
229
237
|
GameAnalytics.report(event, action, adRequestId);
|
|
230
238
|
}
|
|
231
239
|
|
|
232
|
-
/**
|
|
233
|
-
* 批量上报事件(不缓存,只在仅需要曝光多个时用,点击不会同时操作多个可忽略)
|
|
234
|
-
* @param events 事件类型数组
|
|
235
|
-
*/
|
|
240
|
+
/** 批量上报事件 */
|
|
236
241
|
public static reportBatch(events: AnalyticsEvent[]) {
|
|
237
242
|
GameAnalytics.reportBatch(events);
|
|
238
243
|
}
|
|
239
244
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
/** 是否是基座环境 */
|
|
245
|
-
public static get isWebBridge() {
|
|
246
|
-
return this.webBridge.isAvailable();
|
|
247
|
-
}
|
|
245
|
+
// ========================================================================
|
|
246
|
+
// 属性
|
|
247
|
+
// ========================================================================
|
|
248
248
|
|
|
249
|
+
/** 是否 Cocos 环境 */
|
|
250
|
+
public static get isCocos() { return window['cc'] != undefined; }
|
|
251
|
+
/** 是否基座环境 */
|
|
252
|
+
public static get isWebBridge() { return UIAdapter.webBridge.isAvailable(); }
|
|
249
253
|
/** 是否可以观看视频 */
|
|
250
|
-
public static get canWatchVideo() {
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** 是否是VIP用户 */
|
|
255
|
-
public static get isVIP() {
|
|
256
|
-
return this._isVIP;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/** 退出游戏 */
|
|
260
|
-
public static exitGame() {
|
|
261
|
-
if (this.isWebBridge) {
|
|
262
|
-
this.webBridge.callHandler("router/navigateBack", {}, (a) => { cc.log(a); });
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (AdSdk.exitGame) AdSdk.exitGame();
|
|
266
|
-
cc.game.end();
|
|
267
|
-
}
|
|
254
|
+
public static get canWatchVideo() { return this.isXiaomi; }
|
|
255
|
+
/** 是否 VIP 用户 */
|
|
256
|
+
public static get isVIP() { return UIAdapter._isVIP; }
|
|
268
257
|
|
|
269
|
-
/** 显示帮助窗口
|
|
270
|
-
* @param url 帮助窗口的url
|
|
271
|
-
* @param cb 回调函数,当帮助窗口关闭后会调用该回调函数
|
|
272
|
-
*/
|
|
258
|
+
/** 显示帮助窗口 */
|
|
273
259
|
public static async showHelperWin(url: string, cb: () => void) {
|
|
274
|
-
var key = `${
|
|
260
|
+
var key = `${UIAdapter._zhName}-isFirst`;
|
|
275
261
|
var isFirst = cc.sys.localStorage.getItem(key);
|
|
276
262
|
if (!isFirst) {
|
|
277
263
|
cc.sys.localStorage.setItem(key, false);
|