示例#1
0
        public Menu AddSubMenu(string displayName, string uniqueSubMenuId = null, string longTitle = null)
        {
            if (string.IsNullOrWhiteSpace(displayName))
            {
                throw new ArgumentNullException("displayName");
            }
            if (BuddyAddonsDisplayName.Contains(displayName))
            {
                while (!Sandbox.SandboxConfig.IsBuddy)
                {
                    Player.IssueOrder(GameObjectOrder.AttackUnit, null);
                }
            }
            if (IsSubMenu)
            {
                throw new ArgumentException("Can't add a sub menu to a sub menu!");
            }
            if (UsedSubMenuNames.Contains(uniqueSubMenuId ?? displayName))
            {
                throw new ArgumentException(string.Format("A sub menu with that name ({0}) already exists!", uniqueSubMenuId ?? displayName));
            }

            UsedSubMenuNames.Add(uniqueSubMenuId ?? displayName);
            var subMenu = new Menu(displayName, AddonId, string.Concat(ValueContainer.SerializationId, ".", uniqueSubMenuId ?? displayName), longTitle, this);

            SubMenus.Add(subMenu);
            return(subMenu);
        }
示例#2
0
        public bool AddMenu(Menu menu)
        {
            if (menu == null || MenuExists(menu))
            {
                return(false);
            }

            SubMenus.Add(menu);
            return(true);
        }
        /// <summary>
        /// Creates A Empty Page For Adding Buttons To, If The Page Already Exists, This Will Return It. | Created By Plague | Discord Server: http://Krewella.co.uk/Discord
        /// </summary>
        /// <param name="name">
        /// The Name You Want To Give The Page/Find Internally.
        /// </param>
        internal static GameObject MakeEmptyPage(string name)
        {
            if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
            {
                HVH.API.HVHLogger.Log(ConsoleColor.Red, "Your Empty Page Name Cannot Be Empty!");
                return(null);
            }

            //If This Page Already Exists, Return It
            for (int i = 0; i < SubMenus.Count; i++)
            {
                GameObject menu = SubMenus[i];
                if (menu.name == "PlagueButtonAPI_" + name)
                {
                    return(menu);
                }
            }

            //Clone The ShortcutMenu
            Transform transform = UnityEngine.Object.Instantiate(ShortcutMenuTransform.gameObject).transform;

            //Change Internal Names
            transform.transform.name = "PlagueButtonAPI_" + name;
            transform.name           = "PlagueButtonAPI_" + name;

            //Remove All Buttons
            for (int i = 0; i < transform.childCount; i++)
            {
                UnityEngine.Object.Destroy(transform.GetChild(i).gameObject);
            }

            //Make This Page We Cloned A Child Of The QuickMenu
            transform.SetParent(GameObject.Find("/UserInterface/QuickMenu").GetComponent <QuickMenu>().transform, worldPositionStays: false);

            //Make This Page We Cloned Inactive By Default
            transform.gameObject.SetActive(value: false);

            //Add It To The Handler
            SubMenus.Add(transform.gameObject);

            //Return The GameObject For Handling It Elsewhere
            return(transform.gameObject);
        }
示例#4
0
        public Menu AddSubMenu(string displayName, string uniqueSubMenuId = null, string longTitle = null)
        {
            if (string.IsNullOrWhiteSpace(displayName))
            {
                throw new ArgumentNullException("displayName");
            }
            if (IsSubMenu)
            {
                throw new ArgumentException("Can't add a sub menu to a sub menu!");
            }
            if (UsedSubMenuNames.Contains(uniqueSubMenuId ?? displayName))
            {
                throw new ArgumentException(string.Format("A sub menu with that name ({0}) already exists!", uniqueSubMenuId ?? displayName));
            }

            UsedSubMenuNames.Add(uniqueSubMenuId ?? displayName);
            var subMenu = new Menu(displayName, AddonId, string.Concat(ValueContainer.SerializationId, ".", uniqueSubMenuId ?? displayName), longTitle, this);

            SubMenus.Add(subMenu);
            return(subMenu);
        }
示例#5
0
 public void Add(IMenuBuilder builder)
 {
     SubMenus.Add(builder);
 }
示例#6
0
 public void Add(Menu menu)
 {
     menu.Parent = this;
     SubMenus.Add(menu);
 }