示例#1
0
        // 适配mask显示,只显示最上层的mask
        private void _AdjustMaskAndActive()
        {
            //此处排序的是所有界面层,所有界面
            List <InterfaceView> tempList = new List <InterfaceView>();
            var iter = OpeningViewsDic.GetEnumerator();

            while (iter.MoveNext())
            {
                tempList.Add(iter.Current.Value);
            }
            tempList.Sort((a, b) =>
            {
                if (a.Layer() == b.Layer())
                {
                    return(a.GetCanvasDepth() < b.GetCanvasDepth() ? 1 : -1);
                }
                else
                {
                    return(a.Layer() < b.Layer() ? 1 : -1);
                }
            });
            //缓存排序过的打开中界面
            SortOpenViewsList = tempList;
            //调整隐藏显示状态
            _AdjustActiveAndz(tempList);
            //调整maskBg
            _AdjustMaskBg(tempList);

            //设置最上层view
            if (tempList.Count > 0)
            {
                topView = tempList[tempList.Count - 1];
            }
        }
示例#2
0
 //从等待打开界面列表中移除界面
 private void _RemoveWaitOpenValue(InterfaceView viewCan)
 {
     if (WaitOpenViewList.Contains(viewCan))
     {
         WaitOpenViewList.Remove(viewCan);
     }
 }
示例#3
0
        //从已关闭界面列表或永久持有界面列表中,移除指定名字的界面
        private void _ClearCacheView(InterfaceView viewCan)
        {
            InterfaceView tempView = _GetCacheView(viewCan.ViewName(), 0);

            if (tempView != null)
            {
                tempView.DisposeView();
            }
        }
示例#4
0
        //从已打开界面中获取界面
        public InterfaceView GetOpeningView(int viewIdCan)
        {
            InterfaceView tempView = null;

            if (OpeningViewsDic.TryGetValue(viewIdCan, out tempView) && tempView != null)
            {
                return(tempView);
            }
            return(null);
        }
示例#5
0
 // 子界面绑定预置GameObject
 public void BindGo(GameObject subGo, InterfaceView parentViewCan = null)
 {
     selfGo        = subGo;
     selfTransform = subGo.transform;
     if (parentViewCan != null)
     {
         parentView   = parentViewCan;
         rootBaseView = parentView.rootBaseView;
         isSubViewBoo = true;
     }
 }
示例#6
0
        // 主界面绑定预置GameObject
        private void BindGo(GameObject mainGo)
        {
            _instantiateBoo = true;
            selfGo          = mainGo;
            selfTransform   = mainGo.transform;
            selfGo.SetActive(false);
            rootBaseView = this;
            SetParent(true);

            selfGo.gameObject.name = ViewName();
            _instantiateBoo        = false;
        }
示例#7
0
        // 尝试从等待界面、已打开界面,缓存中永久持有界面,已关闭缓存界面中获取界面
        private InterfaceView _TryToGetViewAndType(UiExcel uiData)
        {
            InterfaceView tempView = GetWaitByName(uiData.name);

            if (tempView == null)
            {
                tempView = GetOpeningView(uiData.id);
                if (tempView == null)
                {
                    tempView = _GetCacheView(uiData.name, uiData.holdBoo);
                }
            }
            return(tempView);
        }
示例#8
0
        private InterfaceView _CreateView <T>(UiExcel uiData) where T : new()
        {
            InterfaceView tempView = _NewViewByName <T>(uiData);

            if (tempView == null)
            {
                ZLogger.Error("UIManager:_CreateView 创建UI失败:{0}", uiData.name);
                return(null);
            }

            tempView.updateViewState = _ViewStateChange;
            WaitOpenViewList.Add(tempView);
            return(tempView);
        }
示例#9
0
        private void _AddSubView(InterfaceView viewClsCan)
        {
            var iter = subViewList.GetEnumerator();

            while (iter.MoveNext())
            {
                if (iter.Current == viewClsCan)
                {
                    ZLogger.Error("子界面类已经添加过,子界面名字:{0}", viewClsCan.selfGo.name);
                    return;
                }
            }
            subViewList.Add(viewClsCan);
        }
示例#10
0
        public void Init()
        {
            ZLogger.Info("UI管理层初始化");

            uiRoot = GameObject.Find("UIRoot");

            _layerTypeDic = new Dictionary <int, GameObject>();

            closeViewLayer = GameObject.Find(CLOSE_LAYER);
            _layerTypeDic.Add(CLOSE_LAYER_INT, closeViewLayer);

            nickLayer = GameObject.Find(NICK_LAYER);
            _layerTypeDic.Add(NICK_LAYER_INT, nickLayer);

            lowLayer = GameObject.Find(LOW_LAYER);
            _layerTypeDic.Add(LOW_LAYER_INT, lowLayer);

            middleLayer = GameObject.Find(MIDDLE_LAYER);
            _layerTypeDic.Add(MIDDLE_LAYER_INT, middleLayer);

            dialogLayer = GameObject.Find(DIALOG_LAYER);
            _layerTypeDic.Add(DIALOG_LAYER_INT, dialogLayer);

            highLayer = GameObject.Find(HIGH_LAYER);
            _layerTypeDic.Add(HIGH_LAYER_INT, highLayer);

            topLayer = GameObject.Find(TOP_LAYER);
            _layerTypeDic.Add(TOP_LAYER_INT, topLayer);

            canvas = GameObject.Find(CANVAS_LAYER);

            WaitOpenViewList    = new List <InterfaceView>();
            OpeningViewsDic     = new Dictionary <int, InterfaceView>();
            ForeverCacheViewDic = new List <InterfaceView>();
            CacheViewDic        = new List <InterfaceView>();
            SortOpenViewsList   = new List <InterfaceView>();
            UpdateErrorViewDic  = new Dictionary <string, bool>();
            _PopViewNameDic     = new Dictionary <string, int>();
            openViewCountDic    = new Dictionary <int, int>();
            topView             = null;

            //打开界面数计数器
            ResetOpenViewIndex();

            InitHideLayer();

            RegisterHandler();
            InitBoo = true;
        }
示例#11
0
 //移除界面,包括打开中界面,永久持有界面,已关闭缓存列表
 private void _UpdateDel(int viewId, InterfaceView viewCan)
 {
     if (OpeningViewsDic.ContainsKey(viewId))
     {
         OpeningViewsDic.Remove(viewId);
     }
     if (CacheViewDic.Contains(viewCan))
     {
         CacheViewDic.Remove(viewCan);
     }
     if (ForeverCacheViewDic.Contains(viewCan))
     {
         ForeverCacheViewDic.Remove(viewCan);
     }
 }
示例#12
0
        private void _CloseViewByVo(UiExcel uiDataCan)
        {
            if (uiDataCan == null)
            {
                ZLogger.Error("找不到界面信息,请检查UIExcel表是否配置正确!");
                return;
            }

            InterfaceView tempView = _TryToGetOpenViewAndType(uiDataCan);

            if (tempView != null)
            {
                tempView.Close(false);
            }
        }
示例#13
0
        /// <summary>
        /// 添加子页面,并返回子页面实例
        /// </summary>
        public void AddSubView <T>(String viewName, GameObject subGo) where T : new()
        {
            InterfaceView tempView = null;

            if (UIClassHelper.Instance.UIClassList.Contains(viewName))
            {
                tempView = new T() as InterfaceView;
                tempView.Ctor();
                _AddSubView(tempView);
                tempView.BindGo(subGo, this);
            }
            else
            {
                ZLogger.Error("该界面类不存在于UIClassHelper中,请检查,类名:{0}", viewName);
            }
        }
示例#14
0
        //委托,在每个界面发生状态变化时候需要做的操作
        private void _ViewStateChange(InterfaceView viewCan, UIMgr.ViewStateType type)
        {
            List <UiExcel> tempUiExcelList = DataMgr.Instance.tableUI.GetInfoByNameAndValue("name", viewCan.ViewName());

            if (tempUiExcelList.Count < 1)
            {
                ZLogger.Error("找不到界面的信息,请查看UIExcel表配置是否正确!");
                return;
            }
            UiExcel uiData = tempUiExcelList[0];

            switch (type)
            {
            case ViewStateType.CLOSE:
                UpdateErrorViewDic.Remove(viewCan.ViewName());
                _UpdateCacheView(uiData.id, viewCan, false, uiData.holdBoo);
                _AdjustMaskAndActive();
                break;

            case ViewStateType.LOAD_COMPLETE:
                break;

            case ViewStateType.UNLOAD:
                _UpdateDel(uiData.id, viewCan);
                break;

            case ViewStateType.LOAD_FAIL:
                _RemoveWaitOpenValue(viewCan);
                break;

            case ViewStateType.GIVE_UP_LOAD:
                ZLogger.Info("请注意:{0}放弃加载!!!,原因是:没加载完成之前,有人调用了closeview()", viewCan.ViewName());
                _RemoveWaitOpenValue(viewCan);
                break;

            case ViewStateType.OPEN:
                _RemoveWaitOpenValue(viewCan);
                _UpdateCacheView(uiData.id, viewCan, true, uiData.holdBoo);
                _CheckExclusion(uiData, viewCan);
                _SortOpeningView();
                _AdjustMaskAndActive();
                break;

            case ViewStateType.LOAD_SUCESS:
                break;
            }
        }
示例#15
0
        // 打开界面,供内部调用
        private void _OpenViewByVo <T>(UiExcel uiData, int subIndex, int arg1 = -1, int arg2 = -1, int arg3 = -1, string arg4 = null, string arg5 = null, string arg6 = null) where T : new()
        {
            if (uiData != null)
            {
                InterfaceView tempView = _TryToGetViewAndType(uiData);
                if (tempView == null)
                {
                    tempView = _CreateView <T>(uiData);
                }
                if (tempView == null)
                {
                    ZLogger.Error("页面没有创建过,并且无法重新创建");
                    return;
                }

                tempView.SetCanvasDepth(GetOpenViewIndex(tempView.Layer()));
                tempView.Open(subIndex, arg1, arg2, arg3, arg4, arg5, arg6);
            }
        }
示例#16
0
 //更新缓存(打开中界面,永久持有界面,已关闭缓存列表)
 private void _UpdateCacheView(int uiId, InterfaceView viewCan, bool openBoo, int holdBoo)
 {
     if (openBoo)
     {
         if (holdBoo == 1 && ForeverCacheViewDic.Contains(viewCan))
         {
             ForeverCacheViewDic.Remove(viewCan);
         }
         else if (holdBoo == 0 && CacheViewDic.Contains(viewCan))
         {
             CacheViewDic.Remove(viewCan);
         }
         if (OpeningViewsDic.ContainsKey(uiId))
         {
             OpeningViewsDic[uiId] = viewCan;
         }
         else
         {
             OpeningViewsDic.Add(uiId, viewCan);
         }
     }
     else
     {
         if (holdBoo == 1 && !ForeverCacheViewDic.Contains(viewCan))
         {
             ForeverCacheViewDic.Add(viewCan);
         }
         else if (holdBoo == 0 && !CacheViewDic.Contains(viewCan))
         {
             CacheViewDic.Add(viewCan);
         }
         if (OpeningViewsDic.ContainsKey(uiId))
         {
             OpeningViewsDic.Remove(uiId);
         }
     }
 }
示例#17
0
        private bool subHideForParentBoo; //是否因为父界面隐藏而隐藏

        /// <summary>
        /// 初始化
        /// </summary>
        public void Ctor()
        {
            //----------共有参数
            selfGo        = null;
            selfTransform = null;
            parentView    = null;

            subViewList.Clear();
            compDelegateDic.Clear();

            rootBaseView = null;             //最顶父界面
            isSubViewBoo = false;

            //----------主界面参数
            _showSortIndex  = 0;
            _activeBoo      = false;
            _instantiateBoo = false;
            _openInitBoo    = false;
            _closingViewBoo = false;

            selfParentObj      = null;
            selfState          = 0;
            selfStateChange    = 0;
            closeDestroyBoo    = false;
            maskBgBoo          = false;
            hideOtherViewBoo   = true;
            thickness          = 0; //buzhidao
            openResourceHUDBoo = false;
            sceneCloseBoo      = true;
            loadAsyncGuid      = 0;
            uiPrefabPath       = string.Empty;

            //----------子界面参数
            subInitBoo          = false;
            subOpenBoo          = false;
            subHideForParentBoo = false;
        }
示例#18
0
 // 检查当前这个面板互斥的所有面板关闭 no edit
 private void _CheckExclusion(UiExcel uiData, InterfaceView tgView)
 {
 }