@chiyou/minigame-framework 1.2.61 → 1.2.63
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 +31 -6
- package/src/Framework/Manager/AudioMgr.ts +37 -20
- package/src/Framework/Manager/ExcelMgr.ts +3 -0
- package/src/Framework/Manager/InputMgr.ts +3 -0
- package/src/Framework/Manager/LifeCycleMgr.ts +3 -0
- package/src/Framework/Manager/NodePoolMgr.ts +22 -3
- package/src/Framework/Manager/PrivacyMgr.ts +28 -7
- package/src/Framework/Manager/ResMgr.ts +3 -0
- package/src/Framework/Manager/SocialMgr.ts +3 -0
- package/src/Framework/Manager/SystemMgr.ts +3 -0
- package/src/Framework/Manager/TimerMgr.ts +3 -0
- package/src/Framework/Manager/UIMgr.ts +15 -2
- package/src/Framework/Manager/UserMgr.ts +35 -7
- package/src/Framework/Utils/ServiceLocator.ts +18 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { math, randomRangeInt, view } from 'cc';
|
|
2
2
|
import { LogUtils } from '../Utils/LogUtils';
|
|
3
3
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
4
|
-
import { AudioMgr } from './AudioMgr';
|
|
5
4
|
import { AdCallback, Ad_Record, InterstitialAd_Callback_Status, InterstitialAd_Record, RewardedVideoAd_Callback_Status, RewardedVideoAd_Record, AdSwitchType, AdType, BannerAd_Info, CustomAd_Info, BannerAd_PlatformInfo, CustomAd_PlatformInfo, InterstitialAd_Scene, RewardedVideoAd_Scene, AdPlatformSettingInfo, AdPlatformUnitInfo, AdDefinition } from '../Definition/AdDefinition';
|
|
6
5
|
import { PlatformID } from '../Definition/SystemDefinition';
|
|
7
|
-
import { UserMgr } from './UserMgr';
|
|
8
6
|
import { BaseMgr } from './BaseMgr';
|
|
9
7
|
import { AbsAdAdapter } from '../Adapter/AdAdapter/AbsAdAdapter';
|
|
10
8
|
import { AdAdapterWeiXin } from '../Adapter/AdAdapter/AdAdapterWeiXin';
|
|
@@ -18,6 +16,9 @@ import { AdAdapterTapTap } from '../Adapter/AdAdapter/AdAdapterTapTap';
|
|
|
18
16
|
import { AdAdapterVivo } from '../Adapter/AdAdapter/AdAdapterVivo';
|
|
19
17
|
import { AdAdapterXiaoMi } from '../Adapter/AdAdapter/AdAdapterXiaoMi';
|
|
20
18
|
import { AdAdapterZhiFuBao } from '../Adapter/AdAdapter/AdAdapterZhiFuBao';
|
|
19
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
20
|
+
import type { UserMgr } from './UserMgr';
|
|
21
|
+
import type { AudioMgr } from './AudioMgr';
|
|
21
22
|
|
|
22
23
|
/** 广告管理器 */
|
|
23
24
|
export class AdMgr extends BaseMgr {
|
|
@@ -68,6 +69,9 @@ export class AdMgr extends BaseMgr {
|
|
|
68
69
|
/** 内容区域底部 */
|
|
69
70
|
private static contentBottom: number = 0;
|
|
70
71
|
|
|
72
|
+
private audioMgr: AudioMgr = null;
|
|
73
|
+
private userMgr: UserMgr = null;
|
|
74
|
+
|
|
71
75
|
onLoad(): void {
|
|
72
76
|
super.onLoad();
|
|
73
77
|
|
|
@@ -77,6 +81,8 @@ export class AdMgr extends BaseMgr {
|
|
|
77
81
|
this.destroy();
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
84
|
+
|
|
85
|
+
ServiceLocator.Instance.register("AdMgr", this);
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
/**
|
|
@@ -275,12 +281,26 @@ export class AdMgr extends BaseMgr {
|
|
|
275
281
|
}
|
|
276
282
|
|
|
277
283
|
if (res === RewardedVideoAd_Callback_Status.Status_Watching) {
|
|
278
|
-
|
|
284
|
+
if (this.audioMgr === null) {
|
|
285
|
+
this.audioMgr = ServiceLocator.Instance.get<AudioMgr>("AudioMgr");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (this.audioMgr) {
|
|
289
|
+
this.audioMgr.pauseMusic();
|
|
290
|
+
}
|
|
291
|
+
|
|
279
292
|
AdMgr.Instance.hideAllPermanentAd();
|
|
280
293
|
} else if (res === RewardedVideoAd_Callback_Status.Status_Complete ||
|
|
281
294
|
res === RewardedVideoAd_Callback_Status.Status_Giveup ||
|
|
282
295
|
res === RewardedVideoAd_Callback_Status.Status_Error) {
|
|
283
|
-
|
|
296
|
+
if (this.audioMgr === null) {
|
|
297
|
+
this.audioMgr = ServiceLocator.Instance.get<AudioMgr>("AudioMgr");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (this.audioMgr) {
|
|
301
|
+
this.audioMgr.resumeMusic();
|
|
302
|
+
}
|
|
303
|
+
|
|
284
304
|
AdMgr.Instance.showAllPermanentAd();
|
|
285
305
|
}
|
|
286
306
|
|
|
@@ -522,8 +542,13 @@ export class AdMgr extends BaseMgr {
|
|
|
522
542
|
let adPlatformSettingInfo: AdPlatformSettingInfo = AdMgr.adPlatformSettingMap.get(this.getCurrentPlatformID());
|
|
523
543
|
launchNoAdInterval = adPlatformSettingInfo.launchNoAdInterval_interstitialAd;
|
|
524
544
|
|
|
525
|
-
interstitialAdIntervalBase = adPlatformSettingInfo.
|
|
526
|
-
|
|
545
|
+
interstitialAdIntervalBase = adPlatformSettingInfo.retainUser_interstitialAd_IntervalBase;
|
|
546
|
+
|
|
547
|
+
if (this.userMgr === null) {
|
|
548
|
+
this.userMgr = ServiceLocator.Instance.get<UserMgr>("UserMgr");
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (this.userMgr && this.userMgr.isNewUser()) {
|
|
527
552
|
interstitialAdIntervalBase = adPlatformSettingInfo.registerUser_interstitialAd_IntervalBase;
|
|
528
553
|
}
|
|
529
554
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AudioClip, AudioSource } from "cc";
|
|
2
2
|
import { LogUtils } from "../Utils/LogUtils";
|
|
3
|
-
import { ResMgr } from "./ResMgr";
|
|
4
3
|
import { PlatformID } from "../Definition/SystemDefinition";
|
|
5
4
|
import { FrameworkBase } from "../Definition/FrameworkBase";
|
|
6
5
|
import { BaseMgr } from "./BaseMgr";
|
|
7
6
|
import { FwkErrorCode } from "../Definition/FwkErrorDefinition";
|
|
7
|
+
import { ServiceLocator } from "../Utils/ServiceLocator";
|
|
8
|
+
import type { ResMgr } from "./ResMgr";
|
|
8
9
|
|
|
9
10
|
/** 音频管理器 */
|
|
10
11
|
export class AudioMgr extends BaseMgr {
|
|
@@ -19,6 +20,8 @@ export class AudioMgr extends BaseMgr {
|
|
|
19
20
|
private musicSwitch: boolean = false;
|
|
20
21
|
private musicAudioSource: AudioSource = null;
|
|
21
22
|
|
|
23
|
+
private resMgr: ResMgr = null;
|
|
24
|
+
|
|
22
25
|
onLoad(): void {
|
|
23
26
|
super.onLoad();
|
|
24
27
|
|
|
@@ -28,6 +31,8 @@ export class AudioMgr extends BaseMgr {
|
|
|
28
31
|
this.destroy();
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
ServiceLocator.Instance.register("AudioMgr", this);
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
/**
|
|
@@ -182,16 +187,22 @@ export class AudioMgr extends BaseMgr {
|
|
|
182
187
|
return;
|
|
183
188
|
}
|
|
184
189
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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);
|
|
196
|
+
if (audioClip == null) {
|
|
197
|
+
LogUtils.Instance.error(AudioMgr.TAG, FwkErrorCode.Audio.LoadFailed, {
|
|
198
|
+
operation: "playEffect",
|
|
199
|
+
url: url,
|
|
200
|
+
reason: "资源未加载"
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.effectAudioSource.playOneShot(audioClip);
|
|
193
205
|
}
|
|
194
|
-
this.effectAudioSource.playOneShot(audioClip);
|
|
195
206
|
}
|
|
196
207
|
|
|
197
208
|
/**
|
|
@@ -275,18 +286,24 @@ export class AudioMgr extends BaseMgr {
|
|
|
275
286
|
return;
|
|
276
287
|
}
|
|
277
288
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
LogUtils.Instance.error(AudioMgr.TAG, FwkErrorCode.Audio.LoadFailed, {
|
|
281
|
-
operation: "playMusic",
|
|
282
|
-
url: url,
|
|
283
|
-
reason: "资源未加载"
|
|
284
|
-
});
|
|
285
|
-
return;
|
|
289
|
+
if (this.resMgr === null) {
|
|
290
|
+
this.resMgr = ServiceLocator.Instance.get<ResMgr>("ResMgr");
|
|
286
291
|
}
|
|
287
|
-
this.musicAudioSource.clip = audioClip;
|
|
288
292
|
|
|
289
|
-
this.
|
|
293
|
+
if (this.resMgr) {
|
|
294
|
+
let audioClip: AudioClip = this.resMgr.getAsset("Sounds", url);
|
|
295
|
+
if (audioClip == null) {
|
|
296
|
+
LogUtils.Instance.error(AudioMgr.TAG, FwkErrorCode.Audio.LoadFailed, {
|
|
297
|
+
operation: "playMusic",
|
|
298
|
+
url: url,
|
|
299
|
+
reason: "资源未加载"
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.musicAudioSource.clip = audioClip;
|
|
304
|
+
|
|
305
|
+
this._playMusic();
|
|
306
|
+
}
|
|
290
307
|
}
|
|
291
308
|
|
|
292
309
|
/** 播放音乐(内部方法) */
|
|
@@ -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
|
/** 初始化配置表管理器 */
|
|
@@ -3,6 +3,7 @@ import { BaseMgr } from './BaseMgr';
|
|
|
3
3
|
import { LogUtils } from '../Utils/LogUtils';
|
|
4
4
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
5
5
|
import { TimeUtils } from '../Utils/TimeUtils';
|
|
6
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
6
7
|
|
|
7
8
|
/** 键盘事件项 */
|
|
8
9
|
interface KeyboardEventItem {
|
|
@@ -201,6 +202,8 @@ export class InputMgr extends BaseMgr {
|
|
|
201
202
|
this.destroy();
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
205
|
+
|
|
206
|
+
ServiceLocator.Instance.register("InputMgr", this);
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FrameworkBase } from "../Definition/FrameworkBase";
|
|
2
2
|
import { LogUtils } from "../Utils/LogUtils";
|
|
3
|
+
import { ServiceLocator } from "../Utils/ServiceLocator";
|
|
3
4
|
import { BaseMgr } from "./BaseMgr";
|
|
4
5
|
import { EventMgr } from "./EventMgr";
|
|
5
6
|
|
|
@@ -19,6 +20,8 @@ export class LifeCycleMgr extends BaseMgr {
|
|
|
19
20
|
this.destroy();
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
ServiceLocator.Instance.register("LifeCycleMgr", this);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CCObject, Node, NodePool, Vec3 } from 'cc';
|
|
2
2
|
import { BaseMgr } from './BaseMgr';
|
|
3
3
|
import { LogUtils } from '../Utils/LogUtils';
|
|
4
|
-
import { UIMgr } from './UIMgr';
|
|
5
4
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
5
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
6
|
+
import type { UIMgr } from './UIMgr';
|
|
6
7
|
|
|
7
8
|
/** 节点池配置接口 */
|
|
8
9
|
export interface IPoolConfig {
|
|
@@ -68,6 +69,8 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
68
69
|
enableDebug: false,
|
|
69
70
|
};
|
|
70
71
|
|
|
72
|
+
private uiMgr: UIMgr = null;
|
|
73
|
+
|
|
71
74
|
onLoad(): void {
|
|
72
75
|
super.onLoad();
|
|
73
76
|
|
|
@@ -77,6 +80,8 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
77
80
|
this.destroy();
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
83
|
+
|
|
84
|
+
ServiceLocator.Instance.register("NodePoolMgr", this);
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
/**
|
|
@@ -421,7 +426,15 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
421
426
|
return null;
|
|
422
427
|
}
|
|
423
428
|
|
|
424
|
-
|
|
429
|
+
if (this.uiMgr === null) {
|
|
430
|
+
this.uiMgr = ServiceLocator.Instance.get<UIMgr>("UIMgr");
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (!this.uiMgr) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
let node: Node = this.uiMgr.create_ui(poolInfo.poolConfig.prefabUiName);
|
|
425
438
|
if (!node) {
|
|
426
439
|
LogUtils.Instance.error(NodePoolMgr.TAG, FwkErrorCode.NodePool.CreateFailed, {
|
|
427
440
|
operation: "_createNode",
|
|
@@ -454,7 +467,13 @@ export class NodePoolMgr extends BaseMgr {
|
|
|
454
467
|
|
|
455
468
|
let poolInfo: PoolInfo = this._poolInfoMap.get(poolName);
|
|
456
469
|
|
|
457
|
-
|
|
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);
|
|
476
|
+
}
|
|
458
477
|
|
|
459
478
|
if (poolInfo.poolConfig && poolInfo.poolConfig.enableDebug) {
|
|
460
479
|
this._printPoolState(poolName);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { LogUtils } from '../Utils/LogUtils';
|
|
2
2
|
import { AuthorizeResult, GetSettingResult, KindReminder, KindReminderType, PrivacyDefinition, PrivacyInfo, PrivacyPlatformInfo, PrivacyType, QueryPrivacyResult } from '../Definition/PrivacyDefinition';
|
|
3
3
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
4
|
-
import { UIMgr } from './UIMgr';
|
|
5
4
|
import { ToastDuration } from '../Definition/UIDefinition';
|
|
6
5
|
import { PlatformID } from '../Definition/SystemDefinition';
|
|
7
6
|
import { BaseMgr } from './BaseMgr';
|
|
8
7
|
import { FrameworkBase } from '../Definition/FrameworkBase';
|
|
8
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
9
|
+
import type { UIMgr } from './UIMgr';
|
|
9
10
|
|
|
10
11
|
/** 隐私协议管理器 */
|
|
11
12
|
export class PrivacyMgr extends BaseMgr {
|
|
@@ -19,6 +20,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
19
20
|
/** 已同意的版本号 */
|
|
20
21
|
private kindReminderAgreeVersion: string = "";
|
|
21
22
|
|
|
23
|
+
private uiMgr: UIMgr = null;
|
|
24
|
+
|
|
22
25
|
onLoad(): void {
|
|
23
26
|
super.onLoad();
|
|
24
27
|
|
|
@@ -28,6 +31,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
28
31
|
this.destroy();
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
ServiceLocator.Instance.register("PrivacyMgr", this);
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
/**
|
|
@@ -174,7 +179,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
174
179
|
|
|
175
180
|
this.getPlatformAdapter().requirePrivacyAuthorize((result) => {
|
|
176
181
|
if (!result) {
|
|
177
|
-
|
|
182
|
+
this.showToast("未同意隐私协议,无法使用" + featureName);
|
|
183
|
+
|
|
178
184
|
LogUtils.Instance.info(PrivacyMgr.TAG, "用户拒绝隐私授权", {
|
|
179
185
|
featureName: featureName,
|
|
180
186
|
privacyType: PrivacyType[privacyType],
|
|
@@ -187,7 +193,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
187
193
|
let privacyPlatformInfo: PrivacyPlatformInfo = privacyInfo.privacyPlatformMap.get(this.getCurrentPlatformID());
|
|
188
194
|
let scopeDescription: string = privacyPlatformInfo?.scopeDescription || "未知";
|
|
189
195
|
if (privacyPlatformInfo === null || privacyPlatformInfo.scopeDisable) {
|
|
190
|
-
|
|
196
|
+
this.showToast("不支持[" + scopeDescription + "],无法使用" + featureName);
|
|
197
|
+
|
|
191
198
|
LogUtils.Instance.info(PrivacyMgr.TAG, "隐私功能不支持", {
|
|
192
199
|
featureName: featureName,
|
|
193
200
|
privacyType: PrivacyType[privacyType],
|
|
@@ -210,7 +217,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
210
217
|
let scopeName: string = privacyPlatformInfo.scopeName;
|
|
211
218
|
this.getPlatformAdapter().getSetting(scopeName, (result: GetSettingResult) => {
|
|
212
219
|
if (result === GetSettingResult.Result_SettingNotAvailable) {
|
|
213
|
-
|
|
220
|
+
this.showToast("App版本过低,无法使用" + featureName, ToastDuration.Duration_Long);
|
|
221
|
+
|
|
214
222
|
LogUtils.Instance.info(PrivacyMgr.TAG, "隐私授权失败(版本不支持)", {
|
|
215
223
|
featureName: featureName,
|
|
216
224
|
privacyType: PrivacyType[privacyType],
|
|
@@ -219,7 +227,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
219
227
|
callback(QueryPrivacyResult.Result_Invalid);
|
|
220
228
|
return;
|
|
221
229
|
} else if (result === GetSettingResult.Result_Rejected) {
|
|
222
|
-
|
|
230
|
+
this.showToast("右上角...设置,开启[" + scopeDescription + "]权限,即可使用" + featureName, ToastDuration.Duration_Long);
|
|
231
|
+
|
|
223
232
|
LogUtils.Instance.info(PrivacyMgr.TAG, "用户拒绝权限授权", {
|
|
224
233
|
featureName: featureName,
|
|
225
234
|
privacyType: PrivacyType[privacyType],
|
|
@@ -231,7 +240,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
231
240
|
} else if (result === GetSettingResult.Result_NotExist_AuthorizeAvailable) {
|
|
232
241
|
this.getPlatformAdapter().authorize(scopeName, (result3) => {
|
|
233
242
|
if (result3 === AuthorizeResult.Result_AuthorizeNotAvailable) {
|
|
234
|
-
|
|
243
|
+
this.showToast("App版本过低,无法使用" + featureName, ToastDuration.Duration_Long);
|
|
244
|
+
|
|
235
245
|
LogUtils.Instance.info(PrivacyMgr.TAG, "授权失败(功能不可用)", {
|
|
236
246
|
featureName: featureName,
|
|
237
247
|
privacyType: PrivacyType[privacyType],
|
|
@@ -240,7 +250,8 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
240
250
|
callback(QueryPrivacyResult.Result_Invalid);
|
|
241
251
|
return;
|
|
242
252
|
} else if (result3 === AuthorizeResult.Result_Rejected) {
|
|
243
|
-
|
|
253
|
+
this.showToast("右上角...设置,开启[" + scopeDescription + "]权限,即可使用" + featureName, ToastDuration.Duration_Long);
|
|
254
|
+
|
|
244
255
|
LogUtils.Instance.info(PrivacyMgr.TAG, "用户拒绝授权请求", {
|
|
245
256
|
featureName: featureName,
|
|
246
257
|
privacyType: PrivacyType[privacyType],
|
|
@@ -279,4 +290,14 @@ export class PrivacyMgr extends BaseMgr {
|
|
|
279
290
|
});
|
|
280
291
|
});
|
|
281
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
|
+
}
|
|
282
303
|
}
|
|
@@ -2,6 +2,7 @@ import { Asset, assetManager, AssetManager, ImageAsset } from 'cc';
|
|
|
2
2
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
3
3
|
import { LogUtils } from '../Utils/LogUtils';
|
|
4
4
|
import { BaseMgr } from './BaseMgr';
|
|
5
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
5
6
|
|
|
6
7
|
export type ResBatch = string;
|
|
7
8
|
|
|
@@ -130,6 +131,8 @@ export class ResMgr extends BaseMgr {
|
|
|
130
131
|
this.destroy();
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
134
|
+
|
|
135
|
+
ServiceLocator.Instance.register("ResMgr", this);
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
/**
|
|
@@ -3,6 +3,7 @@ import { PlatformID } from "../Definition/SystemDefinition";
|
|
|
3
3
|
import { FwkErrorCode } from "../Definition/FwkErrorDefinition";
|
|
4
4
|
import { LogUtils } from "../Utils/LogUtils";
|
|
5
5
|
import { BaseMgr } from "./BaseMgr";
|
|
6
|
+
import { ServiceLocator } from "../Utils/ServiceLocator";
|
|
6
7
|
|
|
7
8
|
/** 社交功能管理器 */
|
|
8
9
|
export class SocialMgr extends BaseMgr {
|
|
@@ -23,6 +24,8 @@ export class SocialMgr extends BaseMgr {
|
|
|
23
24
|
this.destroy();
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
ServiceLocator.Instance.register("SocialMgr", this);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
/**
|
|
@@ -15,6 +15,7 @@ import { AppItem, CopyrightInfo, ICPItem, PlatformID } from "../Definition/Syste
|
|
|
15
15
|
import { FwkErrorCode } from "../Definition/FwkErrorDefinition";
|
|
16
16
|
import { LogUtils } from "../Utils/LogUtils";
|
|
17
17
|
import { BaseMgr } from "./BaseMgr";
|
|
18
|
+
import { ServiceLocator } from "../Utils/ServiceLocator";
|
|
18
19
|
|
|
19
20
|
/** 系统管理器 */
|
|
20
21
|
export class SystemMgr extends BaseMgr {
|
|
@@ -39,6 +40,8 @@ export class SystemMgr extends BaseMgr {
|
|
|
39
40
|
this.destroy();
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
ServiceLocator.Instance.register("SystemMgr", this);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FwkErrorCode } from "../Definition/FwkErrorDefinition";
|
|
2
2
|
import { LogUtils } from "../Utils/LogUtils";
|
|
3
|
+
import { ServiceLocator } from "../Utils/ServiceLocator";
|
|
3
4
|
import { BaseMgr } from "./BaseMgr";
|
|
4
5
|
|
|
5
6
|
interface ITimer {
|
|
@@ -27,6 +28,8 @@ export class TimerMgr extends BaseMgr {
|
|
|
27
28
|
this.destroy();
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
ServiceLocator.Instance.register("TimerMgr", this);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Component, Node, Button, Prefab, instantiate, screen, UITransform, v3, view, ResolutionPolicy, math, Tween, tween, Label, Color, Sprite, SpriteFrame, BlockInputEvents, Texture2D } from 'cc';
|
|
2
|
-
import { ResMgr } from './ResMgr';
|
|
3
2
|
import { FwkErrorCode } from '../Definition/FwkErrorDefinition';
|
|
4
3
|
import { LogUtils } from '../Utils/LogUtils';
|
|
5
4
|
import { ToastDuration } from '../Definition/UIDefinition';
|
|
6
5
|
import { BaseMgr } from './BaseMgr';
|
|
6
|
+
import { ServiceLocator } from '../Utils/ServiceLocator';
|
|
7
|
+
import type { ResMgr } from './ResMgr';
|
|
7
8
|
|
|
8
9
|
/** UI 控制器基类 */
|
|
9
10
|
export class UICtrl extends Component {
|
|
@@ -109,6 +110,8 @@ export class UIMgr extends BaseMgr {
|
|
|
109
110
|
/** Toast 历史最大记录数 */
|
|
110
111
|
private toastHistoryMaxCount: number = 10;
|
|
111
112
|
|
|
113
|
+
private resMgr: ResMgr = null;
|
|
114
|
+
|
|
112
115
|
/** 打印 UI 映射(调试用) */
|
|
113
116
|
public print(): void {
|
|
114
117
|
LogUtils.Instance.info(UIMgr.TAG, "UI映射表", {
|
|
@@ -230,6 +233,8 @@ export class UIMgr extends BaseMgr {
|
|
|
230
233
|
this.destroy();
|
|
231
234
|
return;
|
|
232
235
|
}
|
|
236
|
+
|
|
237
|
+
ServiceLocator.Instance.register("UIMgr", this);
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
/**
|
|
@@ -260,7 +265,15 @@ export class UIMgr extends BaseMgr {
|
|
|
260
265
|
* @return UI 节点
|
|
261
266
|
*/
|
|
262
267
|
public create_ui(ui_name: string, parent?: Node): Node {
|
|
263
|
-
|
|
268
|
+
if (this.resMgr === null) {
|
|
269
|
+
this.resMgr = ServiceLocator.Instance.get<ResMgr>("ResMgr");
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (!this.resMgr) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
let uiPrefab: Prefab = this.resMgr.getAsset("GUI", "UIPrefabs/" + ui_name);
|
|
264
277
|
if (!uiPrefab) {
|
|
265
278
|
LogUtils.Instance.error(UIMgr.TAG, FwkErrorCode.UI.PrefabNotFound, {
|
|
266
279
|
operation: "create_ui",
|
|
@@ -5,12 +5,13 @@ import { LogUtils } from "../Utils/LogUtils";
|
|
|
5
5
|
import { BaseMgr } from "./BaseMgr";
|
|
6
6
|
import { PlatformID } from "../Definition/SystemDefinition";
|
|
7
7
|
import { AbsPlatformAdapter } from "../Adapter/PlatformAdapter/AbsPlatformAdapter";
|
|
8
|
-
import { TimerMgr } from "./TimerMgr";
|
|
9
8
|
import { ObjectUtils } from "../Utils/ObjectUtils";
|
|
10
9
|
import { EventMgr } from "./EventMgr";
|
|
11
10
|
import { TimeUtils } from "../Utils/TimeUtils";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { ServiceLocator } from "../Utils/ServiceLocator";
|
|
12
|
+
import type { AdMgr } from "./AdMgr";
|
|
13
|
+
import type { SocialMgr } from "./SocialMgr";
|
|
14
|
+
import type { TimerMgr } from "./TimerMgr";
|
|
14
15
|
|
|
15
16
|
/** 用户管理器 */
|
|
16
17
|
export class UserMgr extends BaseMgr {
|
|
@@ -49,6 +50,10 @@ export class UserMgr extends BaseMgr {
|
|
|
49
50
|
private lastUpdateFullUserData: any = null;
|
|
50
51
|
private lastOnHideUpdateTimestampInSecond: number = 0;
|
|
51
52
|
|
|
53
|
+
private adMgr: AdMgr = null;
|
|
54
|
+
private socialMgr: SocialMgr = null;
|
|
55
|
+
private timerMgr: TimerMgr = null;
|
|
56
|
+
|
|
52
57
|
onLoad(): void {
|
|
53
58
|
super.onLoad();
|
|
54
59
|
|
|
@@ -59,13 +64,21 @@ export class UserMgr extends BaseMgr {
|
|
|
59
64
|
return;
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
ServiceLocator.Instance.register("UserMgr", this);
|
|
68
|
+
|
|
62
69
|
EventMgr.Instance.on(FrameworkBase.Message.LifeCycle_onGameHide, this.onGameHideCallback, this);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
protected onDestroy(): void {
|
|
66
73
|
EventMgr.Instance.off(FrameworkBase.Message.LifeCycle_onGameHide, this.onGameHideCallback, this);
|
|
67
74
|
|
|
68
|
-
|
|
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);
|
|
81
|
+
}
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
/**
|
|
@@ -105,7 +118,13 @@ export class UserMgr extends BaseMgr {
|
|
|
105
118
|
}
|
|
106
119
|
|
|
107
120
|
if (this.userBehaviorPlatformInfo.autoSaveInterval > 0 && this.userBehaviorPlatformInfo.supportServerUserData) {
|
|
108
|
-
|
|
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);
|
|
127
|
+
}
|
|
109
128
|
}
|
|
110
129
|
|
|
111
130
|
LogUtils.Instance.info(UserMgr.TAG, "初始化完成");
|
|
@@ -807,8 +826,17 @@ export class UserMgr extends BaseMgr {
|
|
|
807
826
|
return;
|
|
808
827
|
}
|
|
809
828
|
|
|
810
|
-
if (
|
|
811
|
-
|
|
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()) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
812
840
|
}
|
|
813
841
|
|
|
814
842
|
LogUtils.Instance.info(UserMgr.TAG, "onGameHide 保存用户数据");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
export class ServiceLocator {
|
|
3
|
+
private static _instance: ServiceLocator = new ServiceLocator();
|
|
4
|
+
|
|
5
|
+
public static get Instance(): ServiceLocator {
|
|
6
|
+
return this._instance;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
private _services: Map<string, any> = new Map();
|
|
10
|
+
|
|
11
|
+
public register(name: string, service: any): void {
|
|
12
|
+
this._services.set(name, service);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public get<T>(name: string): T {
|
|
16
|
+
return this._services.get(name) as T;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { NumberUtils } from './Framework/Utils/NumberUtils';
|
|
|
29
29
|
export { ObjectUtils } from './Framework/Utils/ObjectUtils';
|
|
30
30
|
export { TimeUtils } from './Framework/Utils/TimeUtils';
|
|
31
31
|
export { TweenUtils, type AnimOptions, type EasingType, TweenSequence, TweenParallel } from './Framework/Utils/TweenUtils';
|
|
32
|
+
export { ServiceLocator } from './Framework/Utils/ServiceLocator';
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* TweenChain 使用示例:
|