public void ShowMenuExclusive(Menu.MenuType genericMenu) { allMenus = (Resources.FindObjectsOfTypeAll(typeof(Menu)) as Menu[]).ToList(); Menu menuToShow = allMenus.Find(menu => menu.ThisMenuType == genericMenu); allMenus.ForEach(menu => menu.gameObject.SetActive(menu == menuToShow)); }
public void SetMenuMode(Menu.MenuType menuType) { Menu.gameObject.SetActive(true); Menu.Init(menuType); HUD.gameObject.SetActive(false); HUD.DeInit(); }
private List <MenuItem> GetMenuItems(IModule module, Type controller, Menu.MenuType menuType, bool hasAllowAnonymousOnController, bool hasAllowAuthenticatedOnController) { var menuItemList = new List <MenuItem>(); var actions = controller.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (var item in actions) { if (menuType == Menu.MenuType.Admin) { var adminMenuAttributes = item.GetCustomAttributes <AdminMenuItem>(); var amiList = MakeMenuItemList(module, controller, item, adminMenuAttributes, hasAllowAnonymousOnController, hasAllowAuthenticatedOnController); menuItemList.AddRange(amiList); } else if (menuType == Menu.MenuType.WebSite) { var siteMenuAttributes = item.GetCustomAttributes <SiteMenuItem>(); var smiList = MakeMenuItemList(module, controller, item, siteMenuAttributes, hasAllowAnonymousOnController, hasAllowAuthenticatedOnController); menuItemList.AddRange(smiList); } } return(menuItemList); }
//CONSTRUCTOR public MenuButton(Vector2 pos, Tuple <string, string> text, Menu.MenuType nextMenu) : base(pos, text) { this.nextMenu = nextMenu; }
private List <Menu> MakeMenuList(IModule module, IEnumerable <IMenu> moduleMenus, Type controllerType, Menu.MenuType menuType) { var menuList = new List <Menu>(); var hasAllowAnonymousOnController = false; var hasAllowAuthenticatedOnController = false; var anonymous = controllerType.GetCustomAttributes <AllowAnonymousAttribute>(); if (anonymous != null && anonymous.Count() > 0) { hasAllowAnonymousOnController = true; } var allowAuthenticated = controllerType.GetCustomAttributes <AllowAuthenticated>(); if (allowAuthenticated != null && allowAuthenticated.Count() > 0) { hasAllowAuthenticatedOnController = true; } foreach (IMenu menu in moduleMenus) { var existingMenu = menuList.Where(x => x.DisplayName == menu.Name).FirstOrDefault(); if (existingMenu == null) { existingMenu = new Menu(); menuList.Add(existingMenu); } existingMenu.Area = module.Area; existingMenu.Controller = controllerType.Name; existingMenu.Action = "Index"; existingMenu.DisplayName = menu.Name; existingMenu.ModuleName = module.Folder; existingMenu.Type = menuType; existingMenu.MenuItems = GetMenuItems(module, controllerType, menuType, hasAllowAnonymousOnController, hasAllowAuthenticatedOnController); } return(menuList); }