8491fbfa-51fa-4078-adc6-d25c307c5268.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. cc._RF.push(module, '8491fv6UfpAeK3G0lwwfFJo', 'YZ_ShortcutWidget');
  3. // common-plugin/Scripts/YZ_ShortcutWidget.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 CompatibleTool_1 = require("./CompatibleTool");
  27. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  28. var YZ_ShortcutWidget = /** @class */ (function (_super) {
  29. __extends(YZ_ShortcutWidget, _super);
  30. function YZ_ShortcutWidget() {
  31. var _this = _super !== null && _super.apply(this, arguments) || this;
  32. _this._panel = null;
  33. _this._handImg = null;
  34. _this._callback = null;
  35. return _this;
  36. }
  37. Object.defineProperty(YZ_ShortcutWidget.prototype, "Callback", {
  38. set: function (value) {
  39. this._callback = value;
  40. },
  41. enumerable: false,
  42. configurable: true
  43. });
  44. YZ_ShortcutWidget.prototype.onLoad = function () {
  45. this._panel = this.node.getChildByName("Panel");
  46. this._panel.active = false;
  47. this._handImg = cc.find("Panel/handImg", this.node);
  48. this._handImg.runAction(cc.repeatForever(cc.sequence(cc.moveBy(0.5, CompatibleTool_1.default.position(0, -50)), cc.moveBy(0.5, CompatibleTool_1.default.position(0, 50)))));
  49. };
  50. YZ_ShortcutWidget.prototype.onEnable = function () {
  51. var _this = this;
  52. Utils_1.utils.registerServerInitEvent(function () {
  53. if (!Utils_1.utils.isShowCreateShortcutWidget()) {
  54. _this.node.destroy();
  55. }
  56. else {
  57. _this._panel.active = true;
  58. }
  59. }, this);
  60. };
  61. YZ_ShortcutWidget.prototype.onDisable = function () {
  62. Utils_1.utils.unregisterServerInitEvent(this);
  63. };
  64. YZ_ShortcutWidget.prototype.onBtnClickHandler = function (event, data) {
  65. var _this = this;
  66. switch (event.target.name) {
  67. case "Btn_Shortcut": {
  68. if (Utils_1.utils.canCreateShortcut()) {
  69. Utils_1.utils.createShortcut(function (ret) {
  70. if (ret) {
  71. Utils_1.utils.showLog("快捷方式创建成功!");
  72. if (_this._callback) {
  73. _this._callback(true);
  74. }
  75. }
  76. else {
  77. Utils_1.utils.showLog("快捷方式创建失败!");
  78. if (_this._callback) {
  79. _this._callback(false);
  80. }
  81. }
  82. });
  83. }
  84. break;
  85. }
  86. }
  87. };
  88. YZ_ShortcutWidget = __decorate([
  89. ccclass
  90. ], YZ_ShortcutWidget);
  91. return YZ_ShortcutWidget;
  92. }(cc.Component));
  93. exports.default = YZ_ShortcutWidget;
  94. cc._RF.pop();