1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import MainGameView from "./MainGameView";
- import InGameView from "./InGameView";
- export enum ViewType{MainView,IngameView};
- export interface SC{
- Show();
- Close();
- }
- export class ViewManager{
- private static ins:ViewManager;
- public showexportview:number = 0;
-
- private popViewDic:[any][any] = [];
- public ViewSprite:Laya.Sprite = new Laya.Sprite();
- public OtherViewSprite:Laya.Sprite = new Laya.Sprite();
- public curView:any;
- constructor(){
- ViewManager.ins = this;
- Laya.stage.addChild(this.ViewSprite);
- Laya.stage.addChild(this.OtherViewSprite);
- }
- public static get Instance():ViewManager{
- if(ViewManager.ins){
- return ViewManager.ins
- }
- else{
- return new ViewManager();
- }
- }
- ShowView(_viewtype:ViewType,data = null){
- if(this.curView != null){
- this.curView.Close();
- this.curView.destroy();
- this.curView.removeSelf();
- }
- // GuangGao.Clear();
- this.curView = this.CreateView(_viewtype);
- this.curView.name = ViewType[_viewtype];
- this.ViewSprite.addChild(this.curView);
- this.curView.Show(data);
- }
- CloseView(){
- if(this.curView != null){
- this.curView.Close();
- this.curView.destroy();
- this.curView.removeSelf();
- }
- }
- //全屏导出页
- public OpenPopView(viewType:ViewType,data:any = null)
- {
- // GuangGao.Clear();
- var popView;
- if(this.popViewDic[viewType])
- {
- popView = this.popViewDic[viewType];
- this.OtherViewSprite.setChildIndex(popView,this.OtherViewSprite.numChildren - 1);
- popView.visible = true;
- }
- else
- {
- popView = this.CreateView(viewType);
- this.OtherViewSprite.addChild(popView);
- this.popViewDic[viewType] = popView;
- }
- this.showexportview = 1;
- popView.OnOpen(data);
- }
- public ClosePopView(viewType:ViewType)
- {
- var popView = this.popViewDic[viewType];
- if(popView == null){
- return;
- }
- // GuangGao.Clear();
- popView.OnHide();
- popView.visible = false;
- this.showexportview = 0;
- }
- ClearPopViews()
- {
- // GuangGao.Clear();
- }
- CreateView(_viewtype:ViewType){
- switch (_viewtype) {
- case ViewType.MainView:
- return new MainGameView();
- case ViewType.IngameView:
- return new InGameView();
- }
- return null;
- }
- }
|