/// <summary> /// MessageBox /// </summary> /// public void ShowMessageBox(string msg) { UIWindowBase msgWindow = ReadyToShowBaseWindow(WindowID.WindowID_MessageBox); if (msgWindow != null) { ((UIMessageBox)msgWindow).SetMsg(msg); ((UIMessageBox)msgWindow).ResetWindow(); RealShowWindow(msgWindow, WindowID.WindowID_MessageBox); } }
private bool PopUpWindowManager(UIWindowBase 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); }
protected virtual void RealShowWindow(UIWindowBase 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()); } }
// // 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(UIWindowBase 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) { UIWindowBase 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); } }
/// <summary> /// Destroy all window /// </summary> public virtual void ClearAllWindow() { if (dicAllWindows != null) { foreach (KeyValuePair <int, UIWindowBase> window in dicAllWindows) { UIWindowBase baseWindow = window.Value; baseWindow.DestroyWindow(); } dicAllWindows.Clear(); dicShownWindows.Clear(); backSequence.Clear(); } }
public void ShowMessageBox(string msg, string leftStr, UIEventListener.VoidDelegate leftCallBack, string rightStr, UIEventListener.VoidDelegate rightCallBack) { UIWindowBase 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> /// Navigation reShow target windows /// </summary> private 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; } UIWindowBase baseWindow = GetGameWindow(id); baseWindow.ShowWindow(); dicShownWindows[(int)baseWindow.ID] = baseWindow; }
/// <summary> /// Add Collider and BgTexture for target window /// </summary> private void AddColliderBgForWindow(UIWindowBase 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); }
protected void ShowWindowForOtherWindowManager(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)) { UIWindowBase baseWindow = dicAllWindows[(int)id]; if (baseWindow.ID != id) { Debuger.LogError(string.Format("[UIRankManager BaseWindowId :{0} != shownWindowId :{1}]", baseWindow.ID, id)); return; } this.RealShowWindow(baseWindow, baseWindow.ID, showData); } }
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); UIWindowBase 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); UIWindowBase 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); }; }
// 如果当前存在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 override UIWindowBase ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null) { // Check the window control state if (!this.IsWindowInControl(id)) { Debuger.Log("## UIManager has no control power of " + id.ToString()); return(null); } // If the window in shown list just return if (dicShownWindows.ContainsKey((int)id)) { return(null); } UIWindowBase baseWindow = GetGameWindow(id); // If window not in scene start Instantiate new window to scene bool newAdded = false; if (!baseWindow) { newAdded = true; if (UIResourceDefine.windowPrefabPath.ContainsKey((int)id)) { string prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[(int)id]; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); NGUITools.SetActive(uiObject, true); // NOTE: You can add component to the window in the inspector // Or just AddComponent<UIxxxxWindow>() to the target baseWindow = uiObject.GetComponent <UIWindowBase>(); if (baseWindow.ID != id) { Debuger.LogError(string.Format("<color=cyan>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id)); return(null); } // Get the window target root parent Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType); GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform); dicAllWindows[(int)id] = baseWindow; } } } if (baseWindow == null) { Debuger.LogError("[window instance is null.]" + id.ToString()); } // Call reset window when first load new window // Or get forceResetWindow param if (newAdded || (showData != null && showData.forceResetWindow)) { baseWindow.ResetWindow(); } if (showData == null || (showData != null && showData.executeNavLogic)) { // refresh the navigation data ExecuteNavigationLogic(baseWindow, showData); } // Adjust the window depth AdjustBaseWindowDepth(baseWindow); // Add common background collider to window AddColliderBgForWindow(baseWindow); return(baseWindow); }