| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 | 
							- using UnityEngine;
 
- using System.Collections.Generic;
 
- using System;
 
- using FairyGUI;
 
- namespace GFGGame
 
- {
 
-     /// <summary>
 
-     /// ��ͼ������
 
-     /// ������ͼ����ʾ������
 
-     /// </summary>
 
-     public class ViewManager
 
-     {
 
-         private static Dictionary<string, UIView> _viewDic;
 
-         private static GComponent _bottomLayer;
 
-         private static GComponent _topLayer;
 
-         private static Dictionary<string, object[]> _goBackDatas = new Dictionary<string, object[]>();
 
-         public static void Init()
 
-         {
 
-             GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Common"));
 
-             UIConfig.buttonSound = (NAudioClip)UIPackage.GetItemAsset("Common", "click");
 
-             Font afont = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("STZHONGS"));
 
-             FontManager.RegisterFont(new DynamicFont("STZhongsong", afont));
 
-             UIConfig.defaultFont = "STZhongsong";
 
-             Font afont1 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("ZIHUN125"));
 
-             FontManager.RegisterFont(new DynamicFont("ZIHUN125", afont1));
 
-             _viewDic = new Dictionary<string, UIView>();
 
-             //��ʼ����ͼ������
 
-             _bottomLayer = CreateLayer("BottomLayer");
 
-             _topLayer = CreateLayer("TopLayer");
 
-             _topLayer.sortingOrder = ConstSortingOrder.TOP;
 
-         }
 
-         public static void AddChildToBottomLayer(GObject gObject)
 
-         {
 
-             _bottomLayer.AddChild(gObject);
 
-         }
 
-         public static void AddChildToTopLayer(GObject gObject)
 
-         {
 
-             _topLayer.AddChild(gObject);
 
-         }
 
-         /// <summary>
 
-         /// ��ʾһ����ͼ
 
-         /// </summary>
 
-         /// <param name="viewName">Ҫ��ʾ����ͼ����</param>
 
-         /// <param name="viewData">Ҫ���ݸ���ͼ�IJ���</param>
 
-         /// <param name="goBackParams">�Ӹ���ͼ���ص���ͼ��Ϣ</param>
 
-         /// <param name="hideOthers">�Ƿ�ر�������ͼ</param>
 
-         public static void Show(string viewName, object viewData = null, object[] goBackParams = null, bool hideOthers = false, bool resetGobackParams = false)
 
-         {
 
-             if (!FunctionOpenDataManager.Instance.CheckIsFunOpenBgViewName(viewName))
 
-             {
 
-                 return;
 
-             }
 
-             if (hideOthers)
 
-             {
 
-                 HideAllView(viewName);
 
-             }
 
-             UIView obj = null;
 
-             if (_viewDic.ContainsKey(viewName))
 
-             {
 
-                 obj = _viewDic[viewName];
 
-             }
 
-             else
 
-             {
 
-                 obj = CreateViewInstance(viewName) as UIView;
 
-                 _viewDic.Add(viewName, obj);
 
-             }
 
-             if (obj != null)
 
-             {
 
-                 IUIView view = (IUIView)obj;
 
-                 view.viewData = viewData;
 
-                 if (!view.isShowing)
 
-                 {
 
-                     view.Show();
 
-                     Debug.Log("��ǰ��" + viewName);
 
-                 }
 
-                 else
 
-                 {
 
-                     view.Refresh();
 
-                 }
 
-                 if (resetGobackParams)
 
-                 {
 
-                     if (_goBackDatas.ContainsKey(viewName) == true)
 
-                     {
 
-                         _goBackDatas.Remove(viewName);
 
-                     }
 
-                 }
 
-                 if (goBackParams != null)
 
-                 {
 
-                     _goBackDatas[viewName] = goBackParams;
 
-                 }
 
-                 // else 
 
-             }
 
-         }
 
-         public static bool isViewOpen(string viewName)
 
-         {
 
-             UIView obj = null;
 
-             if (_viewDic.ContainsKey(viewName))
 
-             {
 
-                 obj = _viewDic[viewName];
 
-                 if (obj != null)
 
-                 {
 
-                     IUIView view = (IUIView)obj;
 
-                     if (view.isShowing) return true;
 
-                 }
 
-             }
 
-             return false;
 
-         }
 
-         public static bool Show<T>(object viewData = null, object[] goBackParams = null, bool hideOthers = false, bool resetGobackParams = false) where T : class, new()
 
-         {
 
-             string viewName = typeof(T).FullName;
 
-             if (!FunctionOpenDataManager.Instance.CheckIsFunOpenBgViewName(viewName))
 
-             {
 
-                 return false;
 
-             }
 
-             if (hideOthers)
 
-             {
 
-                 HideAllView(viewName);
 
-             }
 
-             UIView obj = null;
 
-             if (_viewDic.ContainsKey(viewName))
 
-             {
 
-                 obj = _viewDic[viewName];
 
-             }
 
-             else
 
-             {
 
-                 obj = new T() as UIView;
 
-                 _viewDic.Add(viewName, obj);
 
-             }
 
-             if (obj != null)
 
-             {
 
-                 IUIView view = (IUIView)obj;
 
-                 view.viewData = viewData;
 
-                 if (!view.isShowing)
 
-                 {
 
-                     view.Show();
 
-                     Debug.Log("��ǰ��" + viewName);
 
-                 }
 
-                 else
 
-                 {
 
-                     view.Refresh();
 
-                 }
 
-                 if (goBackParams != null)
 
-                 {
 
-                     _goBackDatas[viewName] = goBackParams;
 
-                 }
 
-                 else if (resetGobackParams)
 
-                 {
 
-                     if (_goBackDatas.ContainsKey(viewName) == true)
 
-                     {
 
-                         _goBackDatas.Remove(viewName);
 
-                     }
 
-                 }
 
-             }
 
-             return true;
 
-         }
 
-         public static void Hide(string viewName)
 
-         {
 
-             if (!_viewDic.ContainsKey(viewName))
 
-             {
 
-                 return;
 
-             }
 
-             UIView obj = _viewDic[viewName];
 
-             if (obj != null && obj.isShowing)
 
-             {
 
-                 IUIView view = (IUIView)obj;
 
-                 view.Hide();
 
-             }
 
-         }
 
-         public static void Hide<T>()
 
-         {
 
-             string viewName = typeof(T).FullName;
 
-             if (!_viewDic.ContainsKey(viewName))
 
-             {
 
-                 return;
 
-             }
 
-             object obj = _viewDic[viewName];
 
-             if (obj != null)
 
-             {
 
-                 IUIView view = (IUIView)obj;
 
-                 view.Hide();
 
-             }
 
-         }
 
-         public static void GoBackFrom(string viewName, bool clearGoBackDatas = false)
 
-         {
 
-             ViewManager.Hide(viewName);
 
-             if (_goBackDatas.ContainsKey(viewName))
 
-             {
 
-                 object[] gobackItems = _goBackDatas[viewName];
 
-                 string tViewName = gobackItems[0] as string;
 
-                 object tViewData = null;
 
-                 if (gobackItems.Length > 1)
 
-                 {
 
-                     tViewData = gobackItems[1];
 
-                 }
 
-                 ViewManager.Show(tViewName, tViewData);
 
-             }
 
-             else
 
-             {
 
-                 ViewManager.Show(ViewName.MAINUI_VIEW, null, null, true);
 
-             }
 
-         }
 
-         public static object[] GetGoBackDatas(string viewName)
 
-         {
 
-             object[] value;
 
-             _goBackDatas.TryGetValue(viewName, out value);
 
-             return value;
 
-         }
 
-         public static void HideAllView(string excludeViewName = null)
 
-         {
 
-             foreach (string viewName in _viewDic.Keys)
 
-             {
 
-                 if (viewName != excludeViewName)
 
-                 {
 
-                     Hide(viewName);
 
-                 }
 
-             }
 
-         }
 
-         private static object CreateViewInstance(string name)
 
-         {
 
-             // Debug.LogFormat("CreateViewInstance {0}", name);
 
-             Type type = Type.GetType(name);
 
-             if (type != null)
 
-             {
 
-                 return Activator.CreateInstance(type);
 
-             }
 
-             return null;
 
-         }
 
-         private static GComponent CreateLayer(string name)
 
-         {
 
-             GComponent layer = new GComponent();
 
-             layer.name = name;
 
-             GRoot.inst.AddChild(layer);
 
-             layer.SetSize(GRoot.inst.size.x, GRoot.inst.size.y);
 
-             layer.AddRelation(GRoot.inst, RelationType.Size);
 
-             return layer;
 
-         }
 
-         public static bool CheckIsTopView(GComponent viewCom)
 
-         {
 
-             if (viewCom.parent != null)
 
-             {
 
-                 int index = viewCom.parent.GetChildIndex(viewCom);
 
-                 if (index == viewCom.parent.numChildren - 1 && GRoot.inst.GetTopWindow() == null)
 
-                 {
 
-                     return true;
 
-                 }
 
-             }
 
-             if (GRoot.inst.GetTopWindow() == viewCom)
 
-             {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-     }
 
- }
 
 
  |