Exemplo n.º 1
0
        //完全打开一个新的
        private UIViewBase ShowNewView(SO_UIViewConfig config)
        {
            if (!viewDic.ContainsKey(config.viewLayer))
            {
                UtilityHelper.LogError("Show new view failed. Layer error.");
                return(null);
            }

            //加载
            UIViewBase view = CreateUIView(config);

            if (view)
            {
                //创建完毕,初始化
                view.Init();
                view.transform.SetParent(viewDic[config.viewLayer].transform);
                view.GetComponent <RectTransform>().Normalize();
            }
            return(view);
        }
Exemplo n.º 2
0
        //先尝试从缓存中打开,如果失败则打开一个新的
        private void ShowViewFromCacheOrCreateNew(SO_UIViewConfig config, params object[] args)
        {
            //先尝试从缓存区中读取
            UIViewBase view = GetViewFromCache(config);

            //缓存区内没有,打开新的
            if (view == null)
            {
                view = ShowNewView(config);
            }

            if (view != null)
            {
                PushViewToLayer(view, args);
            }
            else
            {
                UtilityHelper.LogError(string.Format("Show view failed -> {0}", config.viewName));
            }
        }
Exemplo n.º 3
0
        //根据指定界面
        public void HideView(UIViewBase view)
        {
            if (view == null)
            {
                return;
            }

            //在窗口栈中的界面都可以关闭
            if (view.layerController != null)
            {
                viewList.Remove(view);
                view.layerController.Popup(view);
                SchemeViewCache(view);
                UpdateViewHideState();
            }
            else
            {
                UtilityHelper.LogError(string.Format("Attamp to hide a error view {0}, not in controller.", view.config.viewName));
            }
        }
Exemplo n.º 4
0
        //从池中获取界面
        private UIViewBase GetViewFromCache(SO_UIViewConfig config)
        {
            if (config == null)
            {
                return(null);
            }

            UIViewBase        view  = null;
            List <UIViewBase> cache = null;

            switch (config.cacheScheme)
            {
            case UIViewCacheScheme.Cache:
                cache = screenUICache;
                break;

            case UIViewCacheScheme.TempCache:
                cache = screenUITempCache;
                break;

            default:
                break;
            }

            if (cache != null)
            {
                for (int i = 0; i < cache.Count; ++i)
                {
                    if (cache[i].config.viewName == config.viewName)
                    {
                        view = cache[i];
                        //从缓冲区中移除
                        cache.RemoveAt(i);
                        break;
                    }
                }
            }

            return(view);
        }
Exemplo n.º 5
0
        //移除全部
        public UIViewBase[] PopupAll()
        {
            if (views.Count == 0)
            {
                return(null);
            }

            UIViewBase cur = null;

            UIViewBase[] allViews = views.ToArray();
            if (views.Count > 0)
            {
                for (int i = views.Count - 1; i >= 0; --i)
                {
                    cur = views[i];
                    views.RemoveAt(i);
                    PopupSingleView(cur);
                }
                topOrder = 0;
            }
            return(allViews);
        }
Exemplo n.º 6
0
        //根据缓存类型处理界面
        private void SchemeViewCache(UIViewBase view)
        {
            if (view != null)
            {
                //根据缓存类型处理
                switch (view.config.cacheScheme)
                {
                case UIViewCacheScheme.Cache:
                    CacheView(view);
                    break;

                case UIViewCacheScheme.TempCache:
                    TempCacheView(view);
                    break;

                case UIViewCacheScheme.AutoRemove:
                    ReleaseView(view);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 7
0
 //压入一个新的窗口(设置为最大order)
 public void Push(UIViewBase view)
 {
     //判断是否本来就在这个队列中
     if (view.layerController != null)
     {
         if (view.ViewOrder == topOrder)
         {
             return;
         }
         else
         {
             views.Remove(view);
             views.Add(view);
             topOrder      += viewOrderStep;
             view.ViewOrder = topOrder;
         }
     }
     else
     {
         views.Add(view);
         topOrder += viewOrderStep;
         PushSingleView(view);
     }
 }