private void ExecuteNavigationLogic(UIBaseWindow baseWindow, ShowWindowData showData) { WindowCoreData windowData = baseWindow.windowData; if (baseWindow.RefreshBackSeqData) { this.RefreshBackSequenceData(baseWindow, showData); } else if (windowData.showMode == UIWindowShowMode.HideOtherWindow) { HideAllShownWindow(); } // If target window is mark as force clear all the navigation sequence data // Show data need force clear the back seq data if (baseWindow.windowData.forceClearNavigation || (showData != null && showData.forceClearBackSeqData)) { Debuger.Log("<color=cyan>## [Enter the start window, reset the backSequenceData for the navigation system.]##</color>"); ClearBackSequence(); } else { if ((showData != null && showData.checkNavigation)) { CheckBackSequenceData(baseWindow); } } }
/// <summary> /// Calculate right depth with windowType /// </summary> /// <param name="baseWindow"></param> private void AdjustBaseWindowDepth(UIBaseWindow baseWindow) { UIWindowType windowType = baseWindow.windowData.windowType; int needDepth = 1; if (windowType == UIWindowType.Normal) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UINormalWindowRoot.gameObject, false) + 1, normalWindowDepth, int.MaxValue); Debuger.Log(string.Format("<color=cyan>[UIWindowType.Normal] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString())); } else if (windowType == UIWindowType.PopUp) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIPopUpWindowRoot.gameObject) + 1, popUpWindowDepth, int.MaxValue); Debuger.Log(string.Format("<color=cyan>[UIWindowType.PopUp] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString())); } else if (windowType == UIWindowType.Fixed) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIFixedWidowRoot.gameObject) + 1, fixedWindowDepth, int.MaxValue); Debuger.Log(string.Format("<color=cyan>[UIWindowType.Fixed] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString())); } if (baseWindow.MinDepth != needDepth) { GameUtility.SetTargetMinPanelDepth(baseWindow.gameObject, needDepth); } // send window added message to game client if (baseWindow.windowData.windowType == UIWindowType.PopUp) { // trigger the window PopRoot added window event EventDispatcher.GetInstance().UIFrameWorkEventManager.TriggerEvent(EventSystemDefine.EventUIFrameWorkPopRootWindowAdded); } baseWindow.MinDepth = needDepth; }
private void RefreshBackSequenceData(UIBaseWindow targetWindow, ShowWindowData showData) { WindowCoreData coreData = targetWindow.windowData; bool dealBackSequence = true; if (dicShownWindows.Count > 0 && dealBackSequence) { List <WindowID> removedKey = null; List <UIBaseWindow> sortedHiddenWindows = new List <UIBaseWindow>(); BackWindowSequenceData backData = new BackWindowSequenceData(); foreach (KeyValuePair <int, UIBaseWindow> 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; } UIBaseWindow window = dicShownWindows[(int)wndId]; if (this.backSequence.Count > 0) { BackWindowSequenceData 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>"); }
private void AdjustBaseWindowDepth(UIBaseWindow baseWindow) { UIWindowType windowType = baseWindow.windowData.windowType; int needDepth = 1; if (windowType == UIWindowType.Normal) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UINormalWindowRoot.gameObject, false) + 1, normalWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.Normal] maxDepth is " + needDepth + baseWindow.GetID); } else if (windowType == UIWindowType.PopUp) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIPopUpWindowRoot.gameObject) + 1, popUpWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.PopUp] maxDepth is " + needDepth); } else if (windowType == UIWindowType.Fixed) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIFixedWidowRoot.gameObject) + 1, fixedWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.Fixed] max depth is " + needDepth); } if (baseWindow.MinDepth != needDepth) { GameUtility.SetTargetMinPanel(baseWindow.gameObject, needDepth); } baseWindow.MinDepth = needDepth; }
public override void ShowWindow(WindowID id, ShowWindowData showData) { if (!IsWindowInControl(id)) { Debuger.Log("UIRankManager has no control power of " + id.ToString()); return; } if (dicShownWindows.ContainsKey((int)id)) { return; } if (dicAllWindows.ContainsKey((int)id)) { UIBaseWindow baseWindow = dicAllWindows[(int)id]; if (baseWindow.ID != id) { Debuger.LogError(string.Format("[UIRankManager BaseWindowId :{0} != shownWindowId :{1}]", baseWindow.ID, id)); return; } if (baseWindow.windowData.navigationMode == UIWindowNavigationMode.NormalNavigation) { BackWindowSequenceData backData = new BackWindowSequenceData(); backData.hideTargetWindow = baseWindow; backSequence.Push(backData); } this.RealShowWindow(baseWindow, baseWindow.ID, showData); } }
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; } }
protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null) { // 检测控制权限 if (!this.IsWindowInControl(id)) { Debug.Log("UIManager has no control power of " + id.ToString()); return(null); } if (shownWindows.ContainsKey(id)) { return(null); } UIBaseWindow baseWindow = GetGameWindow(id); bool newAdded = false; if (!baseWindow) { newAdded = true; // 窗口不存在从内存进行加载 if (UIResourceDefine.windowPrefabPath.ContainsKey(id)) { string prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[id]; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); NGUITools.SetActive(uiObject, true); baseWindow = uiObject.GetComponent <UIBaseWindow>(); // 需要动态添加对应的控制界面,prefab不用添加脚本 Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType); GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform); allWindows[id] = baseWindow; } } } if (baseWindow == null) { Debug.LogError("[window instance is null.]" + id.ToString()); } // 重置界面(第一次添加,强制Reset) if (newAdded || (showData != null && showData.forceResetWindow)) { baseWindow.ResetWindow(); } // 显示界面固定内容 // 导航系统数据更新 RefreshBackSequenceData(baseWindow); // 调整层级depth AdjustBaseWindowDepth(baseWindow); // 添加背景Collider AddColliderBgForWindow(baseWindow); return(baseWindow); }
public override void ShowWindow(WindowID id, ShowWindowData showData = null) { UIBaseWindow baseWindow = ReadyToShowBaseWindow(id, showData); if (baseWindow != null) { RealShowWindow(baseWindow, id, showData); } }
public virtual T GetGameWindowScript <T>(WindowID id) where T : UIBaseWindow { UIBaseWindow baseWindow = GetGameWindow(id); if (baseWindow != null) { return((T)baseWindow); } return((T)((object)null)); }
/// <summary> /// MessageBox弹出 /// </summary> /// public void ShowMessageBox(string msg) { UIBaseWindow msgWindow = ReadyToShowBaseWindow(WindowID.WindowID_MessageBox); if (msgWindow != null) { ((UIMessageBox)msgWindow).SetMsg(msg); ((UIMessageBox)msgWindow).ResetWindow(); RealShowWindow(msgWindow, WindowID.WindowID_MessageBox); } }
/// <summary> /// 显示界面,方面在现实之前做其他操作 /// </summary> protected virtual void RealShowWindow(UIBaseWindow baseWindow, WindowID id) { baseWindow.ShowWindow(); shownWindows[id] = baseWindow; if (baseWindow.windowData.windowType == UIWindowType.Normal) { // 改变当前显示Normal窗口 lastShownNormalWindow = curShownNormalWindow; curShownNormalWindow = baseWindow; } }
private bool ReturnWindowManager(UIBaseWindow baseWindow) { // 退出当前界面子界面 UIManagerBase baseWindowManager = baseWindow.GetWindowManager; bool isValid = false; if (baseWindowManager != null) { isValid = baseWindowManager.ReturnWindow(); } return(isValid); }
private bool PopUpWindowManager(UIBaseWindow baseWindow) { // Recursion call to return windowManager // if the current window has windowManager just call current's windowManager PopUpWindowManager UIManagerBase baseWindowManager = baseWindow.GetWindowManager; bool isValid = false; if (baseWindowManager != null) { isValid = baseWindowManager.PopNavigationWindow(); } return(isValid); }
// // Depth Helper Functions // // Push target GameObject to top depth // Case: when you open multi PopWindow // You want one of these PopWindow stay at the Top // You can register the EventSystemDefine.EventUIFrameWorkPopRootWindowAdded // Call this method to push window to top public static void AdjustTargetWindowDepthToTop(UIBaseWindow targetWindow) { if (targetWindow == null) { return; } Transform windowRoot = UICenterMasterManager.Instance.GetTargetRoot(targetWindow.windowData.windowType); int needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(windowRoot.gameObject, true) + 1, popUpWindowDepth, int.MaxValue); GameUtility.SetTargetMinPanelDepth(targetWindow.gameObject, needDepth); targetWindow.MinDepth = needDepth; }
public void ShowMessageBox(string msg, string centerStr, UIEventListener.VoidDelegate callBack) { UIBaseWindow msgWindow = ReadyToShowBaseWindow(WindowID.WindowID_MessageBox); if (msgWindow != null) { UIMessageBox messageBoxWindow = ((UIMessageBox)msgWindow); ((UIMessageBox)msgWindow).ResetWindow(); messageBoxWindow.SetMsg(msg); messageBoxWindow.SetCenterBtnCallBack(centerStr, callBack); RealShowWindow(msgWindow, WindowID.WindowID_MessageBox); } }
protected virtual void RealShowWindow(UIBaseWindow baseWindow, WindowID id, ShowWindowData showData = null) { BaseWindowContextData contextData = showData == null ? null : showData.contextData; baseWindow.ShowWindow(contextData); dicShownWindows[(int)id] = baseWindow; if (baseWindow.windowData.navigationMode == UIWindowNavigationMode.NormalNavigation) { lastNavigationWindow = curNavigationWindow; curNavigationWindow = baseWindow; Debuger.Log("<color=magenta>### current Navigation window </color>" + baseWindow.ID.ToString()); } }
/// <summary> /// Destroy all window /// </summary> public virtual void ClearAllWindow() { if (dicAllWindows != null) { foreach (KeyValuePair <int, UIBaseWindow> window in dicAllWindows) { UIBaseWindow baseWindow = window.Value; baseWindow.DestroyWindow(); } dicAllWindows.Clear(); dicShownWindows.Clear(); backSequence.Clear(); } }
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 ShowMessageBox(string msg, string leftStr, UIEventListener.VoidDelegate leftCallBack, string rightStr, UIEventListener.VoidDelegate rightCallBack) { UIBaseWindow msgWindow = ReadyToShowBaseWindow(WindowID.WindowID_MessageBox); if (msgWindow != null) { UIMessageBox messageBoxWindow = ((UIMessageBox)msgWindow); ((UIMessageBox)msgWindow).ResetWindow(); messageBoxWindow.SetMsg(msg); messageBoxWindow.SetRightBtnCallBack(rightStr, rightCallBack); messageBoxWindow.SetLeftBtnCallBack(leftStr, leftCallBack); RealShowWindow(msgWindow, WindowID.WindowID_MessageBox); } }
/// <summary> /// 清空所有界面 /// </summary> public virtual void ClearAllWindow() { if (allWindows != null) { foreach (KeyValuePair <WindowID, UIBaseWindow> window in allWindows) { UIBaseWindow baseWindow = window.Value; baseWindow.DestroyWindow(); } allWindows.Clear(); shownWindows.Clear(); backSequence.Clear(); } }
/// <summary> /// Navigation reShow target windows /// </summary> protected void ShowWindowForNavigation(WindowID id) { if (!this.IsWindowInControl(id)) { Debuger.Log("## Current UI Manager has no control power of " + id.ToString()); return; } if (dicShownWindows.ContainsKey((int)id)) { return; } UIBaseWindow baseWindow = GetGameWindow(id); baseWindow.ShowWindow(); dicShownWindows[(int)baseWindow.ID] = baseWindow; }
/// <summary> /// 窗口背景碰撞体处理 /// </summary> private void AddColliderBgForWindow(UIBaseWindow baseWindow) { UIWindowColliderMode colliderMode = baseWindow.windowData.colliderMode; if (colliderMode == UIWindowColliderMode.None) { return; } if (colliderMode == UIWindowColliderMode.Normal) { GameUtility.AddColliderBgToTarget(baseWindow.gameObject, "Mask02", maskAtlas, true); } if (colliderMode == UIWindowColliderMode.WithBg) { GameUtility.AddColliderBgToTarget(baseWindow.gameObject, "Mask02", maskAtlas, false); } }
// 直接打开窗口 protected void ShowWindowForBack(WindowID id) { // 检测控制权限 if (!this.IsWindowInControl(id)) { Debug.Log("UIManager has no control power of " + id.ToString()); return; } if (shownWindows.ContainsKey(id)) { return; } UIBaseWindow baseWindow = GetGameWindow(id); baseWindow.ShowWindow(); shownWindows[baseWindow.GetID] = baseWindow; }
public override void ShowWindow(WindowID id, ShowWindowData data = null) { UIBaseWindow baseWindow = ReadyToShowBaseWindow(id, data); if (baseWindow != null) { RealShowWindow(baseWindow, id); // 是否清空当前导航信息(回到主菜单) if (baseWindow.windowData.isStartWindow) { Debuger.Log("[Enter the start window, reset the backSequenceData for the navigation system.]"); ClearBackSequence(); } if (data != null && data.forceClearBackSeqData) { ClearBackSequence(); } } }
public override void InitWindowOnAwake() { base.InitWindowOnAwake(); InitWindowCoreData(); btnWin = GameUtility.FindDeepChild(this.gameObject, "BtnWin").gameObject; btnLose = GameUtility.FindDeepChild(this.gameObject, "BtnLose").gameObject; btnShop = GameUtility.FindDeepChild(this.gameObject, "BtnShop").gameObject; // win the game // load new scene to show target window UIEventListener.Get(btnWin).onClick = delegate { GameMonoHelper.GetInstance().LoadGameScene("RealGame-EmptyScene", false, delegate { UICenterMasterManager.Instance.ShowWindow(WindowID.WindowID_MatchResult); UIBaseWindow baseWindow = UICenterMasterManager.Instance.GetGameWindow(WindowID.WindowID_MatchResult); ((UIMatchResult)baseWindow).SetMatchResult(true, targetBackWindowId); }); }; // lose the game // load new scene to show target window UIEventListener.Get(btnLose).onClick = delegate { GameMonoHelper.GetInstance().LoadGameScene("RealGame-EmptyScene", false, delegate { UICenterMasterManager.Instance.ShowWindow(WindowID.WindowID_MatchResult); UIBaseWindow baseWindow = UICenterMasterManager.Instance.GetGameWindow(WindowID.WindowID_MatchResult); ((UIMatchResult)baseWindow).SetMatchResult(false, targetBackWindowId); }); }; // show navigation window shop UIEventListener.Get(btnShop).onClick = delegate { UICenterMasterManager.Instance.ShowWindow(WindowID.WindowID_Shop); }; }
private void ExectuteBackSeqData(BackWindowSequenceData backData) { if (backData.backShowTargets != null) { for (int i = 0; i < backData.backShowTargets.Count; i++) { WindowID backId = backData.backShowTargets[i]; ShowWindowForNavigation(backId); if (i == backData.backShowTargets.Count - 1) { UIBaseWindow window = GetGameWindow(backId); if (window.windowData.navigationMode == UIWindowNavigationMode.NormalNavigation) { this.lastNavigationWindow = this.curNavigationWindow; this.curNavigationWindow = window; Debuger.Log("<color=magenta>##[UIManagerBase return window]##</color> Change currentShownNormalWindow : " + backId); } } } } backSequence.Pop(); }
// 如果当前存在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(UIBaseWindow baseWindow) { if (baseWindow.RefreshBackSeqData) { if (backSequence.Count > 0) { BackWindowSequenceData 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!"); } } } }
public override void InitWindowOnAwake() { this.windowID = WindowID.WindowID_Matching; base.InitWindowOnAwake(); InitWindowData(); btnWin = GameUtility.FindDeepChild(this.gameObject, "BtnWin").gameObject; btnLose = GameUtility.FindDeepChild(this.gameObject, "BtnLose").gameObject; // win the game UIEventListener.Get(btnWin).onClick = delegate { GameMonoHelper.GetInstance().LoadGameScene("TestEmptyScene", delegate { // 是否需要一个退出比赛单独接口? // UIManager.GetInstance().ShowWindow(WindowID.WindowID_TopBar); // UIManager.GetInstance().ShowWindow(WindowID.WindowID_LevelDetail); UIManager.GetInstance().ShowWindow(WindowID.WindowID_MatchResult); UIBaseWindow baseWindow = UIManager.GetInstance().GetGameWindow(WindowID.WindowID_MatchResult); ((UIMatchResult)baseWindow).SetMatchResult(true, targetBackWindowId); }); }; // lose the game UIEventListener.Get(btnLose).onClick = delegate { GameMonoHelper.GetInstance().LoadGameScene("TestEmptyScene", delegate { UIManager.GetInstance().ShowWindow(WindowID.WindowID_MatchResult); UIBaseWindow baseWindow = UIManager.GetInstance().GetGameWindow(WindowID.WindowID_MatchResult); ((UIMatchResult)baseWindow).SetMatchResult(false, targetBackWindowId); }); }; }
/// <summary> /// Calculate right depth with windowType /// </summary> /// <param name="baseWindow"></param> private void AdjustBaseWindowDepth(UIBaseWindow baseWindow) { UIWindowType windowType = baseWindow.windowData.windowType; int needDepth = 1; if (windowType == UIWindowType.Normal) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UINormalWindowRoot.gameObject, false) + 1, normalWindowDepth, int.MaxValue); Debuger.Log(string.Format("<color=cyan>[UIWindowType.Normal] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString())); } else if (windowType == UIWindowType.PopUp) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIPopUpWindowRoot.gameObject) + 1, popUpWindowDepth, int.MaxValue); Debuger.Log(string.Format("<color=cyan>[UIWindowType.PopUp] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString())); } else if (windowType == UIWindowType.Fixed) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIFixedWidowRoot.gameObject) + 1, fixedWindowDepth, int.MaxValue); Debuger.Log(string.Format("<color=cyan>[UIWindowType.Fixed] maxDepth is {0} , {1}.</color>", needDepth.ToString(), baseWindow.ID.ToString())); } if (baseWindow.MinDepth != needDepth) GameUtility.SetTargetMinPanelDepth(baseWindow.gameObject, needDepth); // send window added message to game client if (baseWindow.windowData.windowType == UIWindowType.PopUp) { // trigger the window PopRoot added window event EventDispatcher.GetInstance().UIFrameWorkEventManager.TriggerEvent(EventSystemDefine.EventUIFrameWorkPopRootWindowAdded); } baseWindow.MinDepth = needDepth; }
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); }
// 如果当前存在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(UIBaseWindow baseWindow) { if (baseWindow.RefreshBackSeqData) { if (backSequence.Count > 0) { BackWindowSequenceData 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!"); } } }
/// <summary> /// Add Collider and BgTexture for target window /// </summary> private void AddColliderBgForWindow(UIBaseWindow baseWindow) { UIWindowColliderMode colliderMode = baseWindow.windowData.colliderMode; if (colliderMode == UIWindowColliderMode.None) return; GameObject bgObj = null; if (colliderMode == UIWindowColliderMode.Normal) bgObj = GameUtility.AddColliderBgToTarget(baseWindow.gameObject, "Mask02", maskAtlas, true); if (colliderMode == UIWindowColliderMode.WithBg) bgObj = GameUtility.AddColliderBgToTarget(baseWindow.gameObject, "Mask02", maskAtlas, false); baseWindow.OnAddColliderBg(bgObj); }
private void ExecuteNavigationLogic(UIBaseWindow baseWindow, ShowWindowData showData) { WindowCoreData windowData = baseWindow.windowData; if (baseWindow.RefreshBackSeqData) { this.RefreshBackSequenceData(baseWindow, showData); } else if (windowData.showMode == UIWindowShowMode.HideOtherWindow) { HideAllShownWindow(); } // If target window is mark as force clear all the navigation sequence data // Show data need force clear the back seq data if (baseWindow.windowData.forceClearNavigation || (showData != null && showData.forceClearBackSeqData)) { Debuger.Log("<color=cyan>## [Enter the start window, reset the backSequenceData for the navigation system.]##</color>"); ClearBackSequence(); } else { if ((showData != null && showData.checkNavigation)) CheckBackSequenceData(baseWindow); } }
private void AdjustBaseWindowDepth(UIBaseWindow baseWindow) { UIWindowType windowType = baseWindow.windowData.windowType; int needDepth = 1; if (windowType == UIWindowType.Normal) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UINormalWindowRoot.gameObject, false) + 1, normalWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.Normal] maxDepth is " + needDepth + baseWindow.GetID); } else if (windowType == UIWindowType.PopUp) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIPopUpWindowRoot.gameObject) + 1, popUpWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.PopUp] maxDepth is " + needDepth); } else if (windowType == UIWindowType.Fixed) { needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(UIFixedWidowRoot.gameObject) + 1, fixedWindowDepth, int.MaxValue); Debug.Log("[UIWindowType.Fixed] max depth is " + needDepth); } if(baseWindow.MinDepth != needDepth) GameUtility.SetTargetMinPanel(baseWindow.gameObject, needDepth); baseWindow.MinDepth = needDepth; }
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); }
private void RefreshBackSequenceData(UIBaseWindow targetWindow, ShowWindowData showData) { WindowCoreData coreData = targetWindow.windowData; bool dealBackSequence = true; if (dicShownWindows.Count > 0 && dealBackSequence) { List<WindowID> removedKey = null; List<UIBaseWindow> sortedHiddenWindows = new List<UIBaseWindow>(); BackWindowSequenceData backData = new BackWindowSequenceData(); foreach (KeyValuePair<int, UIBaseWindow> 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>"); } } }
// // Depth Helper Functions // // Push target GameObject to top depth // Case: when you open multi PopWindow // You want one of these PopWindow stay at the Top // You can register the EventSystemDefine.EventUIFrameWorkPopRootWindowAdded // Call this method to push window to top public static void AdjustTargetWindowDepthToTop(UIBaseWindow targetWindow) { if (targetWindow == null) return; Transform windowRoot = UICenterMasterManager.Instance.GetTargetRoot(targetWindow.windowData.windowType); int needDepth = Mathf.Clamp(GameUtility.GetMaxTargetDepth(windowRoot.gameObject, true) + 1, popUpWindowDepth, int.MaxValue); GameUtility.SetTargetMinPanelDepth(targetWindow.gameObject, needDepth); targetWindow.MinDepth = needDepth; }