Ejemplo n.º 1
0
        //处理面板隐藏逻辑
        private void ProcessPanelGameObjectActiveState()
        {
            int mask = 0;

            for (int i = m_ActivePanelInfoList.Count - 1; i >= 0; --i)
            {
                PanelInfo panelInfo = m_ActivePanelInfoList[i];

                if (panelInfo.sortIndex < 0)
                {
                    panelInfo.SetActive(false, false);
                    continue;
                }

                if (((mask ^ (int)PanelHideMask.Hide) & (int)PanelHideMask.Hide) == 0)
                {
                    panelInfo.SetActive(false, false);
                }
                else
                {
                    if (((mask ^ (int)PanelHideMask.UnInteractive) & (int)PanelHideMask.UnInteractive) == 0)
                    {
                        panelInfo.SetActive(true, false);
                    }
                    else
                    {
                        panelInfo.SetActive(true, true);
                    }
                }

                mask |= panelInfo.hideMask;
            }
        }
Ejemplo n.º 2
0
        private void OpenDependPanel(int uiID, PanelInfo masterInfo, Action <AbstractPanel> listener, params object[] args)
        {
            if (masterInfo == null)
            {
                Log.e("DependPanel Can not open with null Parent.");
                return;
            }

            PanelInfo panelInfo = LoadPanelInfo(uiID);

            if (panelInfo == null)
            {
                return;
            }

            panelInfo.AddMaster(masterInfo.panelID, args);

            if (panelInfo.isReady)
            {
                ReSortPanel();
                panelInfo.AddOpenCallback(listener);
            }
            else
            {
                panelInfo.AddOpenCallback(listener);
                panelInfo.LoadPanelResAsync();
            }
        }
Ejemplo n.º 3
0
        public void CloseDependPanel <T>(int master, T uiID) where T : IConvertible
        {
            int        eID            = uiID.ToInt32(null);
            List <int> needClosePanel = new List <int>();

            for (int i = m_ActivePanelInfoList.Count - 1; i >= 0; --i)
            {
                if (m_ActivePanelInfoList[i].uiID == eID)
                {
                    m_ActivePanelInfoList[i].RemoveMaster(master);
                    if (m_ActivePanelInfoList[i].nextMaster <= 0)
                    {
                        needClosePanel.Add(m_ActivePanelInfoList[i].panelID);
                    }
                }
            }

            if (needClosePanel.Count > 0)
            {
                for (int i = needClosePanel.Count - 1; i >= 0; --i)
                {
                    PanelInfo info = FindPanelInfoByPanelID(needClosePanel[i]);
                    if (info != null)
                    {
                        ClosePanelInfo(info);
                    }
                }
            }

            ReSortPanel();
        }
Ejemplo n.º 4
0
        public void ClosePanel(AbstractPanel panel)
        {
            if (panel == null)
            {
                return;
            }

            PanelInfo panelInfo = FindPanelInfoByPanelID(panel.panelID);

            //该面板的管理失效,直接移除
            if (panelInfo == null)
            {
                panelInfo = GetPanelFromCache(panel.uiID, false);

                if (panelInfo == null)
                {
                    Log.e("Not Find PanelInfo For Panel.");
                    panel.OnPanelClose(true);
                    GameObject.Destroy(panel.gameObject);
                }
                return;
            }

            ClosePanelInfo(panelInfo);
            ReSortPanel();
        }
Ejemplo n.º 5
0
        public AbstractPanel FindPanel <T>(T uiID) where T : IConvertible
        {
            PanelInfo info = GetPanelFromActive(uiID.ToInt32(null));

            if (info == null)
            {
                return(null);
            }
            return(info.abstractPanel);
        }
Ejemplo n.º 6
0
        public AbstractPage FindPanelPage <T>(int panelID, T uiID) where T : IConvertible
        {
            PanelInfo info = FindPanelInfoByPanelID(panelID);

            if (info == null)
            {
                return(null);
            }

            return(info.GetPage(uiID.ToInt32(null)));
        }
Ejemplo n.º 7
0
 private PanelInfo GetPanelFromActive(int uiID)
 {
     for (int i = m_ActivePanelInfoList.Count - 1; i >= 0; --i)
     {
         if (m_ActivePanelInfoList[i].uiID == uiID)
         {
             PanelInfo panel = m_ActivePanelInfoList[i];
             return(panel);
         }
     }
     return(null);
 }
Ejemplo n.º 8
0
        public void OpenDependPanel <T>(int panelID, T uiID, Action <AbstractPanel> callBack, params object[] args)
            where T : IConvertible
        {
            PanelInfo panelInfo = FindPanelInfoByPanelID(panelID);

            if (panelInfo == null)
            {
                Log.e("OpenDependPanel Not Find PanelID:" + panelID);
                return;
            }
            OpenDependPanel(uiID.ToInt32(null), panelInfo, callBack, args);
        }
Ejemplo n.º 9
0
        private PanelInfo FindPanelInfoByPanelID(int panelID)
        {
            PanelInfo panelInfo = null;

            if (!m_ActivePanelInfoMap.TryGetValue(panelID, out panelInfo))
            {
                //Log.w("Not Find Panel:" + panelID);
                return(null);
            }

            return(panelInfo);
        }
Ejemplo n.º 10
0
        private void ClosePanelInfo(PanelInfo panelInfo)
        {
            if (panelInfo == null)
            {
                return;
            }

            //删除对自己的引用
            panelInfo.RemoveMaster(panelInfo.panelID);

            if (panelInfo.nextMaster > 0)
            {
                //重新调整层级就行
            }
            else             //该面板已经没有任何依赖
            {
                UIData data = UIDataTable.Get(panelInfo.uiID);

                bool destroy = true;
                if (data != null && data.cacheCount > 0)
                {
                    if (GetActiveAndCachedUICount(panelInfo.uiID) <= data.cacheCount)
                    {
                        destroy = false;
                    }
                }

                RemovePanelInfo(panelInfo);

                //恢复层级记录
                m_UIRoot.ReleasePanelSortingOrder(panelInfo.sortIndex);

                //处理是否真正销毁面板逻辑
                if (destroy)
                {
                    panelInfo.ClosePanel(destroy);
                }
                else
                {
                    m_CachedPanelList.Add(panelInfo);
                    panelInfo.ClosePanel(destroy);
                }

                //该面板的删除将影响它的依赖面板
                CheckNeedClosePanel(panelInfo.panelID);

                if (destroy)
                {
                    ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);
                }
            }
        }
Ejemplo n.º 11
0
        private AbstractPage ProcessAttachPage(int panelID, int uiID, GameObject go)
        {
            if (go == null)
            {
                return(null);
            }

            PanelInfo panelInfo = FindPanelInfoByPanelID(panelID);

            if (panelInfo == null || panelInfo.abstractPanel == null)
            {
                Log.e("AttachPage Failed To Find Panel:" + panelID);
                return(null);
            }

            panelInfo.SetSortingOrderDirty();

            AbstractPage page = go.GetComponent <AbstractPage>();

            if (page == null)
            {
                Log.e("Failed To Find Page In UI:" + uiID);
                go.SetActive(true);
                SetPanelSortingOrderDirty();
                return(null);
            }

            UIData panelData = UIDataTable.Get(uiID);

            if (panelData.panelClassType != null)
            {
                if (page.GetType() != panelData.panelClassType)
                {
                    Log.e("ERROR: Prefab Bind C# Class Is Not Same With Define:" + panelData.name);
                }
            }

            page.parentPage = panelInfo.abstractPanel;

            page.uiID = uiID;

            go.SetActive(true);

            page.OpenPage();

            SetPanelSortingOrderDirty();

            return(page);
        }
Ejemplo n.º 12
0
        public void SetPanelVisible(AbstractPanel panel, bool visible)
        {
            if (panel == null)
            {
                return;
            }

            PanelInfo panelInfo = FindPanelInfoByPanelID(panel.panelID);

            if (panelInfo == null)
            {
                return;
            }

            panelInfo.customVisibleFlag = visible;
        }
Ejemplo n.º 13
0
        private void AddPanelInfo(PanelInfo panelInfo)
        {
            if (panelInfo == null)
            {
                return;
            }

            if (m_ActivePanelInfoMap.ContainsKey(panelInfo.panelID))
            {
                Log.e("Already Add Panel to Mgr.");
                return;
            }

            m_ActivePanelInfoList.Add(panelInfo);
            m_ActivePanelInfoMap.Add(panelInfo.panelID, panelInfo);
        }
Ejemplo n.º 14
0
            private void SelectNextMaster()
            {
                m_CurrentMaster = -1;
                m_NextMaster    = -1;

                if (m_OpenInfoList == null)
                {
                    m_SortIndex = -1;
                    return;
                }

                if (m_OpenInfoList.Count == 0)
                {
                    m_SortIndex = -1;
                    return;
                }

                int maxIndex = -1;

                for (int i = m_OpenInfoList.Count - 1; i >= 0; --i)
                {
                    PanelInfo info = UIMgr.Instance.FindPanelInfoByPanelID(m_OpenInfoList[i].MasterID);
                    if (info == null)
                    {
                        ObjectPool <OpenParam> .Instance.Recycle(m_OpenInfoList[i]);

                        m_OpenInfoList.RemoveAt(i);
                        continue;
                    }

                    if (info.sortIndex > maxIndex)
                    {
                        maxIndex     = info.sortIndex;
                        m_NextMaster = info.panelID;
                    }
                }

                if (m_NextMaster == m_PanelID)
                {
                    m_SortIndex = maxIndex;
                }
                else
                {
                    m_SortIndex = maxIndex + 1;
                }
            }
Ejemplo n.º 15
0
        private PanelInfo GetPanelFromCache(int uiID, bool remove)
        {
            for (int i = m_CachedPanelList.Count - 1; i >= 0; --i)
            {
                if (m_CachedPanelList[i].uiID == uiID)
                {
                    PanelInfo panel = m_CachedPanelList[i];
                    if (remove)
                    {
                        m_CachedPanelList.RemoveAt(i);
                    }
                    return(panel);
                }
            }

            return(null);
        }
Ejemplo n.º 16
0
        private void RemovePanelInfo(PanelInfo panelInfo)
        {
            if (panelInfo == null)
            {
                return;
            }

            if (!m_ActivePanelInfoMap.ContainsKey(panelInfo.panelID))
            {
                Log.w("Already Remove Panel:" + panelInfo.uiID);
                return;
            }

            m_ActivePanelInfoMap.Remove(panelInfo.panelID);
            m_ActivePanelInfoList.Remove(panelInfo);
            m_IsPanelInfoListChange = true;
        }
Ejemplo n.º 17
0
        private void LoadPageAsync(int panelID, int uiID, Transform parent, Action <AbstractPage> listener, bool singleton)
        {
            if (parent == null)
            {
                Log.e("Failed to Open Page, parent is Null.");
                return;
            }

            PanelInfo panelInfo = FindPanelInfoByPanelID(panelID);

            if (panelInfo == null)
            {
                Log.e("Not Find Panel To Attach Page:" + panelID);
                return;
            }

            panelInfo.LoadPageResAsync(uiID, parent, singleton, listener);
        }
Ejemplo n.º 18
0
        public void DestroyAllPanel(PanelCloseFilter filter = null)
        {
            for (int i = m_ActivePanelInfoList.Count - 1; i >= 0; --i)
            {
                if (i >= m_ActivePanelInfoList.Count)
                {
                    continue;
                }

                PanelInfo panelInfo = m_ActivePanelInfoList[i];

                if (filter != null)
                {
                    if (!filter(panelInfo.panelID))
                    {
                        continue;
                    }
                }

                RemovePanelInfo(panelInfo);

                m_UIRoot.ReleasePanelSortingOrder(panelInfo.sortIndex);

                panelInfo.ClosePanel(true);

                ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);
            }

            for (int i = m_CachedPanelList.Count - 1; i >= 0; --i)
            {
                if (i >= m_CachedPanelList.Count)
                {
                    continue;
                }

                PanelInfo panelInfo = m_CachedPanelList[i];

                m_CachedPanelList.RemoveAt(i);

                GameObject.Destroy(panelInfo.abstractPanel.gameObject);

                ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);
            }
        }
Ejemplo n.º 19
0
        public IPanel CreateUI(PanelSearchKeys panelSearchKeys)
        {
            var panel = UIKit.Config.LoadPanel(panelSearchKeys);

            UIKit.Root.SetLevelOfPanel(panelSearchKeys.Level, panel);

            UIKit.Config.SetDefaultSizeOfPanel(panel);

            panel.Transform.gameObject.name = panelSearchKeys.GameObjName ?? panelSearchKeys.PanelType.Name;

            panel.Info = PanelInfo.Allocate(panelSearchKeys.GameObjName, panelSearchKeys.Level, panelSearchKeys.UIData,
                                            panelSearchKeys.PanelType, panelSearchKeys.AssetBundleName);

            UIKit.Table.Add(panel);

            panel.Init(panelSearchKeys.UIData);

            return(panel);
        }
Ejemplo n.º 20
0
        //编辑器面板强行删除面板
        public void OnPanelForceDestroy(AbstractPanel panel)
        {
            if (panel == null)
            {
                return;
            }

            PanelInfo panelInfo = FindPanelInfoByPanelID(panel.panelID);

            if (panelInfo == null)
            {
                return;
            }

            RemovePanelInfo(panelInfo);
            CheckNeedClosePanel(panelInfo.panelID);
            ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);

            ReSortPanel();
        }
Ejemplo n.º 21
0
        private PanelInfo LoadPanelInfo(int uiID)
        {
            UIData data = UIDataTable.Get(uiID);

            if (data == null)
            {
                Log.e("Failed to OpenPanel, Not Find UIData for UIID:" + uiID);
                return(null);
            }

            bool      needAdd   = true;
            PanelInfo panelInfo = GetPanelFromCache(uiID, true);

            if (panelInfo == null)
            {
                //缓存中没有,判断当前Panel 是否只支持单例
                if (data.isSingleton)
                {
                    //去当前所有已经开启的面板中寻找
                    panelInfo = GetPanelFromActive(uiID);
                }

                if (panelInfo == null)
                {
                    panelInfo = ObjectPool <PanelInfo> .Instance.Allocate();

                    panelInfo.Set(uiID, nextPanelID);
                }
                else
                {
                    needAdd = false;
                }
            }

            if (needAdd)
            {
                AddPanelInfo(panelInfo);
            }

            return(panelInfo);
        }
Ejemplo n.º 22
0
        public void UnShortCachePanel <T>(T uiID, bool clean = true) where T : IConvertible
        {
            UIData data = UIDataTable.Get(uiID.ToInt32(null));

            if (data == null)
            {
                return;
            }

            data.shortCacheCount = 0;

            if (data.cacheCount > 0)
            {
                return;
            }

            if (!clean)
            {
                return;
            }

            for (int i = m_CachedPanelList.Count - 1; i >= 0; --i)
            {
                if (i >= m_CachedPanelList.Count)
                {
                    continue;
                }

                PanelInfo panelInfo = m_CachedPanelList[i];

                UIData data2 = UIDataTable.Get(panelInfo.uiID);
                if (data2.cacheCount < 1)
                {
                    m_CachedPanelList.RemoveAt(i);

                    GameObject.Destroy(panelInfo.abstractPanel.gameObject);

                    ObjectPool <PanelInfo> .Instance.Recycle(panelInfo);
                }
            }
        }
Ejemplo n.º 23
0
        private void OpenPanel(int uiID, PanelType panelType, Action <AbstractPanel> listener, params object[] args)
        {
            PanelInfo panelInfo = LoadPanelInfo(uiID);

            if (panelInfo == null)
            {
                return;
            }

            panelInfo.sortIndex = m_UIRoot.RequireNextPanelSortingOrder(panelType);
            panelInfo.AddMaster(panelInfo.panelID, args);

            if (panelInfo.isReady)
            {
                ReSortPanel();
                panelInfo.AddOpenCallback(listener);
            }
            else
            {
                panelInfo.AddOpenCallback(listener);
                panelInfo.LoadPanelResAsync();
            }
        }
Ejemplo n.º 24
0
        public void OpenPanel <T>(T uiID, PanelType panelType, Action <AbstractPanel> listener, params object[] args)
            where T : IConvertible
        {
            PanelInfo panelInfo = LoadPanelInfo(uiID.ToInt32(null));

            if (panelInfo == null)
            {
                return;
            }

            panelInfo.sortIndex = m_UIRoot.RequireNextPanelSortingOrder(panelType);
            panelInfo.AddMaster(panelInfo.panelID, args);

            if (panelInfo.isReady)
            {
                ReSortPanel();
                panelInfo.AddOpenCallback(listener);
            }
            else
            {
                panelInfo.AddOpenCallback(listener);
                panelInfo.LoadPanelResAsync();
            }
        }
Ejemplo n.º 25
0
        private void CheckNeedClosePanel(int panelID)
        {
            //该面板的删除将影响它的依赖面板
            RemoveMaster(panelID);

            List <int> needClosePanel = new List <int>();

            for (int i = m_ActivePanelInfoList.Count - 1; i >= 0; --i)
            {
                if (m_ActivePanelInfoList[i].nextMaster <= 0)
                {
                    needClosePanel.Add(m_ActivePanelInfoList[i].panelID);
                }
            }

            for (int i = needClosePanel.Count - 1; i >= 0; --i)
            {
                PanelInfo info = FindPanelInfoByPanelID(needClosePanel[i]);
                if (info != null)
                {
                    ClosePanelInfo(info);
                }
            }
        }
Ejemplo n.º 26
0
 private int PanelCompare(PanelInfo a, PanelInfo b)
 {
     return(a.sortIndex - b.sortIndex);
 }