@cc-component/cc-core 1.2.1 → 1.2.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.
Files changed (32) hide show
  1. package/assets/core/config/LayerUI.ts +4 -6
  2. package/assets/core/editor/LanguageManager.ts +4 -4
  3. package/assets/core/editor/i18nEditorComponent.ts +7 -7
  4. package/assets/core/home/BaseBoxView.ts +1 -1
  5. package/assets/core/home/BaseLoading.ts +19 -22
  6. package/assets/core/home/BaseSkeleton.ts +4 -4
  7. package/assets/core/home/CameraAngel.ts +41 -41
  8. package/assets/core/home/FollowCamera.ts +28 -29
  9. package/assets/core/home/InViewCenter.ts +1 -1
  10. package/assets/core/home/ProgessWindow.ts +2 -2
  11. package/assets/core/home/ResourceManager.ts +12 -12
  12. package/assets/core/home/StateMachine.ts +9 -9
  13. package/assets/core/home/StorageManager.ts +1 -1
  14. package/assets/core/home/ThirdFreeLookCamera.ts +2 -2
  15. package/assets/core/home/TimeManager.ts +1 -1
  16. package/assets/core/home/util/RandomUtil.ts +41 -41
  17. package/assets/core/interface/MainModule.ts +27 -25
  18. package/assets/core/lib/language/Language.ts +3 -4
  19. package/assets/core/lib/language/LanguageData.ts +2 -2
  20. package/assets/core/lib/language/LanguageLabel.ts +2 -2
  21. package/assets/core/lib/language/LanguagePack.ts +4 -5
  22. package/assets/core/lib/language/LanguageSprite.ts +1 -1
  23. package/assets/core/lib/logger/ELoggerLevel.ts +0 -12
  24. package/assets/core/lib/logger/MLogger.ts +7 -8
  25. package/assets/core/lib/net/net/HttpManager.ts +2 -2
  26. package/assets/core/lib/net/net/NetNode.ts +16 -17
  27. package/assets/core/lib/net/net/WebSock.ts +1 -2
  28. package/assets/core/lib/net/net/custom/NetGameTips.ts +8 -9
  29. package/assets/core/lib/net/net/custom/NetNodeGame.ts +1 -1
  30. package/package.json +1 -1
  31. package/assets/core/lib/Logger.ts +0 -286
  32. package/assets/core/lib/Logger.ts.meta +0 -9
@@ -208,7 +208,7 @@ export class ResourceManager {
208
208
  list.push({ name: asset.name, refCount: asset.refCount })
209
209
  }
210
210
  });
211
- console.warn("资源计数:\n", list)
211
+ Logger.warn("资源计数:\n", list)
212
212
  }
213
213
 
214
214
  LogAssetsAll() {
@@ -229,10 +229,10 @@ export class ResourceManager {
229
229
  const { asset, refCount } = record;
230
230
  list.push({ bundle_name: record.bundleName, name: asset.name, refCount: refCount, refCountAsset: asset.refCount })
231
231
  });
232
- console.warn("资源计数:\n", Array.from(bundle_map.values()))
232
+ Logger.warn("资源计数:\n", Array.from(bundle_map.values()))
233
233
 
234
- console.warn("资源总数:", assetManager.assets.count)
235
- console.warn("资源总数:", assetManager.assets)
234
+ Logger.warn("资源总数:", assetManager.assets.count)
235
+ Logger.warn("资源总数:", assetManager.assets)
236
236
  }, 500)
237
237
 
238
238
  }
@@ -294,7 +294,7 @@ export class ResourceManager {
294
294
  let asset = bundle.get(path);
295
295
 
296
296
  if (asset) {
297
- //console.log('已加载==', asset.refCount)
297
+ //Logger.debug('已加载==', asset.refCount)
298
298
  // 记录加载的资源
299
299
  ResourceManager.instance.trackAsset(path, asset, bundleName);
300
300
  ResourceManager.instance.LogAssets(bundleName)
@@ -309,7 +309,7 @@ export class ResourceManager {
309
309
  resolve(null);
310
310
  return;
311
311
  }
312
- console.log('--加载', path)
312
+ Logger.debug('--加载', path)
313
313
  // 记录加载的资源
314
314
  ResourceManager.instance.trackAsset(path, asset, bundleName);
315
315
  ResourceManager.instance.LogAssets(bundleName)
@@ -335,7 +335,7 @@ export class ResourceManager {
335
335
  //加载bundle——预制体
336
336
  assetManager.loadBundle(name, (err, ab: AssetManager.Bundle) => {
337
337
  if (err) {
338
- console.warn(`bundle名称:${name} `, err);
338
+ Logger.warn(`bundle名称:${name} `, err);
339
339
  return;
340
340
  }
341
341
  resolve(ab);
@@ -358,7 +358,7 @@ export class ResourceManager {
358
358
 
359
359
  static async loadDir(bundleName: string, dirName: string, type: any, pre: Function) {
360
360
  return new Promise<void>(resolve => {
361
- //console.warn(bundleName, dirName)
361
+ //Logger.warn(bundleName, dirName)
362
362
 
363
363
  assetManager.getBundle(bundleName).loadDir(dirName, type, (finished: number, total: number, item: any) => {
364
364
  pre(Math.floor((finished / total * 100)));
@@ -366,7 +366,7 @@ export class ResourceManager {
366
366
  // 记录加载的资源
367
367
  assets.forEach(asset => {
368
368
  const asset_info: { uuid: string, path: string } = assetManager.getBundle(bundleName).getAssetInfo(asset.uuid) as { uuid: string, path: string }
369
- //console.warn(asset_info.path)
369
+ //Logger.warn(asset_info.path)
370
370
  ResourceManager.instance.trackAsset(asset_info.path, asset, bundleName);
371
371
  });
372
372
  resolve();
@@ -382,7 +382,7 @@ export class ResourceManager {
382
382
  static async loadScene(bundleName: string, name: string, pre: Function): Promise<SceneAsset> {
383
383
  var promise = new Promise<SceneAsset>(async resolve => {
384
384
  let bundle = assetManager.getBundle(bundleName)
385
- // console.warn("-111-加载c错了=", bun);
385
+ // Logger.warn("-111-加载c错了=", bun);
386
386
  if (!bundle) {
387
387
  bundle = await new Promise<any>(resolve => {
388
388
  assetManager.loadBundle(bundleName, (err, bundle) => {
@@ -395,7 +395,7 @@ export class ResourceManager {
395
395
  pre(Math.floor((finished / total * 100)));
396
396
  }, (err, prefab) => {
397
397
  if (err) {
398
- console.warn("--加载c错了=", bundleName, name, err);
398
+ Logger.warn("--加载c错了=", bundleName, name, err);
399
399
  }
400
400
  resolve(prefab);
401
401
  });
@@ -415,7 +415,7 @@ export class ResourceManager {
415
415
  pre(Math.floor((finished / total * 100)));
416
416
  }, (err) => {
417
417
  if (err) {
418
- console.warn("预加载c错了=", bundleName, name, err);
418
+ Logger.warn("预加载c错了=", bundleName, name, err);
419
419
  }
420
420
  resolve(null)
421
421
  });
@@ -8,7 +8,7 @@ abstract class GameState {
8
8
  abstract enter(): void;
9
9
  abstract execute(): void;
10
10
  exit(): void {
11
- console.log(`${this.constructor.name} 状态退出`);
11
+ Logger.debug(`${this.constructor.name} 状态退出`);
12
12
  }
13
13
  }
14
14
  export interface IStateMachine {
@@ -50,27 +50,27 @@ export class GameController {
50
50
 
51
51
  // 具体状态类:开始游戏
52
52
  export class StartGameState extends GameState {
53
- enter() { console.log("进入游戏..."); }
53
+ enter() { Logger.debug("进入游戏..."); }
54
54
  execute() {
55
- console.log("准备开始游戏...");
55
+ Logger.debug("准备开始游戏...");
56
56
  setTimeout(() => this.delegate.next(), 1000); // 自动进入下一个状态
57
57
  }
58
58
  }
59
59
 
60
60
  // 具体状态类:游戏中
61
61
  export class InGameState extends GameState {
62
- enter() { console.log("进入游戏中..."); }
62
+ enter() { Logger.debug("进入游戏中..."); }
63
63
  execute() {
64
- console.log("正在游戏中...");
64
+ Logger.debug("正在游戏中...");
65
65
  setTimeout(() => this.delegate.next(), 1000);
66
66
  }
67
67
  }
68
68
 
69
69
  // 具体状态类:弹出选择框
70
70
  export class PopupState extends GameState {
71
- enter() { console.log("弹出选择框..."); }
71
+ enter() { Logger.debug("弹出选择框..."); }
72
72
  execute() {
73
- console.log("等待玩家选择...");
73
+ Logger.debug("等待玩家选择...");
74
74
  setTimeout(() => {
75
75
  const choice = prompt("请选择 (确认/取消): ");
76
76
  this.onUserChoice(choice || "取消");
@@ -88,6 +88,6 @@ export class PopupState extends GameState {
88
88
 
89
89
  // 具体状态类:结束游戏
90
90
  export class EndGameState extends GameState {
91
- enter() { console.log("游戏结束..."); }
92
- execute() { console.log("感谢您的游玩!"); }
91
+ enter() { Logger.debug("游戏结束..."); }
92
+ execute() { Logger.debug("感谢您的游玩!"); }
93
93
  }
@@ -50,7 +50,7 @@ export class StorageManager {
50
50
  keywords = this.iss.encryptKey(keywords);
51
51
  }
52
52
  if (null == value) {
53
- console.warn("存储的值为空,则直接移除该存储");
53
+ Logger.warn("存储的值为空,则直接移除该存储");
54
54
  this.remove(key);
55
55
  return;
56
56
  }
@@ -72,7 +72,7 @@ export class ThirdFreeLookCamera extends Component {
72
72
  isDown: boolean = false;
73
73
  private MouseDown(e: EventTouch) {
74
74
  this.isDown = true;
75
- console.log("点击");
75
+ Logger.debug("点击");
76
76
  }
77
77
 
78
78
  private MouseMove(e: EventTouch) {
@@ -181,7 +181,7 @@ export class ThirdFreeLookCamera extends Component {
181
181
  this.angle = Quaternion.GetEulerFromQuat(_quat);
182
182
  this.MouseX = this.angle.y;
183
183
  this.MouseY = this.angle.x;
184
- //console.log(this.MouseX.toFixed(2),this.MouseY.toFixed(2));
184
+ //Logger.debug(this.MouseX.toFixed(2),this.MouseY.toFixed(2));
185
185
  }
186
186
 
187
187
  /*************************FollowIndependentRotation end***************** */
@@ -98,7 +98,7 @@ export class TimeManager {
98
98
  updateCountdownTime(key: string, minutes: number): boolean {
99
99
  const countdownInfo = this.countdowns.get(key);
100
100
  if (!countdownInfo) {
101
- console.warn(`倒计时 ${key} 不存在`);
101
+ Logger.warn(`倒计时 ${key} 不存在`);
102
102
  return false;
103
103
  }
104
104
 
@@ -12,50 +12,50 @@
12
12
  */
13
13
 
14
14
 
15
- /**
16
- * 生成[0, max)的随机数
17
- * @param max
18
- * @returns
19
- */
20
- export function random(min: number, max?: number) {
21
- if (!max) {
22
- max = min;
23
- min = 0;
24
- }
25
- return min + Math.random() * (max - min);
15
+ /**
16
+ * 生成[0, max)的随机数
17
+ * @param max
18
+ * @returns
19
+ */
20
+ export function random(min: number, max?: number) {
21
+ if (!max) {
22
+ max = min;
23
+ min = 0;
26
24
  }
25
+ return min + Math.random() * (max - min);
26
+ }
27
27
 
28
- /**
29
- * 生成[0, max)的随机整数
30
- * @param max
31
- * @returns
32
- */
33
- export function randomInt(min: number, max?: number) {
34
- return Math.floor(random(min, max));
28
+ /**
29
+ * 生成[0, max)的随机整数
30
+ * @param max
31
+ * @returns
32
+ */
33
+ export function randomInt(min: number, max?: number) {
34
+ return Math.floor(random(min, max));
35
+ }
36
+ /**
37
+ * 从数组中随机取出不重复的元素
38
+ * @param array 原始数组
39
+ * @param count 要取的元素个数
40
+ * @returns 随机不重复的元素数组
41
+ */
42
+ export function randomUniqueElements<T>(array: T[], count: number): T[] {
43
+ // 如果请求的元素数量大于数组长度,则警告并限制为数组长度
44
+ if (count > array.length) {
45
+ Logger.warn('请求的元素数量大于数组长度,将返回全部元素');
46
+ count = array.length;
35
47
  }
36
- /**
37
- * 从数组中随机取出不重复的元素
38
- * @param array 原始数组
39
- * @param count 要取的元素个数
40
- * @returns 随机不重复的元素数组
41
- */
42
- export function randomUniqueElements<T>(array: T[], count: number): T[] {
43
- // 如果请求的元素数量大于数组长度,则警告并限制为数组长度
44
- if (count > array.length) {
45
- console.warn('请求的元素数量大于数组长度,将返回全部元素');
46
- count = array.length;
47
- }
48
-
49
- // 创建数组副本,避免修改原始数组
50
- const copy = [...array];
51
- const result: T[] = [];
52
48
 
53
- // 使用 Fisher-Yates 洗牌算法打乱数组顺序
54
- for (let i = copy.length - 1; i > 0; i--) {
55
- const j = Math.floor(Math.random() * (i + 1));
56
- [copy[i], copy[j]] = [copy[j], copy[i]];
57
- }
49
+ // 创建数组副本,避免修改原始数组
50
+ const copy = [...array];
51
+ const result: T[] = [];
58
52
 
59
- // 返回打乱后的数组中前 count 个元素
60
- return copy.slice(0, count);
53
+ // 使用 Fisher-Yates 洗牌算法打乱数组顺序
54
+ for (let i = copy.length - 1; i > 0; i--) {
55
+ const j = Math.floor(Math.random() * (i + 1));
56
+ [copy[i], copy[j]] = [copy[j], copy[i]];
61
57
  }
58
+
59
+ // 返回打乱后的数组中前 count 个元素
60
+ return copy.slice(0, count);
61
+ }
@@ -16,6 +16,7 @@ import { TimeManager } from "../home/TimeManager";
16
16
  import { LanguageManager } from "../lib/language/Language";
17
17
  import { BundleConfigName, HttpType, IBundleConfig, IExtData, IHttpConfig, IInitConfig, IWindowParam, SystemMessage } from "../config/CommonEnum";
18
18
  import { LayerType } from "../config/LayerType";
19
+ import { ELoggerLevel } from "../lib/logger/ELoggerLevel";
19
20
 
20
21
 
21
22
  // const { keepClassName } = keepClass;
@@ -87,13 +88,14 @@ export class MainModule {
87
88
  self._gui = new LayerUI();
88
89
  self._http = new HttpManager();
89
90
  if (!EDITOR) {
91
+ Logger.setLevel(ELoggerLevel.Error);
90
92
  await self._gui.loadConfig(param);
91
93
  const config: EnvironmentConfig = self._gui.current_config;
92
94
  // 免网络
93
95
  self._http.server = config.httpServer;
94
96
  self._http.timeout = config.httpTimeout;
95
97
  }
96
- console.log("初始化完成")
98
+ Logger.debug("初始化完成")
97
99
  }
98
100
 
99
101
  static OpenLoading(is_show: boolean) {
@@ -113,8 +115,8 @@ export class MainModule {
113
115
  let width = node.getComponent(UITransform).contentSize.width;
114
116
  let height = node.getComponent(UITransform).contentSize.height;
115
117
  let windowSize = view.getVisibleSize();
116
- // console.log(windowSize);
117
- // console.log("屏幕:", windowSize);
118
+ // Logger.debug(windowSize);
119
+ // Logger.debug("屏幕:", windowSize);
118
120
  let leftRatio = node.worldPosition.x / windowSize.width;
119
121
  let topRatio = 1 - (node.worldPosition.y / windowSize.height);
120
122
 
@@ -266,22 +268,22 @@ export class MainModule {
266
268
  // static async Http<T>(config: IHttpConfig, params?: any, ext?: { is_show_alert?: boolean }): Promise<HttpReturn<T>> {
267
269
  // return new Promise<HttpReturn<any>>(async (resolve, reject) => {
268
270
  // MainModule.OpenBlockEvents(LayerType.LayerBlockEventsNet, true)
269
- // console.warn(`发起${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${config.url}\n 参数:${params}`,);
271
+ // Logger.warn(`发起${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${config.url}\n 参数:${params}`,);
270
272
  // let ret: HttpReturn<any>;
271
273
  // if (config.type == HttpType.GET) {
272
274
  // ret = await MainModule.http.getJson(config.url, params);
273
275
  // } else if (config.type == HttpType.POST) {
274
276
  // ret = await MainModule.http.postJson(config.url, params);
275
277
  // }
276
- // console.warn(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${config.url}\n 参数:${params}`);
277
- // console.warn(`返回结果:${ret}`);
278
- // console.warn(`返回结果:${JSON.stringify(ret.res)}`);
278
+ // Logger.warn(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${config.url}\n 参数:${params}`);
279
+ // Logger.warn(`返回结果:${ret}`);
280
+ // Logger.warn(`返回结果:${JSON.stringify(ret.res)}`);
279
281
  // MainModule.OpenBlockEvents(LayerType.LayerBlockEventsNet, false)
280
282
  // if (ret.isSucc) {
281
283
  // resolve(ret.res)
282
284
  // }
283
285
  // else {
284
- // console.log(ret.err);
286
+ // Logger.debug(ret.err);
285
287
  // if (ext && ext.is_show_alert || (ext === undefined || ext.is_show_alert === undefined)) {
286
288
  // const param = { des: "网络断开,请检查网络!", enterStr: "重试?", cancelStr: "取消", isDestory: false }
287
289
  // const view = await CommonModule.OpenAlertWindow(param);
@@ -315,7 +317,7 @@ export class MainModule {
315
317
  MainModule.OpenBlockEvents(LayerType.LayerBlockEventsNet, true);
316
318
 
317
319
  const url = MainModule.gui.current_config.httpServer + config.url
318
- console.log(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${url} `, `\n 参数:`, params);
320
+ Logger.debug(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${url} `, `\n 参数:`, params);
319
321
  let ret: HttpReturn<any>;
320
322
  if (config.type === HttpType.GET) {
321
323
  ret = await MainModule.http.getJson(config.url, params);
@@ -323,9 +325,9 @@ export class MainModule {
323
325
  ret = await MainModule.http.postJson(config.url, params, ext);
324
326
  }
325
327
 
326
- console.log(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} 结果 url:${url}\n`, ` 参数:`, params);
327
- console.log(`返回结果:`, ret.res);
328
- //console.warn(`返回结果:${JSON.stringify(ret.res)}`);
328
+ Logger.debug(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} 结果 url:${url}\n`, ` 参数:`, params);
329
+ Logger.debug(`返回结果:`, ret.res);
330
+ //Logger.warn(`返回结果:${JSON.stringify(ret.res)}`);
329
331
 
330
332
  MainModule.OpenBlockEvents(LayerType.LayerBlockEventsNet, false);
331
333
  if (ret.isSucc) {
@@ -352,7 +354,7 @@ export class MainModule {
352
354
  });
353
355
 
354
356
  if (!userChoice) {
355
- console.log("用户取消请求");
357
+ Logger.debug("用户取消请求");
356
358
  originalReject("取消了"); // 用户取消,调用原始 reject
357
359
  return;
358
360
  }
@@ -399,7 +401,7 @@ export class MainModule {
399
401
  return;
400
402
  }
401
403
  else if (MainModule.IsWindowOpen(className)) {
402
- console.warn("重复打开窗口-请检查", config.path)
404
+ Logger.warn("重复打开窗口-请检查", config.path)
403
405
  return;
404
406
  }
405
407
  //console.error('打开:', Array.from(MainModule.Instance.openedWindows.keys()), config.path);
@@ -439,7 +441,7 @@ export class MainModule {
439
441
  list.push(className);
440
442
  const layerUI_list = MainModule.Ins.openWindowLayer.get(LayerType.LayerUI)
441
443
  if (layerUI_list && layerUI_list.length > 0) MainModule.gui.GetLayer(LayerType.LayerGame).active = false;
442
- console.log('LayerType.LayerUI 打开窗口记录:', className, list);
444
+ Logger.debug('LayerType.LayerUI 打开窗口记录:', className, list);
443
445
  MainModule.Emit(SystemMessage.OpenWindow, className)
444
446
 
445
447
  resolve(view);
@@ -556,7 +558,7 @@ export class MainModule {
556
558
  params?.callback?.()
557
559
  }
558
560
  else {
559
- console.log("图片已销毁")
561
+ Logger.debug("图片已销毁")
560
562
  }
561
563
  return;
562
564
  }
@@ -567,7 +569,7 @@ export class MainModule {
567
569
  params?.callback?.()
568
570
  }
569
571
  else {
570
- console.log("图片已销毁")
572
+ Logger.debug("图片已销毁")
571
573
  }
572
574
  }
573
575
  })
@@ -594,7 +596,7 @@ export class MainModule {
594
596
  params?.callback?.()
595
597
  }
596
598
  else {
597
- console.log("动画已销毁")
599
+ Logger.debug("动画已销毁")
598
600
  }
599
601
  }
600
602
  })
@@ -626,10 +628,10 @@ export class MainModule {
626
628
  extra: "extra",
627
629
  zoneId: "default",
628
630
  success(res) {
629
- console.log(`排行榜设置成功: ${res}`);
631
+ Logger.debug(`排行榜设置成功: ${res}`);
630
632
  },
631
633
  fail(res) {
632
- console.log(`排行榜设置失败: ${res.errMsg}`);
634
+ Logger.debug(`排行榜设置失败: ${res.errMsg}`);
633
635
  },
634
636
  });
635
637
  }
@@ -640,7 +642,7 @@ export class MainModule {
640
642
  if (BYTEDANCE) {
641
643
  //@ts-ignore
642
644
  const info = tt.getSystemInfoSync();
643
- console.log('-------抖音', info.appName);
645
+ Logger.debug('-------抖音', info.appName);
644
646
  const appName = info.appName;
645
647
  if (appName.toUpperCase() === "DOUYIN") {//抖音
646
648
  // do something
@@ -862,7 +864,7 @@ export class MainModule {
862
864
  return false;
863
865
  }
864
866
  } else {
865
- console.warn(`窗口 ${className} 未找到或未打开`);
867
+ Logger.warn(`窗口 ${className} 未找到或未打开`);
866
868
  return false;
867
869
  }
868
870
  }
@@ -901,7 +903,7 @@ export class MainModule {
901
903
  const list_layer = MainModule.Ins.openWindowLayer.get(config.layer)
902
904
  list_layer.pop();//移除最后一个
903
905
  this.ShowLayerUI(config, true)
904
- console.log('LayerType.LayerUI 移除窗口记录:', className, list_layer);
906
+ Logger.debug('LayerType.LayerUI 移除窗口记录:', className, list_layer);
905
907
  }
906
908
 
907
909
  this.openedWindows.delete(className);
@@ -930,7 +932,7 @@ export class MainModule {
930
932
  }
931
933
  }
932
934
 
933
- console.log(`共关闭 ${closedCount} 个窗口`);
935
+ Logger.debug(`共关闭 ${closedCount} 个窗口`);
934
936
  return closedCount;
935
937
  }
936
938
 
@@ -985,7 +987,7 @@ export class MainModule {
985
987
  //#region 运行补丁
986
988
  // 默认实现函数
987
989
  static DefaultFunction(param?: any, callBack?: Function) {
988
- console.warn('调用了默认方法,可能该方法未实现', param);
990
+ Logger.warn('调用了默认方法,可能该方法未实现', param);
989
991
  callBack?.();
990
992
  }
991
993
  /**
@@ -1,7 +1,6 @@
1
1
  import { sys } from "cc";
2
2
  import { LanguageData } from "./LanguageData";
3
3
  import { LanguagePack } from "./LanguagePack";
4
- import { Logger } from "../Logger";
5
4
  import { LanguageLabel } from "./LanguageLabel";
6
5
  import { LanguageSprite } from "./LanguageSprite";
7
6
  import { EDITOR } from "cc/env";
@@ -69,18 +68,18 @@ export class LanguageManager {
69
68
 
70
69
  let index = this.languages.indexOf(language);
71
70
  if (index < 0) {
72
- console.log(`当前不支持【${language}】语言,将自动切换到【${this._defaultLanguage}】语言`);
71
+ Logger.debug(`当前不支持【${language}】语言,将自动切换到【${this._defaultLanguage}】语言`);
73
72
  language = this._defaultLanguage;
74
73
  }
75
74
 
76
75
  if (language === LanguageData.current) {
77
- console.log(`当前语言【${language}】语言,没有改变`)
76
+ Logger.debug(`当前语言【${language}】语言,没有改变`)
78
77
  callback && callback();
79
78
  return;
80
79
  }
81
80
 
82
81
  this.loadLanguageAssets(bundleName, language, (lang: string) => {
83
- Logger.logConfig(`当前语言为【${language}】`);
82
+ Logger.debug(`当前语言为【${language}】`);
84
83
  const oldLanguage = LanguageData.current;
85
84
  LanguageData.current = language;
86
85
  this._languagePack.updateLanguage(language);
@@ -80,7 +80,7 @@ export class LanguageData {
80
80
  let url = absoluteUrl.split("://");
81
81
  let paths = url[1].split("/");
82
82
  dbUrl = url[0] + "://" + paths[0] + "/" + paths[1];
83
- //console.log("absoluteUrl112222:", absoluteUrl, dbUrl);
83
+ //Logger.debug("absoluteUrl112222:", absoluteUrl, dbUrl);
84
84
  //label
85
85
  return dbUrl
86
86
 
@@ -93,7 +93,7 @@ export class LanguageData {
93
93
  let uuid = await Editor.Message.request("asset-db", "query-uuid", db_json);
94
94
  await new Promise<void>((resolve) => {
95
95
  assetManager.loadAny(uuid, (err, jsonAsset: JsonAsset) => {
96
- // console.log("2加载表格", jsonAsset, err);
96
+ // Logger.debug("2加载表格", jsonAsset, err);
97
97
  MainModule.gui.config = jsonAsset.json as IConfig;
98
98
  //console.error(MainModule.gui.config)
99
99
  resolve()
@@ -118,7 +118,7 @@ export class LanguageLabel extends Component {
118
118
  const richtext = this.getComponent(RichText);
119
119
  const font: TTFFont | null = LanguageData.font;
120
120
 
121
- // console.log('过呢更新', this.node.name, this.string, LanguageData.current)
121
+ // Logger.debug('过呢更新', this.node.name, this.string, LanguageData.current)
122
122
  if (label) {
123
123
  if (font) {
124
124
  label.font = font;
@@ -156,7 +156,7 @@ export class LanguageLabel extends Component {
156
156
 
157
157
  let uuid = await Editor.Message.request("asset-db", "query-uuid", db_json);
158
158
  assetManager.loadAny(uuid, (err, jsonAsset: JsonAsset) => {
159
- // console.log("加载表格", jsonAsset, err);
159
+ // Logger.debug("加载表格", jsonAsset, err);
160
160
  if (!jsonAsset) return;
161
161
  let labelData = jsonAsset.json;
162
162
  LanguageData.language.set(LanguageDataType.Json, jsonAsset.json);
@@ -12,7 +12,6 @@ import { ResourceManager } from "../../home/ResourceManager";
12
12
  import { SpriteFrame } from "cc";
13
13
  import { sp } from "cc";
14
14
  import { JsonUtil } from "../../home/JsonUtil";
15
- import { Logger } from "../Logger";
16
15
 
17
16
  export class LanguagePack {
18
17
  /**
@@ -62,7 +61,7 @@ export class LanguagePack {
62
61
  return new Promise((resolve, reject) => {
63
62
  const path = `${LanguageData.path_texture}/${lang}`;
64
63
  MainModule.loadDir(bundleName, path, SpriteFrame, () => { }).then(() => {
65
- Logger.logConfig(path, "下载语言包 textures 资源");
64
+ Logger.debug(path, "下载语言包 textures 资源");
66
65
  resolve();
67
66
  });
68
67
  });
@@ -75,7 +74,7 @@ export class LanguagePack {
75
74
  const jsonAsset = await MainModule.loadAsset(bundleName, path, JsonAsset);
76
75
  if (jsonAsset) {
77
76
  LanguageData.language.set(LanguageDataType.Json, jsonAsset.json);
78
- Logger.logConfig(path, "下载语言包 json 资源");
77
+ Logger.debug(path, "下载语言包 json 资源");
79
78
  }
80
79
  else {
81
80
  resolve();
@@ -83,7 +82,7 @@ export class LanguagePack {
83
82
  }
84
83
 
85
84
  MainModule.loadAsset(bundleName, path, TTFFont).then((font: TTFFont) => {
86
- Logger.logConfig(path, "下载语言包 ttf 资源");
85
+ Logger.debug(path, "下载语言包 ttf 资源");
87
86
  LanguageData.font = font;
88
87
  resolve();
89
88
  });
@@ -95,7 +94,7 @@ export class LanguagePack {
95
94
  return new Promise(async (resolve, reject) => {
96
95
  const path = `${LanguageData.path_spine}/${lang}`;
97
96
  MainModule.loadDir(bundleName, path, sp.Skeleton, () => { }).then(() => {
98
- Logger.logConfig(path, "下载语言包 spine 资源");
97
+ Logger.debug(path, "下载语言包 spine 资源");
99
98
  resolve();
100
99
  });
101
100
  });
@@ -115,7 +115,7 @@ export class LanguageSprite extends Component {
115
115
  return;
116
116
  }
117
117
  assetManager.loadAny(uuid, (err, imageAsset: ImageAsset) => {
118
- //console.log("加载图片", imageAsset, err);
118
+ //Logger.debug("加载图片", imageAsset, err);
119
119
  if (!imageAsset) return;
120
120
  let spriteFrame = SpriteFrame.createWithImage(imageAsset);
121
121
  com.updateSpriteEditor(spriteFrame)
@@ -2,15 +2,3 @@ export enum ELoggerLevel {
2
2
  Debug = 1, Info, Warn, Error
3
3
  }
4
4
 
5
- export enum EServerUrl {
6
- Local = "http://192.168.6.17:8085",
7
- OnLine = "https://sx-login.wyx.cn:10005",
8
- Web = "http://49.232.130.221:10007",
9
- /** 杨敏 */
10
- Yang = "http://192.168.1.253:8081",
11
- /** 付思佳 */
12
- Fu = "http://192.168.1.34:8081",
13
- TYF = "http://192.168.1.107:8081",
14
- WYY = "http://192.168.1.46:8081",
15
- HSJ = "http://192.168.1.78:8081",
16
- }
@@ -11,7 +11,7 @@ function none(...data) { }
11
11
  //不同级别日志Title颜色
12
12
  const debugStyle = `color: #17B6C3; font-weight: bold;`;
13
13
  const infoStyle = `color: #008000; font-weight: bold;`;
14
- const warnStyle = `color: #FFFF00; font-weight: bold;`;
14
+ const warnStyle = `color: #ff8800ff; font-weight: bold;`;
15
15
  const errorStyle = `color: #C52B2B; font-weight: bold;`;
16
16
 
17
17
  export class MLogger {
@@ -21,7 +21,7 @@ export class MLogger {
21
21
 
22
22
  /** 脚本加载时自动执行 */
23
23
  private static init = (() => {
24
- MLogger.setLevel(ELoggerLevel.Debug);
24
+ //MLogger.setLevel(ELoggerLevel.Debug);
25
25
  game.on(Game.EVENT_RESTART, () => {
26
26
  this.startTimeMS.clear();
27
27
  });
@@ -58,15 +58,13 @@ export class MLogger {
58
58
  //日志打印对象
59
59
  private constructor(tag: string, level: ELoggerLevel = ELoggerLevel.Info) {
60
60
  this.debug = globalLevel > ELoggerLevel.Debug || level > ELoggerLevel.Debug ?
61
- none : console.log.bind(console, `%c[${globalTag} ${tag} Debug]`, debugStyle);
61
+ none : Logger.debug.bind(console, `%c[${globalTag} ${tag} Debug]`, debugStyle);
62
62
  this.info = globalLevel > ELoggerLevel.Info || level > ELoggerLevel.Info ?
63
- none : console.log.bind(console, `%c[${globalTag} ${tag} Info]`, infoStyle);
63
+ none : Logger.debug.bind(console, `%c[${globalTag} ${tag} Info]`, infoStyle);
64
64
  this.warn = globalLevel > ELoggerLevel.Warn || level > ELoggerLevel.Warn ?
65
- none : console.warn.bind(console, `%c[${globalTag} ${tag} Warn]`, warnStyle);
65
+ none : Logger.warn.bind(console, `%c[${globalTag} ${tag} Warn]`, warnStyle);
66
66
  this.error = globalLevel > ELoggerLevel.Error || level > ELoggerLevel.Error ?
67
67
  none : console.error.bind(console, `%c[${globalTag} ${tag} Error]`, errorStyle);
68
-
69
-
70
68
  }
71
69
 
72
70
  public debug: (...data) => void;
@@ -82,7 +80,7 @@ export class MLogger {
82
80
  /** 给予一个Key,并开始计时 */
83
81
  public static time(key: string) {
84
82
  if (this.startTimeMS.has(key)) {
85
- console.warn("Key已存在", key);
83
+ Logger.warn("Key已存在", key);
86
84
  }
87
85
  this.startTimeMS.set(key, Date.now());
88
86
  }
@@ -115,4 +113,5 @@ export class MLogger {
115
113
  // /** 日志打印类 */
116
114
  // const Logger: typeof MLogger;
117
115
  // }
116
+ //@ts-ignore
118
117
  window.Logger = MLogger;