Exemple #1
0
        /// <summary>
        /// 关闭目标界面
        /// </summary>
        public static void ClosePage(WTUIPage target)
        {
            if (target == null)
            {
                return;
            }
            if (target.isActive() == false)
            {
                if (m_currentPageNodes != null)
                {
                    for (int i = 0; i < m_currentPageNodes.Count; i++)
                    {
                        if (m_currentPageNodes[i] == target)
                        {
                            m_currentPageNodes.RemoveAt(i);
                            break;
                        }
                    }
                    return;
                }
            }

            if (m_currentPageNodes != null && m_currentPageNodes.Count >= 1 && m_currentPageNodes[m_currentPageNodes.Count - 1] == target)
            {
                m_currentPageNodes.RemoveAt(m_currentPageNodes.Count - 1);

                if (m_currentPageNodes.Count > 0)
                {
                    WTUIPage page = m_currentPageNodes[m_currentPageNodes.Count - 1];
                    if (page.isAsyncUI)
                    {
                        ShowPage(page.name, page, () =>
                        {
                            target.Hide();
                        });
                    }
                    else
                    {
                        ShowPage(page.name, page);
                        target.Hide();
                    }

                    return;
                }
            }
            else if (target.CheckIfNeedBack())
            {
                for (int i = 0; i < m_currentPageNodes.Count; i++)
                {
                    if (m_currentPageNodes[i] == target)
                    {
                        m_currentPageNodes.RemoveAt(i);
                        target.Hide();
                        break;
                    }
                }
            }

            target.Hide();
        }
Exemple #2
0
        /// <summary>
        /// 关闭顶层界面
        /// </summary>
        public static void ClosePage()
        {
            //Debug.Log("Back&Close PageNodes Count:" + m_currentPageNodes.Count);
            //修改
            if (m_currentPageNodes == null || m_currentPageNodes.Count <= 0)
            {
                return;
            }

            WTUIPage closePage = m_currentPageNodes[m_currentPageNodes.Count - 1];

            m_currentPageNodes.RemoveAt(m_currentPageNodes.Count - 1);//从list中移除目前最后一个界面


            if (m_currentPageNodes.Count > 0)                                     //还有其他界面
            {
                WTUIPage page = m_currentPageNodes[m_currentPageNodes.Count - 1]; //移除过后最后一个界面
                if (page.isAsyncUI)
                {
                    ShowPage(page.name, page, () =>
                    {
                        closePage.Hide();
                    });
                }
                else
                {
                    ShowPage(page.name, page);


                    closePage.Hide();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 隐藏其他可隐藏的界面
        /// </summary>
        private static void HideOldNodes()
        {
            if (m_currentPageNodes.Count < 0)
            {
                return;
            }
            WTUIPage topPage = m_currentPageNodes[m_currentPageNodes.Count - 1];

            if (topPage.mode == UIMode.HideOther)
            {
                for (int i = m_currentPageNodes.Count - 2; i >= 0; i--)
                {
                    if (m_currentPageNodes[i].isActive())
                    {
                        m_currentPageNodes[i].Hide();
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        ///
        /// 将目标弹到顶层
        /// </summary>
        private static void PopNode(WTUIPage page)
        {
            if (m_currentPageNodes == null)
            {
                m_currentPageNodes = new List <WTUIPage>();
            }

            if (page == null)
            {
                Debug.LogError("[UI] page popup is null.");
                return;
            }

            //sub pages should not need back.
            if (CheckIfNeedBack(page) == false)
            {
                return;
            }

            bool _isFound = false;

            for (int i = 0; i < m_currentPageNodes.Count; i++)
            {
                if (m_currentPageNodes[i].Equals(page))
                {
                    m_currentPageNodes.RemoveAt(i);
                    m_currentPageNodes.Add(page);
                    _isFound = true;
                    break;
                }
            }

            //if dont found in old nodes
            //should add in nodelist.
            if (!_isFound)
            {
                m_currentPageNodes.Add(page);
            }

            //弹出新界面的时候隐藏其他界面
            HideOldNodes();
        }
Exemple #5
0
        private static void ShowPage(string pageName, WTUIPage pageInstance, Action callback, object pageData, bool isAsync)
        {
            if (string.IsNullOrEmpty(pageName) || pageInstance == null)
            {
                Debug.LogError("[UI] show page error with :" + pageName + " maybe null instance.");
                return;
            }

            if (m_allPages == null)
            {
                m_allPages = new Dictionary <string, WTUIPage>();
            }

            WTUIPage page = null;

            if (m_allPages.ContainsKey(pageName))
            {
                page = m_allPages[pageName];
            }
            else
            {
                m_allPages.Add(pageName, pageInstance);
                page = pageInstance;
            }


            //if (page.isActive() == false)
            {
                page.m_data = pageData;

                if (isAsync)
                {
                    page.Show(callback);
                }
                else
                {
                    page.Show();
                }
            }
        }
Exemple #6
0
 public static void ShowPage(string pageName, WTUIPage pageInstance, Action callback, object pageData)
 {
     ShowPage(pageName, pageInstance, callback, pageData, true);
 }
Exemple #7
0
 /// <summary>
 /// 异步显示制定界面
 /// </summary>
 public static void ShowPage(string pageName, WTUIPage pageInstance, Action callback)
 {
     ShowPage(pageName, pageInstance, callback, null, true);
 }
Exemple #8
0
 public static void ShowPage(string pageName, WTUIPage pageInstance, object pageData)
 {
     ShowPage(pageName, pageInstance, null, pageData, false);
 }
Exemple #9
0
 public static void ShowPage(string pageName, WTUIPage pageInstance)
 {
     ShowPage(pageName, pageInstance, null, null, false);
 }
Exemple #10
0
 private static bool CheckIfNeedBack(WTUIPage page)
 {
     return(page != null && page.CheckIfNeedBack());
 }