UIBase.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import { xGame } from "../../xGame";
  2. import UIMgr from "./UIMgr";
  3. /**
  4. * ui基类
  5. */
  6. export default class UIBase extends fairygui.Window {
  7. public contentPane: fairygui.GComponent;
  8. /**窗口是否应用果冻弹出效果 */
  9. protected isEject: boolean = true;
  10. public isHide = true;//是否调用hide关闭
  11. /**调用show时传入的参数 */
  12. protected _openParam: any;
  13. /**banner误点*/
  14. public showbanner: boolean = true;
  15. public static lastShowBanner: number = 0;
  16. public static showBannerNum: number = 0;
  17. public bannerButton: fairygui.GButton;
  18. public bannerButtonY: number;
  19. public bannerTop: number;
  20. public className: string = "";
  21. //
  22. public static uiName: string = "";
  23. public isMuti: boolean = false;
  24. public constructor() {
  25. super();
  26. // this.modal = true;
  27. this.showbanner = false;
  28. this.onConstructor();
  29. }
  30. public checkActive(show) {
  31. }
  32. public getUIName() {
  33. return UIBase.uiName;
  34. }
  35. /**UI创建时必须的操作统一放这里,比如fgui的creatInstance */
  36. protected onConstructor(): void {
  37. }
  38. protected onInit(): void {
  39. // this.modal = true;
  40. if (!!this.contentPane) {
  41. this.contentPane.setSize(fairygui.GRoot.inst.width, fairygui.GRoot.inst.height);
  42. }
  43. this.setPivot(0.5, 0.5, false);
  44. }
  45. protected doShowAnimation(): void {
  46. if (!this.isEject)
  47. return;
  48. super.doShowAnimation();
  49. Laya.Tween.clearTween(this);
  50. this.scaleX = this.scaleY = 0.8;
  51. let tweenFunc1 = (func: Function) => {
  52. Laya.Tween.to(this, { scaleX: 1.1, scaleY: 1.1 }, 100, Laya.Ease.linearIn, Laya.Handler.create(this, func));
  53. }
  54. let tweenFunc2 = (func: Function) => {
  55. Laya.Tween.to(this, { scaleX: 1, scaleY: 1 }, 60, Laya.Ease.linearOut, Laya.Handler.create(this, this.refresh));
  56. }
  57. tweenFunc1(tweenFunc2)
  58. }
  59. public show(...args): void {
  60. super.show();
  61. this._openParam = args;
  62. this.isHide = false;
  63. xGame.uiMgr.checkUIState();
  64. // 五点
  65. // if (this.showbanner) {
  66. // //banner闪烁通用处理
  67. // if (this.bannerButton && HWCommonMgr.Inst.getIsStrongSafe()) {
  68. // if (hw_common.config.getBannerControl()) {
  69. // this.bannerButton.y = Laya.stage.height - 180;
  70. // this.bannerButton.alpha = 0;
  71. // this.bannerButton.visible = false;
  72. // this.bannerButton.touchable = false;
  73. // //关闭按钮延迟显示
  74. // TimeMgr.inst.newTimer(this, 0, 500, null, this.showBannerButton);
  75. // //如果设置了 则代表此界面需要banner闪烁
  76. // TimeMgr.inst.newTimer(this, 0, 1500, null, this.moveBannerButton);
  77. // } else {
  78. // this.bannerButton.alpha = 1;
  79. // this.bannerButton.visible = true;
  80. // this.bannerButton.touchable = true;
  81. // if (this.bannerButton) {
  82. // let proportion = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth;
  83. // if (proportion >= 1.78) {
  84. // this.bannerButton.y = Laya.stage.height - 355;
  85. // } else {
  86. // this.bannerButton.y = Laya.stage.height - 315;
  87. // }
  88. // }
  89. // hw_common.rule_express.show({ top: this.bannerTop });
  90. // }
  91. // } else {
  92. // if (!HWCommonMgr.Inst.getIsStrongSafe()) {
  93. // if (this.bannerButton) {
  94. // let proportion = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth;
  95. // if (proportion >= 1.78) {
  96. // this.bannerButton.y = Laya.stage.height - 355;
  97. // } else {
  98. // this.bannerButton.y = Laya.stage.height - 315;
  99. // }
  100. // }
  101. // }
  102. // if (this.bannerButton) {
  103. // return;
  104. // }
  105. // !HWCommonMgr.Inst.checkRefreshBannerByTime() && HWCommonMgr.Inst.checkRefreshBannerByCount();
  106. // HWCommonMgr.Inst.needShowGuess_web = true;
  107. // hw_common.rule_express.show({ top: this.bannerTop });
  108. // }
  109. // } else {
  110. // HWCommonMgr.Inst.needShowGuess_web = false;
  111. // hw_common.rule_express.closeAll();
  112. // }
  113. }
  114. private moveBannerButton() {
  115. // if (!HWCommonMgr.Inst.getIsStrongSafe()) {
  116. // return;
  117. // }
  118. // trace("触发了刷新banner")
  119. // // this.bannerButton.y = this.bannerButtonY - 120;
  120. // if (hw_common.platform.iswxgame) {
  121. // let proportion = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth;
  122. // if (proportion >= 1.78) {
  123. // this.bannerButton.y = Laya.stage.height - 355;
  124. // } else {
  125. // this.bannerButton.y = Laya.stage.height - 315;
  126. // }
  127. // } else {
  128. // this.bannerButton.y = Laya.stage.height - 300;
  129. // }
  130. // !HWCommonMgr.Inst.checkRefreshBannerByTime() && HWCommonMgr.Inst.checkRefreshBannerByCount();
  131. // hw_common.rule_express.show({ top: this.bannerTop });
  132. }
  133. private showBannerButton() {
  134. this.bannerButton.visible = true;
  135. Laya.Tween.to(this.bannerButton, { alpha: 1 }, 500, Laya.Ease.linearOut, Laya.Handler.create(this, () => {
  136. this.bannerButton.touchable = true;
  137. }));
  138. }
  139. public hide(): void {
  140. super.hide();
  141. this.isHide = true;
  142. //
  143. xGame.uiMgr.checkUIState();
  144. // if (this.bannerButton && HWCommonMgr.Inst.getIsStrongSafe()) {
  145. // TimeMgr.Inst.removeNativeTimer(this.moveBannerButton, this);
  146. // this.bannerButton.y = this.bannerButton.y = Laya.stage.height - 180;
  147. // }
  148. // let lastWin = ViewMgr.Inst.isLastWindowShowBanner();
  149. // //关掉的时候判断上一个窗口是否要显示
  150. // if (lastWin && lastWin.showbannerstatus) {
  151. // //如果要显示
  152. // hw_common.rule_express.show({ top: lastWin.bannerTop });
  153. // } else {
  154. // //不显示 关掉
  155. // hw_common.rule_express.closeAll();
  156. // }
  157. // if (ViewMgr.Inst.isLastWindowShowExcitation()) {
  158. // this.showExcitation()
  159. // } else {
  160. // this.hideExcitation()
  161. // }
  162. // // hw_common.platform.showBannerAd(ViewMgr.Inst.isLastWindowShowBanner());
  163. // // ViewMgr.Inst.hideWindow(this);
  164. // if (ViewMgr.Inst.showWindowNum() <= 0 && ViewMgr.Inst.currentScene instanceof LobbyScene) {
  165. // //检查是否要显示主界面格子
  166. // EventMgr.Inst.SendEvent(EventDef.UI_ShowLobbyExcitation);
  167. // }
  168. }
  169. protected Dispose(): void {
  170. super.dispose();
  171. }
  172. public myUpdate(delay: number): void {
  173. }
  174. protected refresh(): void { }
  175. public addUIClick(obj, func, arr = null) {
  176. obj.onClick(this, func, arr);
  177. obj.onClick(this, this.playBtnSound);
  178. }
  179. public offUIClick(obj, func) {
  180. obj.offClick(this, func);
  181. }
  182. public playBtnSound() {
  183. xGame.soundMgr.playSound(xGame.common.btnClickStr);
  184. }
  185. }