예제 #1
0
        /// <summary>
        /// 弹出窗口,出栈
        /// </summary>
        /// <param name="uiName"></param>
        private void UnLoadStackUI(string uiName, bool isDestroy = false)
        {
            //有两个以上弹窗出现时
            if (_stackCurrentUI.Count >= 2)
            {
                //第一个出栈
                BaseUI topUI = _stackCurrentUI.Pop();
                topUI.Close(isDestroy: isDestroy);

                //第二个重新显示
                BaseUI nextUI = _stackCurrentUI.Peek();
                nextUI.Show(true);
            }
            //当前只有一个弹窗
            else if (_stackCurrentUI.Count == 1)
            {
                //出栈的窗体进行隐藏
                BaseUI topUI = _stackCurrentUI.Pop();
                topUI.Close(isDestroy: isDestroy);
            }
        }
예제 #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);
        }