Esempio n. 1
0
        private void SetMenuUI(int menuId)
        {
            if (menuId > 0)
            {
                MenuConfig config = configSet [menuId];

                if (mainUiModule.IsActive == false)
                {
                    mainUiModule.IsActive = true;
                }
                if (config.mainUIType != 0)
                {
                    mainUiModule.SetParameter(config.mainUIType);
                    mainUiModule.Enter();
                }
            }
        }
Esempio n. 2
0
        private void OpenWindow(MenuChangeVO vo, IModule module)
        {
            MenuConfig config = configSet [vo.menuId];

            //Debug.Log("MenuManager.OpenWindow config.name="+config.name+ " module=" + module + "  module.MenuId=" + module.MenuId );

            if (vo.isCloseOthers)
            {
                Queue <IModule> closeWinQueue = new Queue <IModule>();


                if (config.showType == ShowType.Screen)
                {
                    foreach (var item in modules)
                    {
                        if (!item.Value.IsActive)
                        {
                            continue;
                        }
                        MenuConfig itemConfig = configSet [item.Value.MenuId];

                        if (itemConfig != null && config.menuId != itemConfig.menuId)
                        {
                            closeWinQueue.Enqueue(item.Value);
                        }
                    }
                }
                else if (config.showType == ShowType.Popup)
                {
                    foreach (var item in modules)
                    {
                        if (!item.Value.IsActive)
                        {
                            continue;
                        }
                        MenuConfig itemConfig = configSet [item.Value.MenuId];

                        if (itemConfig != null && config.menuId != itemConfig.menuId && config.showIndex == itemConfig.showIndex)
                        {
                            closeWinQueue.Enqueue(item.Value);
                        }
                    }
                }

                while (closeWinQueue.Count > 0)
                {
                    CloseWindow(closeWinQueue.Dequeue(), false);
                }
            }


            if (modules.ContainsKey(vo.menuId))
            {
                modules [vo.menuId] = module;
            }
            else
            {
                modules.Add(vo.menuId, module);
            }


            module.IsActive = true;
            module.rectTransform.SetParent(GetRoot(vo.isPreInstance ? MenuLayerType.Layer_PreInstance : config.layer), false);
            if (vo.isPreInstance)
            {
                module.rectTransform.SetAsFirstSibling();
            }
            else
            {
                module.rectTransform.SetAsLastSibling();
            }
            module.SetParameter(vo.parameter);

            if (!vo.isBackState)
            {
                if (!vo.isPreInstance)
                {
                    module.Enter();
                }
            }
            else
            {
                vo.isBackState = false;
                module.OnBack();
            }



            if (config.showType == ShowType.Screen)
            {
                activeFullScreenWindowCount++;
                //Debug.Log("MenuManager.OpenWindow config.name="+config.name+ " activeFullScreenWindowCount="+activeFullScreenWindowCount);
            }



            if (vo.isPreInstance)
            {
                DelayClose(vo);
                return;
            }

            CheckMainUI(config.menuId);



            //TODO blurbg
            if (config.showBlurBG)
            {
                if (blurBG != null)
                {
                    blurBG.OnOpenMenu(config);
                }
            }

            if (config.isPushMenuId)
            {
                if (openedMenuIds.IndexOf(config.menuId) != -1)
                {
                    openedMenuIds.Remove(config.menuId);
                }
                openedMenuIds.Add(config.menuId);
            }
        }