author suo
  class BaseUICenter { protected _managers : Map = new Map ( ) ; protected _openingUI : Array < number > = new Array ( ) ; constructor ( ) { } public addManager ( id , className ) { if ( className == null ) { return ; } var manager = new className ( ) ; manager . id = id ; this . _managers . addValue ( id , manager ) ; } public getManager ( id ) { if ( this . _managers == null ) { return null ; } return this . _managers . getValueByKey ( id ) ; } public isExist ( id ) { if ( this . _managers == null ) { return false ; } return this . _managers . isExist ( id ) ; } public getOpenParam ( id ) { var manager = this . getManager ( id ) ; if ( manager != null ) { return manager . getOpenParam ( ) ; } return null ; } public setOpenParam ( id , param ) { var manager = this . getManager ( id ) ; if ( manager != null ) { return manager . setOpenParam ( param ) ; } return null ; } public isOpen ( id ) { var manager = this . getManager ( id ) ; if ( manager != null ) { return manager . isOpened ; } return true ; } public openUI ( id , param = null ) { var manager = this . getManager ( id ) ; if ( manager != null ) { this . _openingUI . push ( id ) ; manager . open ( this . onUIinitCallBack , param ) ; } } public closeUI ( id ) { var manager = this . getManager ( id ) ; if ( manager != null ) { manager . close ( ) ; var index = this . _openingUI . indexOf ( id ) ; if ( index != - 1 ) { this . _openingUI . splice ( index , 1 ) ; } } } public closeAll ( ) { var index = - 1 ; while ( this . _openingUI . length != 0 ) { index = this . _openingUI . pop ( ) ; var manager = this . getManager ( index ) ; if ( manager != null ) { manager . close ( ) ; } } } private onUIinitCallBack ( id ) { if ( this . _openingUI != null ) { this . _openingUI . push ( id ) ; } else { this . _openingUI = new Array ( ) ; this . _openingUI . push ( id ) ; } } public dispose ( ) { if ( this . _managers != null ) { for ( var i = 0 ; i < this . _managers . length ; i ++ ) { var manager = this . _managers . getValueByIndex ( i ) ; if ( manager != null ) { manager . dispose ( ) ; manager = null ; } } this . _managers . dispose ( ) ; this . _managers = null ; } if ( this . _openingUI != null ) { this . _openingUI . splice ( 0 , this . _openingUI . length ) ; this . _openingUI = null ; } } }