70e24796-29b4-4333-b422-66922be42859.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. "use strict";
  2. cc._RF.push(module, '70e24eWKbRDM7QiZpIr5ChZ', 'YZ_RecordWidget');
  3. // common-plugin/Scripts/YZ_RecordWidget.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 YZ_RecordWidget = /** @class */ (function (_super) {
  28. __extends(YZ_RecordWidget, _super);
  29. function YZ_RecordWidget() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. _this._panel = null;
  32. _this._normalBtn = null;
  33. _this._actionBtn = null;
  34. _this._isRecording = false;
  35. _this._originScale = 1;
  36. return _this;
  37. }
  38. YZ_RecordWidget.prototype.onLoad = function () {
  39. this._panel = this.node.getChildByName("Panel");
  40. this._panel.active = false;
  41. var background = this._panel.getChildByName("Background");
  42. this._normalBtn = background.getChildByName("normalBtn");
  43. this._actionBtn = background.getChildByName("actionBtn");
  44. this._originScale = this._actionBtn.scale;
  45. };
  46. YZ_RecordWidget.prototype._onGameMessage = function (event) {
  47. switch (event.type) {
  48. case "YZ_RecordStart": {
  49. this._updateState();
  50. break;
  51. }
  52. case "YZ_RecordEnd": {
  53. this._updateState();
  54. break;
  55. }
  56. }
  57. };
  58. YZ_RecordWidget.prototype.onEnable = function () {
  59. var _this = this;
  60. cc.game.on("YZ_CommonMessage", this._onGameMessage, this);
  61. Utils_1.utils.registerServerInitEvent(function () {
  62. _this._panel.on(cc.Node.EventType.TOUCH_END, function (event) {
  63. event.stopPropagation();
  64. if (!Utils_1.utils.isRecording) {
  65. Utils_1.utils.recordStart();
  66. }
  67. else {
  68. Utils_1.utils.isSuccess = undefined;
  69. if (Utils_1.utils.cur_tool && Utils_1.utils.cur_tool.isClickEnd != undefined) {
  70. Utils_1.utils.cur_tool.isClickEnd = true;
  71. }
  72. Utils_1.utils.recordEnd();
  73. }
  74. }, _this);
  75. _this._updateState();
  76. if (Utils_1.utils.isShowRecordWidget()) {
  77. _this._panel.active = true;
  78. }
  79. else {
  80. Utils_1.utils.showLog("不支持录屏!");
  81. _this.node.destroy();
  82. }
  83. }, this);
  84. // if (PlatUtils.IsDouyin) {
  85. // utils.showLog("record onEnable");
  86. // utils.Tool_Douyin.isAutoShare = true;
  87. // }
  88. if (Utils_1.utils.cur_tool && Utils_1.utils.cur_tool.isAutoShare != undefined) {
  89. Utils_1.utils.cur_tool.isAutoShare = true;
  90. }
  91. };
  92. YZ_RecordWidget.prototype.onDisable = function () {
  93. cc.game.targetOff(this);
  94. // utils.isRecording = false;
  95. // this._updateState();
  96. // if (PlatUtils.IsDouyin) {
  97. // utils.showLog("record onDisable");
  98. // // utils.Tool_Douyin.isAutoShare = false;
  99. // }
  100. // utils.recordEnd();
  101. };
  102. YZ_RecordWidget.prototype._updateState = function () {
  103. if (Utils_1.utils.isRecording) {
  104. this._normalBtn.active = false;
  105. this._actionBtn.active = true;
  106. this._actionBtn.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(0.3, this._originScale * 0.8), cc.scaleTo(0.3, this._originScale))));
  107. }
  108. else {
  109. this._normalBtn.active = true;
  110. this._actionBtn.stopAllActions();
  111. this._actionBtn.active = false;
  112. }
  113. };
  114. YZ_RecordWidget = __decorate([
  115. ccclass
  116. ], YZ_RecordWidget);
  117. return YZ_RecordWidget;
  118. }(cc.Component));
  119. exports.default = YZ_RecordWidget;
  120. cc._RF.pop();