/// <summary> /// 获得自动存储序列 /// </summary> /// <param name="_closeWinIds">关闭的窗口组</param> /// <returns>存储序列</returns> public List <int> GetAutoRestoreSequence(List <int> _closeWinIds) { List <int> winIds = new List <int>(); Stack <WindowSequence> stack = OnGetOpenWindowSequence(); #if DEBUGLOG Debug.LogFormat("【Before】GetAutoRestoreSequence=>Close【{0}】,Stack=>【{1}】", _closeWinIds.JsonSerialize(), stack.JsonSerialize()); #endif if (stack.Count > 0) { WindowSequence ws = stack.Peek(); if (ws.IsSameOpenWindow(_closeWinIds)) { winIds = ws.sequenceCloseWindows; stack.Pop(); } } #if DEBUGLOG Debug.LogFormat("【After】GetAutoRestoreSequence=>Close【{0}】,Stack=>【{1}】", _closeWinIds.JsonSerialize(), stack.JsonSerialize()); #endif return(winIds); }
/// <summary> /// 开启窗口序列 /// </summary> /// <param name="_winCfgs">窗口配置组</param> public void OpenWindowSerialize(XLS_Config_Table_UIWindowSetting[] _winCfgs) { Dictionary <int, int> sameLayerLessThenSiblingIndex = new Dictionary <int, int>(); List <int> lessThenSiblingIndex = new List <int>(); Dictionary <int, UIWindowHolder> winHolders = OnSearchAllWindowHolders(); List <int> openWinIds = new List <int>(); List <int> sequenceCloseWinIds = new List <int>(); if (_winCfgs != null && _winCfgs.Length > 0) { #region 统计需要隐藏的各层级的最大SiblingIndex foreach (XLS_Config_Table_UIWindowSetting cfg in _winCfgs) { if (!openWinIds.Contains(cfg.id)) { openWinIds.Add(cfg.id); } switch (cfg.winOpenMode) { case enUIWindowOpenMode.WhenDisplayHiddenSameLayerAndLessThanSiblingIndex: if (!sameLayerLessThenSiblingIndex.ContainsKey(cfg.layer)) { sameLayerLessThenSiblingIndex.Add(cfg.layer, winHolders[cfg.id].windowSiblingIndex); } else { sameLayerLessThenSiblingIndex[cfg.layer] = Mathf.Max(sameLayerLessThenSiblingIndex[cfg.layer], winHolders[cfg.id].windowSiblingIndex); } break; case enUIWindowOpenMode.WhenDisplayHiddenLessThanSiblingIndex: if (!lessThenSiblingIndex.Contains(winHolders[cfg.id].windowSiblingIndex)) { lessThenSiblingIndex.Add(winHolders[cfg.id].windowSiblingIndex); } else { lessThenSiblingIndex[0] = Mathf.Max(lessThenSiblingIndex[0], winHolders[cfg.id].windowSiblingIndex); } break; } } #endregion } List <int> hiddenWinIds = new List <int>(); if (winHolders != null && winHolders.Count > 0) { #region 收集要隐藏的窗口ID foreach (KeyValuePair <int, UIWindowHolder> holder in winHolders) { if ( sameLayerLessThenSiblingIndex.ContainsKey(holder.Value.winCfg.layer) && holder.Value.windowSiblingIndex < sameLayerLessThenSiblingIndex[holder.Value.winCfg.layer] ) { if (!hiddenWinIds.Contains(holder.Key)) { hiddenWinIds.Add(holder.Key); } if (!sequenceCloseWinIds.Contains(holder.Key) && holder.Value.winCfg.isAutoRestoreSequenceWindow) { sequenceCloseWinIds.Add(holder.Key); } } if ( lessThenSiblingIndex.Count > 0 && holder.Value.windowSiblingIndex < lessThenSiblingIndex[0] ) { if (!hiddenWinIds.Contains(holder.Key)) { hiddenWinIds.Add(holder.Key); } if (!sequenceCloseWinIds.Contains(holder.Key) && holder.Value.winCfg.isAutoRestoreSequenceWindow) { sequenceCloseWinIds.Add(holder.Key); } } } #endregion } foreach (int wid in hiddenWinIds) { winHolders[wid].SetTargetActive(false); } Stack <WindowSequence> winSeq = OnGetOpenWindowSequence(); if (winSeq.Count > 0) { WindowSequence ws = winSeq.Peek(); if (!ws.IsSameOpenWindow(openWinIds)) { winSeq.Push(new WindowSequence(openWinIds, sequenceCloseWinIds)); } } else if (openWinIds.Count > 0) { winSeq.Push(new WindowSequence(openWinIds, sequenceCloseWinIds)); } #if DEBUGLOG Debug.LogFormat("sameLayerLessThenSiblingIndex【{0}】,lessThenSiblingIndex【{1}】,hiddenWinIds【{2}】", sameLayerLessThenSiblingIndex.JsonSerialize(), lessThenSiblingIndex.JsonSerialize(), hiddenWinIds.JsonSerialize()); Debug.LogFormat("open windows=>【{0}】,sequence close windows=>【{1}】", openWinIds.JsonSerialize(), sequenceCloseWinIds.JsonSerialize()); #endif }