LoadingView.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. e =
  5. (this && this.__decorate) ||
  6. function (t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", {value: !0});
  17. const s = t("App"),
  18. o = t("GameText"),
  19. a = t("BaseView"),
  20. n = t("LoadingController"),
  21. {ccclass: r, property: l} = cc._decorator;
  22. t = class extends a.default {
  23. constructor() {
  24. super(...arguments),
  25. (this.tipNode = null),
  26. (this.progressBar = null),
  27. (this.progressLabel = null),
  28. (this.targetPregress = 0),
  29. (this.curPregress = 0),
  30. (this.versionLab = null),
  31. (this.isDownHotFile = !1),
  32. (this.closeType = 2);
  33. }
  34. initUI() {
  35. super.initUI(),
  36. (this.curPregress = 0),
  37. this.targetPregress || (this.targetPregress = 0.1),
  38. (this.progressBar.progress = 0),
  39. (this.versionLab.string = s.default.Platform.getVersionStr());
  40. }
  41. showTipNode() {
  42. (this.tipNode.active = !0),
  43. this.tipNode.on(
  44. cc.Node.EventType.TOUCH_END,
  45. () => {
  46. this.tipNode.active = !1;
  47. },
  48. this
  49. );
  50. }
  51. initData() {
  52. this._tempData = s.default.GameDataMsr.tempData;
  53. }
  54. onProgress(t) {
  55. this.targetPregress = t;
  56. }
  57. onHotProgress(t, e, i) {
  58. isNaN(t) && (t = 0),
  59. (this.progressBar.progress = t),
  60. (this.progressLabel.string = `${o.GameText.getText(lang.loading_updating)} ${Math.floor(100 * t)}% (${(
  61. e / 1024
  62. ).toFixed(3)}KB / ${(i / 1024).toFixed(3)}KB)`);
  63. }
  64. checkHot() {
  65. this.progressLabel.string = o.GameText.getText(lang.loading_check_update);
  66. }
  67. open() {
  68. (this.enabled = !0), this._tempData.isCheckUpdate && (this.progressLabel.string = "0%");
  69. }
  70. update(t) {
  71. var e;
  72. this._tempData.isCheckUpdate &&
  73. ((e = this.targetPregress),
  74. this.curPregress < e &&
  75. ((this.curPregress += 0.08),
  76. this.curPregress > e && (this.curPregress = e),
  77. (this.progressBar.progress = this.curPregress),
  78. (this.progressLabel.string = Math.floor(100 * this.curPregress) + "%")),
  79. 1 <= this.curPregress && (this.applyFunc(n.LoadingConst.ProgressComplete), (this.enabled = !1)));
  80. }
  81. onTouchAgainGame() {
  82. cc.audioEngine.stopAll(), cc.game.restart();
  83. }
  84. };
  85. e([l({type: cc.Node})], t.prototype, "tipNode", void 0),
  86. e([l(cc.ProgressBar)], t.prototype, "progressBar", void 0),
  87. e([l(cc.Label)], t.prototype, "progressLabel", void 0),
  88. e([l(cc.Label)], t.prototype, "versionLab", void 0),
  89. (t = e([r], t)),
  90. (i.default = t);