示例#1
0
        /// <summary>
        /// 从当前UI列表缓存中卸载UI窗体
        /// </summary>
        /// <param name="uiName"></param>
        private void UnLoadParallelUI(string uiName, bool isDestroy = false)
        {
            BaseUI baseUI;

            //当前UI显示列表中没有记录或者总表中没有记录则直接返回
            _dictCurrentShowUIs.TryGetValue(uiName, out baseUI);
            if (baseUI == null)
            {
                _dictLoadedAllUIs.TryGetValue(uiName, out baseUI);
                if (baseUI == null)
                {
                    return;
                }
            }
            else
            {
                //隐藏窗口并从列表中移除
                _dictCurrentShowUIs.Remove(uiName);
            }

            baseUI.Close(isDestroy: isDestroy);

            //如果需要清空已有 popup 窗口
            if (baseUI.CurrentUIType.isClearPopUp)
            {
                ClearPopUpStackArray();
            }

            if (baseUI.CurrentUIType.uiNodeType == UINodeTypeEnum.PopUp)
            {
                //正在显示的窗口和栈缓存的窗口再次进行显示处理
                //判断栈里是否有窗口,有则冻结响应
                if (_stackCurrentUI.Count > 0)
                {
                    BaseUI topUI = _stackCurrentUI.Peek();
                    if (!topUI.AssetsName.Equals(uiName))
                    {
                        topUI.OnEnabled(true);
                        if (!topUI.IsShowing)
                        {
                            topUI.OnShow();
                        }
                        topUI.CheckMask();
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 显示(打开)UI窗口
        /// 功能:
        /// 1、根据UI窗体的名称,加载到UI窗口缓存列表
        /// 2、根据不同UI显示模式,做不同的加载处理
        /// </summary>
        /// <param name="uiName">UI窗体预制件名称</param>
        public IBaseUI Show(string uiName)
        {
            BaseUI baseUI = null;

            if (string.IsNullOrEmpty(uiName))
            {
                throw new Exception("UI--uiName 为 Null");
            }

            //根据名称加载窗体到UI窗体缓存中
            baseUI = LoadUIToAndFromAllList(uiName);
            if (baseUI == null)
            {
                throw new Exception("UI--baseUI 加载失败");
            }

            var    modelType    = UIModelBehavior.Instance.GetBehavior(uiName);
            UIType targetUIType = modelType != null ? modelType : baseUI.CurrentUIType;

            //判断是否清空“栈”结构体集合
            if (targetUIType.isClearPopUp)
            {
                ClearPopUpStackArray();
            }

            //只针对pop up 类型窗口适用 uiShowMode 功能
            if (targetUIType.uiNodeType == UINodeTypeEnum.PopUp)
            {
                switch (targetUIType.uiShowMode)
                {
                case UIShowModeEnum.Parallel:
                    LoadParallelUI(uiName);
                    break;

                case UIShowModeEnum.Stack:
                    LoadStackUI(uiName);
                    break;

                case UIShowModeEnum.Unique:
                    LoadUniqueUI(uiName);
                    break;

                default:
                    throw new Exception("未登记的UI类型--" + targetUIType.uiShowMode);
                }
            }
            else
            {
                //获取当前UI,进行展示处理
                _dictLoadedAllUIs.TryGetValue(uiName, out baseUI);
                if (baseUI != null)
                {
                    if (baseUI.IsShowing)
                    {
                        baseUI.OnShow();
                    }
                    else
                    {
                        if (baseUI.IsInitOver)
                        {
                            baseUI.OnEnabled(false);
                        }
                        baseUI.Show();
                    }
                }
            }
            return(baseUI);
        }