Ejemplo n.º 1
0
        /// <summary>
        /// 当前面板是否可以缓存pid
        /// </summary>
        /// <param name="pType"></param>
        /// <returns></returns>
        public bool CanCachePanel(PanelID pid)
        {
            PanelCacheLv cacheLv = CacheLv;

            if (cacheLv == PanelCacheLv.None || IsStartPanel)
            {
                return(false);
            }


            bool           canCache = false;
            LocalPanelInfo localP2  = null;

            if (DataManager.Manager <UIPanelManager>().TryGetLocalPanelInfo(pid, out localP2) && !localP2.IgnoreCache)
            {
                if (cacheLv == PanelCacheLv.All)
                {
                    canCache = true;
                }
                else
                {
                    PanelRootType r1 = UIRootHelper.Instance.GetRootTypePanelType(PType);
                    PanelRootType r2 = UIRootHelper.Instance.GetRootTypePanelType(localP2.PType);
                    canCache = (r1 >= r2);
                    if (!canCache && CacheLv == PanelCacheLv.Dialog &&
                        r2 == PanelRootType.PopUp)
                    {
                        canCache = true;
                    }
                }
            }
            return(canCache);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// 获取目标面板类型的最大深度
    /// </summary>
    /// <param name="rootType"></param>
    /// <param name="includeHide"></param>
    /// <returns></returns>
    public int GetTargetRootMaxDepth(PanelRootType rootType, bool includeHide)
    {
        int       max              = 0;
        Transform targetRoot       = UIRootHelper.Instance.GetPanelRoot(rootType);
        int       targetStartDepth = UIRootHelper.Instance.GetPanelDepthByType(rootType);

        if (targetRoot != null)
        {
            UIPanel[] panels = targetRoot.GetComponentsInChildren <UIPanel>(includeHide);
            if (panels.Length > 0)
            {
                List <UIPanel> lsPanels = new List <UIPanel>(panels);
                //排序
                lsPanels.Sort(delegate(UIPanel left, UIPanel right)
                {
                    return(left.depth - right.depth);
                });
                max = lsPanels[lsPanels.Count - 1].depth;
            }
        }

        return((max == 0) ? targetStartDepth : max);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 根据当前显示面板重新检测当前获取焦点面板
    /// </summary>
    /// <param name="panelID">当前显示面板</param>
    private void CheckFocusDatas(PanelID panelID)
    {
        LocalPanelInfo panelInfo = null;

        if (!TryGetLocalPanelInfo(panelID, out panelInfo) || !panelInfo.IsNeedCalculateFocus)
        {
            return;
        }
        PanelRootType rootType = UIRootHelper.Instance.GetRootTypePanelType(panelInfo.PType);

        oldFocusTempData.Clear();
        curFocusTempData.Clear();
        oldFocusTempData.AddRange(GetFocusPanels());
        RemoveAllFocusPanel();

        PanelRootType tempRootType     = PanelRootType.None;
        PanelRootType maxFocusRootType = PanelRootType.None;

        LocalPanelInfo tempPanelInfo = null;

        List <uint> showPanelsKeys = new List <uint>();

        showPanelsKeys.AddRange(showPanels);
        PanelID     showNormal        = PanelID.None;
        int         maxRootPanelDepth = 0;
        UIPanelBase tempPanelBase     = null;
        PanelID     pid = PanelID.None;

        for (int i = 0; i < showPanelsKeys.Count; i++)
        {
            pid = (PanelID)showPanelsKeys[i];
            if (!TryGetLocalPanelInfo(pid, out tempPanelInfo) || !tempPanelInfo.IsNeedCalculateFocus)
            {
                continue;
            }
            if (tempPanelInfo.PType == PanelType.Normal)
            {
                showNormal = tempPanelInfo.PID;
            }
            tempRootType = UIRootHelper.Instance.GetRootTypePanelType(tempPanelInfo.PType);
            if ((tempRootType == PanelRootType.None || maxFocusRootType < tempRootType) && tempRootType != PanelRootType.MarQueen
                //&& tempPanelInfo.PType != PanelType.SmartPopUp
                )
            {
                maxFocusRootType = tempRootType;
            }
            tempPanelBase = GetPanel(pid);
            if (tempRootType == maxFocusRootType && tempPanelBase.Depth > maxRootPanelDepth)
            {
                maxRootPanelDepth = tempPanelBase.Depth;
            }
        }

        for (int i = 0; i < showPanelsKeys.Count; i++)
        {
            pid = (PanelID)showPanelsKeys[i];
            if (!TryGetLocalPanelInfo(pid, out tempPanelInfo) || !tempPanelInfo.IsNeedCalculateFocus)
            {
                continue;
            }
            tempRootType  = UIRootHelper.Instance.GetRootTypePanelType(tempPanelInfo.PType);
            tempPanelBase = GetPanel(pid);
            if (tempRootType < maxFocusRootType)
            {
                if (maxFocusRootType == PanelRootType.Fixed)
                {
                    if (showNormal != PanelID.None)
                    {
                        if (tempPanelBase.PanelId == showNormal)
                        {
                            AddFocusPanel(pid);
                        }
                    }
                    else
                    {
                        AddFocusPanel(pid);
                    }
                }
            }
            else if (tempRootType == maxFocusRootType)
            {
                if (maxFocusRootType == PanelRootType.Main || tempPanelBase.Depth >= maxRootPanelDepth)
                {
                    AddFocusPanel(pid);
                }
            }
            else if (tempRootType > maxFocusRootType)
            {
                AddFocusPanel(pid);
            }
        }

        //3、对比焦点变化的面板
        curFocusTempData.AddRange(GetFocusPanels());

        PanelFocusData focusData = new PanelFocusData();

        focusData.GetFocus = false;
        for (int i = 0; i < oldFocusTempData.Count; i++)
        {
            if (curFocusTempData.Contains(oldFocusTempData[i]))
            {
                curFocusTempData.Remove(oldFocusTempData[i]);
            }
            else
            {
                focusData.ID = oldFocusTempData[i];
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.UIEVENT_PANELFOCUSSTATUSCHANGED, focusData);
            }
        }

        focusData.GetFocus = true;
        for (int i = 0; i < curFocusTempData.Count; i++)
        {
            focusData.ID = curFocusTempData[i];
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.UIEVENT_PANELFOCUSSTATUSCHANGED, focusData);
        }
    }