Esempio n. 1
0
        public static void ClosePage()
        {
            //Debug.Log("Back&Close PageNodes Count:" + m_currentPageNodes.Count);

            if (m_currentPageNodes == null || m_currentPageNodes.Count <= 1)
            {
                return;
            }

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

            m_currentPageNodes.RemoveAt(m_currentPageNodes.Count - 1);

            //show older page.
            //TODO:Sub pages.belong to root node.
            if (m_currentPageNodes.Count > 0)
            {
                UIbase page = m_currentPageNodes[m_currentPageNodes.Count - 1];
                if (page.isAsyncUI)
                {
                    ShowPage(page.name, page, () =>
                    {
                        closePage.Hide();
                    });
                }
                else
                {
                    ShowPage(page.name, page);

                    //after show to hide().
                    closePage.Hide();
                }
            }
        }
Esempio n. 2
0
        private static void HideOldNodes()
        {
            if (m_currentPageNodes.Count < 0)
            {
                return;
            }
            UIbase topPage = m_currentPageNodes[m_currentPageNodes.Count - 1];

            if (topPage.mode == UIMode.HideOther)
            {
                //form bottm to top.
                for (int i = m_currentPageNodes.Count - 2; i >= 0; i--)
                {
                    if (m_currentPageNodes[i].isActive())
                    {
                        m_currentPageNodes[i].Hide();
                    }
                }
            }
        }
Esempio n. 3
0
        private static void ShowPage(string pageName, UIbase 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, UIbase>();
            }

            UIbase page = null;

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

            //if active before,wont active again.
            //if (page.isActive() == false)
            {
                //before show should set this data if need. maybe.!!
                page.m_data = pageData;

                if (isAsync)
                {
                    page.Show(callback);
                }
                else
                {
                    page.Show();
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 将目标节点设置在顶部
        /// </summary>
        private static void PopNode(UIbase page)
        {
            if (m_currentPageNodes == null)
            {
                m_currentPageNodes = new List <UIbase>();
            }

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

            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 (!_isFound)
            {
                m_currentPageNodes.Add(page);
            }

            HideOldNodes();
        }
Esempio n. 5
0
        public static void ClosePage(UIbase 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);

                //show older page.
                //TODO:Sub pages.belong to root node.
                if (m_currentPageNodes.Count > 0)
                {
                    UIbase 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();
        }
Esempio n. 6
0
 public static void ShowPage(string pageName, UIbase pageInstance, Action callback, object pageData)
 {
     ShowPage(pageName, pageInstance, callback, pageData, true);
 }
Esempio n. 7
0
 public static void ShowPage(string pageName, UIbase pageInstance, Action callback)
 {
     ShowPage(pageName, pageInstance, callback, null, true);
 }
Esempio n. 8
0
 public static void ShowPage(string pageName, UIbase pageInstance, object pageData)
 {
     ShowPage(pageName, pageInstance, null, pageData, false);
 }
Esempio n. 9
0
 public static void ShowPage(string pageName, UIbase pageInstance)
 {
     ShowPage(pageName, pageInstance, null, null, false);
 }
Esempio n. 10
0
 private static bool CheckIfNeedBack(UIbase page)
 {
     return(page != null && page.CheckIfNeedBack());
 }