Example #1
0
        private static bool CheckIfNeedBack(UIWindowBase win)
        {
            UIType type = win.type;
            UIMode mode = win.mode;

            if (type == UIType.Fixed || type == UIType.PopUp)// || type == UIType.None)
            {
                return(false);
            }
            else if (mode == UIMode.DoNothing)// mode == UIMode.NoNeedBack ||)
            {
                return(false);
            }
            return(true);
        }
Example #2
0
        private static IEnumerator OpenningWindow(UIWindowBase win, CallBack <UIWindowBase> callback)
        {
            win.state = UIWindowState.Openning;

            yield return(win.OpenAnimation());

            win.OnOpenAfterAnimation();
            PopNode(win);
            win.state = UIWindowState.Ready;

            if (callback != null)
            {
                callback(win);
            }
        }
Example #3
0
        public void CloseNodeWindow(bool isImmediately = false)
        {
            UIWindowBase win = UIManager.CloseNodeWindow(isImmediately);

            if (win)
            {
                if (UIDic.ContainsKey(win.name))
                {
                    UIDic.Remove(win.name);
                }
                else
                {
                    Debug.LogError("GameScene don't hava UI Window!");
                }
            }
        }
Example #4
0
        private static IEnumerator ClosingWindow(UIWindowBase closeWin, bool isImmediately = false, string afterOpenWinName = null)
        {
            if (closeWin.state != UIWindowState.Closed)
            {
                closeWin.state = UIWindowState.Exiting;
                closeWin.OnExit();
                if (!isImmediately)
                {
                    yield return(closeWin.ExitAnimation());
                }
                closeWin.Closed();
                closeWin.state = UIWindowState.Closed;
            }

            if (!string.IsNullOrEmpty(afterOpenWinName))
            {
                OpenWindow(afterOpenWinName);
            }
        }
Example #5
0
        /// <summary>
        /// Close target page
        /// </summary>
        public static void CloseWindow(UIWindowBase target, bool isImmediately = false)
        {
            if (target == null)
            {
                return;
            }
            if (target.state == UIWindowState.Closed)
            {
                for (int i = 0; i < m_currentWindowNodes.Count; i++)
                {
                    if (m_currentWindowNodes[i] == target)
                    {
                        m_currentWindowNodes.RemoveAt(i);
                        break;
                    }
                }
                return;
            }

            if (m_currentWindowNodes.Count >= 1 && m_currentWindowNodes[m_currentWindowNodes.Count - 1] == target)
            {
                CloseNodeWindow();
            }
            else if (CheckIfNeedBack(target))
            {
                for (int i = 0; i < m_currentWindowNodes.Count; i++)
                {
                    if (m_currentWindowNodes[i] == target)
                    {
                        m_currentWindowNodes.RemoveAt(i);
                        UIRoot.Instance.StartCoroutine(ClosingWindow(target, isImmediately));
                        return;
                    }
                }
            }

            UIRoot.Instance.StartCoroutine(ClosingWindow(target, isImmediately));
        }
Example #6
0
        /// <summary>
        /// close current page in the "top" node.
        /// </summary>
        public static UIWindowBase CloseNodeWindow(bool isImmediately = false)
        {
            //Debug.Log("Back&Close PageNodes Count:" + m_currentPageNodes.Count);

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

            UIWindowBase closeWin = m_currentWindowNodes[m_currentWindowNodes.Count - 1];

            m_currentWindowNodes.RemoveAt(m_currentWindowNodes.Count - 1);

            //show older page.
            //TODO:Sub pages.belong to root node.
            if (m_currentWindowNodes.Count > 0)
            {
                UIWindowBase win = m_currentWindowNodes[m_currentWindowNodes.Count - 1];
                UIRoot.Instance.StartCoroutine(ClosingWindow(closeWin, isImmediately, win.windowName));
            }

            return(closeWin);
        }
Example #7
0
        /// <summary>
        /// make the target node to the top.
        /// </summary>
        private static void PopNode(UIWindowBase win)
        {
            //sub pages should not need back.
            if (!CheckIfNeedBack(win))
            {
                return;
            }

            bool _isFound = false;

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

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

            if (win.mode == UIMode.HideOther && m_currentWindowNodes.Count >= 2)
            {
                //form bottm to top.
                for (int i = m_currentWindowNodes.Count - 2; i >= 0; i--)
                {
                    CloseWindow(m_currentWindowNodes[i]);
                }
            }
        }