Esempio n. 1
0
        private void OnHideUI(UIInfoData uiInfo, DelOnCompleteHideUI onComplete = null)
        {
            if (!_showUIDic.ContainsKey(uiInfo.UIID))
            {
                return;
            }
            int uiid = uiInfo.UIID;

            // 委托不为空等待逻辑执行完成后再隐藏UI
            if (null != onComplete)
            {
                onComplete += delegate
                {
                    _showUIDic.Remove(uiInfo.UIID);
                    if (uiInfo.CoreData.IsDestoryOnClosed && _allUIDic.ContainsKey(uiid))
                    {
                        _allUIDic.Remove(uiInfo.UIID);
                    }
                };
                _showUIDic[uiid].HideUI(onComplete);
            }
            else
            {
                _showUIDic[uiid].HideUI();
                _showUIDic.Remove(uiInfo.UIID);
                if (uiInfo.CoreData.IsDestoryOnClosed && _allUIDic.ContainsKey(uiid))
                {
                    _allUIDic.Remove(uiInfo.UIID);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 显示UI,包括导航栈,模态属性初始化等
 /// </summary>
 /// <param name="uiInfo"></param>
 /// <param name="onComplete"></param>
 /// <param name="param"></param>
 public static void ShowUI(UIInfoData uiInfo, DelOnCompleteShowUI onComplete = null, object param = null)
 {
     if (null == uiInfo || CoreGlobeVar.INVAILD_UIID == uiInfo.UIID)
     {
         return;
     }
     UIManager._instance.OnShowUI(uiInfo, onComplete, param);
 }
Esempio n. 3
0
        /// <summary>
        /// 关闭UI,根据导航策略采取不同关闭行为
        /// </summary>
        /// <param name="uiInfo"></param>
        /// <param name="onComplete"></param>
        public static void CloseUI(UIInfoData uiInfo, DelOnCompleteHideUI onComplete = null)
        {
            if (null == uiInfo || CoreGlobeVar.INVAILD_UIID == uiInfo.UIID)
            {
                return;
            }
            switch (uiInfo.CoreData.NavigationMode)
            {
            case UINavigationMode.NormalNavigation:
                UIManager._instance.OnCloseReturnUI(uiInfo);
                break;

            case UINavigationMode.IngoreNavigation:
                UIManager._instance.OnHideUI(uiInfo, onComplete);
                break;

            default:
                break;
            }
        }
Esempio n. 4
0
        private void OnShowUI(UIInfoData uiInfo, DelOnCompleteShowUI onComplete = null, object param = null)
        {
            UIBase showUI = LoadShowUI(uiInfo);

            if (null == showUI)
            {
                return;
            }
            // 设置模态窗口
            Utils.AddUIMask(showUI, GetUITypeRootTrans(uiInfo));
            RefreshNavData(showUI);
            // 不同显示模式采取不同差异化策略
            switch (uiInfo.CoreData.ShowModel)
            {
            case UIShowModel.DoNoting:
                break;

            case UIShowModel.HideOther:
            case UIShowModel.HideEverything:
                HideAllOtherUI(showUI);
                break;

            case UIShowModel.TypeMutex:
                CheckMutexHidden(showUI);
                break;

            case UIShowModel.DestoryOther:
                break;

            default:
                break;
            }
            CheckNavData(showUI);
            showUI.ShowUI(onComplete, param);
            _showUIDic[uiInfo.UIID] = showUI;
            if (showUI.IsAddedToBackSequence)
            {
                showUI.PreUIInfo = null == _curNavUIBase ? null : _curNavUIBase.infoData;
                _curNavUIBase    = showUI;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 通过UIinfo加载UI,并缓存到allUIDic
        /// </summary>
        /// <param name="uiInfo"></param>
        /// <returns></returns>
        private UIBase LoadShowUI(UIInfoData uiInfo)
        {
            if (_showUIDic.ContainsKey(uiInfo.UIID))
            {
                return(null);
            }
            UIBase showUI = GetUIBase(uiInfo.UIID);

            if (null == showUI)
            {
                string     resourcePath = uiInfo.ResPathStr + "/" + uiInfo.ResNameStr;
                GameObject cacheUI      = Resources.Load <GameObject>(resourcePath);
                if (null != cacheUI)
                {
                    GameObject willShowUI = GameObject.Instantiate(cacheUI);
                    willShowUI.SetActive(true);
                    showUI = willShowUI.GetComponent <UIBase>();
                    Utils.AddChildToParent(GetUITypeRootTrans(uiInfo), willShowUI.transform);
                    _allUIDic[uiInfo.UIID] = showUI;
                    willShowUI             = null;
                }
            }
            return(showUI);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取当前uiid对应的类型root节点
        /// </summary>
        /// <param name="uiInfo"></param>
        /// <returns></returns>
        private RectTransform GetUITypeRootTrans(UIInfoData uiInfo)
        {
            if (null != uiInfo)
            {
                switch (uiInfo.CoreData.RootType)
                {
                case UIRootType.Base:
                    return(_baseUIRoot);

                case UIRootType.PopUp:
                    return(_popupUIRoot);

                case UIRootType.Fixed:
                    return(_fixedUIRoot);

                case UIRootType.SecondPopUp:
                    return(_sencondPopUpUIRoot);

                default:
                    return(null);
                }
            }
            return(null);
        }
Esempio n. 7
0
        private void OnCloseReturnUI(UIInfoData uiInfo, DelOnCompleteHideUI onComplete = null)
        {
            if (!_showUIDic.ContainsKey(uiInfo.UIID))
            {
                return;
            }
            // 没有导航数据使用前置UI的Infodata导回去
            if (0 == _backSequenceStack.Count)
            {
                if (null == _curNavUIBase)
                {
                    return;
                }
                UIInfoData preUIInfo = _curNavUIBase.PreUIInfo;
                if (null != preUIInfo)
                {
                    if (null == onComplete)
                    {
                        onComplete = delegate { OnShowUI(preUIInfo); };
                    }
                    else
                    {
                        onComplete += delegate { OnShowUI(preUIInfo); };
                    }
                    OnHideUI(uiInfo, onComplete);
                }
                return;
            }
            // 有导航数据
            NavigationData uiReturnInfo = _backSequenceStack.Peek();

            if (null != uiReturnInfo)
            {
                int willShowUIID = uiReturnInfo.HideTargetUI.infoData.UIID;
                if (uiInfo.UIID != willShowUIID)
                {
                    return;
                }
                if (!_showUIDic.ContainsKey(willShowUIID))
                {
                    return;
                }
                DelOnCompleteHideUI tmpDel = delegate
                {
                    int siblingIndex = 0;
                    foreach (int backId in uiReturnInfo.BackShowTargetsList)
                    {
                        if (_showUIDic.ContainsKey(backId))
                        {
                            continue;
                        }
                        if (!_allUIDic.ContainsKey(backId))
                        {
                            if (null == NavBackUIReload(backId, siblingIndex + 1))
                            {
                                continue;
                            }
                        }
                        _allUIDic[backId].ReShowUI();
                        _showUIDic[backId] = _allUIDic[backId];
                        siblingIndex       = _showUIDic[backId].Trans.GetSiblingIndex();
                    }
                    _allUIDic.TryGetValue(uiReturnInfo.BackShowTargetsList[uiReturnInfo.BackShowTargetsList.Count - 1], out _curNavUIBase);
                    _backSequenceStack.Pop();
                };
                if (null == onComplete)
                {
                    onComplete = tmpDel;
                }
                else
                {
                    onComplete += tmpDel;
                }
                OnHideUI(uiInfo, onComplete);
            }
            ReShowHiddenAllCache();
        }
Esempio n. 8
0
 /// <summary>
 /// 经过反向导航栈然后关闭隐藏UI
 /// </summary>
 /// <param name="uiInfo"></param>
 public static void CloseReturnUI(UIInfoData uiInfo, DelOnCompleteHideUI onComplete = null)
 {
     UIManager._instance.OnCloseReturnUI(uiInfo, onComplete);
 }