private void RefreshBackSequenceData(UIWindowBase targetWindow, ShowWindowData showData) { WindowCoreData coreData = targetWindow.windowData; bool dealBackSequence = true; if (dicShownWindows.Count > 0 && dealBackSequence) { List <WindowID> removedKey = null; List <UIWindowBase> sortedHiddenWindows = new List <UIWindowBase>(); NavigationData backData = new NavigationData(); foreach (KeyValuePair <int, UIWindowBase> window in dicShownWindows) { if (coreData.showMode != UIWindowShowMode.DoNothing) { if (window.Value.windowData.windowType == UIWindowType.Fixed) { continue; } if (removedKey == null) { removedKey = new List <WindowID>(); } removedKey.Add((WindowID)window.Key); window.Value.HideWindowDirectly(); } if (window.Value.windowData.windowType != UIWindowType.Fixed) { sortedHiddenWindows.Add(window.Value); } } if (removedKey != null) { for (int i = 0; i < removedKey.Count; i++) { dicShownWindows.Remove((int)removedKey[i]); } } // Push new navigation data if (coreData.navigationMode == UIWindowNavigationMode.NormalNavigation && (showData == null || (!showData.ignoreAddNavData))) { // Add to return show target list sortedHiddenWindows.Sort(this.compareWindowFun); List <WindowID> navHiddenWindows = new List <WindowID>(); for (int i = 0; i < sortedHiddenWindows.Count; i++) { WindowID pushWindowId = sortedHiddenWindows[i].ID; navHiddenWindows.Add(pushWindowId); } backData.hideTargetWindow = targetWindow; backData.backShowTargets = navHiddenWindows; backSequence.Push(backData); Debuger.Log("<color=cyan>### !!!Push new Navigation data!!! ###</color>"); } } }
public void CloseWindow(WindowID wndId) { if (!IsWindowInControl(wndId)) { Debuger.LogError("## Current UI Manager has no control power of " + wndId.ToString()); return; } if (!dicShownWindows.ContainsKey((int)wndId)) { return; } UIWindowBase window = dicShownWindows[(int)wndId]; if (this.backSequence.Count > 0) { NavigationData seqData = this.backSequence.Peek(); if (seqData != null && seqData.hideTargetWindow == window) { PopNavigationWindow(); Debuger.Log("<color=magenta>## close window use PopNavigationWindow() ##</color>"); return; } } HideWindow(wndId); Debuger.Log("<color=magenta>## close window without PopNavigationWindow() ##</color>"); }
protected override int GetCurrentShownWindow() { if (backSequence.Count > 0) { NavigationData data = backSequence.Peek(); return((int)data.hideTargetWindow.ID); } return((int)WindowID.WindowID_Invaild); }
// 如果当前存在BackSequence数据 // 1.栈顶界面不是当前要显示的界面需要清空BackSequence(导航被重置) // 2.栈顶界面是当前显示界面,如果类型为(NeedBack)则需要显示所有backShowTargets界面 // 栈顶不是即将显示界面(导航序列被打断) // 如果当前导航队列顶部元素和当前显示的界面一致,表示和当前的导航数衔接上,后续导航直接使用导航数据 // 不一致则表示,导航已经失效,下次点击返回按钮,我们直接根据window的preWindowId确定跳转到哪一个界面 // 如果测试:进入到demo的 关卡详情,点击失败按钮,然后你可以选择从游戏中跳转到哪一个界面,查看导航输出信息 // 可以知道是否破坏了导航数据 // if the navigation stack top window not equals to current show window just clear the navigation stack // check whether the navigation is broken // Example:(we from mainmenu to uilevelwindow to uileveldetailwindow) // UILevelDetailWindow <- UILevelWindow <- UIMainMenu (current navigation stack top element is UILevelDetailWindow) // click the GotoGame in UILevelDetailWindow to enter the real Game // 1. Exit game we want to enter UILevelDetailWindow(OK, the same as navigation stack top UILevelDetailWindow) so we not break the navigation // when we enter the UILevelDetailWindow our system will follow the navigation system // 2. Exit game we want to enter UISkillWindow(OK, not the same as navigation stack top UILevelDetailWindow)so we break the navigation // reset the navigation data // when we click return Button in the UISkillWindow we will find UISkillWindow's preWindowId to navigation because our navigation data is empty // we should use preWindowId for navigating to next window // HOW to Test // when you in the MatchResultWindow , you need click the lose button choose to different window and check the ConsoleLog find something useful private void CheckBackSequenceData(UIWindowBase baseWindow) { if (baseWindow.RefreshBackSeqData) { if (backSequence.Count > 0) { NavigationData backData = backSequence.Peek(); if (backData.hideTargetWindow != null) { if (backData.hideTargetWindow.ID != baseWindow.ID) { Debuger.Log("<color=cyan>## UICenterMasterManager : clear sequence data ##</color>"); Debuger.Log("## UICenterMasterManager : Hide target window and show window id is " + backData.hideTargetWindow.ID + " != " + baseWindow.ID); ClearBackSequence(); } } else { Debuger.LogError("Back data hide target window is null!"); } } } }
protected bool RealPopNavigationWindow() { if (backSequence.Count == 0) { if (curNavigationWindow == null) { return(false); } if (PopUpWindowManager(curNavigationWindow)) { return(true); } // if curNavigationWindow BackSequenceData is null // Check window's preWindowId // if preWindowId defined just move to target Window(preWindowId) WindowID preWindowId = curNavigationWindow.PreWindowID; if (preWindowId != WindowID.WindowID_Invaild) { Debuger.LogWarning(string.Format(string.Format("## Current nav window {0} need show pre window {1}.", curNavigationWindow.ID.ToString(), preWindowId.ToString()))); HideWindow(curNavigationWindow.ID, delegate { ShowWindowData showData = new ShowWindowData(); showData.executeNavLogic = false; ShowWindow(preWindowId, showData); }); } else { Debuger.LogWarning("## CurrentShownWindow " + curNavigationWindow.ID + " preWindowId is " + WindowID.WindowID_Invaild); } return(false); } NavigationData backData = backSequence.Peek(); if (backData != null) { // check the current navigation data int curId = this.GetCurrentShownWindow(); if (curId != (int)backData.hideTargetWindow.ID) { Debuger.Log("<color=red>Can't PopUp seq data [backData.hideTargetWindow.ID != this.curShownWindowId]</color>"); return(false); } if (PopUpWindowManager(backData.hideTargetWindow)) { return(true); } WindowID hideId = backData.hideTargetWindow.ID; if (!dicShownWindows.ContainsKey((int)hideId)) { ExectuteBackSeqData(backData); } else { HideWindow(hideId, delegate { ExectuteBackSeqData(backData); }); } } return(true); }