Пример #1
0
    /// <summary>
    /// 更新导航信息
    /// </summary>
    /// <param name="panelBase"></param>
    private void UpdateNavigationInfo(PanelID pid, bool ignoreCache)
    {
        LocalPanelInfo localPanelInfo = null;

        if (TryGetLocalPanelInfo(pid, out localPanelInfo))
        {
            if (localPanelInfo.IsStartPanel)
            {
                ClearCacheStack();
            }

            if ((localPanelInfo.HidePanelMask == 0 &&
                 localPanelInfo.CacheLv == PanelCacheLv.None))
            {
                return;
            }

            HideCondition condition = (info) =>
            {
                if (info != null && (localPanelInfo.IsMatchHideType(info.PType) ||
                                     localPanelInfo.CanCachePanel(info.PID)))
                {
                    return(true);
                }
                return(false);
            };


            List <UIPanelBase.PanelData> cachePanels = new List <UIPanelBase.PanelData>();
            if (showPanels.Count > 0 && condition != null)
            {
                List <PanelID> lstHide = new List <PanelID>();

                UIPanelBase.PanelData       panelBackspaceData = null;
                UIPanelBase.PanelReturnData lastReturnData     = (null != panelCacheStack && panelCacheStack.Count != 0) ? panelCacheStack.Peek() : null;
                bool           canCache  = (null == lastReturnData || lastReturnData.PID != pid);
                PanelID        tempPID   = PanelID.None;
                UIPanelBase    tempPBase = null;
                LocalPanelInfo tempInfo  = null;

                for (int i = 0, max = showPanels.Count; i < max; i++)
                {
                    tempPID   = (PanelID)showPanels[i];
                    tempPBase = GetPanel(tempPID);
                    if (null == tempPBase)
                    {
                        continue;
                    }
                    if (TryGetLocalPanelInfo(tempPID, out tempInfo) && condition(tempInfo))
                    {
                        lstHide.Add(tempPID);
                        if (!ignoreCache && canCache && localPanelInfo.CanCachePanel(tempPID))
                        {
                            panelBackspaceData = tempPBase.GetPanelData();
                            if (null == panelBackspaceData.JumpData)
                            {
                                panelBackspaceData.JumpData = new UIPanelBase.PanelJumpData();
                            }
                            panelBackspaceData.JumpData.IsBackspacing = true;
                            cachePanels.Add(panelBackspaceData);
                        }
                    }
                }

                if (cachePanels.Count > 0)
                {
                    cachePanels.Sort((left, right) =>
                    {
                        UIPanelBase pleft  = GetPanel(left.PID);
                        UIPanelBase pright = GetPanel(right.PID);
                        return(pleft.Depth - pright.Depth);
                    });

                    panelCacheStack.Push(new UIPanelBase.PanelReturnData()
                    {
                        PID            = pid,
                        CachePanelList = cachePanels,
                    });
                }

                for (int i = 0; i < lstHide.Count; i++)
                {
                    HidePanel(lstHide[i], false);
                }
            }
        }
    }