Exemplo n.º 1
0
        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>");
                }
            }
        }
Exemplo n.º 2
0
        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>");
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 protected override int GetCurrenShownWindow()
 {
     if (backSequence.Count > 0)
     {
         BackWindowSequenceData data = backSequence.Peek();
         return((int)data.hideTargetWindow.ID);
     }
     return((int)WindowID.WindowID_Invaild);
 }
Exemplo n.º 8
0
        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!");
                    }
                }
            }
        }
Exemplo n.º 9
0
 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();
 }
Exemplo n.º 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(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!");
                    }
                }
            }
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
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.WindowID_Invaild)
                {
                    Debuger.LogWarning(string.Format(string.Format("## Current nav window {0} need show pre window {1}.", curNavigationWindow.ID.ToString(), preWindowId.ToString())));
                    HideWindow(curNavigationWindow.ID, delegate
                    {
                        ShowWindowData showData  = new ShowWindowData();
                        showData.executeNavLogic = false;
                        ShowWindow(preWindowId, showData);
                    });
                }
                else
                {
                    Debuger.LogWarning("## CurrentShownWindow " + curNavigationWindow.ID + " preWindowId is " + WindowID.WindowID_Invaild);
                }
                return(false);
            }
            BackWindowSequenceData backData = backSequence.Peek();

            if (backData != null)
            {
                // check the current back data

                int curId = this.GetCurrenShownWindow();
                if (curId != (int)backData.hideTargetWindow.ID)
                {
                    Debuger.Log("<color=red>Can't PopUp seq data [backData.hideTargetWindow.ID != this.curShownWindowId]</color>");
                    return(false);
                }

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

                WindowID hideId = backData.hideTargetWindow.ID;
                if (!dicShownWindows.ContainsKey((int)hideId))
                {
                    ExectuteBackSeqData(backData);
                }
                else
                {
                    HideWindow(hideId, delegate
                    {
                        ExectuteBackSeqData(backData);
                    });
                }
            }
            return(true);
        }
        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>");
                }
            }
        }
Exemplo n.º 14
0
        // 界面导航返回
        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);
        }
Exemplo n.º 15
0
        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);
        }