示例#1
0
 public Coroutine OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
 {
     // 企图关闭当前的View
     Debug.Log("Open " + rViewName);
     MaybeCloseTopView(rViewState);
     return(this.StartCoroutine(Open_Async(rViewName, rViewState, rOpenCompleted)));
 }
示例#2
0
        /// <summary>
        /// 企图关闭一个当前的View,当存在当前View时候,并且传入的View是需要Dispatch的。
        /// </summary>
        private void MaybeCloseTopView(View.State rViewState)
        {
            // 得到顶层结点
            CKeyValuePair <string, View> rTopNode = null;

            if (this.mCurPageViews.Count > 0)
            {
                rTopNode = this.mCurPageViews.Last();
            }
            if (rTopNode == null)
            {
                return;
            }

            string rViewGUID = rTopNode.Key;
            View   rView     = rTopNode.Value;

            if (rView == null)
            {
                return;
            }

            if (rViewState == View.State.PageSwitch)
            {
                // 移除顶层结点
                this.mCurPageViews.Remove(rViewGUID);
                rView.Close();
                DestroyView(rView);
            }
        }
示例#3
0
 /// <summary>
 /// 打开一个View
 /// </summary>
 public async Task <View> OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
 {
     // 企图关闭当前的View
     Debug.Log("-- Open UI View: " + rViewName);
     MaybeCloseTopView(rViewState);
     return(await OpenViewAsync(rViewName, rViewState, rOpenCompleted));
 }
示例#4
0
 /// <summary>
 /// 打开一个View
 /// </summary>
 public async Task OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
 {
     // 企图关闭当前的View
     Debug.Log("Open " + rViewName);
     MaybeCloseTopView(rViewState);
     await Open_Async(rViewName, rViewState, rOpenCompleted);
 }
示例#5
0
        /// <summary>
        /// 企图关闭一个当前的View,当存在当前View时候,并且传入的View是需要Dispatch的。
        /// </summary>
        private void MaybeCloseTopView(View.State rViewState)
        {
            // 得到顶层结点
            CKeyValuePair <string, View> rTopNode = null;

            if (this.mCurFixedViews.Count > 0)
            {
                rTopNode = this.mCurViews.Last();
            }

            if (rTopNode == null)
            {
                return;
            }

            string rViewGUID = rTopNode.Key;
            View   rView     = rTopNode.Value;

            if (rView == null)
            {
                return;
            }

            if (rViewState == View.State.dispatch)
            {
                // 移除顶层结点
                this.mCurViews.Remove(rViewGUID);
                rView.Close();
                CoroutineManager.Instance.Start(DestroyView_Async(rView));
            }
        }
示例#6
0
 /// <summary>
 /// 打开一个View
 /// </summary>
 public async Task <View> OpenAsync(string rViewName, View.State rViewState, ViewModel rViewModel = null, Action <View> rOpenCompleted = null)
 {
     // 企图关闭当前的View
     Debug.Log("Open " + rViewName);
     this.MaybeCloseTopView(rViewState);
     return(await OpenViewAsync(rViewName, rViewState, rViewModel, rOpenCompleted));
 }
示例#7
0
        /// <summary>
        /// 打开一个View
        /// </summary>
        public void Open(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
        {
            // 企图关闭当前的View
            MaybeCloseTopView(rViewState);

            this.StartCoroutine(Open_Async(rViewName, rViewState, rOpenCompleted));
        }
示例#8
0
        /// <summary>
        /// 打开一个View
        /// </summary>
        public void Open(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
        {
            // 企图关闭当前的View
            Debug.Log("Open " + rViewName);
            MaybeCloseTopView(rViewState);

            CoroutineManager.Instance.Start(Open_Async(rViewName, rViewState, rOpenCompleted));
        }
示例#9
0
        private IEnumerator Open_Async(string rViewName, View.State rViewState, Action <View> rOpenCompleted)
        {
            var rLoaderRequest = UIAssetLoader.Instance.LoadUI(rViewName);

            yield return(rLoaderRequest);

            OpenView(rViewName, rLoaderRequest.ViewPrefabGo, rViewState, rOpenCompleted);
        }
示例#10
0
        /// <summary>
        /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换
        /// </summary>
        public void OpenView(string rViewName, GameObject rViewPrefab, View.State rViewState, Action <View> rOpenCompleted)
        {
            if (rViewPrefab == null)
            {
                return;
            }

            //把View的GameObject结点加到rootCanvas下
            GameObject rViewGo = this.RootCanvas.transform.AddChild(rViewPrefab, "UI");

            View rView = View.CreateView(rViewGo);

            if (rView == null)
            {
                Debug.LogErrorFormat("GameObject {0} has not View script.", rViewGo.name);
                UtilTool.SafeExecute(rOpenCompleted, null);
                return;
            }

            //生成GUID
            string rViewGUID = Guid.NewGuid().ToString();

            //为View的初始化设置
            rView.Initialize(rViewName, rViewGUID, rViewState);

            //新的View的存储逻辑
            switch (rView.CurState)
            {
            case View.State.fixing:
                mCurFixedViews.Add(rViewGUID, rView);
                break;

            case View.State.overlap:
                mCurViews.Add(rViewGUID, rView);
                break;

            case View.State.dispatch:
                if (mCurViews.Count == 0)
                {
                    mCurViews.Add(rViewGUID, rView);
                }
                else
                {
                    mCurViews[mCurViews.Last().Key] = rView;
                }
                break;

            default:
                break;
            }

            rView.Open((rNewView) =>
            {
                UnloadUnusedViewAssets();
                UtilTool.SafeExecute(rOpenCompleted, rNewView);
            });
        }
示例#11
0
        /// <summary>
        /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换
        /// </summary>
        private void OpenView(GameObject rViewPrefab, View.State rViewState, Action <View> rOpenCompleted)
        {
            if (rViewPrefab == null)
            {
                return;
            }

            //把View的GameObject结点加到rootCanvas下
            GameObject rViewGo = this.rootCanvas.transform.AddChild(rViewPrefab, "UI");

            View rView = rViewGo.SafeGetComponent <View>();

            if (rView == null)
            {
                Debug.LogErrorFormat("GameObject {0} has not View script.", rViewGo.name);
                UtilTool.SafeExecute(rOpenCompleted, null);
                return;
            }

            //生成GUID
            string rViewGUID = Guid.NewGuid().ToString();

            //为View的初始化设置
            rView.Initialize(rViewGUID, rViewState);

            //新的View的存储逻辑
            switch (rView.curState)
            {
            case View.State.fixing:
                curFixedViews.Add(rViewGUID, rView);
                break;

            case View.State.overlap:
                curViews.Add(rViewGUID, rView);
                break;

            case View.State.dispatch:
                if (curViews.Count == 0)
                {
                    curViews.Add(rViewGUID, rView);
                }
                else
                {
                    curViews[curViews.LastKey()] = rView;
                }
                break;

            default:
                break;
            }

            rView.Open(rOpenCompleted);
        }
示例#12
0
        public async Task <View> OpenPageUIAsync(string rViewName, View.State rState, Action <View> rOpenCompleted = null)
        {
            var rView = await ViewManager.Instance.OpenAsync(rViewName, rState, rOpenCompleted);

            if (rView != null && rView.IsBackCache)
            {
                this.mBackCaches.Push(new BackCache()
                {
                    ViewName = rView.ViewName,
                    ViewGUID = rView.GUID,
                    State    = rView.CurState,
                });
            }
            return(rView);
        }
示例#13
0
 public void OpenPageUI(string rViewName, View.State rState, Action <View> rOpenCompleted = null)
 {
     ViewManager.Instance.Open(rViewName, rState, (rView) =>
     {
         if (rView != null && rView.IsBackCache)
         {
             this.mBackCaches.Push(new BackCache()
             {
                 ViewName = rView.ViewName,
                 ViewGUID = rView.GUID,
                 State    = rView.CurState,
             });
         }
         UtilTool.SafeExecute(rOpenCompleted, rView);
     });
 }
示例#14
0
        /// <summary>
        /// 企图关闭一个当前的View,当存在当前View时候,并且传入的View是需要Dispatch的。
        /// </summary>
        private void MaybeCloseTopView(View.State rViewState)
        {
            // 得到顶层结点
            KeyValuePair <string, View> rTopNode = this.mCurViews.Last();

            string rViewGUID = rTopNode.Key;
            View   rView     = rTopNode.Value;

            if (rView == null)
            {
                return;
            }

            if (rViewState == View.State.dispatch)
            {
                // 移除顶层结点
                this.mCurViews.Remove(rViewGUID);
                rView.Close();
                this.StartCoroutine(DestroyView_Async(rView));
            }
        }
示例#15
0
 public Coroutine OpenAsync(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
 {
     return(this.StartCoroutine(Open_Async(rViewName, rViewState, rOpenCompleted)));
 }
示例#16
0
        /// <summary>
        /// 初始化View,如果是Dispatch类型的话,只对curViews顶层View进行交换
        /// </summary>
        public async Task <View> OpenView(string rViewName, GameObject rViewPrefab, View.State rViewState, ViewModel rViewModel, Action <View> rOpenCompleted)
        {
            if (rViewPrefab == null)
            {
                return(null);
            }

            //把View的GameObject结点加到rootCanvas下
            GameObject rViewGo = null;

            switch (rViewState)
            {
            case View.State.Fixing:
                rViewGo = this.DynamicRoot.transform.AddChildNoScale(rViewPrefab, "UI");
                break;

            case View.State.Popup:
                rViewGo = this.PopupRoot.transform.AddChildNoScale(rViewPrefab, "UI");
                break;

            case View.State.Frame:
                rViewGo = this.FrameRoot.transform.AddChildNoScale(rViewPrefab, "UI");
                break;

            case View.State.PageSwitch:
            case View.State.PageOverlap:
                rViewGo = this.PageRoot.transform.AddChildNoScale(rViewPrefab, "UI");
                break;
            }

            var    rView     = View.CreateView(rViewGo);
            string rViewGUID = Guid.NewGuid().ToString();   //生成GUID

            if (rView == null)
            {
                Debug.LogErrorFormat("GameObject {0} is null.", rViewGo.name);
                UtilTool.SafeExecute(rOpenCompleted, null);
                return(null);
            }
            // 设置Default ViewModel
            rView.DefaultViewModel = rViewModel;

            //新的View的存储逻辑
            switch (rViewState)
            {
            case View.State.Fixing:
                mCurFixedViews.Add(rViewGUID, rView);
                break;

            case View.State.Frame:
                mCurFrameViews.Add(rViewGUID, rView);
                break;

            case View.State.PageSwitch:
                if (mCurPageViews.Count == 0)
                {
                    mCurPageViews.Add(rViewGUID, rView);
                }
                else
                {
                    var rTopNode = this.mCurPageViews.Last();
                    mCurPageViews.Remove(rTopNode.Key);
                    mCurPageViews.Add(rViewGUID, rView);
                }
                break;

            case View.State.PageOverlap:
                mCurPageViews.Add(rViewGUID, rView);
                break;

            case View.State.Popup:
                mCurPageViews.Add(rViewGUID, rView);
                break;

            default:
                break;
            }

            try
            {
                await rView.Initialize(rViewName, rViewGUID, rViewState);   //为View的初始化设置

                await rView.Open();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            UtilTool.SafeExecute(rOpenCompleted, rView);
            return(rView);
        }
示例#17
0
        private async Task <View> OpenViewAsync(string rViewName, View.State rViewState, ViewModel rViewModel, Action <View> rOpenCompleted)
        {
            var rLoaderRequest = UIAssetLoader.Instance.LoadUI(rViewName);

            return(await OpenView(rViewName, rLoaderRequest.ViewPrefabGo, rViewState, rViewModel, rOpenCompleted));
        }
示例#18
0
 public void Open(string rViewName, View.State rViewState, ViewModel rViewModel, Action <View> rOpenCompleted = null)
 {
     this.OpenAsync(rViewName, rViewState, rViewModel, rOpenCompleted).WarpErrors();
 }
示例#19
0
        private async Task Open_Async(string rViewName, View.State rViewState, Action <View> rOpenCompleted)
        {
            var rLoaderRequest = await Framework.WindUI.UIAssetLoader.Instance.LoadUI(rViewName);

            OpenView(rViewName, rLoaderRequest.ViewPrefabGo, rViewState, rOpenCompleted);
        }
示例#20
0
        public void Open(string rViewName, View.State rViewState, Action <View> rOpenCompleted = null)
        {
#pragma warning disable 4014
            this.OpenAsync(rViewName, rViewState, rOpenCompleted);
#pragma warning restore 4014
        }