@chiyou/minigame-framework 1.2.62 → 1.2.64
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/package.json +1 -1
- package/src/Framework/Manager/AdMgr.ts +23 -9
- package/src/Framework/Manager/AudioMgr.ts +14 -6
- package/src/Framework/Manager/ExcelMgr.ts +3 -0
- package/src/Framework/Manager/NodePoolMgr.ts +14 -6
- package/src/Framework/Manager/PrivacyMgr.ts +18 -20
- package/src/Framework/Manager/UIMgr.ts +8 -3
- package/src/Framework/Manager/UserMgr.ts +25 -10
package/package.json
CHANGED
|
@@ -69,6 +69,9 @@ export class AdMgr extends BaseMgr {
|
|
|
69
69
|
/** 内容区域底部 */
|
|
70
70
|
private static contentBottom: number = 0;
|
|
71
71
|
|
|
72
|
+
private audioMgr: AudioMgr = null;
|
|
73
|
+
private userMgr: UserMgr = null;
|
|
74
|
+
|
|
72
75
|
onLoad(): void {
|
|
73
76
|
super.onLoad();
|
|
74
77
|
|
|
@@ -278,18 +281,26 @@ export class AdMgr extends BaseMgr {
|
|
|
278
281
|
}
|
|
279
282
|
|
|
280
283
|
if (res === RewardedVideoAd_Callback_Status.Status_Watching) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
if (AdMgr.Instance.audioMgr === null) {
|
|
285
|
+
AdMgr.Instance.audioMgr = ServiceLocator.Instance.get<AudioMgr>("AudioMgr");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (AdMgr.Instance.audioMgr) {
|
|
289
|
+
AdMgr.Instance.audioMgr.pauseMusic();
|
|
284
290
|
}
|
|
291
|
+
|
|
285
292
|
AdMgr.Instance.hideAllPermanentAd();
|
|
286
293
|
} else if (res === RewardedVideoAd_Callback_Status.Status_Complete ||
|
|
287
294
|
res === RewardedVideoAd_Callback_Status.Status_Giveup ||
|
|
288
295
|
res === RewardedVideoAd_Callback_Status.Status_Error) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
audioMgr.resumeMusic();
|
|
296
|
+
if (AdMgr.Instance.audioMgr === null) {
|
|
297
|
+
AdMgr.Instance.audioMgr = ServiceLocator.Instance.get<AudioMgr>("AudioMgr");
|
|
292
298
|
}
|
|
299
|
+
|
|
300
|
+
if (AdMgr.Instance.audioMgr) {
|
|
301
|
+
AdMgr.Instance.audioMgr.resumeMusic();
|
|
302
|
+
}
|
|
303
|
+
|
|
293
304
|
AdMgr.Instance.showAllPermanentAd();
|
|
294
305
|
}
|
|
295
306
|
|
|
@@ -531,10 +542,13 @@ export class AdMgr extends BaseMgr {
|
|
|
531
542
|
let adPlatformSettingInfo: AdPlatformSettingInfo = AdMgr.adPlatformSettingMap.get(this.getCurrentPlatformID());
|
|
532
543
|
launchNoAdInterval = adPlatformSettingInfo.launchNoAdInterval_interstitialAd;
|
|
533
544
|
|
|
534
|
-
interstitialAdIntervalBase = adPlatformSettingInfo.
|
|
545
|
+
interstitialAdIntervalBase = adPlatformSettingInfo.retainUser_interstitialAd_IntervalBase;
|
|
546
|
+
|
|
547
|
+
if (this.userMgr === null) {
|
|
548
|
+
this.userMgr = ServiceLocator.Instance.get<UserMgr>("UserMgr");
|
|
549
|
+
}
|
|
535
550
|
|
|
536
|
-
|
|
537
|
-
if (userMgr && userMgr.isNewUser()) {
|
|
551
|
+
if (this.userMgr && this.userMgr.isNewUser()) {
|
|
538
552
|
interstitialAdIntervalBase = adPlatformSettingInfo.registerUser_interstitialAd_IntervalBase;
|
|
539
553
|
}
|
|
540
554
|
}
|
|
@@ -20,6 +20,8 @@ export class AudioMgr extends BaseMgr {
|
|
|
20
20
|
private musicSwitch: boolean = false;
|
|
21
21
|
private musicAudioSource: AudioSource = null;
|
|
22
22
|
|
|
23
|
+
private resMgr: ResMgr = null;
|
|
24
|
+
|
|
23
25
|
onLoad(): void {
|
|
24
26
|
super.onLoad();
|
|
25
27
|
|
|
@@ -185,9 +187,12 @@ export class AudioMgr extends BaseMgr {
|
|
|
185
187
|
return;
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
if (this.resMgr === null) {
|
|
191
|
+
this.resMgr = ServiceLocator.Instance.get<ResMgr>("ResMgr");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (this.resMgr) {
|
|
195
|
+
let audioClip: AudioClip = this.resMgr.getAsset("Sounds", url);
|
|
191
196
|
if (audioClip == null) {
|
|
192
197
|
LogUtils.Instance.error(AudioMgr.TAG, FwkErrorCode.Audio.LoadFailed, {
|
|
193
198
|
operation: "playEffect",
|
|
@@ -281,9 +286,12 @@ export class AudioMgr extends BaseMgr {
|
|
|
281
286
|
return;
|
|
282
287
|
}
|
|
283
288
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
if (this.resMgr === null) {
|
|
290
|
+
this.resMgr = ServiceLocator.Instance.get<ResMgr>("ResMgr");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (this.resMgr) {
|
|
294
|
+
let audioClip: AudioClip = this.resMgr.getAsset("Sounds", url);
|
|
287
295
|
if (audioClip == null) {
|
|
288
296
|
LogUtils.Instance.error(AudioMgr.TAG, FwkErrorCode.Audio.LoadFailed, {
|
|
289
297
|
operation: "playMusic",
|
|
@@ -2,6 +2,7 @@ import CSV from '../Utils/CSVUtils';
|
|
|
2
2
|
import { LogUtils } from '../Utils/LogUtils';
|
|
3
3
|
import { BaseMgr } from './BaseMgr';
|
|
4
4
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
5
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
5
6
|
|
|
6
7
|
/** Excel/CSV 配置表管理器 */
|
|
7
8
|
export class ExcelMgr extends BaseMgr {
|
|
@@ -20,6 +21,8 @@ export class ExcelMgr extends BaseMgr {
|
|
|
20
21
|
this.destroy();
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
ServiceLocator.Instance.register("ExcelMgr", this);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/** 初始化配置表管理器 */
|
|
@@ -69,6 +69,8 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
69
69
|
enableDebug: false,
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
private uiMgr: UIMgr = null;
|
|
73
|
+
|
|
72
74
|
onLoad(): void {
|
|
73
75
|
super.onLoad();
|
|
74
76
|
|
|
@@ -424,12 +426,15 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
424
426
|
return null;
|
|
425
427
|
}
|
|
426
428
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
if (this.uiMgr === null) {
|
|
430
|
+
this.uiMgr = ServiceLocator.Instance.get<UIMgr>("UIMgr");
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (!this.uiMgr) {
|
|
429
434
|
return null;
|
|
430
435
|
}
|
|
431
436
|
|
|
432
|
-
let node: Node = uiMgr.create_ui(poolInfo.poolConfig.prefabUiName);
|
|
437
|
+
let node: Node = this.uiMgr.create_ui(poolInfo.poolConfig.prefabUiName);
|
|
433
438
|
if (!node) {
|
|
434
439
|
LogUtils.Instance.error(NodePoolMgr.TAG, FwkErrorCode.NodePool.CreateFailed, {
|
|
435
440
|
operation: "_createNode",
|
|
@@ -462,9 +467,12 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
462
467
|
|
|
463
468
|
let poolInfo: PoolInfo = this._poolInfoMap.get(poolName);
|
|
464
469
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
if (this.uiMgr === null) {
|
|
471
|
+
this.uiMgr = ServiceLocator.Instance.get<UIMgr>("UIMgr");
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (this.uiMgr) {
|
|
475
|
+
this.uiMgr.destroy_ui(poolName, node);
|
|
468
476
|
}
|
|
469
477
|
|
|
470
478
|
if (poolInfo.poolConfig && poolInfo.poolConfig.enableDebug) {
|
|
@@ -20,6 +20,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
20
20
|
/** 已同意的版本号 */
|
|
21
21
|
private kindReminderAgreeVersion: string = "";
|
|
22
22
|
|
|
23
|
+
private uiMgr: UIMgr = null;
|
|
24
|
+
|
|
23
25
|
onLoad(): void {
|
|
24
26
|
super.onLoad();
|
|
25
27
|
|
|
@@ -175,13 +177,9 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
let uiMgr = ServiceLocator.Instance.get<UIMgr>("UIMgr");
|
|
179
|
-
|
|
180
180
|
this.getPlatformAdapter().requirePrivacyAuthorize((result) => {
|
|
181
181
|
if (!result) {
|
|
182
|
-
|
|
183
|
-
uiMgr.showToast("未同意隐私协议,无法使用" + featureName);
|
|
184
|
-
}
|
|
182
|
+
this.showToast("未同意隐私协议,无法使用" + featureName);
|
|
185
183
|
|
|
186
184
|
LogUtils.Instance.info(PrivacyMgr.TAG, "用户拒绝隐私授权", {
|
|
187
185
|
featureName: featureName,
|
|
@@ -195,9 +193,7 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
195
193
|
let privacyPlatformInfo: PrivacyPlatformInfo = privacyInfo.privacyPlatformMap.get(this.getCurrentPlatformID());
|
|
196
194
|
let scopeDescription: string = privacyPlatformInfo?.scopeDescription || "未知";
|
|
197
195
|
if (privacyPlatformInfo === null || privacyPlatformInfo.scopeDisable) {
|
|
198
|
-
|
|
199
|
-
uiMgr.showToast("不支持[" + scopeDescription + "],无法使用" + featureName);
|
|
200
|
-
}
|
|
196
|
+
this.showToast("不支持[" + scopeDescription + "],无法使用" + featureName);
|
|
201
197
|
|
|
202
198
|
LogUtils.Instance.info(PrivacyMgr.TAG, "隐私功能不支持", {
|
|
203
199
|
featureName: featureName,
|
|
@@ -221,9 +217,7 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
221
217
|
let scopeName: string = privacyPlatformInfo.scopeName;
|
|
222
218
|
this.getPlatformAdapter().getSetting(scopeName, (result: GetSettingResult) => {
|
|
223
219
|
if (result === GetSettingResult.Result_SettingNotAvailable) {
|
|
224
|
-
|
|
225
|
-
uiMgr.showToast("App版本过低,无法使用" + featureName, ToastDuration.Duration_Long);
|
|
226
|
-
}
|
|
220
|
+
this.showToast("App版本过低,无法使用" + featureName, ToastDuration.Duration_Long);
|
|
227
221
|
|
|
228
222
|
LogUtils.Instance.info(PrivacyMgr.TAG, "隐私授权失败(版本不支持)", {
|
|
229
223
|
featureName: featureName,
|
|
@@ -233,9 +227,7 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
233
227
|
callback(QueryPrivacyResult.Result_Invalid);
|
|
234
228
|
return;
|
|
235
229
|
} else if (result === GetSettingResult.Result_Rejected) {
|
|
236
|
-
|
|
237
|
-
uiMgr.showToast("右上角...设置,开启[" + scopeDescription + "]权限,即可使用" + featureName, ToastDuration.Duration_Long);
|
|
238
|
-
}
|
|
230
|
+
this.showToast("右上角...设置,开启[" + scopeDescription + "]权限,即可使用" + featureName, ToastDuration.Duration_Long);
|
|
239
231
|
|
|
240
232
|
LogUtils.Instance.info(PrivacyMgr.TAG, "用户拒绝权限授权", {
|
|
241
233
|
featureName: featureName,
|
|
@@ -248,9 +240,7 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
248
240
|
} else if (result === GetSettingResult.Result_NotExist_AuthorizeAvailable) {
|
|
249
241
|
this.getPlatformAdapter().authorize(scopeName, (result3) => {
|
|
250
242
|
if (result3 === AuthorizeResult.Result_AuthorizeNotAvailable) {
|
|
251
|
-
|
|
252
|
-
uiMgr.showToast("App版本过低,无法使用" + featureName, ToastDuration.Duration_Long);
|
|
253
|
-
}
|
|
243
|
+
this.showToast("App版本过低,无法使用" + featureName, ToastDuration.Duration_Long);
|
|
254
244
|
|
|
255
245
|
LogUtils.Instance.info(PrivacyMgr.TAG, "授权失败(功能不可用)", {
|
|
256
246
|
featureName: featureName,
|
|
@@ -260,9 +250,7 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
260
250
|
callback(QueryPrivacyResult.Result_Invalid);
|
|
261
251
|
return;
|
|
262
252
|
} else if (result3 === AuthorizeResult.Result_Rejected) {
|
|
263
|
-
|
|
264
|
-
uiMgr.showToast("右上角...设置,开启[" + scopeDescription + "]权限,即可使用" + featureName, ToastDuration.Duration_Long);
|
|
265
|
-
}
|
|
253
|
+
this.showToast("右上角...设置,开启[" + scopeDescription + "]权限,即可使用" + featureName, ToastDuration.Duration_Long);
|
|
266
254
|
|
|
267
255
|
LogUtils.Instance.info(PrivacyMgr.TAG, "用户拒绝授权请求", {
|
|
268
256
|
featureName: featureName,
|
|
@@ -302,4 +290,14 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
302
290
|
});
|
|
303
291
|
});
|
|
304
292
|
}
|
|
293
|
+
|
|
294
|
+
private showToast(msg: string, duration?: ToastDuration) {
|
|
295
|
+
if (this.uiMgr === null) {
|
|
296
|
+
this.uiMgr = ServiceLocator.Instance.get<UIMgr>("UIMgr");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (this.uiMgr) {
|
|
300
|
+
this.uiMgr.showToast(msg, duration);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
305
303
|
}
|
|
@@ -110,6 +110,8 @@ export class UIMgr extends BaseMgr {
|
|
|
110
110
|
/** Toast 历史最大记录数 */
|
|
111
111
|
private toastHistoryMaxCount: number = 10;
|
|
112
112
|
|
|
113
|
+
private resMgr: ResMgr = null;
|
|
114
|
+
|
|
113
115
|
/** 打印 UI 映射(调试用) */
|
|
114
116
|
public print(): void {
|
|
115
117
|
LogUtils.Instance.info(UIMgr.TAG, "UI映射表", {
|
|
@@ -263,12 +265,15 @@ export class UIMgr extends BaseMgr {
|
|
|
263
265
|
* @return UI 节点
|
|
264
266
|
*/
|
|
265
267
|
public create_ui(ui_name: string, parent?: Node): Node {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
+
if (this.resMgr === null) {
|
|
269
|
+
this.resMgr = ServiceLocator.Instance.get<ResMgr>("ResMgr");
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (!this.resMgr) {
|
|
268
273
|
return null;
|
|
269
274
|
}
|
|
270
275
|
|
|
271
|
-
let uiPrefab: Prefab = resMgr.getAsset("GUI", "UIPrefabs/" + ui_name);
|
|
276
|
+
let uiPrefab: Prefab = this.resMgr.getAsset("GUI", "UIPrefabs/" + ui_name);
|
|
272
277
|
if (!uiPrefab) {
|
|
273
278
|
LogUtils.Instance.error(UIMgr.TAG, FwkErrorCode.UI.PrefabNotFound, {
|
|
274
279
|
operation: "create_ui",
|
|
@@ -50,6 +50,10 @@ export class UserMgr extends BaseMgr {
|
|
|
50
50
|
private lastUpdateFullUserData: any = null;
|
|
51
51
|
private lastOnHideUpdateTimestampInSecond: number = 0;
|
|
52
52
|
|
|
53
|
+
private adMgr: AdMgr = null;
|
|
54
|
+
private socialMgr: SocialMgr = null;
|
|
55
|
+
private timerMgr: TimerMgr = null;
|
|
56
|
+
|
|
53
57
|
onLoad(): void {
|
|
54
58
|
super.onLoad();
|
|
55
59
|
|
|
@@ -68,9 +72,12 @@ export class UserMgr extends BaseMgr {
|
|
|
68
72
|
protected onDestroy(): void {
|
|
69
73
|
EventMgr.Instance.off(FrameworkBase.Message.LifeCycle_onGameHide, this.onGameHideCallback, this);
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (this.timerMgr === null) {
|
|
76
|
+
this.timerMgr = ServiceLocator.Instance.get<TimerMgr>("TimerMgr");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (this.timerMgr) {
|
|
80
|
+
this.timerMgr.removeTimer(this.autoSaveUserDataExecute, this);
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
83
|
|
|
@@ -111,9 +118,12 @@ export class UserMgr extends BaseMgr {
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
if (this.userBehaviorPlatformInfo.autoSaveInterval > 0 && this.userBehaviorPlatformInfo.supportServerUserData) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
if (this.timerMgr === null) {
|
|
122
|
+
this.timerMgr = ServiceLocator.Instance.get<TimerMgr>("TimerMgr");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (this.timerMgr) {
|
|
126
|
+
this.timerMgr.addTimer(0, this.userBehaviorPlatformInfo.autoSaveInterval, -1, this.autoSaveUserDataExecute, this);
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
|
|
@@ -816,10 +826,15 @@ export class UserMgr extends BaseMgr {
|
|
|
816
826
|
return;
|
|
817
827
|
}
|
|
818
828
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
829
|
+
if (this.adMgr === null) {
|
|
830
|
+
this.adMgr = ServiceLocator.Instance.get<AdMgr>("AdMgr");
|
|
831
|
+
}
|
|
832
|
+
if (this.socialMgr === null) {
|
|
833
|
+
this.socialMgr = ServiceLocator.Instance.get<SocialMgr>("SocialMgr");
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (this.adMgr && this.socialMgr) {
|
|
837
|
+
if (this.adMgr.isRewardedVideoAdShowing() && this.socialMgr.isSharing()) {
|
|
823
838
|
return;
|
|
824
839
|
}
|
|
825
840
|
}
|