3bceedf07edad9dce70e6cb1e8bc2094e1a107a0.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Button, color, Component, Enum, EventHandler, SpriteFrame, _decorator, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _crd, ccclass, property, menu, PARAM_TYPE, BhvButtonGroup;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. return {
  8. setters: [function (_cc) {
  9. _cclegacy = _cc.cclegacy;
  10. __checkObsolete__ = _cc.__checkObsolete__;
  11. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  12. Button = _cc.Button;
  13. color = _cc.color;
  14. Component = _cc.Component;
  15. Enum = _cc.Enum;
  16. EventHandler = _cc.EventHandler;
  17. SpriteFrame = _cc.SpriteFrame;
  18. _decorator = _cc._decorator;
  19. }],
  20. execute: function () {
  21. _crd = true;
  22. _cclegacy._RF.push({}, "41df676L55LvJ52uxkQpfxJ", "BhvButtonGroup", undefined);
  23. __checkObsolete__(['Button', 'color', 'Color', 'Component', 'Enum', 'EventHandler', 'SpriteFrame', '_decorator']);
  24. ({
  25. ccclass,
  26. property,
  27. menu
  28. } = _decorator);
  29. PARAM_TYPE = /*#__PURE__*/function (PARAM_TYPE) {
  30. PARAM_TYPE[PARAM_TYPE["CHILDREN_INDEX"] = 0] = "CHILDREN_INDEX";
  31. PARAM_TYPE[PARAM_TYPE["CHILDREN_NAME"] = 1] = "CHILDREN_NAME";
  32. return PARAM_TYPE;
  33. }(PARAM_TYPE || {});
  34. /**
  35. * 群体事件,适合绑定节点组的回调信息
  36. * 将该组件的所处节点的所有子节点,绑定相同的回调对象,并将组件名设置到customEventData属性中
  37. */
  38. _export("BhvButtonGroup", BhvButtonGroup = (_dec = menu("OopsFramework/UI/Button Group (按钮组控制)"), _dec2 = property({
  39. type: Enum(Button.Transition)
  40. }), _dec3 = property({
  41. visible: function visible() {
  42. // @ts-ignore
  43. return this.transition === Button.Transition.COLOR;
  44. }
  45. }), _dec4 = property({
  46. visible: function visible() {
  47. // @ts-ignore
  48. return this.transition === Button.Transition.COLOR;
  49. }
  50. }), _dec5 = property({
  51. visible: function visible() {
  52. // @ts-ignore
  53. return this.transition === Button.Transition.COLOR;
  54. }
  55. }), _dec6 = property({
  56. visible: function visible() {
  57. // @ts-ignore
  58. return this.transition === Button.Transition.COLOR;
  59. }
  60. }), _dec7 = property({
  61. type: SpriteFrame,
  62. visible: function visible() {
  63. // @ts-ignore
  64. return this.transition === Button.Transition.SPRITE;
  65. }
  66. }), _dec8 = property({
  67. type: SpriteFrame,
  68. visible: function visible() {
  69. // @ts-ignore
  70. return this.transition === Button.Transition.SPRITE;
  71. }
  72. }), _dec9 = property({
  73. type: SpriteFrame,
  74. visible: function visible() {
  75. // @ts-ignore
  76. return this.transition === Button.Transition.SPRITE;
  77. }
  78. }), _dec10 = property({
  79. type: SpriteFrame,
  80. visible: function visible() {
  81. // @ts-ignore
  82. return this.transition === Button.Transition.SPRITE;
  83. }
  84. }), _dec11 = property({
  85. visible: function visible() {
  86. // @ts-ignore
  87. return this.transition === Button.Transition.SCALE || this.transition === Button.Transition.COLOR;
  88. }
  89. }), _dec12 = property({
  90. visible: function visible() {
  91. // @ts-ignore
  92. return this.transition === Button.Transition.SCALE;
  93. }
  94. }), _dec13 = property({
  95. type: Enum(PARAM_TYPE)
  96. }), _dec14 = property({
  97. type: [EventHandler]
  98. }), _dec15 = property({
  99. tooltip: '规避3.x引擎BUG,EventHandler.component位为空导致找不到触发事件的脚本名的问题',
  100. readonly: true
  101. }), ccclass(_class = _dec(_class = (_class2 = class BhvButtonGroup extends Component {
  102. constructor() {
  103. super(...arguments);
  104. _initializerDefineProperty(this, "transition", _descriptor, this);
  105. _initializerDefineProperty(this, "hoverColor", _descriptor2, this);
  106. _initializerDefineProperty(this, "normalColor", _descriptor3, this);
  107. _initializerDefineProperty(this, "pressedColor", _descriptor4, this);
  108. _initializerDefineProperty(this, "disabledColor", _descriptor5, this);
  109. _initializerDefineProperty(this, "normalSprite", _descriptor6, this);
  110. _initializerDefineProperty(this, "pressedSprite", _descriptor7, this);
  111. _initializerDefineProperty(this, "hoverSprite", _descriptor8, this);
  112. _initializerDefineProperty(this, "disabledSprite", _descriptor9, this);
  113. _initializerDefineProperty(this, "duration", _descriptor10, this);
  114. _initializerDefineProperty(this, "zoomScale", _descriptor11, this);
  115. _initializerDefineProperty(this, "paramType", _descriptor12, this);
  116. _initializerDefineProperty(this, "touchEvents", _descriptor13, this);
  117. _initializerDefineProperty(this, "EventHandler_component", _descriptor14, this);
  118. }
  119. onLoad() {
  120. this.node.children.forEach((node, nodeIndex) => {
  121. var comp = node.getComponent(Button);
  122. if (comp == null) comp = node.addComponent(Button); // 同步属性
  123. // comp.target = node;
  124. // comp.transition = this.transition;
  125. // comp.zoomScale = this.zoomScale;
  126. // comp.disabledSprite = this.disabledSprite;
  127. // comp.hoverSprite = this.hoverSprite;
  128. // comp.normalSprite = this.normalSprite;
  129. // comp.pressedSprite = this.pressedSprite;
  130. // comp.hoverColor = this.hoverColor;
  131. // comp.normalColor = this.normalColor;
  132. // comp.pressedColor = this.pressedColor;
  133. // comp.disabledColor = this.disabledColor;
  134. // 绑定回调事件
  135. this.touchEvents.forEach(event => {
  136. // 克隆数据,每个节点获取的都是不同的回调
  137. var hd = new EventHandler(); //copy对象
  138. hd.component = event.component == "" ? this.EventHandler_component : event.component;
  139. hd.handler = event.handler;
  140. hd.target = event.target;
  141. if (this.paramType === PARAM_TYPE.CHILDREN_INDEX) {
  142. hd.customEventData = nodeIndex.toString();
  143. } else {
  144. hd.customEventData = node.name;
  145. }
  146. comp.clickEvents.push(hd);
  147. });
  148. });
  149. }
  150. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "transition", [_dec2], {
  151. configurable: true,
  152. enumerable: true,
  153. writable: true,
  154. initializer: function initializer() {
  155. return Button.Transition.NONE;
  156. }
  157. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "hoverColor", [_dec3], {
  158. configurable: true,
  159. enumerable: true,
  160. writable: true,
  161. initializer: function initializer() {
  162. return color(255, 255, 255);
  163. }
  164. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "normalColor", [_dec4], {
  165. configurable: true,
  166. enumerable: true,
  167. writable: true,
  168. initializer: function initializer() {
  169. return color(214, 214, 214);
  170. }
  171. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "pressedColor", [_dec5], {
  172. configurable: true,
  173. enumerable: true,
  174. writable: true,
  175. initializer: function initializer() {
  176. return color(211, 211, 211);
  177. }
  178. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "disabledColor", [_dec6], {
  179. configurable: true,
  180. enumerable: true,
  181. writable: true,
  182. initializer: function initializer() {
  183. return color(124, 124, 124);
  184. }
  185. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "normalSprite", [_dec7], {
  186. configurable: true,
  187. enumerable: true,
  188. writable: true,
  189. initializer: function initializer() {
  190. return null;
  191. }
  192. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "pressedSprite", [_dec8], {
  193. configurable: true,
  194. enumerable: true,
  195. writable: true,
  196. initializer: function initializer() {
  197. return null;
  198. }
  199. }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "hoverSprite", [_dec9], {
  200. configurable: true,
  201. enumerable: true,
  202. writable: true,
  203. initializer: function initializer() {
  204. return null;
  205. }
  206. }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "disabledSprite", [_dec10], {
  207. configurable: true,
  208. enumerable: true,
  209. writable: true,
  210. initializer: function initializer() {
  211. return null;
  212. }
  213. }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "duration", [_dec11], {
  214. configurable: true,
  215. enumerable: true,
  216. writable: true,
  217. initializer: function initializer() {
  218. return 1.0;
  219. }
  220. }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "zoomScale", [_dec12], {
  221. configurable: true,
  222. enumerable: true,
  223. writable: true,
  224. initializer: function initializer() {
  225. return 1.1;
  226. }
  227. }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "paramType", [_dec13], {
  228. configurable: true,
  229. enumerable: true,
  230. writable: true,
  231. initializer: function initializer() {
  232. return PARAM_TYPE.CHILDREN_INDEX;
  233. }
  234. }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "touchEvents", [_dec14], {
  235. configurable: true,
  236. enumerable: true,
  237. writable: true,
  238. initializer: function initializer() {
  239. return [];
  240. }
  241. }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "EventHandler_component", [_dec15], {
  242. configurable: true,
  243. enumerable: true,
  244. writable: true,
  245. initializer: function initializer() {
  246. return "VMModify";
  247. }
  248. })), _class2)) || _class) || _class));
  249. _cclegacy._RF.pop();
  250. _crd = false;
  251. }
  252. };
  253. });
  254. //# sourceMappingURL=3bceedf07edad9dce70e6cb1e8bc2094e1a107a0.js.map