Example #1
0
        private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData)
        {
            try
            {
                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData);
                if (uiForm == null)
                {
                    throw new GameFrameworkException("Can not create UI form in helper.");
                }

                uiForm.OnInit(serialId, uiFormAssetName, uiGroup, pauseCoveredUIForm, isNewInstance, userData);
                uiGroup.AddUIForm(uiForm);
                uiForm.OnOpen(userData);
                uiGroup.Refresh();

                if (m_OpenUIFormSuccessEventHandler != null)
                {
                    OpenUIFormSuccessEventArgs openUIFormSuccessEventArgs = OpenUIFormSuccessEventArgs.Create(uiForm, duration, userData);
                    m_OpenUIFormSuccessEventHandler(this, openUIFormSuccessEventArgs);
                    ReferencePool.Release(openUIFormSuccessEventArgs);
                }
            }
            catch (Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    OpenUIFormFailureEventArgs openUIFormFailureEventArgs = OpenUIFormFailureEventArgs.Create(serialId, uiFormAssetName, uiGroup.Name, pauseCoveredUIForm, exception.ToString(), userData);
                    m_OpenUIFormFailureEventHandler(this, openUIFormFailureEventArgs);
                    ReferencePool.Release(openUIFormFailureEventArgs);
                    return;
                }

                throw;
            }
        }
        /// <summary>
        /// 立即打开界面
        /// </summary>
        /// <param name="serialId"></param>
        /// <param name="uiFormAssetName"></param>
        /// <param name="uiGroup"></param>
        /// <param name="uiFormInstance"></param>
        /// <param name="pauseCoveredUIForm"></param>
        /// <param name="isNewInstance"></param>
        /// <param name="duration"></param>
        /// <param name="userData"></param>
        private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool isNewInstance, float duration, object userData)
        {
            try
            {
                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData);
                if (uiForm == null)
                {
                    Log.Error("Can not create UI form in helper.");
                }
                if (uiGroup.CurrentUIForm != null && uiGroup.CurrentUIForm.SerialId != uiForm.SerialId)
                {
                    uiGroup.CurrentUIForm.OnClose(null);
                }

                uiForm.OnInit(serialId, uiFormAssetName, uiGroup, isNewInstance, userData);
                uiGroup.AddUIForm(uiForm);
                uiForm.OnOpen(userData);
                uiGroup.Refresh();

                if (m_OpenUIFormSuccessEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(this, new OpenUIFormSuccessEventArgs(uiForm, duration, userData));
                }
            }
            catch (System.Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    m_OpenUIFormFailureEventHandler(this, new OpenUIFormFailureEventArgs(serialId, uiFormAssetName, uiGroup.Name, exception.ToString(), userData));
                    return;
                }

                throw;
            }
        }
Example #3
0
        private void InternalOpenUIForm(int uiFormTypeId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData)
        {
            try
            {
                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData);
                if (uiForm == null)
                {
                    throw new GameFrameworkException("Can not create UI form in helper.");
                }

                uiForm.OnInit(uiFormTypeId, uiGroup, pauseCoveredUIForm, isNewInstance, userData);
                uiGroup.AddUIForm(uiForm);
                uiForm.OnOpen(userData);
                uiGroup.Refresh();
                m_OpenUIFormSuccessEventHandler?.Invoke(this, new OpenUIFormSuccessEventArgs(uiFormAssetName, uiForm, duration, userData));
            }
            catch (Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    m_OpenUIFormFailureEventHandler(this, new OpenUIFormFailureEventArgs(uiFormTypeId, uiFormAssetName, uiGroup.Name, pauseCoveredUIForm, string.Format("{0}\n{1}", exception.Message, exception.StackTrace), userData));
                    return;
                }

                throw;
            }
        }
Example #4
0
        private void InternalOpenUIForm(int serialId, string uiFormAssetName, object uiFormInstance, bool isNewInstance, float duration)
        {
            try
            {
                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, GetUIGroup, userData);
                if (uiForm == null)
                {

                }

                uiForm.OnInit(serialId, uiFormAssetName, GetUIGroup, isNewInstance, userData);
                uiGroup.AddUIForm(uiForm);
                uiForm.OnOpen(userData);
                GetUIGroup.Refresh();

                if (m_OpenUIFormSuccessEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(this, new OpenUIFormSuccessEventArgs(uiForm, duration, userData));
                }
            }
            catch (Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(this, new OpenUIFormSuccessEventArgs(serialId, uiUIFormAssetName);
                    return;
                }
                throw;
            }
        }
Example #5
0
        public IUIForm OpenForm(string formName, object formAsset, string groupName)
        {
            if (formAsset == null)
            {
                throw new ArgumentNullException("invalid form asset");
            }

            if (string.IsNullOrEmpty(formName))
            {
                throw new ArgumentException("invalid form name");
            }

            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException("invalid group name");
            }

            if (!m_Groups.ContainsKey(groupName))
            {
                throw new ArgumentException(string.Format("not exists group '{0}'", groupName));
            }

            IUIGroup group = m_Groups[groupName];

            IUIForm form = null;
            LinkedListNode <IUIForm> node = m_Forms.First;

            while (node != null)
            {
                if (node.Value.FormName.Equals(formName))
                {
                    form = node.Value;
                    break;
                }
                node = node.Next;
            }
            if (form == null)
            {
                form       = m_Creater.InstantiateForm(formAsset);
                form.Group = group;
                group.AddForm(form);
                m_Forms.AddLast(form);
                form.FormName = formName;
                form.OnInit();
            }

            if (form.Group != null && form.Group != group)
            {
                form.Group.RemoveForm(form);
                form.Group = group;
            }

            group.OpenForm(form);
            return(form);
        }
Example #6
0
        private IUIForm InnerOpenUIForm(string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, object userData)
        {
            IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData);

            Guard.Verify <ArgumentException>(uiForm == null, $"Can not create UI form in helper.");

            uiForm.OnInit(uiFormAssetName, uiGroup, pauseCoveredUIForm, isNewInstance, userData);

            uiGroup.AddUIForm(uiForm);
            uiGroup.RefreshOnlyOlds();
            uiForm.OnOpen(userData);
            uiGroup.RefreshOnlyNew();

            return(uiForm);
        }