Ejemplo n.º 1
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new GameFrameworkException("UI form is invalid.");
            }

            UIGroup uiGroup = (UIGroup)uiForm.UIGroup;

            if (uiGroup == null)
            {
                throw new GameFrameworkException("UI group is invalid.");
            }

            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(m_IsShutdown, userData);
            uiGroup.Refresh();

            if (m_CloseUIFormCompleteEventHandler != null)
            {
                CloseUIFormCompleteEventArgs closeUIFormCompleteEventArgs = CloseUIFormCompleteEventArgs.Create(uiForm.SerialId, uiForm.UIFormAssetName, uiGroup, userData);
                m_CloseUIFormCompleteEventHandler(this, closeUIFormCompleteEventArgs);
                ReferencePool.Release(closeUIFormCompleteEventArgs);
            }

            m_RecycleQueue.Enqueue(uiForm);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new GameFrameworkException("UI form is invalid.");
            }

            UIGroup uiGroup = (UIGroup)uiForm.UIGroup;

            if (uiGroup == null)
            {
                throw new GameFrameworkException("UI group is invalid.");
            }

            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(userData);
            uiGroup.Refresh();

            if (m_CloseUIFormCompleteEventHandler != null)
            {
                m_CloseUIFormCompleteEventHandler(this, new CloseUIFormCompleteEventArgs(uiForm.SerialId, uiForm.UIFormAssetName, uiGroup, userData));
            }

            m_RecycleQueue.AddLast(uiForm);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new GameFrameworkException("UI form is invalid.");
            }

            UIGroup uiGroup = uiForm.UIGroup as UIGroup;

            if (uiGroup == null)
            {
                throw new GameFrameworkException("UI group is invalid.");
            }

            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(userData);
            uiGroup.Refresh();

            m_CloseUIFormCompleteEventHandler?.Invoke(this, new CloseUIFormCompleteEventArgs(uiForm.TypeId, userData));

            m_RecycleQueue.AddLast(new RecycleNode(uiForm));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 关闭界面。
        /// </summary>
        /// <param name="uiForm">要关闭的界面。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void CloseUIForm(IUIForm uiForm, object userData, bool isRelease = false)
        {
            Guard.Verify <ArgumentException>(uiForm == null, $"UI form is invalid.");

            UIGroup uiGroup = (UIGroup)uiForm.UIGroup;

            Guard.Verify <ArgumentException>(uiGroup == null, $"UI group is invalid.");

            // 先关闭前台界面,再激活后台界面
            uiGroup.RemoveUIForm(uiForm);
            uiForm.OnClose(userData);
            uiGroup.Refresh();

            if (isRelease)
            {
                m_InstancePool.Release(uiForm.UIFormInstance);
            }
            else
            {
                m_InstancePool.Unspawn(uiForm.UIFormInstance);
            }
        }
Ejemplo n.º 5
0
        public void CloseForm(IUIForm form)
        {
            if (!form.IsShow)
            {
                return;
            }
            if (form == m_Forms.Last.Value)
            {
                IUIForm prevForm = m_Forms.Last.Previous == null ? null : m_Forms.Last.Previous.Value;
                if (prevForm != null && prevForm.IsShow)
                {
                    prevForm.OnFocus();
                }
                else
                {
                    m_CurrentDepth = 0;
                }
            }

            m_Forms.Remove(form);
            m_Forms.AddFirst(form);
            form.OnClose();
        }