public override void ShowWindow(WindowID id, ShowWindowData data) { if (!IsWindowInControl(id)) { Debug.Log("UIRankManager has no control power of " + id.ToString()); return; } if (shownWindows.ContainsKey(id)) return; if (allWindows.ContainsKey(id)) { UIBaseWindow baseWindow = allWindows[id]; if (baseWindow.windowData.showMode == UIWindowShowMode.NeedBack) { BackWindowSequenceData backData = new BackWindowSequenceData(); backData.hideTargetWindow = baseWindow; backSequence.Push(backData); } allWindows[id].ShowWindow(); shownWindows[id] = allWindows[id]; this.lastShownNormalWindow = this.curShownNormalWindow; curShownNormalWindow = baseWindow; } }
public override void ShowWindow(WindowID id, ShowWindowData data) { if (!IsWindowInControl(id)) { Debug.Log("UIRankManager has no control power of " + id.ToString()); return; } if (shownWindows.ContainsKey(id)) { return; } if (allWindows.ContainsKey(id)) { UIBaseWindow baseWindow = allWindows[id]; if (baseWindow.windowData.showMode == UIWindowShowMode.NeedBack) { BackWindowSequenceData backData = new BackWindowSequenceData(); backData.hideTargetWindow = baseWindow; backSequence.Push(backData); } allWindows[id].ShowWindow(); shownWindows[id] = allWindows[id]; this.lastShownNormalWindow = this.curShownNormalWindow; curShownNormalWindow = baseWindow; } }
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) { Debuger.Log("[**Need to clear all back window sequence data**]."); Debuger.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!"); } } } }
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); }
// 界面导航返回 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); }