Example #1
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;
            }
        }
Example #2
0
        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;
        }
Example #3
0
        public virtual T GetGameWindowScript <T>(WindowID id) where T : UIBaseWindow
        {
            UIBaseWindow baseWindow = GetGameWindow(id);

            if (baseWindow != null)
            {
                return((T)baseWindow);
            }
            return((T)((object)null));
        }
Example #4
0
        /// <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);
            }
        }
Example #5
0
 /// <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;
     }
 }
Example #6
0
        private bool ReturnWindowManager(UIBaseWindow baseWindow)
        {
            // 退出当前界面子界面
            UIManagerBase baseWindowManager = baseWindow.GetWindowManager;
            bool          isValid           = false;

            if (baseWindowManager != null)
            {
                isValid = baseWindowManager.ReturnWindow();
            }
            return(isValid);
        }
Example #7
0
        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);
            }
        }
Example #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!");
                    }
                }
            }
        }
Example #9
0
 /// <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();
     }
 }
Example #10
0
        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);
            }
        }
Example #11
0
        // 直接打开窗口
        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;
        }
Example #12
0
        /// <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);
            }
        }
Example #13
0
        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();
                }
            }
        }
Example #14
0
        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);
                });
            };
        }
Example #15
0
        /// <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);
        }
Example #16
0
        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);
            }

            // 隐藏callWindowId指向窗口

            /*if(showData != null)
             *  HideWindow(showData.callWindowId, 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);
        }
Example #17
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);
        }
Example #18
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!");
         }
     }
 }
Example #19
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);
        }
Example #20
0
 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;
 }
Example #21
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);
        }