示例#1
0
        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);
        }
示例#2
0
        // 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 = Instance.GetTargetRoot(targetWindow.windowData.windowType);
            int       needDepth  = Mathf.Clamp(UGUITools.GetMaxTargetDepth(windowRoot.gameObject, true) + 1, popUpWindowDepth, int.MaxValue);

            UGUITools.SetTargetMinPanelDepth(targetWindow.gameObject, needDepth);
            targetWindow.MinDepth = needDepth;
        }
示例#3
0
        protected virtual void RealShowWindow(UIWindowBase baseWindow, WindowID id, ShowWindowData showData = null)
        {
            BaseWindowContextData contextData = showData == null ? null : showData.contextData;

            baseWindow.ReadyToShowWindow(contextData);
            dicShownWindows[id] = baseWindow;
            if (baseWindow.windowData.navigationMode == UIWindowNavigationMode.NormalNavigation)
            {
                lastNavigationWindow = curNavigationWindow;
                curNavigationWindow  = baseWindow;
                Debug.Log("<color=magenta>### current Navigation window </color>" + baseWindow.ID.ToString());
            }
        }
示例#4
0
        /// <summary>
        /// Navigation reShow target windows
        /// </summary>
        private void ShowWindowForNavigation(WindowID id)
        {
            if (!this.IsWindowInControl(id))
            {
                Debug.Log("## Current UI Manager has no control power of " + id.ToString());
                return;
            }
            if (dicShownWindows.ContainsKey(id))
            {
                return;
            }

            UIWindowBase baseWindow = GetGameWindow(id);

            baseWindow.ReadyToShowWindow();
            dicShownWindows[baseWindow.ID] = baseWindow;
        }
示例#5
0
        public override UIWindowBase ShowWindow(WindowID id, ShowWindowData showData = null)
        {
            UIWindowBase baseWindow = ReadyToShowBaseWindow(id, showData);

            if (baseWindow != null)
            {
                RealShowWindow(baseWindow, id, showData);
            }
            else
            {
                baseWindow = GetGameWindow(id);
                if (baseWindow != null)
                {
                    BaseWindowContextData contextData = showData == null ? null : showData.contextData;
                    baseWindow.ReadyToShowWindow(contextData);
                }
            }
            return(baseWindow);
        }
示例#6
0
        /// <summary>
        /// 关闭窗口。如果有导航就返回上一个界面
        /// 如果没有就直接根据窗口的设定关闭或者隐藏窗口
        /// </summary>
        /// <param name="wndId"></param>
        public void CloseWindow(WindowID wndId)
        {
            if (!IsWindowInControl(wndId))
            {
                Debug.LogError("## Current UI Manager has no control power of " + wndId.ToString());
                return;
            }

            if (!dicShownWindows.ContainsKey(wndId))
            {
                return;
            }

            UIWindowBase window = dicShownWindows[wndId];

            if (this.backSequence.Count > 0)
            {
                NavigationData seqData = this.backSequence.Peek();
                if (seqData != null && seqData.CloseTargetWindow == window)
                {
                    PopNavigationWindow();
                    Debug.Log("<color=magenta>## close window use PopNavigationWindow() ##</color>");
                    return;
                }
            }


            switch (dicShownWindows[wndId].windowData.closeModel)
            {
            case UIWindowCloseModel.Destory:
                DestroyWindow(wndId, null);
                break;

            case UIWindowCloseModel.Hide:
                HideWindow(wndId);
                break;
            }


            //  HideWindow(wndId);
            Debug.Log("<color=magenta>## close window without PopNavigationWindow() ##</color>");
        }
示例#7
0
        /// <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 = UGUITools.AddColliderBgToTarget(baseWindow.gameObject, "Mask02", true);
            }
            if (colliderMode == UIWindowColliderMode.WithBg)
            {
                bgObj = UGUITools.AddColliderBgToTarget(baseWindow.gameObject, "Mask02", false);
            }
            baseWindow.OnAddColliderBg(bgObj);
        }
示例#8
0
 /// <summary>
 /// Destroy all window
 /// </summary>
 public virtual void ClearAllWindow()
 {
     if (dicAllWindows != null)
     {
         foreach (KeyValuePair <WindowID, UIWindowBase> window in dicAllWindows)
         {
             UIWindowBase baseWindow = window.Value;
             if (baseWindow != null)
             {
                 baseWindow.DestroyWindow();
             }
             else
             {
                 Debug.LogError(window.Key + "为空");
             }
         }
         dicAllWindows.Clear();
         dicShownWindows.Clear();
         backSequence.Clear();
     }
 }
示例#9
0
 protected void ShowWindowForOtherWindowManager(WindowID id, ShowWindowData showData)
 {
     if (!IsWindowInControl(id))
     {
         Debug.Log("UIRankManager has no control power of " + id.ToString());
         return;
     }
     if (dicShownWindows.ContainsKey(id))
     {
         return;
     }
     if (dicAllWindows.ContainsKey(id))
     {
         UIWindowBase baseWindow = dicAllWindows[id];
         if (baseWindow.ID != id)
         {
             Debug.LogError(string.Format("[UIRankManager BaseWindowId :{0} != shownWindowId :{1}]", baseWindow.ID, id));
             return;
         }
         this.RealShowWindow(baseWindow, baseWindow.ID, showData);
     }
 }
示例#10
0
        // 如果当前存在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.CloseTargetWindow != null)
                    {
                        if (backData.CloseTargetWindow.ID != baseWindow.ID)
                        {
                            Debug.Log("<color=#2a5caa>## UICenterMasterManager : clear sequence data ##</color>");
                            Debug.Log("## UICenterMasterManager : Hide target window and show window id is " + backData.CloseTargetWindow.ID + " != " + baseWindow.ID);
                            ClearBackSequence();
                        }
                    }
                    else
                    {
                        Debug.LogError("Back data hide target window is null!");
                    }
                }
            }
        }
示例#11
0
        // Deal with Navigation sequence data Look At UIRankManager example
        // you can change Navigation data when pop up window
        // !! Not used for UICenterMasterManager !!
        // Just for Sub window Manager
        //
        // Fixed Bug : When you close the navigation window by CloseBtn may cause the Navigation Data add more time
        // Check Navigation data when Call Manager's PopNavigationWindow, we just add DealWithNavigationWhenPopWindow method for deal with navigation when pop up window
        //
        protected virtual void DealWithNavigationWhenPopWindow()
        {
            if (dicShownWindows.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < this.managedWindowIds.Count; i++)
            {
                if (!dicShownWindows.ContainsKey(managedWindowIds[i]))
                {
                    continue;
                }
                UIWindowBase wnd = dicShownWindows[managedWindowIds[i]];
                if (wnd.windowData.navigationMode == UIWindowNavigationMode.NormalNavigation &&
                    !wnd.IsLock)
                {
                    NavigationData nd = new NavigationData();
                    nd.CloseTargetWindow = wnd;
                    backSequence.Push(nd);
                    break;
                }
            }
        }
示例#12
0
        protected override UIWindowBase ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
        {
            // Check the window control state
            if (!this.IsWindowInControl(id))
            {
                Debug.Log("## UIManager has no control power of " + id.ToString());
                return(null);
            }

            // If the window in shown list just return
            if (dicShownWindows.ContainsKey(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(id))
                {
                    GameObject prefab = Resources.Load <GameObject>(UIResourceDefine.windowPrefabPath[id]);
                    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)
                        {
                            Debug.LogError(string.Format("<color=#2a5caa>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id));
                            return(null);
                        }

                        // Get the window target root parent
                        Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType);
                        Transform t          = uiObject.transform;
                        t.SetParent(targetRoot.transform);
                        t.localPosition = Vector3.zero;
                        t.localRotation = Quaternion.identity;
                        t.localScale    = Vector3.one;
                        uiObject.layer  = targetRoot.gameObject.layer;
                        RectTransform _targetRectTransform = uiObject.GetComponent <RectTransform>();
                        if (_targetRectTransform.anchorMax == Vector2.one && _targetRectTransform.anchorMin == Vector2.zero)
                        {
                            //如果是拉伸就吧边角设置成0
                            UGUITools.SetRectTransformOffset(uiObject, Vector2.zero, Vector2.zero);
                        }
                        UGUITools.SetRectTransformAnchoredPosition(uiObject, Vector2.zero);
                        //  baseWindow = UGUITools.AddChild(targetRoot.gameObject, prefab).GetComponent<UIWindowBase>();
                        if (baseWindow.ID != id)
                        {
                            Debug.LogError(string.Format("<color=#2a5caa>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id));
                            return(null);
                        }
                        dicAllWindows[id] = baseWindow;
                        prefab            = null;
                    }
                }
            }

            if (baseWindow == null)
            {
                Debug.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);
        }
示例#13
0
        private void RefreshBackSequenceData(UIWindowBase targetWindow, ShowWindowData showData)
        {
            WindowCoreData coreData = targetWindow.windowData;

            if (dicShownWindows.Count == 0)
            {
                return;
            }

            List <WindowID>     removedKey          = null;
            List <UIWindowBase> sortedHiddenWindows = new List <UIWindowBase>();

            NavigationData backData = new NavigationData();

            foreach (KeyValuePair <WindowID, UIWindowBase> window in dicShownWindows)
            {
                if (coreData.showMode != UIWindowShowMode.DoNothing)
                {
                    if (window.Value.windowData.windowType == UIWindowType.BackgroundLayer)
                    {
                        continue;
                    }
                    if (removedKey == null)
                    {
                        removedKey = new List <WindowID>();
                    }
                    removedKey.Add(window.Key);
                    window.Value.HideWindowDirectly();
                }

                if (window.Value.windowData.windowType != UIWindowType.BackgroundLayer)
                {
                    sortedHiddenWindows.Add(window.Value);
                }
            }

            if (removedKey != null)
            {
                for (int i = 0; i < removedKey.Count; i++)
                {
                    dicShownWindows.Remove(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.CloseTargetWindow = targetWindow;
                backData.backShowTargets   = navHiddenWindows;

                backSequence.Push(backData);
                Debug.Log("<color=#2a5caa>### !!!Push new Navigation data!!! ###</color>");
            }
        }
示例#14
0
        /// <summary>
        /// 根据窗口类型清除对应panl下的窗口
        /// 根据UIWindowCloseModel 来确定是删除还是隐藏
        /// </summary>
        /// <param name="type"></param>
        public virtual void ClearAllWindowByWindowTypeAndCloseModel(UIWindowType type)
        {
            switch (type)
            {
            case UIWindowType.BackgroundLayer:
            {
                for (int i = 0; i < UIBackgroundLayerRoot.transform.childCount; i++)
                {
                    UIWindowBase chidWindow = UIBackgroundLayerRoot.transform.GetChild(i).GetComponent <UIWindowBase>();
                    switch (chidWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Destory:
                        DestroyWindow(chidWindow.ID, null);
                        break;

                    case UIWindowCloseModel.Hide:
                        HideWindow(chidWindow.ID);
                        break;
                    }
                }
            }
            break;

            case UIWindowType.ForegroundLayer:
            {
                for (int i = 0; i < UIForegroundLayerRoot.transform.childCount; i++)
                {
                    UIWindowBase chidWindow = UIForegroundLayerRoot.transform.GetChild(i).GetComponent <UIWindowBase>();
                    switch (chidWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Destory:
                        DestroyWindow(chidWindow.ID, null);
                        break;

                    case UIWindowCloseModel.Hide:
                        HideWindow(chidWindow.ID);
                        break;
                    }
                }
            }
            break;

            case UIWindowType.NormalLayer:
            {
                for (int i = 0; i < UINormalLayerRoot.transform.childCount; i++)
                {
                    UIWindowBase chidWindow = UINormalLayerRoot.transform.GetChild(i).GetComponent <UIWindowBase>();
                    switch (chidWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Destory:
                        DestroyWindow(chidWindow.ID, null);
                        break;

                    case UIWindowCloseModel.Hide:
                        HideWindow(chidWindow.ID);
                        break;
                    }
                }
            }
            break;
            }
        }