/// <summary> /// Enters a new menu /// </summary> /// <param name="menu">Sub menu</param> public static void EnterMenu(Menu menu) { _menuStack.Push(menu); if (menu != null && menu.SelectedItem != null) { menu.SelectedItem.OnHighlighted(); } }
/// <summary> /// Adds a menu item into menu /// </summary> /// <param name="parent">Parent menu</param> /// <param name="text">Text</param> /// <param name="toggle">Is toggle</param> /// <param name="on">Is on</param> /// <param name="subMenu">Sub menu</param> /// <param name="activateEventHandler">Activated event handler</param> /// <param name="highlightedEventHandler">Highlighted event handler</param> /// <param name="preActivateEventHandler">Pre-activated event handler</param> public static MenuItem AddMenuItem(Menu parent, string text, bool toggle = false, bool on = false, Menu subMenu = null, MenuItemEventHandler activateEventHandler = null, MenuItemEventHandler preActivateEventHandler = null, MenuItemEventHandler highlightedEventHandler = null, object data = null) { MenuItem mi = new MenuItem() { Text = text, IsToggle = toggle, On = on, SubMenu = subMenu }; if (activateEventHandler != null) mi.Activated += activateEventHandler; if (preActivateEventHandler != null) mi.PreActivated += preActivateEventHandler; if (highlightedEventHandler != null) mi.Highlighted += highlightedEventHandler; mi.Data = data; parent.Add(mi); return mi; }
/// <summary> /// Initialize vehicle spawn menu /// </summary> private static void InitVehicleSpawnMenu() { Menus.Vehicles.SpawnVehicle = new Menu(MenuText.Vehicle.Spawn.I00_TITLE); for (int i = 0; i < VehicleStorage.MAIN_CATEGORIES.Length; i++) { MenuItem mi = AddMenuItem(Menus.Vehicles.SpawnVehicle, VehicleStorage.MAIN_CATEGORIES[i]); Menu subMenu = new Menu(VehicleStorage.MAIN_CATEGORIES[i]); if (i < VehicleStorage.SUB_CATEGORY_COUNT) { for (int j = 0; j < VehicleStorage.SUB_CATEGORIES[i].Length; j++) { MenuItem miSub = AddMenuItem(subMenu, VehicleStorage.SUB_CATEGORIES[i][j]); Menu menu = new Menu(VehicleStorage.SUB_CATEGORIES[i][j]); for (int k = 0; k < VehicleStorage.VEHICLES[i][j].Length; k++) { MenuItem miVehicle = AddMenuItem(menu, VehicleStorage.VEHICLES[i][j][k].Name, false, false, null, Feature.Vehicle.SpawnVehicle, null, null, VehicleStorage.VEHICLES[i][j][k]); } miSub.SubMenu = menu; } } else { for (int j = 0; j < VehicleStorage.VEHICLES[i][0].Length; j++) { MenuItem miVehicle = AddMenuItem(subMenu, VehicleStorage.VEHICLES[i][0][j].Name, false, false, null, Feature.Vehicle.SpawnVehicle, null, null, VehicleStorage.VEHICLES[i][0][j]); } } mi.SubMenu = subMenu; } }
/// <summary> /// Initializes get specific weapon menu /// </summary> private static void InitSpecificWeaponMenu() { Menus.Weapons.GetSpecificWeapon = new Menu(MenuText.Weapon.SpecificWeapon.I00_TITLE); Menu[] mCategory = new Menu[WeaponStorage.WEAPON_CATEGORY_COUNT]; for (int i = 0; i < WeaponStorage.WEAPON_CATEGORY_COUNT; i++) { mCategory[i] = new Menu(WeaponStorage.WEAPON_CATEGORY_NAMES[i]); Menu[] mWeapon = new Menu[Weapon.WeaponStorage.WEAPONS[i].Length]; for (int j = 0; j < WeaponStorage.WEAPONS[i].Length; j++) { mWeapon[j] = new Menu(WeaponStorage.WEAPONS[i][j].Name); AddMenuItem(mCategory[i], WeaponStorage.WEAPONS[i][j].Name, false, false, mWeapon[j], null, Feature.Weapon.PreEnterSpecificWeaponMenu, null, WeaponStorage.WEAPONS[i][j]); } AddMenuItem(Menus.Weapons.GetSpecificWeapon, WeaponStorage.WEAPON_CATEGORY_NAMES[i], false, false, mCategory[i]); } }
/// <summary> /// Initialize Secondary color menu /// </summary> private static void InitSecondaryColorMenu() { Menus.Vehicles.Paints.SecondaryColor = new Menu(MenuText.Vehicle.Paint.CHOOSE_PAINT_TYPE); for (int i = 0; i < PaintStorage.PAINT_TYPES.Length; i++) { Menu subMenu = new Menu(PaintStorage.PAINT_TYPES[i]); for (int j = 0; j < PaintStorage.PAINTS[i].Length; j++) { MenuItem mi = AddMenuItem(subMenu, PaintStorage.PAINTS[i][j].Name); mi.Data = PaintStorage.PAINTS[i][j]; mi.Highlighted += Feature.Vehicle.Paint.ApplyColor; } MenuItem m = AddMenuItem(Menus.Vehicles.Paints.SecondaryColor, PaintStorage.PAINT_TYPES[i], false, false, subMenu, null, Feature.Vehicle.Paint.PreEnterPaintTypeMenu, Feature.Vehicle.Paint.SelectPaintType, i); } }
/// <summary> /// Initialize location - location teleporter menu /// </summary> private static void InitLocationTeleporterMenu() { Menus.Locations.LTeleporter = new Menu(MenuText.Location.LocationTeleporter.I00_TITLE); AddMenuItem(Menus.Locations.LTeleporter, MenuText.Location.LocationTeleporter.I01_MAP_MARKER, false, false, null, Feature.Location.LocationTeleporter.MapMarker); foreach (TeleportCategory tc in TeleportTargetStorage.CATEGORIES) { Menu menu = new Menu(tc.Name); AddTeleportTargetsToMenu(menu, tc.Targets); AddMenuItem(Menus.Locations.LTeleporter, tc.Name, false, false, menu); } }
/// <summary> /// Adds teleport targets into menu /// </summary> /// <param name="parent">Parent menu</param> /// <param name="targets">Teleport targets</param> private static void AddTeleportTargetsToMenu(Menu parent, TeleportTarget[] targets) { foreach (TeleportTarget tt in targets) { MenuItem mi = AddMenuItem(parent, tt.Name, false, false, null, Feature.Location.LocationTeleporter.Target, null, null, tt); } }
/// <summary> /// Gets whether the specified menu is in the menu stack /// </summary> /// <param name="menu">Menu object</param> /// <returns>true if in the menu stack; otherwise false</returns> public static bool IsMenuInStack(Menu menu) { return _menuStack.Contains(menu); }
private static void GenerateSpecificWeaponMenu(Menu.Menu menu, WeaponData weapon) { menu.Clear(); int weaponHash = Function.Call<int>(Hash.GET_HASH_KEY, weapon.InternalValue); bool hasWeapon = HasWeapon(weaponHash); MenuStorage.AddMenuItem(menu, MenuText.Weapon.SpecificWeapon.HAS, true, hasWeapon, null, SetHasWeapon, null, null, weapon); if (hasWeapon) { Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character.Handle, weaponHash, true); int maxAmmo = Function.Call<int>(Hash.GET_MAX_AMMO_IN_CLIP, Game.Player.Character.Handle, weaponHash, false); if (maxAmmo > 0) { MenuStorage.AddMenuItem(menu, MenuText.Weapon.SpecificWeapon.FILL_AMMO_CLIP, false, false, null, SetFillAmmoClip, null, null, weapon); } if (weapon.AttachmentCount > 0) { for (int i = 0; i < weapon.AttachmentCount; i++) { WeaponData wd = weapon.Clone(); wd.SelectedAttachmentIndex = i; WeaponAttachmentData wad = weapon.GetAttachmentData(i); int hash = Function.Call<int>(Hash.GET_HASH_KEY, wad.InternalValue); bool has = HasAttachment(weaponHash, hash); MenuStorage.AddMenuItem(menu, wad.Name, true, has, null, SetAttachment, null, null, wd); } } if (weapon.HasTint) { int index = Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, Game.Player.Character.Handle, weaponHash); Menu.Menu menuTint = new Menu.Menu(MenuText.Weapon.SpecificWeapon.SELECT_TINT); for (int i = (int)WeaponStorage.WeaponTint.Normal; i <= (int)WeaponStorage.WeaponTint.Platinum; i++) { MenuStorage.AddMenuItem(menuTint, Enum.GetName(typeof(WeaponStorage.WeaponTint), (WeaponStorage.WeaponTint)i), false, false, null, null, null, SetWeaponTint, weapon); } menuTint.SelectedIndex = index; MenuStorage.AddMenuItem(menu, MenuText.Weapon.SpecificWeapon.TINT, false, false, menuTint); } } else { int unarmed = Function.Call<int>(Hash.GET_HASH_KEY, WeaponStorage.WEAPON_UNARMED); Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character.Handle, unarmed, true); } }
/// <summary> /// Sets auto save /// </summary> /// <param name="sender">Source menu item</param> public static void SetAutoSave(Menu.MenuItem sender) { AutoSave = sender.On; }