Exemple #1
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>");
        }
Exemple #2
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!");
                    }
                }
            }
        }
Exemple #3
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;
                }
            }
        }
Exemple #4
0
        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.Invaild)
                {
                    Debug.LogWarning(string.Format(string.Format("## Current nav window {0} need show pre window {1}.", curNavigationWindow.ID.ToString(), preWindowId.ToString())));
                    switch (curNavigationWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Hide:
                    {
                        HideWindow(curNavigationWindow.ID, delegate
                            {
                                ShowWindowData showData  = new ShowWindowData();
                                showData.executeNavLogic = false;
                                ShowWindow(preWindowId, showData);
                            });
                    }
                    break;

                    case UIWindowCloseModel.Destory:
                    {
                        DestroyWindow(curNavigationWindow.ID, delegate
                            {
                                ShowWindowData showData  = new ShowWindowData();
                                showData.executeNavLogic = false;
                                ShowWindow(preWindowId, showData);
                            });
                    }
                    break;
                    }
                }
                else
                {
                    Debug.LogWarning("## CurrentShownWindow " + curNavigationWindow.ID + " preWindowId is " + WindowID.Invaild);
                }
                return(false);
            }
            NavigationData backData = backSequence.Peek();

            if (backData != null)
            {
                // check the current navigation data
                WindowID curId = this.GetCurrentShownWindow();
                if (curId != backData.CloseTargetWindow.ID)
                {
                    Debug.Log("<color=red>Can't PopUp seq data [backData.hideTargetWindow.ID != this.curShownWindowId]</color>");
                    return(false);
                }

                if (PopUpWindowManager(backData.CloseTargetWindow))
                {
                    return(true);
                }

                WindowID closeId = backData.CloseTargetWindow.ID;
                if (!dicShownWindows.ContainsKey(closeId))
                {
                    ExectuteBackSeqData(backData);
                }
                else
                {
                    switch (backData.CloseTargetWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Hide:
                    {
                        HideWindow(closeId, delegate
                            {
                                ExectuteBackSeqData(backData);
                            });
                    }
                    break;

                    case UIWindowCloseModel.Destory:
                    {
                        CheckDirectlyDestroyWIndow(closeId, delegate
                            {
                                ExectuteBackSeqData(backData);
                            });
                    }
                    break;
                    }
                }
            }
            return(true);
        }
Exemple #5
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>");
            }
        }