private static async Task ProcessMenuPool() { MenuPool.ProcessMenus(); if (MenuPool.ToList().Count == 0 && Camera != null) { Camera = null; ShowShopMenu(); } if (Game.IsControlJustPressed(0, (Control)244) || Game.IsDisabledControlJustPressed(0, (Control)244)) //M { ShowInGameMenu(); } if (Game.IsControlJustPressed(0, (Control)174) || Game.IsDisabledControlJustPressed(0, (Control)174)) // left { if (User.GetStatusType() != StatusTypes.Spectator) { return; } var list = new NavigationList <Player>(); list.AddRange(new PlayerList().Where(p => !p.IsDead).Where(p => !p.IsInvincible)); try { User.StartSpec(list.MovePrevious); } catch (Exception e) { Debug.WriteLine($"{list.Count} | {e}"); User.StartSpec(list.First()); } } else if (Game.IsControlJustPressed(0, (Control)175) || Game.IsDisabledControlJustPressed(0, (Control)175)) // right { if (User.GetStatusType() != StatusTypes.Spectator) { return; } var list = new NavigationList <Player>(); list.AddRange(new PlayerList().Where(p => !p.IsDead).Where(p => !p.IsInvincible)); try { User.StartSpec(list.MoveNext); } catch (Exception e) { Debug.WriteLine($"{list.Count} | {e}"); User.StartSpec(list.Last()); } } }
/// <summary> /// Sets up the NativeUI menu /// </summary> private void SetupMenu() { if (menuPool != null) { menuPool.ToList().ForEach(menu => { menu.Clear(); }); } menu = new UIMenu("Two Player Mod", Enabled() ? "~g~Enabled" : "~r~Disabled"); menuPool.Add(menu); UIMenuItem toggleItem = new UIMenuItem("Toggle mod", "Toggle Two Player mode"); toggleItem.Activated += ToggleMod_Activated; menu.AddItem(toggleItem); UIMenu allPlayersMenu = menuPool.AddSubMenu(menu, "Players"); menu.MenuItems.FirstOrDefault(item => { return(item.Text.Equals("Players")); }).Description = "Configure players"; foreach (UserIndex player in userIndices) { bool check = bool.Parse(PlayerSettings.GetValue(player, EnabledKey, false.ToString())); UIMenu playerMenu = menuPool.AddSubMenu(allPlayersMenu, "Player " + player); UIMenuItem playerItem = allPlayersMenu.MenuItems.FirstOrDefault(item => { return(item.Text.Equals("Player " + player)); }); string controllerGuid = PlayerSettings.GetValue(player, ControllerKey, ""); playerItem.Description = "Configure player " + player; if (!string.IsNullOrEmpty(controllerGuid)) { playerItem.SetRightBadge(UIMenuItem.BadgeStyle.Star); } UIMenuCheckboxItem togglePlayerItem = new UIMenuCheckboxItem("Toggle player " + player, check, "Enables/disables this player"); togglePlayerItem.CheckboxEvent += (s, enabled) => { PlayerSettings.SetValue(player, EnabledKey, enabled.ToString()); RefreshSubItems(togglePlayerItem, playerMenu, enabled); }; playerMenu.AddItem(togglePlayerItem); playerMenu.AddItem(ConstructSettingsListItem(player, "Character", "Select a character for player " + player, CharacterHashKey, PedHash.Trevor)); playerMenu.AddItem(ConstructSettingsListItem(player, "Blip sprite", "Select a blip sprite for player " + player, BlipSpriteKey, BlipSprite.Standard)); playerMenu.AddItem(ConstructSettingsListItem(player, "Blip color", "Select a blip color for player " + player, BlipColorKey, BlipColor.Green)); UIMenu controllerMenu = menuPool.AddSubMenu(playerMenu, "Assign controller"); playerMenu.MenuItems.FirstOrDefault(item => { return(item.Text.Equals("Assign controller")); }).Description = "Assign controller to player " + player; foreach (InputManager manager in InputManager.GetAvailableInputManagers()) { UIMenuItem controllerItem = new UIMenuItem(manager.DeviceName, "Assign this controller to player " + player); string guid = manager.DeviceGuid; if (PlayerSettings.GetValue(player, ControllerKey, "").Equals(guid)) { controllerItem.SetRightBadge(UIMenuItem.BadgeStyle.Star); } if (manager is DirectInputManager) { DirectInputManager directManager = (DirectInputManager)manager; bool configured = DirectInputManager.IsConfigured(directManager.device, GetIniFile()); controllerItem.Enabled = configured; if (!configured) { controllerItem.Description = "Please configure this controller first from the main menu"; } } controllerItem.Activated += (s, i) => { if (i.Enabled) { PlayerSettings.SetValue(player, ControllerKey, guid); controllerMenu.MenuItems.ForEach(item => { if (item == controllerItem) { item.SetRightBadge(UIMenuItem.BadgeStyle.Star); } else { item.SetRightBadge(UIMenuItem.BadgeStyle.None); } }); } }; controllerMenu.AddItem(controllerItem); } RefreshSubItems(togglePlayerItem, playerMenu, check); } UIMenuCheckboxItem cameraItem = new UIMenuCheckboxItem("GTA:SA style camera", customCamera, "Enables/disables the GTA:SA style camera"); cameraItem.CheckboxEvent += (s, i) => { customCamera = !customCamera; Settings.SetValue(Name, CustomCameraKey, customCamera.ToString()); Settings.Save(); }; menu.AddItem(cameraItem); UIMenu controllersMenu = menuPool.AddSubMenu(menu, "Configure controllers"); menu.MenuItems.FirstOrDefault(item => { return(item.Text.Equals("Configure controllers")); }).Description = "Configure controllers before assigning them to players"; foreach (Joystick stick in DirectInputManager.GetDevices()) { UIMenuItem stickItem = new UIMenuItem(stick.Information.ProductName, "Configure " + stick.Information.ProductName); controllersMenu.AddItem(stickItem); stickItem.Activated += (s, i) => { ControllerWizard wizard = new ControllerWizard(stick); bool success = wizard.StartConfiguration(GetIniFile()); if (success) { UI.Notify("Controller successfully configured, you can now assign this controller"); } else { UI.Notify("Controller configuration canceled, please configure your controller before playing"); } SetupMenu(); }; } menu.RefreshIndex(); }
public StreetRaces() { Game.FadeScreenIn(500); Util.GetClasses(); ClassList = RaceClasses; //Enum.GetValues(typeof(Raceclass)).Cast<dynamic>().ToList(); Tick += OnTick; KeyDown += OnKeyDown; KeyUp += OnKeyUp; LoadRaceTriggers(); _menuPool = new MenuPool(); //Car Saver Menu RaceSetupMenu = new UIMenu("Race Setup", "Change your preferences before the race."); _menuPool.Add(RaceSetupMenu); AdvancedOptionsMenu = new UIMenu("Adv. Options", "For those who know what they're doing."); _menuPool.Add(AdvancedOptionsMenu); AdvancedOptions = new UIMenuItem("Advanced Options", ""); AdvancedOptions.SetLeftBadge(UIMenuItem.BadgeStyle.Michael); RaceSetupMenu.AddItem(AdvancedOptions); RaceSetupMenu.BindMenuToItem(AdvancedOptionsMenu, AdvancedOptions); CarClass = new UIMenuListItem("Vehicle Class", ClassList, 0); RaceSetupMenu.AddItem(CarClass); SetupCarsNumber = new UIMenuListItem("Nº of Racers", NumberOfRacersList, 0); RaceSetupMenu.AddItem(SetupCarsNumber); SetupLaps = new UIMenuListItem("Nº of Laps", LapsList, 0); RaceSetupMenu.AddItem(SetupLaps); MoneyBet = new UIMenuListItem("Bet", MoneyBetList, 0, "Each racer bets this ammount of money. The winner gets it all."); RaceSetupMenu.AddItem(MoneyBet); RaceSetupMenu.AddItem(UseNitro); RaceSetupMenu.AddItem(AllowHelicopter); RaceSetupMenu.AddItem(AIGodmode); RaceSetupMenu.AddItem(AllowFilling); ForceTuneconfig = new UIMenuListItem("Auto Opponent Tuning", TuneconfigListText, 0, "Opponent cars can be randomly tuned for more variety."); AdvancedOptionsMenu.AddItem(ForceTuneconfig); //Test AdvancedOptionsMenu.AddItem(ImmersiveCheckpoints); AdvancedOptionsMenu.AddItem(DebugMode); AdvancedOptionsMenu.AddItem(Traffic); AdvancedOptionsMenu.AddItem(AICatchup); AdvancedOptionsMenu.AddItem(AICurvePathing); AdvancedOptionsMenu.AddItem(AIRearEnd); AdvancedOptionsMenu.AddItem(AISlamToWall); AdvancedOptionsMenu.AddItem(AISpinout); StartRace = new UIMenuItem("Start Race", ""); RaceSetupMenu.AddItem(StartRace); foreach (UIMenu menu in _menuPool.ToList()) { menu.RefreshIndex(); menu.OnItemSelect += OnItemSelect; menu.OnListChange += OnListChange; menu.OnCheckboxChange += OnCheckboxChange; /* menu.OnIndexChange += OnItemChange; * menu.OnMenuClose += OnMenuClose;*/ } SetupCarsNumber.Index = Util.GetRandomInt(0, NumberOfRacersList.Count / 2); SetupLaps.Index = Util.GetRandomInt(0, LapsList.Count / 2); }