8cb1a7be369ddb83f0b95c8d1006ff34bd717caa.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, oops, ViewUtil, ModuleUtil, _crd;
  4. function _reportPossibleCrUseOfoops(extras) {
  5. _reporterNs.report("oops", "../../core/Oops", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfUICallbacks(extras) {
  8. _reporterNs.report("UICallbacks", "../../core/gui/layer/Defines", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfViewUtil(extras) {
  11. _reporterNs.report("ViewUtil", "../../core/utils/ViewUtil", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfecs(extras) {
  14. _reporterNs.report("ecs", "../../libs/ecs/ECS", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfCompType(extras) {
  17. _reporterNs.report("CompType", "../../libs/ecs/ECSModel", _context.meta, extras);
  18. }
  19. function _reportPossibleCrUseOfCCComp(extras) {
  20. _reporterNs.report("CCComp", "./CCComp", _context.meta, extras);
  21. }
  22. function _reportPossibleCrUseOfCCVMParentComp(extras) {
  23. _reporterNs.report("CCVMParentComp", "./CCVMParentComp", _context.meta, extras);
  24. }
  25. _export("ModuleUtil", void 0);
  26. return {
  27. setters: [function (_unresolved_) {
  28. _reporterNs = _unresolved_;
  29. }, function (_cc) {
  30. _cclegacy = _cc.cclegacy;
  31. __checkObsolete__ = _cc.__checkObsolete__;
  32. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  33. }, function (_unresolved_2) {
  34. oops = _unresolved_2.oops;
  35. }, function (_unresolved_3) {
  36. ViewUtil = _unresolved_3.ViewUtil;
  37. }],
  38. execute: function () {
  39. _crd = true;
  40. _cclegacy._RF.push({}, "52a6cdAO5tGxaeE1TprZ5VK", "ModuleUtil", undefined);
  41. __checkObsolete__(['Node', '__private']);
  42. _export("ModuleUtil", ModuleUtil = class ModuleUtil {
  43. /**
  44. * 添加界面组件
  45. * @param ent 模块实体
  46. * @param ctor 界面逻辑组件
  47. * @param uiId 界面资源编号
  48. * @param uiArgs 界面参数
  49. */
  50. static addViewUi(ent, ctor, uiId, uiArgs = null) {
  51. const uic = {
  52. onAdded: (node, params) => {
  53. const comp = node.getComponent(ctor); //@ts-ignore
  54. if (!ent.has(ctor)) ent.add(comp);
  55. }
  56. };
  57. (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
  58. error: Error()
  59. }), oops) : oops).gui.open(uiId, uiArgs, uic);
  60. }
  61. /**
  62. * 异步添加视图层组件
  63. * @param ent 模块实体
  64. * @param ctor 界面逻辑组件
  65. * @param uiId 界面资源编号
  66. * @param uiArgs 界面参数
  67. * @returns 界面节点
  68. */
  69. static addViewUiAsync(ent, ctor, uiId, uiArgs = null) {
  70. return new Promise((resolve, reject) => {
  71. const uic = {
  72. onAdded: (node, params) => {
  73. const comp = node.getComponent(ctor);
  74. ent.add(comp);
  75. resolve(node);
  76. },
  77. onLoadFailure: () => {
  78. resolve(null);
  79. }
  80. };
  81. (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
  82. error: Error()
  83. }), oops) : oops).gui.open(uiId, uiArgs, uic);
  84. });
  85. }
  86. /**
  87. * 通过资源内存中获取预制上的组件添加到ECS实体中
  88. * @param ent 模块实体
  89. * @param ctor 界面逻辑组件
  90. * @param parent 显示对象父级
  91. * @param url 显示资源地址
  92. */
  93. static addView(ent, ctor, parent, url) {
  94. const node = (_crd && ViewUtil === void 0 ? (_reportPossibleCrUseOfViewUtil({
  95. error: Error()
  96. }), ViewUtil) : ViewUtil).createPrefabNode(url);
  97. const comp = node.getComponent(ctor);
  98. ent.add(comp);
  99. node.parent = parent;
  100. }
  101. /**
  102. * 业务实体上移除界面组件
  103. * @param ent 模块实体
  104. * @param ctor 界面逻辑组件
  105. * @param uiId 界面资源编号
  106. * @param isDestroy 是否释放界面缓存(默认为释放界面缓存)
  107. */
  108. static removeViewUi(ent, ctor, uiId, isDestroy = true) {
  109. if (isDestroy) ent.remove(ctor, isDestroy);
  110. (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
  111. error: Error()
  112. }), oops) : oops).gui.remove(uiId, isDestroy);
  113. }
  114. });
  115. _cclegacy._RF.pop();
  116. _crd = false;
  117. }
  118. };
  119. });
  120. //# sourceMappingURL=8cb1a7be369ddb83f0b95c8d1006ff34bd717caa.js.map