import { xGame } from "../../xGame"; import UIMgr from "./UIMgr"; /** * ui基类 */ export default class UIBase extends fairygui.Window { public contentPane: fairygui.GComponent; /**窗口是否应用果冻弹出效果 */ protected isEject: boolean = true; public isHide = true;//是否调用hide关闭 /**调用show时传入的参数 */ protected _openParam: any; /**banner误点*/ public showbanner: boolean = true; public static lastShowBanner: number = 0; public static showBannerNum: number = 0; public bannerButton: fairygui.GButton; public bannerButtonY: number; public bannerTop: number; public className: string = ""; // public static uiName: string = ""; public isMuti: boolean = false; public constructor() { super(); // this.modal = true; this.showbanner = false; this.onConstructor(); } public checkActive(show) { } public getUIName() { return UIBase.uiName; } /**UI创建时必须的操作统一放这里,比如fgui的creatInstance */ protected onConstructor(): void { } protected onInit(): void { // this.modal = true; if (!!this.contentPane) { this.contentPane.setSize(fairygui.GRoot.inst.width, fairygui.GRoot.inst.height); } this.setPivot(0.5, 0.5, false); } protected doShowAnimation(): void { if (!this.isEject) return; super.doShowAnimation(); Laya.Tween.clearTween(this); this.scaleX = this.scaleY = 0.8; let tweenFunc1 = (func: Function) => { Laya.Tween.to(this, { scaleX: 1.1, scaleY: 1.1 }, 100, Laya.Ease.linearIn, Laya.Handler.create(this, func)); } let tweenFunc2 = (func: Function) => { Laya.Tween.to(this, { scaleX: 1, scaleY: 1 }, 60, Laya.Ease.linearOut, Laya.Handler.create(this, this.refresh)); } tweenFunc1(tweenFunc2) } public show(...args): void { super.show(); this._openParam = args; this.isHide = false; xGame.uiMgr.checkUIState(); // 五点 // if (this.showbanner) { // //banner闪烁通用处理 // if (this.bannerButton && HWCommonMgr.Inst.getIsStrongSafe()) { // if (hw_common.config.getBannerControl()) { // this.bannerButton.y = Laya.stage.height - 180; // this.bannerButton.alpha = 0; // this.bannerButton.visible = false; // this.bannerButton.touchable = false; // //关闭按钮延迟显示 // TimeMgr.inst.newTimer(this, 0, 500, null, this.showBannerButton); // //如果设置了 则代表此界面需要banner闪烁 // TimeMgr.inst.newTimer(this, 0, 1500, null, this.moveBannerButton); // } else { // this.bannerButton.alpha = 1; // this.bannerButton.visible = true; // this.bannerButton.touchable = true; // if (this.bannerButton) { // let proportion = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth; // if (proportion >= 1.78) { // this.bannerButton.y = Laya.stage.height - 355; // } else { // this.bannerButton.y = Laya.stage.height - 315; // } // } // hw_common.rule_express.show({ top: this.bannerTop }); // } // } else { // if (!HWCommonMgr.Inst.getIsStrongSafe()) { // if (this.bannerButton) { // let proportion = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth; // if (proportion >= 1.78) { // this.bannerButton.y = Laya.stage.height - 355; // } else { // this.bannerButton.y = Laya.stage.height - 315; // } // } // } // if (this.bannerButton) { // return; // } // !HWCommonMgr.Inst.checkRefreshBannerByTime() && HWCommonMgr.Inst.checkRefreshBannerByCount(); // HWCommonMgr.Inst.needShowGuess_web = true; // hw_common.rule_express.show({ top: this.bannerTop }); // } // } else { // HWCommonMgr.Inst.needShowGuess_web = false; // hw_common.rule_express.closeAll(); // } } private moveBannerButton() { // if (!HWCommonMgr.Inst.getIsStrongSafe()) { // return; // } // trace("触发了刷新banner") // // this.bannerButton.y = this.bannerButtonY - 120; // if (hw_common.platform.iswxgame) { // let proportion = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth; // if (proportion >= 1.78) { // this.bannerButton.y = Laya.stage.height - 355; // } else { // this.bannerButton.y = Laya.stage.height - 315; // } // } else { // this.bannerButton.y = Laya.stage.height - 300; // } // !HWCommonMgr.Inst.checkRefreshBannerByTime() && HWCommonMgr.Inst.checkRefreshBannerByCount(); // hw_common.rule_express.show({ top: this.bannerTop }); } private showBannerButton() { this.bannerButton.visible = true; Laya.Tween.to(this.bannerButton, { alpha: 1 }, 500, Laya.Ease.linearOut, Laya.Handler.create(this, () => { this.bannerButton.touchable = true; })); } public hide(): void { super.hide(); this.isHide = true; // xGame.uiMgr.checkUIState(); // if (this.bannerButton && HWCommonMgr.Inst.getIsStrongSafe()) { // TimeMgr.Inst.removeNativeTimer(this.moveBannerButton, this); // this.bannerButton.y = this.bannerButton.y = Laya.stage.height - 180; // } // let lastWin = ViewMgr.Inst.isLastWindowShowBanner(); // //关掉的时候判断上一个窗口是否要显示 // if (lastWin && lastWin.showbannerstatus) { // //如果要显示 // hw_common.rule_express.show({ top: lastWin.bannerTop }); // } else { // //不显示 关掉 // hw_common.rule_express.closeAll(); // } // if (ViewMgr.Inst.isLastWindowShowExcitation()) { // this.showExcitation() // } else { // this.hideExcitation() // } // // hw_common.platform.showBannerAd(ViewMgr.Inst.isLastWindowShowBanner()); // // ViewMgr.Inst.hideWindow(this); // if (ViewMgr.Inst.showWindowNum() <= 0 && ViewMgr.Inst.currentScene instanceof LobbyScene) { // //检查是否要显示主界面格子 // EventMgr.Inst.SendEvent(EventDef.UI_ShowLobbyExcitation); // } } protected Dispose(): void { super.dispose(); } public myUpdate(delay: number): void { } protected refresh(): void { } public addUIClick(obj, func, arr = null) { obj.onClick(this, func, arr); obj.onClick(this, this.playBtnSound); } public offUIClick(obj, func) { obj.offClick(this, func); } public playBtnSound() { xGame.soundMgr.playSound(xGame.common.btnClickStr); } }