97b23328-7fb6-4a62-8412-648471c4c34b.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. "use strict";
  2. cc._RF.push(module, '97b23Mof7ZKYoQSZIRxxMNL', 'LogOutView');
  3. // common-plugin/Scripts/LogOutView.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var Utils_1 = require("./Utils");
  26. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  27. var LogOutView = /** @class */ (function (_super) {
  28. __extends(LogOutView, _super);
  29. function LogOutView() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. _this.scrollView = null;
  32. _this.content = null;
  33. _this.logLabel = null;
  34. _this.logArray = [];
  35. _this.clearBtn = null;
  36. _this.showLogViewBtn = null;
  37. _this.hideLogViewBtn = null;
  38. return _this;
  39. // update (dt) {}
  40. }
  41. LogOutView.prototype.onLoad = function () {
  42. if (Utils_1.utils.otherConfig && Utils_1.utils.otherConfig.group) {
  43. this.node.group = Utils_1.utils.otherConfig.group;
  44. }
  45. var ratio = 1;
  46. if (cc.winSize.height < cc.winSize.width) {
  47. // 横屏游戏
  48. ratio = cc.winSize.width / 1920 * 0.7;
  49. }
  50. else {
  51. ratio = cc.winSize.width / 1080;
  52. }
  53. this.node.scale = ratio;
  54. };
  55. LogOutView.prototype.start = function () {
  56. var _this = this;
  57. this.initUi();
  58. this.initListener();
  59. this.initData();
  60. this.schedule(function () {
  61. _this.showLog();
  62. }, 0);
  63. };
  64. /**
  65. * 初始化UI
  66. */
  67. LogOutView.prototype.initUi = function () {
  68. this.scrollView = this.node.getChildByName("ScrollView").getComponent(cc.ScrollView);
  69. this.showLogViewBtn = this.node.getChildByName("BtnShowLogView");
  70. this.hideLogViewBtn = this.node.getChildByName("BtnHideLogView");
  71. this.clearBtn = this.node.getChildByName("BtnClearLog");
  72. this.content = this.scrollView.content;
  73. this.logLabel = this.content.children[0];
  74. this.content.removeAllChildren();
  75. };
  76. /**
  77. * 添加LOG输出
  78. * @param logContent log
  79. */
  80. LogOutView.prototype.addLog = function (logContent) {
  81. var optionalParams = [];
  82. for (var _i = 1; _i < arguments.length; _i++) {
  83. optionalParams[_i - 1] = arguments[_i];
  84. }
  85. var str = "";
  86. str += logContent;
  87. optionalParams.forEach(function (element) {
  88. str += "," + element;
  89. });
  90. this.logArray.push(str);
  91. };
  92. LogOutView.prototype.showLog = function () {
  93. var _this = this;
  94. if (this.logArray.length > 0) {
  95. var tempAry = this.logArray;
  96. this.logArray = [];
  97. tempAry.forEach(function (log) {
  98. var tempLogLabel = cc.instantiate(_this.logLabel);
  99. tempLogLabel.getComponent(cc.Label).string = "\u65E5\u5FD7\u8F93\u51FA\uFF1A" + log;
  100. _this.content.addChild(tempLogLabel);
  101. });
  102. }
  103. };
  104. /**
  105. * 初始化监听事件
  106. */
  107. LogOutView.prototype.initListener = function () {
  108. };
  109. /**
  110. * 初始化数据
  111. */
  112. LogOutView.prototype.initData = function () {
  113. };
  114. /**
  115. * 显示日志框
  116. */
  117. LogOutView.prototype.onShowLogView = function () {
  118. this.scrollView.node.active = true;
  119. this.clearBtn.active = true;
  120. this.showLogViewBtn.active = false;
  121. this.hideLogViewBtn.active = true;
  122. };
  123. /**
  124. * 隐藏日志框
  125. */
  126. LogOutView.prototype.onHideLogView = function () {
  127. this.scrollView.node.active = false;
  128. this.clearBtn.active = false;
  129. this.showLogViewBtn.active = true;
  130. this.hideLogViewBtn.active = false;
  131. };
  132. /**
  133. * 清空日志
  134. */
  135. LogOutView.prototype.clearLogView = function () {
  136. this.content.removeAllChildren();
  137. };
  138. LogOutView = __decorate([
  139. ccclass
  140. ], LogOutView);
  141. return LogOutView;
  142. }(cc.Component));
  143. exports.default = LogOutView;
  144. cc._RF.pop();