private void CheckBackSequenceData(UIWindowBase baseWindow) { if (baseWindow.IsNavigationWindow) { if (backSequence.Count > 0) { BackWindowSequenceData backData = backSequence.Peek(); if (backData.hideTargetWindow != null) { if (backData.hideTargetWindow.WindowID != baseWindow.WindowID) { Debug.Log("<color=cyan>## UICenterMasterManager : clear sequence data ##</color>"); Debug.Log("## UICenterMasterManager : Hide target window and show window id is " + backData.hideTargetWindow.WindowID + " != " + baseWindow.WindowID); ClearBackSequence(); } } else { Debug.LogError("Back data hide target window is null!"); } } } }
private void CheckBackSequenceData(UIBaseWindow baseWindow) { // 如果当前存在BackSequence数据 // 1.栈顶界面不是当前要显示的界面需要清空BackSequence(导航被重置) // 2.栈顶界面是当前显示界面,如果类型为(NeedBack)则需要显示所有backShowTargets界面 WindowData windowData = baseWindow.windowData; if (baseWindow.RefreshBackSeqData) { if (backSequence.Count > 0) { BackWindowSequenceData backData = backSequence.Peek(); if (backData.hideTargetWindow != null) { // 栈顶不是即将显示界面(导航序列被打断) if (backData.hideTargetWindow.GetID != baseWindow.GetID) { Debug.Log("[**Need to clear all back window sequence data**]."); Debug.Log("[hide target window and show window id is " + backData.hideTargetWindow.GetID + " != " + baseWindow.GetID); backSequence.Clear(); } else { // NeedBack类型要将backShowTargets界面显示 if (windowData.showMode == UIWindowShowMode.NeedBack && backData.backShowTargets != null) { for (int i = 0; i < backData.backShowTargets.Count; i++) { WindowID backId = backData.backShowTargets[i]; // 保证最上面为currentShownWindow if (i == backData.backShowTargets.Count - 1) { Debug.Log("change currentShownNormalWindow : " + backId); // 改变当前活跃Normal窗口 this.lastShownNormalWindow = this.curShownNormalWindow; this.curShownNormalWindow = GetGameWindow(backId); } ShowWindowForBack(backId); } } } } else { Debug.LogError("Back data hide target window is null!"); } } } }
private void HideOtherWindow(UIWindowBase targetWindow) { UIWindowData windowData = targetWindow.windowData; List <UIWindowBase> sortedHiddenWindows = new List <UIWindowBase>(); removedKey.Clear(); var enumerator = showWindows.GetEnumerator(); while (enumerator.MoveNext()) { UIWindowBase window = enumerator.Current.Value; int windowId = enumerator.Current.Key; removedKey.Add(windowId); window.HideWindowDirectly(); sortedHiddenWindows.Add(window); } // 从显示窗口集合移除 for (int i = 0; i < removedKey.Count; i++) { showWindows.Remove(removedKey[i]); } // 根据窗口depath排序 sortedHiddenWindows.Sort(compareWindowFun); List <int> navHiddenWindows = new List <int>(); for (int i = 0; i < sortedHiddenWindows.Count; i++) { int pushWindowId = sortedHiddenWindows[i].WindowID; navHiddenWindows.Add(pushWindowId); } BackWindowSequenceData backData = new BackWindowSequenceData(); backData.hideTargetWindow = targetWindow; backData.backShowTargets = navHiddenWindows; backSequence.Push(backData); Debug.Log("<color=cyan>### !!!Push new Navigation data!!! ###</color>"); }
public void CloseWindow(int windowId) { if (!IsRegisterWindow(windowId)) { Debug.LogError("## Current UI Manager has no control power of " + windowId.ToString()); return; } UIWindowBase window = null; if (!showWindows.TryGetValue(windowId, out window)) { return; } if (this.backSequence.Count > 0) { BackWindowSequenceData seqData = this.backSequence.Peek(); if (seqData != null && seqData.hideTargetWindow == window) { ReturnWindow(); Debug.Log("<color=magenta>## close window use PopNavigationWindow() ##</color>"); return; } } HideWindow(windowId, delegate { ShowWindowData showData = new ShowWindowData(); showData.executeNavLogic = false; int preWindowId = window.PreWindowID; if (preWindowId == UIWindowID.WINDOWID_INVAILD) { Debug.LogWarning("## CurrentShownWindow " + window.WindowID + " preWindowId is " + UIWindowID.WINDOWID_INVAILD); return; } ShowWindow(preWindowId, null); }); Debug.Log("<color=magenta>## close window without PopNavigationWindow() ##</color>"); }
// 界面导航返回 protected bool RealReturnWindow() { if (backSequence.Count == 0) { // 如果当前BackSequenceData 不存在返回数据 // 检测当前Window的preWindowId是否指向上一级合法菜单 if (curShownNormalWindow == null) { return(false); } if (ReturnWindowManager(curShownNormalWindow)) { return(true); } WindowID preWindowId = curShownNormalWindow.GetPreWindowID; if (preWindowId != WindowID.WindowID_Invaild) { HideWindow(curShownNormalWindow.GetID, delegate { ShowWindow(preWindowId, null); }); } else { Debug.LogWarning("currentShownWindow " + curShownNormalWindow.GetID + " preWindowId is " + WindowID.WindowID_Invaild); } return(false); } BackWindowSequenceData backData = backSequence.Peek(); if (backData != null) { // 退出当前界面子界面 if (ReturnWindowManager(backData.hideTargetWindow)) { return(true); } WindowID hideId = backData.hideTargetWindow.GetID; if (backData.hideTargetWindow != null && shownWindows.ContainsKey(hideId)) { HideWindow(hideId, delegate { if (backData.backShowTargets != null) { for (int i = 0; i < backData.backShowTargets.Count; i++) { WindowID backId = backData.backShowTargets[i]; ShowWindowForBack(backId); if (i == backData.backShowTargets.Count - 1) { Debug.Log("change currentShownNormalWindow : " + backId); { // 改变当前活跃Normal窗口 this.lastShownNormalWindow = this.curShownNormalWindow; this.curShownNormalWindow = GetGameWindow(backId); } } } } // 隐藏当前界面 backSequence.Pop(); }); } else { return(false); } } return(true); }
public void RefreshBackSequenceData(UIBaseWindow baseWindow) { WindowData windowData = baseWindow.windowData; if (baseWindow.RefreshBackSeqData) { bool dealBackSequence = true; if (curShownNormalWindow != null) { if (curShownNormalWindow.windowData.showMode == UIWindowShowMode.NoNeedBack) { dealBackSequence = false; HideWindow(curShownNormalWindow.GetID, null); } Debug.Log("* current shown Normal Window is " + curShownNormalWindow.GetID); } if (shownWindows.Count > 0 && dealBackSequence) { List <WindowID> removedKey = null; List <WindowID> newPushList = new List <WindowID>(); List <UIBaseWindow> sortByMinDepth = new List <UIBaseWindow>(); BackWindowSequenceData backData = new BackWindowSequenceData(); foreach (KeyValuePair <WindowID, UIBaseWindow> window in shownWindows) { bool needToHide = true; if (windowData.showMode == UIWindowShowMode.NeedBack || window.Value.windowData.windowType == UIWindowType.Fixed) { needToHide = false; } if (needToHide) { if (removedKey == null) { removedKey = new List <WindowID>(); } removedKey.Add(window.Key); // HideOther类型 直接隐藏其他窗口 window.Value.HideWindowDirectly(); } // 将Window添加到BackSequence中 if (window.Value.CanAddedToBackSeq) { sortByMinDepth.Add(window.Value); } } if (removedKey != null) { for (int i = 0; i < removedKey.Count; i++) { shownWindows.Remove(removedKey[i]); } } // push to backToShowWindows stack if (sortByMinDepth.Count > 0) { // 按照层级顺序存入显示List中 sortByMinDepth.Sort(new CompareBaseWindow()); for (int i = 0; i < sortByMinDepth.Count; i++) { WindowID pushWindowId = sortByMinDepth[i].GetID; newPushList.Add(pushWindowId); } backData.hideTargetWindow = baseWindow; backData.backShowTargets = newPushList; backSequence.Push(backData); } } } else if (windowData.showMode == UIWindowShowMode.NoNeedBack) { HideAllShownWindow(true); } CheckBackSequenceData(baseWindow); }
private bool RealReturnWindow() { if (backSequence.Count == 0) { // 如果当前BackSequenceData 不存在返回数据 // 检测当前Window的preWindowId是否指向上一级合法菜单 if (curShownWindow == null) { return(false); } int preWindowId = curShownWindow.PreWindowID; if (preWindowId == UIWindowID.WINDOWID_INVAILD) { Debug.LogWarning("## CurrentShownWindow " + curShownWindow.WindowID + " preWindowId is " + UIWindowID.WINDOWID_INVAILD); return(false); } Debug.LogWarning(string.Format("## Current nav window {0} need show pre window {1}.", curShownWindow.WindowID.ToString(), preWindowId.ToString())); ShowWindowForBack(preWindowId); HideWindow(curShownWindow.WindowID); curShownWindow = GetWindow(preWindowId); return(true); } BackWindowSequenceData backData = backSequence.Peek(); if (backData != null) { int hideId = backData.hideTargetWindow.WindowID; if (backData.hideTargetWindow != null && showWindows.ContainsKey(hideId)) { if (backData.backShowTargets != null) { for (int i = 0; i < backData.backShowTargets.Count; i++) { int backId = backData.backShowTargets[i]; ShowWindowForBack(backId); if (i == backData.backShowTargets.Count - 1) { Debug.Log("change currentShownNormalWindow : " + backId); // 改变当前活跃Normal窗口 this.lastShownWindow = this.curShownWindow; this.curShownWindow = GetWindow(backId); } } } HideWindow(hideId, delegate { // 隐藏当前界面 backSequence.Pop(); }); return(true); } } return(true); }