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

            UIGroup uiGroup = uiFormBase.UIGroup;

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

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

            if (m_CloseUIFormCompleteEventHandler != null)
            {
                m_CloseUIFormCompleteEventHandler(uiFormBase.SerialId, uiFormBase.UIFormAssetName, uiGroup, userData);
            }

            m_RecycleQueue.Enqueue(uiFormBase);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 是否是合法的界面
        /// </summary>
        /// <param name="uiForm">界面</param>
        /// <returns>界面是否合法</returns>
        public bool IsValidUIForm(UIFormBase uiForm)
        {
            if (uiForm == null)
            {
                return(false);
            }

            return(HasUIForm(uiForm.SerialId));
        }
Exemplo n.º 3
0
 private void OnOpenUIFormSuccess(UIFormBase uiForm, float duration, object userData)
 {
     Log.Info("Open UI form success, uiform name '{0}',duration time '{1}'.", uiForm.UIFormAssetName, duration);
     if (m_EnableOpenUIFormSuccessEvent)
     {
         //todo
         //Debug.Log("加载UI资源成功"+ duration);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 设置界面是否被加锁
        /// </summary>
        /// <param name="uiForm">要设置是否被加锁的界面</param>
        /// <param name="locked">界面是否被加锁</param>
        public void SetUIFormInstanceLocked(UIFormBase uiForm, bool locked)
        {
            if (uiForm == null)
            {
                Log.Warning("UI form is invalid.");
                return;
            }

            m_UIManager.SetUIFormInstanceLocked(uiForm.gameObject, locked);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 设置界面的优先级
        /// </summary>
        /// <param name="uiForm">要设置优先级的界面</param>
        /// <param name="priority">界面优先级</param>
        public void SetUIFormInstancePriority(UIFormBase uiForm, int priority)
        {
            if (uiForm == null)
            {
                Log.Warning("UI form is invalid.");
                return;
            }

            m_UIManager.SetUIFormInstancePriority(uiForm.gameObject, priority);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取界面
        /// </summary>
        /// <param name="uiFormAssetName">界面资源名称</param>
        /// <returns>要获取的界面</returns>
        public UIFormBase[] GetUIForms(string uiFormAssetName)
        {
            UIFormBase[] uiForms     = m_UIManager.GetUIForms(uiFormAssetName);
            UIFormBase[] uiFormImpls = new UIFormBase[uiForms.Length];
            for (int i = 0; i < uiForms.Length; i++)
            {
                uiFormImpls[i] = uiForms[i];
            }

            return(uiFormImpls);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取所有已加载的界面
        /// </summary>
        /// <returns>所有已加载的界面</returns>
        public UIFormBase[] GetAllLoadedUIForms()
        {
            UIFormBase[] uiForms     = m_UIManager.GetAllLoadedUIForms();
            UIFormBase[] uiFormImpls = new UIFormBase[uiForms.Length];
            for (int i = 0; i < uiForms.Length; i++)
            {
                uiFormImpls[i] = uiForms[i];
            }

            return(uiFormImpls);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 初始化界面组界面信息的新实例
        /// </summary>
        /// <param name="uiForm">界面</param>
        public UIFormInfo(UIFormBase uiFormBase)
        {
            if (uiFormBase == null)
            {
                throw new Exception("UI form is invalid.");
            }

            m_UIFormBase = uiFormBase;
            m_Paused     = true;
            m_Covered    = true;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 激活界面
        /// </summary>
        /// <param name="uiFormBase">要激活的界面</param>
        /// <param name="userData">用户自定义数据</param>
        public void RefocusUIForm(UIFormBase uiFormBase, object userData)
        {
            UIFormInfo uiFormInfo = GetUIFormInfo(uiFormBase);

            if (uiFormInfo == null)
            {
                throw new Exception("Can not find UI form info.");
            }

            m_UIFormInfos.Remove(uiFormInfo);
            m_UIFormInfos.AddFirst(uiFormInfo);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取界面
        /// </summary>
        /// <param name="serialId">界面序列编号</param>
        /// <returns>要获取的界面</returns>
        public UIFormBase GetUIForm(int serialId)
        {
            foreach (KeyValuePair <string, UIGroup> uiGroup in m_UIGroups)
            {
                UIFormBase uiForm = uiGroup.Value.GetUIForm(serialId);
                if (uiForm != null)
                {
                    return(uiForm);
                }
            }

            return(null);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 界面管理器轮询
        /// </summary>
        public void OnUpdate(float deltaTime, float unscaledDeltaTime)
        {
            while (m_RecycleQueue.Count > 0)
            {
                UIFormBase uiForm = m_RecycleQueue.Dequeue();
                uiForm.OnRecycle();
                m_InstancePool.Unspawn(uiForm.Handle);
            }

            foreach (KeyValuePair <string, UIGroup> uiGroup in m_UIGroups)
            {
                uiGroup.Value.OnUpdate(deltaTime, unscaledDeltaTime);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 关闭界面
        /// </summary>
        /// <param name="serialId">要关闭界面的序列编号</param>
        /// <param name="userData">用户自定义数据</param>
        public void CloseUIForm(int serialId, object userData)
        {
            if (IsLoadingUIForm(serialId))
            {
                m_UIFormsToReleaseOnLoad.Add(serialId);
                return;
            }

            UIFormBase uiFormBase = GetUIForm(serialId);

            if (uiFormBase == null)
            {
                throw new Exception(TextUtil.Format("Can not find UI form '{0}'.", serialId.ToString()));
            }

            CloseUIForm(uiFormBase, userData);
        }
Exemplo n.º 13
0
        private UIFormInfo GetUIFormInfo(UIFormBase uiFormBase)
        {
            if (uiFormBase == null)
            {
                throw new Exception("UI form is invalid.");
            }

            foreach (UIFormInfo uiFormInfo in m_UIFormInfos)
            {
                if (uiFormInfo.UIFormBase == uiFormBase)
                {
                    return(uiFormInfo);
                }
            }

            return(null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 获取界面
        /// </summary>
        /// <param name="uiFormAssetName">界面资源名称</param>
        /// <returns>要获取的界面</returns>
        public UIFormBase GetUIForm(string uiFormAssetName)
        {
            if (string.IsNullOrEmpty(uiFormAssetName))
            {
                throw new Exception("UI form asset name is invalid.");
            }

            foreach (KeyValuePair <string, UIGroup> uiGroup in m_UIGroups)
            {
                UIFormBase uiFormBase = uiGroup.Value.GetUIForm(uiFormAssetName);
                if (uiFormBase != null)
                {
                    return(uiFormBase);
                }
            }

            return(null);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 激活界面
        /// </summary>
        /// <param name="uiForm">要激活的界面</param>
        /// <param name="userData">用户自定义数据</param>
        public void RefocusUIForm(UIFormBase uiForm, object userData)
        {
            if (uiForm == null)
            {
                throw new Exception("UI form is invalid.");
            }

            UIGroup uiGroup = uiForm.UIGroup;

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

            uiGroup.RefocusUIForm(uiForm, userData);
            uiGroup.Refresh();
            uiForm.OnRefocus(userData);
        }
Exemplo n.º 16
0
        private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData)
        {
            try
            {
                GameObject gameObject = uiFormInstance as GameObject;
                if (gameObject == null)
                {
                    Log.Error("UI form instance is invalid.");
                }

                Transform transform = gameObject.transform;
                transform.SetParent(uiGroup.UIGroupTransform);
                transform.localScale = Vector3.one;

                UIFormBase uiFormBase = transform.GetComponent <UIFormBase>();
                if (uiFormBase == null)
                {
                    throw new Exception("Can't find UI form.");
                }


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

                if (m_OpenUIFormSuccessEventHandler != null)
                {
                    m_OpenUIFormSuccessEventHandler(uiFormBase, duration, userData);
                }
            }
            catch (Exception exception)
            {
                if (m_OpenUIFormFailureEventHandler != null)
                {
                    m_OpenUIFormFailureEventHandler(serialId, uiFormAssetName, uiGroup.Name, pauseCoveredUIForm, exception.ToString(), userData);
                    return;
                }

                throw;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 从界面组移除界面
        /// </summary>
        /// <param name="uiFormBase">要移除的界面</param>
        public void RemoveUIForm(UIFormBase uiFormBase)
        {
            UIFormInfo uiFormInfo = GetUIFormInfo(uiFormBase);

            if (uiFormInfo == null)
            {
                throw new Exception(TextUtil.Format("Can not find UI form info for serial id '{0}', UI form asset name is '{1}'.", uiFormBase.SerialId.ToString(), uiFormBase.UIFormAssetName));
            }

            if (!uiFormInfo.Covered)
            {
                uiFormInfo.Covered = true;
                uiFormBase.OnCover();
            }

            if (!uiFormInfo.Paused)
            {
                uiFormInfo.Paused = true;
                uiFormBase.OnPause();
            }

            m_UIFormInfos.Remove(uiFormInfo);
        }
Exemplo n.º 18
0
 /// <summary>
 /// 激活界面
 /// </summary>
 /// <param name="uiForm">要激活的界面</param>
 /// <param name="userData">用户自定义数据</param>
 public void RefocusUIForm(UIFormBase uiForm, object userData)
 {
     m_UIManager.RefocusUIForm(uiForm, userData);
 }
Exemplo n.º 19
0
 /// <summary>
 /// 激活界面
 /// </summary>
 /// <param name="uiForm">要激活的界面</param>
 public void RefocusUIForm(UIFormBase uiForm)
 {
     m_UIManager.RefocusUIForm(uiForm);
 }
Exemplo n.º 20
0
 /// <summary>
 /// 关闭界面
 /// </summary>
 /// <param name="uiForm">要关闭的界面</param>
 /// <param name="userData">用户自定义数据</param>
 public void CloseUIForm(UIFormBase uiForm, object userData)
 {
     m_UIManager.CloseUIForm(uiForm, userData);
 }
Exemplo n.º 21
0
 /// <summary>
 /// 关闭界面
 /// </summary>
 /// <param name="uiForm">要关闭的界面</param>
 public void CloseUIForm(UIFormBase uiForm)
 {
     m_UIManager.CloseUIForm(uiForm);
 }
Exemplo n.º 22
0
 /// <summary>
 /// 是否是合法的界面
 /// </summary>
 /// <param name="uiForm">界面</param>
 /// <returns>界面是否合法</returns>
 public bool IsValidUIForm(UIFormBase uiForm)
 {
     return(m_UIManager.IsValidUIForm(uiForm));
 }
Exemplo n.º 23
0
 /// <summary>
 /// 关闭界面
 /// </summary>
 /// <param name="uiFormBase">要关闭的界面</param>
 public void CloseUIForm(UIFormBase uiFormBase)
 {
     CloseUIForm(uiFormBase, null);
 }
Exemplo n.º 24
0
 /// <summary>
 /// 激活界面
 /// </summary>
 /// <param name="uiForm">要激活的界面</param>
 public void RefocusUIForm(UIFormBase uiForm)
 {
     RefocusUIForm(uiForm, null);
 }
Exemplo n.º 25
0
        /// <summary>
        /// 往界面组增加界面
        /// </summary>
        /// <param name="uiFormBase">要增加的界面</param>
        public void AddUIForm(UIFormBase uiFormBase)
        {
            UIFormInfo uiFormInfo = new UIFormInfo(uiFormBase);

            m_UIFormInfos.AddFirst(uiFormInfo);
        }