using System.Collections.Generic; namespace SAMP.API { public class Menu { #region Class Variables private static List _qMenuStore = new List(); private int _nId = -1; #endregion #region Constructor /// /// Creates a new Menu object. /// /// The title for the new menu. /// How many colums shall the new menu have. /// The position of the menu. /// The width for the first column. /// The width for the second column. public Menu(string title, int columns, Vector2 position, float col1width, float col2width=0.0f) { _nId = Core.Natives.CreateMenu(title, columns, position.X, position.Y, col1width, col2width); _qMenuStore.Add(this); } #endregion #region Accessors & Mutators /// /// Gets the ID of this Menu. /// internal int ID { get { return _nId; } } /// /// Sets the caption of a column in the menu. /// /// Which column in the menu shall be manipulated. /// The caption-text for the column. public void SetColumnHeader(int column, string text) { Core.Natives.SetMenuColumnHeader(this.ID, column, text); } #endregion #region Public Methods /// /// Finds the Menu whose ID is menuid. /// /// The menu ID to search for. /// Returns a Menu whose ID is menuid. internal static Menu Get(int menuid) { foreach(Menu menu in _qMenuStore) if(menu.ID == menuid) return menu; return null; } /// /// Determines whether the specified menu ID is valid. /// /// The menu ID to check. /// Returns a System.Boolean representing whether the specified menu ID is valid. public static bool IsValid(Menu menu) { return Core.Natives.IsValidMenu(menu.ID) == 1; } /// /// Adds an item to the Menu. /// /// The title for the new menu item. /// The column to add the item to. public void AddItem(string title, int column = 0) { Core.Natives.AddMenuItem(this.ID, column, title); } /// /// Destroys the Menu. Setting the object to null (destructing) calls this method. /// public bool Destroy() { _qMenuStore.Remove(this); return Core.Natives.DestroyMenu(this.ID) == 1; } /// /// Disables the Menu. /// public void Disable() { Core.Natives.DestroyMenu(this.ID); } /// /// Disables a row in the menu. /// public void DisableRow(int row) { Core.Natives.DisableMenuRow(this.ID, row); } #endregion }; };