| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 | 
							- using FairyGUI;
 
- using UnityEngine;
 
- using System.Collections.Generic;
 
- namespace GFGGame
 
- {
 
-     /// <summary>
 
-     /// FairyGUI中Window的扩展类,功能界面基本都用这个
 
-     /// </summary>
 
-     public class BaseWindow : UIView, IUIView
 
-     {
 
-         private Window _window;
 
-         private GGraph _btnClose;
 
-         private bool _clickBlankToClose;
 
-         private bool _modal;
 
-         public bool modal
 
-         {
 
-             get => _modal;
 
-             set
 
-             {
 
-                 _modal = value;
 
-                 if (_window != null)
 
-                 {
 
-                     _window.modal = modal;
 
-                 }
 
-             }
 
-         }
 
-         protected bool bringToFontOnClick
 
-         {
 
-             set
 
-             {
 
-                 _window.bringToFontOnClick = value;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 点击空白关闭,true关闭,false不关闭,默认值关闭
 
-         /// </summary>
 
-         protected bool clickBlankToClose
 
-         {
 
-             set
 
-             {
 
-                 _clickBlankToClose = value;
 
-                 if (this.viewCom != null && this.viewCom.root != null)
 
-                 {
 
-                     if (_clickBlankToClose)
 
-                     {
 
-                         CheckCreateCloseButton();
 
-                     }
 
-                     else
 
-                     {
 
-                         CheckRemoveCloseButton();
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         public override GComponent viewCom
 
-         {
 
-             get => this._window;
 
-             set
 
-             {
 
-                 contentPane = value;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 设置视图组件
 
-         /// </summary>
 
-         private GComponent contentPane
 
-         {
 
-             set
 
-             {
 
-                 if (_window == null)
 
-                 {
 
-                     _window = new Window();
 
-                 }
 
-                 _window.contentPane = value;
 
-                 _window.modal = modal;
 
-             }
 
-         }
 
-         public override void Dispose()
 
-         {
 
-             // if (packageName == ResPathUtil.GetUIPackagePath("CommonGame") || packageName == ResPathUtil.GetUIPackagePath("Common") || packageName == ResPathUtil.GetUIPackagePath("Main")) return;//这几个包不释放
 
-             
 
-             if (_window != null)
 
-             {
 
-                 _window.RemoveFromParent();
 
-                 _window.Dispose();
 
-                 _window = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         /// <summary>
 
-         /// 打开界面
 
-         /// </summary>
 
-         public override void Show()
 
-         {
 
-             if (_window != null)
 
-             {
 
-                 _window.Show();
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 刷新界面
 
-         /// </summary>
 
-         protected override void BringToFront()
 
-         {
 
-             if (_window != null)
 
-             {
 
-                 this._window.BringToFront();
 
-             }
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             _clickBlankToClose = true;
 
-             if (isfullScreen)
 
-             {
 
-                 viewAnimationType = EnumViewAnimationType.None;
 
-             }
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             CheckCreateCloseButton();
 
-         }
 
-         
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             CheckRemoveCloseButton();
 
-         }
 
-         protected override void OnDoHideAnimationCompleted()
 
-         {
 
-             if (this._window != null)
 
-             {
 
-                 this._window.Hide();
 
-             }
 
-         }
 
-         virtual protected void closeEventHandler(EventContext context)
 
-         {
 
-             Hide();
 
-         }
 
-         private void CheckCreateCloseButton()
 
-         {
 
-             if (_clickBlankToClose)
 
-             {
 
-                 _btnClose = CloseButtonPool.GetCloseButton();
 
-                 _window.AddChildAt(_btnClose, 0);
 
-                 _btnClose.onClick.Add(closeEventHandler);
 
-                 _btnClose.x = -(_btnClose.width - _window.width) / 2;
 
-                 _btnClose.y = -(_btnClose.height - _window.height) / 2;
 
-             }
 
-         }
 
-         private void CheckRemoveCloseButton()
 
-         {
 
-             if (_btnClose != null)
 
-             {
 
-                 _btnClose.onClick.Remove(closeEventHandler);
 
-                 _btnClose.RemoveFromParent();
 
-                 CloseButtonPool.PutCloseButton(_btnClose);
 
-                 _btnClose = null;
 
-             }
 
-         }
 
-         private class CloseButtonPool
 
-         {
 
-             private static List<GGraph> _pool = new List<GGraph>();
 
-             public static GGraph GetCloseButton()
 
-             {
 
-                 GGraph btnClose = null;
 
-                 if (_pool.Count > 0)
 
-                 {
 
-                     int i = _pool.Count - 1;
 
-                     btnClose = _pool[i];
 
-                     _pool.RemoveAt(_pool.Count - 1);
 
-                 }
 
-                 else
 
-                 {
 
-                     btnClose = new GGraph();
 
-                     btnClose.DrawRect(ViewManager.ViewWidth, GRoot.inst.height, 0, Color.red, UIConfig.modalLayerColor);
 
-                     btnClose.AddRelation(GRoot.inst, RelationType.Size);
 
-                     btnClose.alpha = 0;
 
-                 }
 
-                 return btnClose;
 
-             }
 
-             public static void PutCloseButton(GGraph gGraph)
 
-             {
 
-                 if (!_pool.Contains(gGraph))
 
-                 {
 
-                     _pool.Add(gGraph);
 
-                 }
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |