private static void VehicleControlMenu(UIMenu menu) { var clampItem = new UIMenuItem("Clamp Vehicle", "Clamp the nearest vehicle"); clampItem.SetRightBadge(UIMenuItem.BadgeStyle.Car); menu.AddItem(clampItem); var stickerItem = new UIMenuItem("Place Sticker", "Place a seized sticker on the nearest vehicle"); stickerItem.SetRightBadge(UIMenuItem.BadgeStyle.Car); menu.AddItem(stickerItem); var removeClamp = new UIMenuItem("Remove Object", "Removes a nearby clamp or sticker"); menu.AddItem(removeClamp); menu.OnItemSelect += (sender, item, index) => { if (item == stickerItem) { Main.StickerHandler(); } else if (item == clampItem) { Main.ClampHandler(); } else if (item == removeClamp) { Main.UpdateObject(); } Toggle(); }; }
private static void VehicleSpawnMenu(UIMenu menu) { foreach (var value in Main.Categories) { var category = menuPool.AddSubMenu(mainMenu, value); category.MouseControlsEnabled = false; foreach (KeyValuePair <string, Dictionary <string, string> > kvp in Main.VehicleDatabase) { foreach (KeyValuePair <string, string> categories in kvp.Value) { if (categories.Value == value) { var menuItem = new UIMenuItem(kvp.Key.Substring(categories.Value.Length), $"{categories.Key}"); menuItem.SetRightBadge(UIMenuItem.BadgeStyle.Car); category.AddItem(menuItem); var enabled = Main.Disabled.Contains(categories.Key); if (enabled) { menuItem.SetRightBadge(UIMenuItem.BadgeStyle.Lock); menuItem.Description = "Out of service"; } menuItem.Enabled = !enabled; } } } category.OnItemSelect += (sender, item, index) => { theItemDescription = String.Copy(item.Description); Main.SpawnVehicle(item.Description); BaseScript.TriggerEvent("chat:addMessage", new { color = new[] { 0, 0, 0 }, args = new[] { "[DokkaebiSpawner]", $"Spawned {theItemDescription} successfully." } }); Toggle(); }; } }
public void AddMenuStart(UIMenu menu) { UIMenuItem newitem = new UIMenuItem("Start", "Begin playing Undead Streets"); newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick); menu.AddItem(newitem); menu.OnItemSelect += delegate(UIMenu sender, UIMenuItem item, int index) { if (ReferenceEquals(item, newitem)) { this.mainMenu.Visible = !this.mainMenu.Visible; Main.StartMod(); } }; }
public void AddMenuStart(UIMenu menu) { var newitem = new UIMenuItem("Start", "Begin playing Undead Streets"); newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick); menu.AddItem(newitem); menu.OnItemSelect += (sender, item, index) => { if (item == newitem) { mainMenu.Visible = !mainMenu.Visible; Main.StartMod(); } }; }
private void AddMenuItemRequestAVehicle(UIMenu menu) { var newItem = new UIMenuItem("Request A Vehicle", "Request a new personal vehicle nearby."); newItem.SetRightBadge(UIMenuItem.BadgeStyle.Car); menu.AddItem(newItem); menu.OnItemSelect += (sender, item, index) => { if (item != newItem) { return; } //string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup."; //UI.ShowSubtitle(String.Format(output, dish)); UI.Notify("Requesting a vehicle"); PersonalVehicleController.DeployANewPersonalVehicle(CurrentPlayerName, true); }; }
public UIMenuItem AddMenuItem(UIMenu menu, string title = "Menu", string subTitle = "", string rightLabel = "", UIMenuItem.BadgeStyle badge = UIMenuItem.BadgeStyle.None, bool isBadgeLeft = true) { var menuItem = new UIMenuItem(title, subTitle); if (rightLabel != "") { menuItem.SetRightLabel(rightLabel); } if (isBadgeLeft) { menuItem.SetLeftBadge(badge); } else { menuItem.SetRightBadge(badge); } menu.AddItem(menuItem); return(menuItem); }
private void AddMenuItemSaveAVehicle(UIMenu menu) { var newItem = new UIMenuItem("Save Current Vehicle", "Save the vehicle you are currently in."); newItem.SetRightBadge(UIMenuItem.BadgeStyle.Car); menu.AddItem(newItem); menu.OnItemSelect += (sender, item, index) => { if (item != newItem) { return; } //Vehicle vehicle = Game.Player.Character.CurrentVehicle; // get the vehicle our player is in if (Game.Player.Character.CurrentVehicle == null) { UI.Notify("Player is not in a vehicle..."); return; } UI.Notify("Saving current vehicle..."); JsonController.SaveCurrentVehicleToJson(CurrentPlayerName); }; }
public void AddMenuCook(UIMenu menu) { var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."); newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star); newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick); menu.AddItem(newitem); menu.OnItemSelect += (sender, item, index) => { if (item == newitem) { string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup."; CitizenFX.Core.UI.Screen.ShowSubtitle(String.Format(output, dish)); } }; menu.OnIndexChange += (sender, index) => { if (sender.MenuItems[index] == newitem) { newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None); } }; }
/// <summary> /// Updates the player items. /// </summary> public void UpdatePlayerlist() { // Remove leftover menu items if they exist. if (menu.MenuItems.Count > 0) { menu.MenuItems.Clear(); } // Create a new player list. PlayerList pl = new PlayerList(); // Loop through the playerlist. foreach (Player p in pl) { // Create a button for this player and add it to the menu. UIMenuItem playerItem = new UIMenuItem(p.Name, "[" + (p.Handle < 10 ? "0" : "") + p.Handle + "] " + p.Name + " (Server ID: " + p.ServerId + ")"); playerItem.SetRightLabel("→→→"); menu.AddItem(playerItem); // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // If the player item is pressed. if (item == playerItem) { // Create the player object. Player player = new Player(int.Parse(item.Description.Substring(1, 2).ToString())); // Create the menu for the player & set the width offset. UIMenu PlayerMenu = new UIMenu(player.Name, "[" + (player.Handle < 10 ? "0" : "") + player.Handle + "] " + player.Name + " (Server ID: " + player.ServerId + ")", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; PlayerMenu.SetMenuWidthOffset(50); PlayerMenu.RefreshIndex(); PlayerMenu.UpdateScaleform(); // Create all player options buttons. UIMenuItem teleportBtn = new UIMenuItem("Teleport To Player", "Teleport to this player."); UIMenuItem teleportInVehBtn = new UIMenuItem("Teleport Into Vehicle", "Teleport into the player's vehicle."); UIMenuItem setWaypointBtn = new UIMenuItem("Set Waypoint", "Set a waypoint to this player."); UIMenuItem spectateBtn = new UIMenuItem("Spectate Player", "Spectate this player."); UIMenuItem summonBtn = new UIMenuItem("Summon Player", "Bring this player to your location."); summonBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem killBtn = new UIMenuItem("Kill Player", "Kill the selected player! Why are you so cruel :("); killBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem kickPlayerBtn = new UIMenuItem("~r~Kick Player", "~r~Kick~s~ this player from the server, you need to specify a reason " + "otherwise the kick will be cancelled."); kickPlayerBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem permBanBtn = new UIMenuItem("~r~Ban Player", "Ban the player from the server forever."); permBanBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem tempBanBtn = new UIMenuItem("~r~Tempban Player", "Ban the player from the server for the specified amount of hours. " + "The player will be able to rejoin after the ban expires."); tempBanBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); // Add all buttons to the player options submenu. Keeping permissions in mind. if (cf.IsAllowed(Permission.OPTeleport)) { PlayerMenu.AddItem(teleportBtn); PlayerMenu.AddItem(teleportInVehBtn); } if (cf.IsAllowed(Permission.OPWaypoint)) { PlayerMenu.AddItem(setWaypointBtn); } if (cf.IsAllowed(Permission.OPSpectate)) { PlayerMenu.AddItem(spectateBtn); } if (cf.IsAllowed(Permission.OPSummon)) { PlayerMenu.AddItem(summonBtn); } if (cf.IsAllowed(Permission.OPKill)) { PlayerMenu.AddItem(killBtn); } if (cf.IsAllowed(Permission.OPKick)) { PlayerMenu.AddItem(kickPlayerBtn); } if (cf.IsAllowed(Permission.OPTempBan)) { PlayerMenu.AddItem(tempBanBtn); } if (cf.IsAllowed(Permission.OPPermBan)) { PlayerMenu.AddItem(permBanBtn); } // Add the player menu to the menu pool. MainMenu.Mp.Add(PlayerMenu); // Set the menu invisible. menu.Visible = false; // Set the player menu visible. PlayerMenu.Visible = true; // If a button is pressed in the player's options menu. PlayerMenu.OnItemSelect += (sender2, item2, index2) => { // Teleport button is pressed. if (item2 == teleportBtn) { cf.TeleportToPlayerAsync(player.Handle, false); } // Teleport in vehicle button is pressed. else if (item2 == teleportInVehBtn) { cf.TeleportToPlayerAsync(player.Handle, true); } // Set waypoint button is pressed. else if (item2 == setWaypointBtn) { World.WaypointPosition = GetEntityCoords(GetPlayerPed(player.Handle), true); //Subtitle.Info($"A new waypoint has been set to ~y~{player.Name}~z~.", prefix: "Info:"); } // Spectate player button is pressed. else if (item2 == spectateBtn) { if (player.Handle == PlayerId()) { //Subtitle.Error("You can ~h~not~h~ spectate yourself!", prefix: "Error:"); Notify.Error("Sorry, you can ~r~~h~not~h~ ~s~spectate yourself!"); } else { cf.SpectateAsync(player.Handle); } } // Summon player button is pressed. else if (item2 == summonBtn) { if (player.Handle == PlayerId()) { Notify.Error("Sorry, you can ~r~~h~not~h~ ~s~summon yourself!"); } else { cf.SummonPlayer(player); } } // Kill player button is pressed. else if (item2 == killBtn) { //Subtitle.Info($"~y~{player.Name} ~z~has been killed.", prefix: "Info:"); Notify.Success($"Player ~y~<C>{player.Name}</C> ~s~has been killed."); cf.KillPlayer(player); } // Kick player button is pressed. else if (item2 == kickPlayerBtn) { // Close the menu. PlayerMenu.GoBack(); // Kick the player. cf.KickPlayer(player, true); // Update the player list. UpdatePlayerlist(); // Refresh the index & update scaleform. menu.RefreshIndex(); menu.UpdateScaleform(); } else if (item2 == tempBanBtn) { cf.BanPlayer(player: player, forever: false); } else if (item2 == permBanBtn) { cf.BanPlayer(player: player, forever: true); } }; // Reopen the playerlist menu when a player specific menu is closed. PlayerMenu.OnMenuClose += (sender2) => { menu.Visible = true; }; } }; } ; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { string menuTitle = "Saved Vehicles"; #region Create menus and submenus // Create the menu. menu = new UIMenu(menuTitle, "Manage Saved Vehicles", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create submenus. UIMenu spawnSavedVehicles = new UIMenu(menuTitle, "Spawn Saved Vehicle", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; UIMenu deleteSavedVehicles = new UIMenu(menuTitle, "~r~Delete Saved Vehicle", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; #endregion #region Create, add and bind buttons to the menus. // Create menu buttons. UIMenuItem saveVeh = new UIMenuItem("Save Current Vehicle", "Save the vehicle you are currently in."); saveVeh.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuItem savedVehiclesBtn = new UIMenuItem("Spawn Saved Vehicle", "Select a vehicle from your saved vehicles list."); savedVehiclesBtn.SetRightLabel("→→→"); UIMenuItem deleteSavedVehiclesBtn = new UIMenuItem("~r~Delete Saved Vehicle", "~r~Delete ~s~a saved vehicle."); deleteSavedVehiclesBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Alert); deleteSavedVehiclesBtn.SetRightLabel("→→→"); // Add buttons to the menu. menu.AddItem(saveVeh); menu.AddItem(savedVehiclesBtn); menu.AddItem(deleteSavedVehiclesBtn); // Bind submenus to menu items. if (cf.IsAllowed(Permission.SVSpawn)) { menu.BindMenuToItem(spawnSavedVehicles, savedVehiclesBtn); } else { savedVehiclesBtn.Enabled = false; savedVehiclesBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); savedVehiclesBtn.Description = "This option has been disabled by the server owner."; } menu.BindMenuToItem(deleteSavedVehicles, deleteSavedVehiclesBtn); #endregion #region Button pressed events // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Save the current vehicle. if (item == saveVeh) { cf.SaveVehicle(); } // Open and refresh the "spawn saved vehicle from list" submenu. else if (item == savedVehiclesBtn) { // Remove all old items. spawnSavedVehicles.MenuItems.Clear(); // Get all saved vehicles. SavedVehiclesDict = cf.GetSavedVehicles(); // Loop through all saved vehicles and create a button for it, then add that button to the submenu. foreach (KeyValuePair <string, CommonFunctions.VehicleInfo> savedVehicle in SavedVehiclesDict) { //MainMenu.Cf.Log(savedVehicle.ToString()); UIMenuItem vehBtn = new UIMenuItem(savedVehicle.Key.Substring(4), "Click to spawn this saved vehicle."); vehBtn.SetRightLabel($"({savedVehicle.Value.name})"); spawnSavedVehicles.AddItem(vehBtn); if (!IsModelInCdimage(savedVehicle.Value.model)) { vehBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); vehBtn.Enabled = false; vehBtn.Description = "This model is not available on this server, if this is an addon vehicle or DLC vehicle, please make sure " + "that it's being streamed on this server."; } else { if (!VehicleSpawner.allowedCategories[GetVehicleClassFromName(savedVehicle.Value.model)]) { vehBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); vehBtn.Enabled = false; vehBtn.Description = "This vehicle is not available on this server because you do not have permissions for this vehicle class."; } } } // Sort the menu items (case IN-sensitive) by name. spawnSavedVehicles.MenuItems.Sort((pair1, pair2) => pair1.Text.ToString().ToLower().CompareTo(pair2.Text.ToString().ToLower())); // Refresh the index of the page. spawnSavedVehicles.RefreshIndex(); // Update the scaleform. spawnSavedVehicles.UpdateScaleform(); } // Delete saved vehicle. else if (item == deleteSavedVehiclesBtn) { deleteSavedVehicles.MenuItems.Clear(); // Get the dictionary containing all saved vehicles. SavedVehiclesDict = cf.GetSavedVehicles(); // Loop through the list and add all saved vehicles to the menu. foreach (KeyValuePair <string, CommonFunctions.VehicleInfo> savedVehicle in SavedVehiclesDict) { //MainMenu.Cf.Log(savedVehicle.ToString()); UIMenuItem vehBtn = new UIMenuItem(savedVehicle.Key.Substring(4), "Are you sure you want to delete this saved vehicle? This action cannot be undone!"); vehBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Alert); vehBtn.SetRightLabel($"({savedVehicle.Value.name})"); deleteSavedVehicles.AddItem(vehBtn); } // Sort the menu items (case IN-sensitive) by name. deleteSavedVehicles.MenuItems.Sort((pair1, pair2) => pair1.Text.ToString().ToLower().CompareTo(pair2.Text.ToString().ToLower())); deleteSavedVehicles.RefreshIndex(); deleteSavedVehicles.UpdateScaleform(); } }; #endregion #region Handle saved vehicles being pressed. (spawning) // When a vehicle is selected... spawnSavedVehicles.OnItemSelect += (sender2, item2, index2) => { CommonFunctions.VehicleInfo vehInfo = SavedVehiclesDict["veh_" + item2.Text]; // Spawn a vehicle using the hash, and pass on the vehicleInfo dictionary containing all saved vehicle mods. if (MainMenu.VehicleSpawnerMenu != null) { cf.SpawnVehicle(vehInfo.model, MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, false, vehicleInfo: vehInfo, saveName: item2.Text); } else { cf.SpawnVehicle(vehInfo.model, true, true, false, vehicleInfo: vehInfo, saveName: item2.Text); } }; // Handle vehicle deletions deleteSavedVehicles.OnItemSelect += (sender2, item2, index2) => { var vehDictName = "veh_" + item2.Text; new StorageManager().DeleteSavedStorageItem(vehDictName); deleteSavedVehicles.GoBack(); }; #endregion // Add the submenus to the menu pool. MainMenu.Mp.Add(spawnSavedVehicles); MainMenu.Mp.Add(deleteSavedVehicles); }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Create the menu. menu = new UIMenu("BigFam Crew", "Misc Settings", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; UIMenu teleportMenu = new UIMenu("BigFam Crew", "Teleport Locations", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; UIMenuItem teleportMenuBtn = new UIMenuItem("Teleport Locations", "Teleport to pre-configured locations, added by the server owner."); menu.BindMenuToItem(teleportMenu, teleportMenuBtn); MainMenu.Mp.Add(teleportMenu); // Create the menu items. UIMenuItem tptowp = new UIMenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); UIMenuCheckboxItem speedKmh = new UIMenuCheckboxItem("Show Speed KM/H", ShowSpeedoKmh, "Show a speedometer on your screen indicating your speed in KM/h."); UIMenuCheckboxItem speedMph = new UIMenuCheckboxItem("Show Speed MPH", ShowSpeedoMph, "Show a speedometer on your screen indicating your speed in MPH."); UIMenuCheckboxItem coords = new UIMenuCheckboxItem("Show Coordinates", ShowCoordinates, "Show your current coordinates at the top of your screen."); UIMenuCheckboxItem hideRadar = new UIMenuCheckboxItem("Hide Radar", HideRadar, "Hide the radar/minimap."); UIMenuCheckboxItem hideHud = new UIMenuCheckboxItem("Hide Hud", HideHud, "Hide all hud elements."); UIMenuCheckboxItem showLocation = new UIMenuCheckboxItem("Location Display", ShowLocation, "Shows your current location and heading, as well as the nearest cross road. Just like PLD."); UIMenuItem saveSettings = new UIMenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu."); saveSettings.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuCheckboxItem joinQuitNotifs = new UIMenuCheckboxItem("Join / Quit Notifications", JoinQuitNotifications, "Receive notifications when someone joins or leaves the server."); UIMenuCheckboxItem deathNotifs = new UIMenuCheckboxItem("Death Notifications", DeathNotifications, "Receive notifications when someone dies or gets killed."); UIMenuCheckboxItem nightVision = new UIMenuCheckboxItem("Toggle Night Vision", false, "Enable or disable night vision."); UIMenuCheckboxItem thermalVision = new UIMenuCheckboxItem("Toggle Thermal Vision", false, "Enable or disable thermal vision."); UIMenuItem clearArea = new UIMenuItem("Clear Area", "Clears the area around your player (100 meters) of everything! Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up and reset."); UIMenuCheckboxItem lockCamX = new UIMenuCheckboxItem("Lock Camera Horizontal Rotation", false, "Locks your camera horizontal rotation. Could be useful in helicopters I guess."); UIMenuCheckboxItem lockCamY = new UIMenuCheckboxItem("Lock Camera Vertical Rotation", false, "Locks your camera vertical rotation. Could be useful in helicopters I guess."); UIMenu connectionSubmenu = new UIMenu(GetPlayerName(PlayerId()), "Connection Options", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; UIMenuItem connectionSubmenuBtn = new UIMenuItem("Connection Options", "Server connection/game quit options."); UIMenuItem quitSession = new UIMenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. " + "Use this if you need to have addons streamed but want to use the rockstar editor."); UIMenuItem quitGame = new UIMenuItem("Quit Game", "Exits the game after 5 seconds."); UIMenuItem disconnectFromServer = new UIMenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. " + "~r~This feature is not recommended, quit the game instead for a better experience."); connectionSubmenu.AddItem(quitSession); connectionSubmenu.AddItem(quitGame); connectionSubmenu.AddItem(disconnectFromServer); UIMenuCheckboxItem locationBlips = new UIMenuCheckboxItem("Location Blips", ShowLocationBlips, "Shows blips on the map for some common locations."); UIMenuCheckboxItem playerBlips = new UIMenuCheckboxItem("Show Player Blips", ShowPlayerBlips, "Shows blips on the map for all players."); MainMenu.Mp.Add(connectionSubmenu); connectionSubmenu.RefreshIndex(); connectionSubmenu.UpdateScaleform(); menu.BindMenuToItem(connectionSubmenu, connectionSubmenuBtn); connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { cf.QuitGame(); } else if (item == quitSession) { cf.QuitSession(); } else if (item == disconnectFromServer) { BaseScript.TriggerServerEvent("vMenu:DisconnectSelf"); } }; // Add menu items to the menu. if (cf.IsAllowed(Permission.MSTeleportToWp)) { menu.AddItem(tptowp); } // Always allowed // menu.AddItem(speedKmh); // menu.AddItem(speedMph); if (cf.IsAllowed(Permission.MSConnectionMenu)) { menu.AddItem(connectionSubmenuBtn); connectionSubmenuBtn.SetRightLabel("→→→"); } if (cf.IsAllowed(Permission.MSShowCoordinates)) { menu.AddItem(coords); } if (cf.IsAllowed(Permission.MSShowLocation)) { menu.AddItem(showLocation); } if (cf.IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddItem(deathNotifs); } if (cf.IsAllowed(Permission.MSDeathNotifs)) { menu.AddItem(joinQuitNotifs); } if (cf.IsAllowed(Permission.MSNightVision)) { menu.AddItem(nightVision); } if (cf.IsAllowed(Permission.MSThermalVision)) { menu.AddItem(thermalVision); } if (cf.IsAllowed(Permission.MSLocationBlips)) { menu.AddItem(locationBlips); ToggleBlips(ShowLocationBlips); } if (cf.IsAllowed(Permission.MSPlayerBlips)) { menu.AddItem(playerBlips); } if (cf.IsAllowed(Permission.MSTeleportLocations)) { menu.AddItem(teleportMenuBtn); teleportMenuBtn.SetRightLabel("→→→"); string json = LoadResourceFile(GetCurrentResourceName(), "config/locations.json"); if (string.IsNullOrEmpty(json)) { Notify.Error("An error occurred while loading the locations file."); } else { try { Newtonsoft.Json.Linq.JObject data = JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>(json); foreach (Newtonsoft.Json.Linq.JToken teleport in data["teleports"]) { string name = teleport["name"].ToString(); float heading = (float)teleport["heading"]; Vector3 coordinates = new Vector3((float)teleport["coordinates"]["x"], (float)teleport["coordinates"]["y"], (float)teleport["coordinates"]["z"]); UIMenuItem tpBtn = new UIMenuItem(name, $"Teleport to X: {(int)coordinates.X} Y: {(int)coordinates.Y} Z: {(int)coordinates.Z} HEADING: {(int)heading}."); teleportMenu.AddItem(tpBtn); tpLocations.Add(coordinates); tpLocationsHeading.Add(heading); } teleportMenu.OnItemSelect += async(sender, item, index) => { await cf.TeleportToCoords(tpLocations[index], true); SetEntityHeading(PlayerPedId(), tpLocationsHeading[index]); }; } catch (JsonReaderException ex) { Debug.Write($"\n[vMenu] An error occurred whie loading the teleport locations!\nReport the following error details to the server owner:\n{ex.Message}.\n"); } } } if (cf.IsAllowed(Permission.MSClearArea)) { menu.AddItem(clearArea); } // Always allowed // menu.AddItem(hideRadar); menu.AddItem(hideHud); menu.AddItem(lockCamX); // menu.AddItem(lockCamY); menu.AddItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, _checked) => { if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == coords) { ShowCoordinates = _checked; } else if (item == hideHud) { HideHud = _checked; } else if (item == hideRadar) { HideRadar = _checked; if (!_checked) { DisplayRadar(true); } } else if (item == showLocation) { ShowLocation = _checked; } else if (item == deathNotifs) { DeathNotifications = _checked; } else if (item == joinQuitNotifs) { JoinQuitNotifications = _checked; } else if (item == nightVision) { SetNightvision(_checked); } else if (item == thermalVision) { SetSeethrough(_checked); } else if (item == lockCamX) { LockCameraX = _checked; } else if (item == lockCamY) { LockCameraY = _checked; } else if (item == locationBlips) { ToggleBlips(_checked); ShowLocationBlips = _checked; } else if (item == playerBlips) { ShowPlayerBlips = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { cf.TeleportToWp(); } // save settings else if (item == saveSettings) { UserDefaults.SaveSettings(); } // clear area else if (item == clearArea) { var pos = Game.PlayerPed.Position; ClearAreaOfEverything(pos.X, pos.Y, pos.Z, 100f, false, false, false, false); } }; }
private void CreateMenu() { VehicleData vd = new VehicleData(); allowedCategories = new List <bool>() { cf.IsAllowed(Permission.VSCompacts), cf.IsAllowed(Permission.VSSedans), cf.IsAllowed(Permission.VSSUVs), cf.IsAllowed(Permission.VSCoupes), cf.IsAllowed(Permission.VSMuscle), cf.IsAllowed(Permission.VSSportsClassic), cf.IsAllowed(Permission.VSSports), cf.IsAllowed(Permission.VSSuper), cf.IsAllowed(Permission.VSMotorcycles), cf.IsAllowed(Permission.VSOffRoad), cf.IsAllowed(Permission.VSIndustrial), cf.IsAllowed(Permission.VSUtility), cf.IsAllowed(Permission.VSVans), cf.IsAllowed(Permission.VSCycles), cf.IsAllowed(Permission.VSBoats), cf.IsAllowed(Permission.VSHelicopters), cf.IsAllowed(Permission.VSPlanes), cf.IsAllowed(Permission.VSService), cf.IsAllowed(Permission.VSEmergency), cf.IsAllowed(Permission.VSMilitary), cf.IsAllowed(Permission.VSCommercial), cf.IsAllowed(Permission.VSTrains), }; // Create the menu. menu = new UIMenu(GetPlayerName(PlayerId()), "Vehicle Spawner", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create the buttons and checkboxes. UIMenuItem spawnByName = new UIMenuItem("Spawn Vehicle By Model Name", "Enter the name of a vehicle to spawn."); UIMenuCheckboxItem spawnInVeh = new UIMenuCheckboxItem("Spawn Inside Vehicle", SpawnInVehicle, "This will teleport you into the vehicle when you spawn it."); UIMenuCheckboxItem replacePrev = new UIMenuCheckboxItem("Replace Previous Vehicle", SpawnInVehicle, "This will automatically delete your previously spawned vehicle when you spawn a new vehicle."); // Add the items to the menu. if (cf.IsAllowed(Permission.VSSpawnByName)) { menu.AddItem(spawnByName); } menu.AddItem(spawnInVeh); menu.AddItem(replacePrev); // Create the submenus for each category. var vl = new Vehicles(); // Loop through all the vehicle classes. for (var vehClass = 0; vehClass < 22; vehClass++) { // Get the class name. string className = cf.GetLocalizedName($"VEH_CLASS_{vehClass.ToString()}"); // Create a button & a menu for it, add the menu to the menu pool and add & bind the button to the menu. UIMenuItem btn = new UIMenuItem(className, $"Spawn a vehicle from the ~o~{className} ~s~class."); btn.SetRightLabel("→→→"); UIMenu vehicleClassMenu = new UIMenu("Vehicle Spawner", className, true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; MainMenu.Mp.Add(vehicleClassMenu); menu.AddItem(btn); if (allowedCategories[vehClass]) { menu.BindMenuToItem(vehicleClassMenu, btn); } else { btn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); btn.Description = "This category has been disabled by the server owner."; btn.Enabled = false; } // Create a dictionary for the duplicate vehicle names (in this vehicle class). var duplicateVehNames = new Dictionary <string, int>(); // Loop through all the vehicles in the vehicle class. foreach (var veh in vl.VehicleClasses[className]) { // Convert the model name to start with a Capital letter, converting the other characters to lowercase. var properCasedModelName = veh[0].ToString().ToUpper() + veh.ToLower().Substring(1); // Get the localized vehicle name, if it's "NULL" (no label found) then use the "properCasedModelName" created above. var vehName = cf.GetVehDisplayNameFromModel(veh) != "NULL" ? cf.GetVehDisplayNameFromModel(veh) : properCasedModelName; // Loop through all the menu items and check each item's title/text and see if it matches the current vehicle (display) name. var duplicate = false; for (var itemIndex = 0; itemIndex < vehicleClassMenu.MenuItems.Count; itemIndex++) { // If it matches... if (vehicleClassMenu.MenuItems[itemIndex].Text.ToString() == vehName) { // Check if the model was marked as duplicate before. if (duplicateVehNames.Keys.Contains(vehName)) { // If so, add 1 to the duplicate counter for this model name. duplicateVehNames[vehName]++; } // If this is the first duplicate, then set it to 2. else { duplicateVehNames[vehName] = 2; } // The model name is a duplicate, so get the modelname and add the duplicate amount for this model name to the end of the vehicle name. vehName += $" ({duplicateVehNames[vehName].ToString()})"; // Then create and add a new button for this vehicle. if (cf.DoesModelExist(veh)) { var vehBtn = new UIMenuItem(vehName) { Enabled = true }; vehicleClassMenu.AddItem(vehBtn); } else { var vehBtn = new UIMenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false }; vehicleClassMenu.AddItem(vehBtn); vehBtn.SetRightBadge(UIMenuItem.BadgeStyle.Lock); } // Mark duplicate as true and break from the loop because we already found the duplicate. duplicate = true; break; } } // If it's not a duplicate, add the model name. if (!duplicate) { if (cf.DoesModelExist(veh)) { var vehBtn = new UIMenuItem(vehName) { Enabled = true }; vehicleClassMenu.AddItem(vehBtn); } else { var vehBtn = new UIMenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false }; vehicleClassMenu.AddItem(vehBtn); vehBtn.SetRightBadge(UIMenuItem.BadgeStyle.Lock); } } } vehicleClassMenu.OnItemSelect += (sender2, item2, index2) => { cf.SpawnVehicle(vl.VehicleClasses[className][index2], SpawnInVehicle, ReplaceVehicle); }; } // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == spawnByName) { // Passing "custom" as the vehicle name, will ask the user for input. cf.SpawnVehicle("custom", SpawnInVehicle, ReplaceVehicle); } }; // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, _checked) => { if (item == spawnInVeh) { SpawnInVehicle = _checked; } else if (item == replacePrev) { ReplaceVehicle = _checked; } }; }
private void CreateMenu() { //VehicleData vd = new VehicleData(); #region initial setup. // Create the menu. menu = new UIMenu("BigFam Crew", "Vehicle Spawner", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create the buttons and checkboxes. UIMenuItem spawnByName = new UIMenuItem("Spawn Vehicle By Model Name", "Enter the name of a vehicle to spawn."); UIMenuCheckboxItem spawnInVeh = new UIMenuCheckboxItem("Spawn Inside Vehicle", SpawnInVehicle, "This will teleport you into the vehicle when you spawn it."); UIMenuCheckboxItem replacePrev = new UIMenuCheckboxItem("Replace Previous Vehicle", ReplaceVehicle, "This will automatically delete your previously spawned vehicle when you spawn a new vehicle."); // Add the items to the menu. if (cf.IsAllowed(Permission.VSSpawnByName)) { // menu.AddItem(spawnByName); } //menu.AddItem(spawnInVeh); //menu.AddItem(replacePrev); #endregion #region addon cars menu // Vehicle Addons List UIMenu addonCarsMenu = new UIMenu("Addon Vehicles", "Spawn An Addon Vehicle", true) { MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false, ScaleWithSafezone = false }; UIMenuItem addonCarsBtn = new UIMenuItem("Addon Vehicles", "A list of addon vehicles available on this server."); addonCarsBtn.SetRightLabel("→→→"); menu.AddItem(addonCarsBtn); if (cf.IsAllowed(Permission.VSAddon)) { if (AddonVehicles != null) { if (AddonVehicles.Count > 0) { menu.BindMenuToItem(addonCarsMenu, addonCarsBtn); MainMenu.Mp.Add(addonCarsMenu); foreach (KeyValuePair <string, uint> veh in AddonVehicles) { string localizedName = GetLabelText(GetDisplayNameFromVehicleModel(veh.Value)); string name = localizedName != "NULL" ? localizedName : GetDisplayNameFromVehicleModel(veh.Value); name = name != "CARNOTFOUND" ? name : veh.Key; UIMenuItem carBtn = new UIMenuItem(name, $"Click to spawn {name}."); carBtn.SetRightLabel($"({veh.Key.ToString()})"); if (!IsModelInCdimage(veh.Value)) { carBtn.Enabled = false; carBtn.Description = "This vehicle is not available. Please ask the server owner to check if the vehicle is being streamed correctly."; carBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); } addonCarsMenu.AddItem(carBtn); } /* * //AddonVehicles.ToList(); * List<UIMenuItem> buttonsList = new List<UIMenuItem> { }; * menu.BindMenuToItem(addonCarsMenu, addonCarsBtn); * MainMenu.Mp.Add(addonCarsMenu); * foreach (KeyValuePair<string, uint> veh in AddonVehicles) * { * string localizedName = GetLabelText(GetDisplayNameFromVehicleModel(veh.Value)); * string name = localizedName != "NULL" ? localizedName : GetDisplayNameFromVehicleModel(veh.Value); * name = name != "CARNOTFOUND" ? name : veh.Key; * UIMenuItem carBtn = new UIMenuItem(name, $"Click to spawn {name}."); * carBtn.SetRightLabel($"({veh.Key.ToString()})"); * if (!IsModelInCdimage(veh.Value)) * { * carBtn.Enabled = false; * carBtn.Description = "This vehicle is not available. Please ask the server owner to check if the vehicle is being streamed correctly."; * carBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); * } * * buttonsList.Add(carBtn); * } * * buttonsList.Sort((prev, next) => String.Compare(prev.Text, next.Text)); * * buttonsList.ForEach(carBtn => * { * addonCarsMenu.AddItem(carBtn); * }); */ addonCarsMenu.OnItemSelect += (sender, item, index) => { cf.SpawnVehicle(AddonVehicles.ElementAt(index).Key, SpawnInVehicle, ReplaceVehicle); }; addonCarsMenu.RefreshIndex(); addonCarsMenu.UpdateScaleform(); } else { addonCarsBtn.Enabled = false; addonCarsBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); addonCarsBtn.Description = "There are no addon vehicles available on this server."; } } else { addonCarsBtn.Enabled = false; addonCarsBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); addonCarsBtn.Description = "The list containing all addon cars could not be loaded, is it configured properly?"; } } else { addonCarsBtn.Enabled = false; addonCarsBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); addonCarsBtn.Description = "Access to this list has been restricted by the server owner."; } #endregion #region vehicle classes submenus // Create the submenus for each category. var vl = new Vehicles(); // Loop through all the vehicle classes. for (var vehClass = 0; vehClass < 22; vehClass++) { // Get the class name. string className = cf.GetLocalizedName($"VEH_CLASS_{vehClass.ToString()}"); // Create a button & a menu for it, add the menu to the menu pool and add & bind the button to the menu. UIMenuItem btn = new UIMenuItem(className, $"Spawn a vehicle from the ~o~{className} ~s~class."); btn.SetRightLabel("→→→"); UIMenu vehicleClassMenu = new UIMenu("Vehicle Spawner", className, true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; /* * MainMenu.Mp.Add(vehicleClassMenu); * menu.AddItem(btn); * * if (allowedCategories[vehClass]) * { * menu.BindMenuToItem(vehicleClassMenu, btn); * } * else * { * btn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); * btn.Description = "This category has been disabled by the server owner."; * btn.Enabled = false; * } */ // Create a dictionary for the duplicate vehicle names (in this vehicle class). var duplicateVehNames = new Dictionary <string, int>(); #region Add vehicles per class // Loop through all the vehicles in the vehicle class. foreach (var veh in vl.VehicleClasses[className]) { // Convert the model name to start with a Capital letter, converting the other characters to lowercase. var properCasedModelName = veh[0].ToString().ToUpper() + veh.ToLower().Substring(1); // Get the localized vehicle name, if it's "NULL" (no label found) then use the "properCasedModelName" created above. var vehName = cf.GetVehDisplayNameFromModel(veh) != "NULL" ? cf.GetVehDisplayNameFromModel(veh) : properCasedModelName; // Loop through all the menu items and check each item's title/text and see if it matches the current vehicle (display) name. var duplicate = false; for (var itemIndex = 0; itemIndex < vehicleClassMenu.MenuItems.Count; itemIndex++) { // If it matches... if (vehicleClassMenu.MenuItems[itemIndex].Text.ToString() == vehName) { // Check if the model was marked as duplicate before. if (duplicateVehNames.Keys.Contains(vehName)) { // If so, add 1 to the duplicate counter for this model name. duplicateVehNames[vehName]++; } // If this is the first duplicate, then set it to 2. else { duplicateVehNames[vehName] = 2; } // The model name is a duplicate, so get the modelname and add the duplicate amount for this model name to the end of the vehicle name. vehName += $" ({duplicateVehNames[vehName].ToString()})"; // Then create and add a new button for this vehicle. if (cf.DoesModelExist(veh)) { var vehBtn = new UIMenuItem(vehName) { Enabled = true }; vehicleClassMenu.AddItem(vehBtn); } else { var vehBtn = new UIMenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false }; vehicleClassMenu.AddItem(vehBtn); vehBtn.SetRightBadge(UIMenuItem.BadgeStyle.Lock); } // Mark duplicate as true and break from the loop because we already found the duplicate. duplicate = true; break; } } // If it's not a duplicate, add the model name. if (!duplicate) { if (cf.DoesModelExist(veh)) { var vehBtn = new UIMenuItem(vehName) { Enabled = true }; vehicleClassMenu.AddItem(vehBtn); } else { var vehBtn = new UIMenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false }; vehicleClassMenu.AddItem(vehBtn); vehBtn.SetRightBadge(UIMenuItem.BadgeStyle.Lock); } } } #endregion // Handle button presses vehicleClassMenu.OnItemSelect += (sender2, item2, index2) => { cf.SpawnVehicle(vl.VehicleClasses[className][index2], SpawnInVehicle, ReplaceVehicle); }; } #endregion #region handle events // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == spawnByName) { // Passing "custom" as the vehicle name, will ask the user for input. cf.SpawnVehicle("custom", SpawnInVehicle, ReplaceVehicle); } }; // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, _checked) => { if (item == spawnInVeh) { SpawnInVehicle = _checked; } else if (item == replacePrev) { ReplaceVehicle = _checked; } }; #endregion }
/// <summary> /// Creates the menu(s). /// </summary> private void CreateMenu() { // Create the menu. menu = new UIMenu(GetPlayerName(PlayerId()), "Player Appearance", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; //Create the submenus. spawnSavedPedMenu = new UIMenu("Saved Peds", "Spawn a saved ped", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; deleteSavedPedMenu = new UIMenu("Saved Peds", "Delete a saved ped", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; pedTextures = new UIMenu("Ped Customization", "Customize your ped", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Add the (submenus) to the menu pool. MainMenu.Mp.Add(pedTextures); MainMenu.Mp.Add(spawnSavedPedMenu); MainMenu.Mp.Add(deleteSavedPedMenu); // Create the menu items. UIMenuItem pedCustomization = new UIMenuItem("Ped Customization", "Modify your ped's appearance."); pedCustomization.SetRightLabel("→→→"); UIMenuItem savePed = new UIMenuItem("Save Current Ped", "Save your current ped and clothes."); savePed.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuItem spawnSavedPed = new UIMenuItem("Spawn Saved Ped", "Spawn one of your saved peds."); spawnSavedPed.SetRightLabel("→→→"); UIMenuItem deleteSavedPed = new UIMenuItem("Delete Saved Ped", "Delete one of your saved peds."); deleteSavedPed.SetRightLabel("→→→"); deleteSavedPed.SetLeftBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem spawnByName = new UIMenuItem("Spawn Ped By Name", "Enter a model name of a custom ped you want to spawn."); List <dynamic> walkstyles = new List <dynamic>() { "Normal", "Injured", "Tough Guy", "Femme", "Gangster", "Posh", "Sexy", "Business", "Drunk", "Hipster" }; UIMenuListItem walkingStyle = new UIMenuListItem("Walking Style", walkstyles, 0, "Change the walking style of your current ped. " + "You need to re-apply this each time you change player model or load a saved ped."); // Add items to the mneu. menu.AddItem(pedCustomization); menu.AddItem(savePed); menu.AddItem(spawnSavedPed); menu.AddItem(deleteSavedPed); menu.AddItem(walkingStyle); // Bind items to the submenus. if (cf.IsAllowed(Permission.PACustomize)) { menu.BindMenuToItem(pedTextures, pedCustomization); } else { pedCustomization.Enabled = false; pedCustomization.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); pedCustomization.Description = "This option has been disabled by the server owner."; } if (cf.IsAllowed(Permission.PASpawnSaved)) { menu.BindMenuToItem(spawnSavedPedMenu, spawnSavedPed); } else { spawnSavedPed.Enabled = false; spawnSavedPed.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); spawnSavedPed.Description = "This option has been disabled by the server owner."; } menu.BindMenuToItem(deleteSavedPedMenu, deleteSavedPed); UIMenu addonPeds = new UIMenu("Model Spawner", "Spawn Addon Ped", true) { MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false, ScaleWithSafezone = false }; UIMenuItem addonPedsBtn = new UIMenuItem("Addon Peds", "Choose a player skin from the addons list available on this server."); menu.AddItem(addonPedsBtn); MainMenu.Mp.Add(addonPeds); if (AddonPeds != null) { if (AddonPeds.Count > 0) { addonPedsBtn.SetRightLabel("→→→"); foreach (KeyValuePair <string, uint> ped in AddonPeds) { var button = new UIMenuItem(ped.Key, "Click to use this ped."); addonPeds.AddItem(button); if (!IsModelAPed(ped.Value) || !IsModelInCdimage(ped.Value)) { button.Enabled = false; button.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); button.Description = "This ped is not available on this server. Are you sure the model is valid?"; } } addonPeds.OnItemSelect += (sender, item, index) => { if (item.Enabled) { cf.SetPlayerSkin(AddonPeds.ElementAt(index).Value); } else { Notify.Error("This ped is not available. Please ask the server owner to verify this addon ped."); } }; menu.BindMenuToItem(addonPeds, addonPedsBtn); } else { addonPedsBtn.Enabled = false; addonPedsBtn.Description = "This server does not have any addon peds available."; addonPedsBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); } } else { addonPedsBtn.Enabled = false; addonPedsBtn.Description = "This server does not have any addon peds available."; addonPedsBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); } addonPeds.RefreshIndex(); addonPeds.UpdateScaleform(); // Add the spawn by name button after the addon peds menu item. menu.AddItem(spawnByName); // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == pedCustomization) { RefreshCustomizationMenu(); } else if (item == spawnSavedPed) { RefreshSpawnSavedPedMenu(); } else if (item == deleteSavedPed) { RefreshDeleteSavedPedMenu(); } else if (item == savePed) { cf.SavePed(); } else if (item == spawnByName) { cf.SpawnPedByName(); } }; // Loop through all the modelNames and create lists of max 50 ped names each. for (int i = 0; i < (modelNames.Count / 50) + 1; i++) { List <dynamic> pedList = new List <dynamic>(); for (int ii = 0; ii < 50; ii++) { int index = ((i * 50) + ii); if (index >= modelNames.Count) { break; } int max = ((modelNames.Count / 50) != i) ? 50 : modelNames.Count % 50; pedList.Add(modelNames[index] + $" ({(ii + 1).ToString()}/{max.ToString()})"); } UIMenuListItem pedl = new UIMenuListItem("Peds #" + (i + 1).ToString(), pedList, 0); menu.AddItem(pedl); if (!cf.IsAllowed(Permission.PASpawnNew)) { pedl.Enabled = false; pedl.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); pedl.Description = "This option has been disabled by the server owner."; } } // Handle list selections. menu.OnListSelect += (sender, item, index) => { if (item == walkingStyle) { Subtitle.Custom("Ped is: " + IsPedMale(PlayerPedId())); cf.SetWalkingStyle(walkstyles[index].ToString()); } else { int i = ((sender.CurrentSelection - 7) * 50) + index; string modelName = modelNames[i]; if (cf.IsAllowed(Permission.PASpawnNew)) { cf.SetPlayerSkin(modelName); } } }; }
/// <summary> /// Updates the player items. /// </summary> public void UpdatePlayerlist() { // Remove leftover menu items if they exist. if (menu.MenuItems.Count > 0) { menu.MenuItems.Clear(); } // Create a new player list. PlayerList pl = new PlayerList(); // Loop through the playerlist. foreach (Player p in pl) { // Create a button for this player and add it to the menu. UIMenuItem playerItem = new UIMenuItem(p.Name, "[" + (p.Handle < 10 ? "0" : "") + p.Handle + "] " + p.Name + " (Server ID: " + p.ServerId + ")"); playerItem.SetRightLabel("→→→"); menu.AddItem(playerItem); // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // If the player item is pressed. if (item == playerItem) { // Create the player object. Player player = new Player(int.Parse(item.Description.Substring(1, 2).ToString())); // Create the menu for the player & set the width offset. UIMenu PlayerMenu = new UIMenu(player.Name, "[" + (player.Handle < 10 ? "0" : "") + player.Handle + "] " + player.Name + " (Server ID: " + player.ServerId + ")", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; PlayerMenu.SetMenuWidthOffset(50); // Create all player options buttons. UIMenuItem teleportBtn = new UIMenuItem("Teleport To Player", "Teleport to this player."); UIMenuItem teleportInVehBtn = new UIMenuItem("Teleport Into Vehicle", "Teleport into the player's vehicle."); UIMenuItem setWaypointBtn = new UIMenuItem("Toggle GPS Route", "Enables or disables drawing a GPS route to this player."); UIMenuItem spectateBtn = new UIMenuItem("Spectate Player", "Spectate this player."); UIMenuItem summonBtn = new UIMenuItem("Summon Player", "Bring this player to your location."); summonBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem killBtn = new UIMenuItem("Kill Player", "Kill the selected player! Why are you so cruel :("); killBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem kickPlayerBtn = new UIMenuItem("~r~Kick Player", "~r~Kick~s~ this player from the server, you need to specify a reason " + "otherwise the kick will be cancelled."); kickPlayerBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem permBanBtn = new UIMenuItem("~r~Ban Player", "Ban the player from the server forever."); permBanBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); UIMenuItem tempBanBtn = new UIMenuItem("~r~Tempban Player", "Ban the player from the server for the specified amount of hours. " + "The player will be able to rejoin after the ban expires."); tempBanBtn.SetRightBadge(UIMenuItem.BadgeStyle.Alert); // Add all buttons to the player options submenu. Keeping permissions in mind. if (cf.IsAllowed(Permission.OPTeleport)) { PlayerMenu.AddItem(teleportBtn); PlayerMenu.AddItem(teleportInVehBtn); } if (cf.IsAllowed(Permission.OPWaypoint)) { PlayerMenu.AddItem(setWaypointBtn); } if (cf.IsAllowed(Permission.OPSpectate)) { PlayerMenu.AddItem(spectateBtn); } if (cf.IsAllowed(Permission.OPSummon)) { PlayerMenu.AddItem(summonBtn); } if (cf.IsAllowed(Permission.OPKill)) { PlayerMenu.AddItem(killBtn); } if (cf.IsAllowed(Permission.OPKick)) { PlayerMenu.AddItem(kickPlayerBtn); } if (cf.IsAllowed(Permission.OPTempBan)) { PlayerMenu.AddItem(tempBanBtn); } if (cf.IsAllowed(Permission.OPPermBan)) { PlayerMenu.AddItem(permBanBtn); } // Add the player menu to the menu pool. MainMenu.Mp.Add(PlayerMenu); // Set the menu invisible. menu.Visible = false; // Set the player menu visible. PlayerMenu.Visible = true; // If a button is pressed in the player's options menu. PlayerMenu.OnItemSelect += (sender2, item2, index2) => { // Teleport button is pressed. if (item2 == teleportBtn) { cf.TeleportToPlayerAsync(player.Handle, false); } // Teleport in vehicle button is pressed. else if (item2 == teleportInVehBtn) { cf.TeleportToPlayerAsync(player.Handle, true); } // Set waypoint button is pressed. else if (item2 == setWaypointBtn) { bool selectedPedRouteAlreadyActive = false; if (PlayersWaypointList.Count > 0) { if (PlayersWaypointList.Contains(player.Handle)) { selectedPedRouteAlreadyActive = true; } foreach (int playerId in PlayersWaypointList) { int playerPed = GetPlayerPed(playerId); if (DoesEntityExist(playerPed) && DoesBlipExist(GetBlipFromEntity(playerPed))) { int oldBlip = GetBlipFromEntity(playerPed); SetBlipRoute(oldBlip, false); RemoveBlip(ref oldBlip); Notify.Custom($"~g~GPS route to ~s~<C>{GetPlayerName(playerId)}</C>~g~ is now disabled."); } } PlayersWaypointList.Clear(); } if (!selectedPedRouteAlreadyActive) { if (player.Handle != PlayerId()) { int ped = GetPlayerPed(player.Handle); int blip = GetBlipFromEntity(ped); if (DoesBlipExist(blip)) { SetBlipColour(blip, 58); SetBlipRouteColour(blip, 58); SetBlipRoute(blip, true); } else { blip = AddBlipForEntity(ped); SetBlipColour(blip, 58); SetBlipRouteColour(blip, 58); SetBlipRoute(blip, true); } PlayersWaypointList.Add(player.Handle); Notify.Custom($"~g~GPS route to ~s~<C>{player.Name}</C>~g~ is now active, press the ~s~Toggle GPS Route~g~ button again to disable the route."); } else { Notify.Error("You can not set a waypoint to yourself."); } } } // Spectate player button is pressed. else if (item2 == spectateBtn) { if (player.Handle == PlayerId()) { Notify.Error("Sorry, you can ~r~~h~not~h~ ~s~spectate yourself!", true, true); } else { cf.SpectateAsync(player.Handle); } } // Summon player button is pressed. else if (item2 == summonBtn) { if (player.Handle == PlayerId()) { Notify.Error("Sorry, you can ~r~~h~not~h~ ~s~summon yourself!", true, true); } else { cf.SummonPlayer(player); } } // Kill player button is pressed. else if (item2 == killBtn) { Notify.Success($"Player ~y~<C>{player.Name}</C> ~s~has been killed."); cf.KillPlayer(player); } // Kick player button is pressed. else if (item2 == kickPlayerBtn) { // Close the menu. PlayerMenu.GoBack(); // Kick the player. cf.KickPlayer(player, true); // Update the player list. UpdatePlayerlist(); // Refresh the index & update scaleform. menu.RefreshIndex(); menu.UpdateScaleform(); } else if (item2 == tempBanBtn) { // Close the menu. PlayerMenu.GoBack(); // ban player cf.BanPlayer(player: player, forever: false); // Update the player list. UpdatePlayerlist(); // Refresh the index & update scaleform. menu.RefreshIndex(); menu.UpdateScaleform(); } else if (item2 == permBanBtn) { // Close the menu. PlayerMenu.GoBack(); // ban player cf.BanPlayer(player: player, forever: true); // Update the player list. UpdatePlayerlist(); // Refresh the index & update scaleform. menu.RefreshIndex(); menu.UpdateScaleform(); } }; // Reopen the playerlist menu when a player specific menu is closed. PlayerMenu.OnMenuClose += (sender2) => { menu.Visible = true; }; PlayerMenu.RefreshIndex(); PlayerMenu.UpdateScaleform(); } }; } ; }
/// <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 static void Main() { // Create a fiber to process our menus MenusProcessFiber = new GameFiber(ProcessLoop); // Create the MenuPool to easily process our menus menuPool = new MenuPool(); // Create our main menu mainMenu = new UIMenu("RAGENative UI", "~b~RAGENATIVEUI SHOWCASE"); // Add our main menu to the MenuPool menuPool.Add(mainMenu); // create our items and add them to our main menu mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?")); mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", "", "Banana", "Apple", "Pizza", "Quartilicious", 0xF00D)); mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.")); var menuItem = new UIMenuItem("Go to another menu."); mainMenu.AddItem(menuItem); cookItem.SetLeftBadge(UIMenuItem.BadgeStyle.Star); cookItem.SetRightBadge(UIMenuItem.BadgeStyle.Tick); carsList = new UIMenuListItem("Cars Models", "", "Adder", "Bullet", "Police", "Police2", "Asea", "FBI", "FBI2", "Firetruk", "Ambulance", "Rhino"); mainMenu.AddItem(carsList); spawnCar = new UIMenuItem("Spawn Car"); mainMenu.AddItem(spawnCar); coloredItem = new UIMenuItem("Color!"); mainMenu.AddItem(coloredItem); mainMenu.RefreshIndex(); mainMenu.OnItemSelect += OnItemSelect; mainMenu.OnListChange += OnListChange; mainMenu.OnCheckboxChange += OnCheckboxChange; mainMenu.OnIndexChange += OnItemChange; // Create another menu newMenu = new UIMenu("RAGENative UI", "~b~RAGENATIVEUI SHOWCASE"); newMenu.CounterOverride = "Counter Override"; menuPool.Add(newMenu); // add it to the menu pool for (int i = 0; i < 35; i++) // add items { newMenu.AddItem(new UIMenuItem("PageFiller " + i.ToString(), "Sample description that takes more than one line. More so, it takes way more than two lines since it's so long. Wow, check out this length!")); } newMenu.RefreshIndex(); mainMenu.BindMenuToItem(newMenu, menuItem); // and bind it to an item in our main menu // Start our process fiber MenusProcessFiber.Start(); // Continue with our plugin... in this example, hibernate to prevent it from being unloaded GameFiber.Hibernate(); }
private static void SetObservations(UIMenu menu) { menu.Title.Caption = "Observations"; menu.Subtitle.Caption = $"Set your observations!"; menu.Subtitle.Centered = true; var setHeartRate = new UIMenuItem("Set Heart Rate:"); var setBloodPressure = new UIMenuItem("Set Blood Pressure:"); var setSpO2 = new UIMenuItem("Set SpO2:"); var setTemperature = new UIMenuItem("Set Temperature:"); var setBloodSugar = new UIMenuItem("Set Blood Sugar:"); UIMenuListItem setPupils = new UIMenuListItem("Set Pupils", pupilTypes, 0); var setRespRate = new UIMenuItem("Set Resp Rate:"); UIMenuListItem setEcgRythm = new UIMenuListItem("Set ECG Rhythm", ecgRythmTypes, 0); UIMenuListItem setLungSounds = new UIMenuListItem("Set Lung Sounds", lungSoundsTypes, 0); var setPatientName = new UIMenuItem("Set Patient Name:"); var resetObservations = new UIMenuItem("Reset Observations"); menu.AddItem(setHeartRate); menu.AddItem(setBloodPressure); menu.AddItem(setSpO2); menu.AddItem(setTemperature); menu.AddItem(setBloodSugar); menu.AddItem(setPupils); menu.AddItem(setRespRate); menu.AddItem(setEcgRythm); menu.AddItem(setLungSounds); menu.AddItem(setPatientName); menu.AddItem(resetObservations); if (Main.ecgRythm != -1) { setEcgRythm.Index = Main.ecgRythm; } if (Main.lungSounds != -1) { setLungSounds.Index = Main.lungSounds; } if (Main.pupils != -1) { setPupils.Index = Main.pupils; } setEcgRythm.OnListSelected += (_arg, _selection) => { var before = Main.ecgRythm; string beforeString; if (before == -1) { beforeString = ""; } else { beforeString = Convert.ToString(ecgRythmTypes[before]); } Main.ListUpdates("ECG Rythm", beforeString, Convert.ToString(ecgRythmTypes[_selection]), Main.ecgRythmUnit); Main.ecgRythm = _selection; }; setPupils.OnListSelected += (_arg, _selection) => { var before = Main.pupils; string beforeString; if (before == -1) { beforeString = ""; } else { beforeString = Convert.ToString(pupilTypes[before]); } Main.ListUpdates("Pupils", beforeString, Convert.ToString(pupilTypes[_selection]), Main.pupilsUnit); Main.pupils = _selection; }; setLungSounds.OnListSelected += (_arg, _selection) => { var before = Main.lungSounds; string beforeString; if (before == -1) { beforeString = ""; } else { beforeString = Convert.ToString(lungSoundsTypes[before]); } Main.ListUpdates("Lung Sounds", beforeString, Convert.ToString(lungSoundsTypes[_selection]), Main.lungSoundsUnit); Main.lungSounds = _selection; }; if (!IsStringNullOrEmpty(Main.heartRate)) { setHeartRate.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setHeartRate.SetRightLabel(Main.heartRate + Main.heartRateUnit); } if (!IsStringNullOrEmpty(Main.bloodPressure)) { setBloodPressure.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setBloodPressure.SetRightLabel(Main.bloodPressure + "/" + Main.bloodPressure2 + Main.bloodPressureUnit); } if (!IsStringNullOrEmpty(Main.spO2)) { setSpO2.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setSpO2.SetRightLabel(Main.spO2 + Main.spO2Unit); } if (!IsStringNullOrEmpty(Main.temperature)) { setTemperature.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setTemperature.SetRightLabel(Main.temperature + Main.temperatureUnit); } if (!IsStringNullOrEmpty(Main.bloodSugar)) { setBloodSugar.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setBloodSugar.SetRightLabel(Main.bloodSugar + Main.bloodSugarUnit); } if (!IsStringNullOrEmpty(Main.respRate)) { setRespRate.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setRespRate.SetRightLabel(Main.respRate + Main.respRateUnit); } if (!IsStringNullOrEmpty(Main.patientName)) { setPatientName.SetRightBadge(UIMenuItem.BadgeStyle.Tick); setPatientName.SetRightLabel(Main.patientName); } menu.OnItemSelect += (sender, item, index) => { if (item == setHeartRate) { Main.InputHandler("Enter Heart Rate:", "heartRate", Main.heartRate); } else if (item == setBloodPressure) { Main.InputHandler("Enter Blood Pressure (First):", "bloodpressure", Main.bloodPressure); } else if (item == setSpO2) { Main.InputHandler("Enter SpO2:", "spO2", Main.spO2); } else if (item == setTemperature) { Main.InputHandler("Enter Temperature:", "temperature", Main.temperature); } else if (item == setRespRate) { Main.InputHandler("Enter Resp Rate:", "respRate", Main.respRate); } else if (item == setBloodSugar) { Main.InputHandler("Enter Blood Sugar:", "bloodsugar", Main.bloodSugar); } else if (item == setPatientName) { Main.InputHandler("Enter Patient Name:", "patientname", Main.patientName); } else if (item == resetObservations) { Main.ResetObservations(); } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Create the menu. menu = new UIMenu(GetPlayerName(PlayerId()), "Misc Settings", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create the menu items. UIMenuItem tptowp = new UIMenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); UIMenuCheckboxItem speedKmh = new UIMenuCheckboxItem("Show Speed KM/H", ShowSpeedoKmh, "Show a speedometer on your screen indicating your speed in KM/h."); UIMenuCheckboxItem speedMph = new UIMenuCheckboxItem("Show Speed MPH", ShowSpeedoMph, "Show a speedometer on your screen indicating your speed in MPH."); UIMenuCheckboxItem coords = new UIMenuCheckboxItem("Show Coordinates", ShowCoordinates, "Show your current coordinates at the top of your screen."); UIMenuCheckboxItem hideRadar = new UIMenuCheckboxItem("Hide Radar", HideRadar, "Hide the radar/minimap."); UIMenuCheckboxItem hideHud = new UIMenuCheckboxItem("Hide Hud", HideHud, "Hide all hud elements."); UIMenuCheckboxItem showLocation = new UIMenuCheckboxItem("Location Display", ShowLocation, "Shows your current location and heading, as well as the nearest cross road. Just like PLD."); UIMenuItem saveSettings = new UIMenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu."); saveSettings.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuCheckboxItem joinQuitNotifs = new UIMenuCheckboxItem("Join / Quit Notifications", JoinQuitNotifications, "Receive notifications when someone joins or leaves the server."); UIMenuCheckboxItem deathNotifs = new UIMenuCheckboxItem("Death Notifications", DeathNotifications, "Receive notifications when someone dies or gets killed."); // Add menu items to the menu. if (cf.IsAllowed(Permission.MSTeleportToWp)) { menu.AddItem(tptowp); } // Always allowed menu.AddItem(speedKmh); menu.AddItem(speedMph); if (cf.IsAllowed(Permission.MSShowCoordinates)) { menu.AddItem(coords); } if (cf.IsAllowed(Permission.MSShowLocation)) { menu.AddItem(showLocation); } if (cf.IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddItem(deathNotifs); } if (cf.IsAllowed(Permission.MSDeathNotifs)) { menu.AddItem(joinQuitNotifs); } // Always allowed menu.AddItem(hideRadar); menu.AddItem(hideHud); menu.AddItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, _checked) => { if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == coords) { ShowCoordinates = _checked; } else if (item == hideHud) { HideHud = _checked; } else if (item == hideRadar) { HideRadar = _checked; } else if (item == showLocation) { ShowLocation = _checked; } else if (item == deathNotifs) { DeathNotifications = _checked; } else if (item == joinQuitNotifs) { JoinQuitNotifications = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { cf.TeleportToWp(); } else if (item == saveSettings) { UserDefaults.SaveSettingsAsync(); } }; }
private static void GetObservations(UIMenu menu) { menu.Title.Caption = "Observations"; menu.Subtitle.Caption = $"Patient Name: {name}"; menu.Subtitle.Centered = true; var getHeartRate = new UIMenuItem("Heart Rate:"); var getBloodPressure = new UIMenuItem("Blood Pressure:"); var getSpO2 = new UIMenuItem("SpO2:"); var getTemperature = new UIMenuItem("Temperature:"); var getBloodSugar = new UIMenuItem("Blood Sugar:"); var getPupils = new UIMenuItem("Pupils:"); var getRespRate = new UIMenuItem("Resp Rate:"); var getEcgRythm = new UIMenuItem("ECG Rhythm:"); var getLungSounds = new UIMenuItem("Lung Sounds:"); var disableUpdates = new UIMenuItem("Disable Updates", "You will stop receiving updates from this patient"); menu.AddItem(getHeartRate); menu.AddItem(getBloodPressure); menu.AddItem(getSpO2); menu.AddItem(getTemperature); menu.AddItem(getBloodSugar); menu.AddItem(getPupils); menu.AddItem(getRespRate); menu.AddItem(getEcgRythm); menu.AddItem(getLungSounds); menu.AddItem(disableUpdates); menu.OnItemSelect += (sender, item, index) => { if (item == getHeartRate) { if (showHeartRate.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Heart Rate"); } else { showHeartRate.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getBloodPressure) { if (showBloodPressure.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Blood Pressure"); } else { showBloodPressure.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getSpO2) { if (showSpO2.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "SpO2"); } else { showSpO2.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getTemperature) { if (showTemperature.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Temperature"); } else { showTemperature.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getRespRate) { if (showRespRate.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Resp Rate"); } else { showRespRate.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getBloodSugar) { if (showBloodSugar.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Blood Sugar"); } else { showBloodSugar.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getEcgRythm) { if (showEcgRythm.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "ECG Rhythm"); } else { showEcgRythm.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getLungSounds) { if (showLungSounds.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Lung Sounds"); } else { showLungSounds.Add(viewingClientId); ReloadMenu("get"); } } else if (item == getPupils) { if (showPupils.Contains(viewingClientId)) { Main.RequestCivUpdate(viewingClientId, "Pupils"); } else { showPupils.Add(viewingClientId); ReloadMenu("get"); } } else if (item == disableUpdates) { Main.subscribedIds.Remove(viewingClientId); ClearShows(viewingClientId); Toggle(); } }; if (showHeartRate.Contains(viewingClientId)) { if (IsStringNullOrEmpty(pHeartRate)) { getHeartRate.SetRightLabel("Observing"); } else { getHeartRate.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getHeartRate.SetRightLabel(pHeartRate + Main.heartRateUnit); } } else { getHeartRate.SetRightLabel("Observe"); } if (showBloodPressure.Contains(viewingClientId)) { if (IsStringNullOrEmpty(pBloodPressure)) { getBloodPressure.SetRightLabel("Observing"); } else { getBloodPressure.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getBloodPressure.SetRightLabel(pBloodPressure + Main.bloodPressureUnit); } } else { getBloodPressure.SetRightLabel("Observe"); } if (showSpO2.Contains(viewingClientId)) { if (IsStringNullOrEmpty(pSpO2)) { getSpO2.SetRightLabel("Observing"); } else { getSpO2.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getSpO2.SetRightLabel(pSpO2 + Main.spO2Unit); } } else { getSpO2.SetRightLabel("Observe"); } if (showTemperature.Contains(viewingClientId)) { if (IsStringNullOrEmpty(pTemperature)) { getTemperature.SetRightLabel("Observing"); } else { getTemperature.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getTemperature.SetRightLabel(pTemperature + Main.temperatureUnit); } } else { getTemperature.SetRightLabel("Observe"); } if (showBloodSugar.Contains(viewingClientId)) { if (IsStringNullOrEmpty(pBloodSugar)) { getBloodSugar.SetRightLabel("Observing"); } else { getBloodSugar.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getBloodSugar.SetRightLabel(pBloodSugar + Main.bloodSugarUnit); } } else { getBloodSugar.SetRightLabel("Observe"); } if (showPupils.Contains(viewingClientId)) { if ((pPupils == -1)) { getPupils.SetRightLabel("Observing"); } else { getPupils.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getPupils.SetRightLabel(pupilTypes[pPupils] + Main.pupilsUnit); } } else { getPupils.SetRightLabel("Observe"); } if (showRespRate.Contains(viewingClientId)) { if (IsStringNullOrEmpty(pRespRate)) { getRespRate.SetRightLabel("Observing"); } else { getRespRate.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getRespRate.SetRightLabel(pRespRate + Main.respRateUnit); } } else { getRespRate.SetRightLabel("Observe"); } if (showEcgRythm.Contains(viewingClientId)) { if ((pEcgRythm == -1)) { getEcgRythm.SetRightLabel("Observing"); } else { getEcgRythm.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getEcgRythm.SetRightLabel(ecgRythmTypes[pEcgRythm] + Main.ecgRythmUnit); } } else { getEcgRythm.SetRightLabel("Observe"); } if (showLungSounds.Contains(viewingClientId)) { if ((pLungSounds == -1)) { getLungSounds.SetRightLabel("Observing"); } else { getLungSounds.SetRightBadge(UIMenuItem.BadgeStyle.Tick); getLungSounds.SetRightLabel(lungSoundsTypes[pLungSounds] + Main.lungSoundsUnit); } } else { getLungSounds.SetRightLabel("Observe"); } }
/// <summary> /// Creates the menu(s). /// </summary> private void CreateMenu() { // Create the menu. menu = new UIMenu(GetPlayerName(PlayerId()), "Player Appearance", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; //Create the submenus. spawnSavedPedMenu = new UIMenu("Saved Peds", "Spawn a saved ped", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; deleteSavedPedMenu = new UIMenu("Saved Peds", "Delete a saved ped", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; pedTextures = new UIMenu("Ped Customization", "Customize your ped", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Add the (submenus) to the menu pool. MainMenu.Mp.Add(pedTextures); MainMenu.Mp.Add(spawnSavedPedMenu); MainMenu.Mp.Add(deleteSavedPedMenu); // Create the menu items. UIMenuItem pedCustomization = new UIMenuItem("Ped Customization", "Modify your ped's appearance."); pedCustomization.SetRightLabel("→→→"); UIMenuItem savePed = new UIMenuItem("Save Current Ped", "Save your current ped and clothes."); savePed.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuItem spawnSavedPed = new UIMenuItem("Spawn Saved Ped", "Spawn one of your saved peds."); spawnSavedPed.SetRightLabel("→→→"); UIMenuItem deleteSavedPed = new UIMenuItem("Delete Saved Ped", "Delete one of your saved peds."); deleteSavedPed.SetRightLabel("→→→"); deleteSavedPed.SetLeftBadge(UIMenuItem.BadgeStyle.Alert); // Add items to the mneu. menu.AddItem(pedCustomization); menu.AddItem(savePed); menu.AddItem(spawnSavedPed); menu.AddItem(deleteSavedPed); // Bind items to the submenus. if (cf.IsAllowed(Permission.PACustomize)) { menu.BindMenuToItem(pedTextures, pedCustomization); } else { pedCustomization.Enabled = false; pedCustomization.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); pedCustomization.Description = "This option has been disabled by the server owner."; } if (cf.IsAllowed(Permission.PASpawnSaved)) { menu.BindMenuToItem(spawnSavedPedMenu, spawnSavedPed); } else { spawnSavedPed.Enabled = false; spawnSavedPed.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); spawnSavedPed.Description = "This option has been disabled by the server owner."; } menu.BindMenuToItem(deleteSavedPedMenu, deleteSavedPed); // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == pedCustomization) { RefreshCustomizationMenu(); } else if (item == spawnSavedPed) { RefreshSpawnSavedPedMenu(); } else if (item == deleteSavedPed) { RefreshDeleteSavedPedMenu(); } else if (item == savePed) { cf.SavePed(); } }; // Loop through all the modelNames and create lists of max 50 ped names each. for (int i = 0; i < (modelNames.Count / 50) + 1; i++) { List <dynamic> pedList = new List <dynamic>(); for (int ii = 0; ii < 50; ii++) { int index = ((i * 50) + ii); if (index >= modelNames.Count) { break; } int max = ((modelNames.Count / 50) != i) ? 50 : modelNames.Count % 50; pedList.Add(modelNames[index] + $" ({(ii + 1).ToString()}/{max.ToString()})"); } UIMenuListItem pedl = new UIMenuListItem("Peds #" + (i + 1).ToString(), pedList, 0); menu.AddItem(pedl); if (!cf.IsAllowed(Permission.PASpawnNew)) { pedl.Enabled = false; pedl.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); pedl.Description = "This option has been disabled by the server owner."; } } // Handle list selections. menu.OnListSelect += (sender, item, index) => { int i = ((sender.CurrentSelection - 4) * 50) + index; string modelName = modelNames[i]; if (cf.IsAllowed(Permission.PASpawnNew)) { cf.SetPlayerSkin(modelName); } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { string menuTitle = "Saved Vehicles"; #region Create menus and submenus // Create the menu. menu = new UIMenu(menuTitle, "Manage Saved Vehicles", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create submenus. UIMenu savedVehicles = new UIMenu(menuTitle, "Spawn Saved Vehicle", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; UIMenu deleteSavedVehicles = new UIMenu(menuTitle, "~r~Delete Saved Vehicle", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; #endregion #region Create, add and bind buttons to the menus. // Create menu buttons. UIMenuItem saveVeh = new UIMenuItem("Save Current Vehicle", "Save the vehicle you are currently in."); saveVeh.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuItem savedVehiclesBtn = new UIMenuItem("Spawn Saved Vehicle", "Select a vehicle from your saved vehicles list."); savedVehiclesBtn.SetRightLabel("→→→"); UIMenuItem deleteSavedVehiclesBtn = new UIMenuItem("~r~Delete Saved Vehicle", "~r~Delete ~s~a saved vehicle."); deleteSavedVehiclesBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Alert); deleteSavedVehiclesBtn.SetRightLabel("→→→"); // Add buttons to the menu. menu.AddItem(saveVeh); menu.AddItem(savedVehiclesBtn); menu.AddItem(deleteSavedVehiclesBtn); // Bind submenus to menu items. if (cf.IsAllowed(Permission.SVSpawn)) { menu.BindMenuToItem(savedVehicles, savedVehiclesBtn); } else { savedVehiclesBtn.Enabled = false; savedVehiclesBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); savedVehiclesBtn.Description = "This option has been disabled by the server owner."; } menu.BindMenuToItem(deleteSavedVehicles, deleteSavedVehiclesBtn); #endregion #region Button pressed events // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Save the current vehicle. if (item == saveVeh) { cf.SaveVehicle(); } // Open and refresh the "spawn saved vehicle from list" submenu. else if (item == savedVehiclesBtn) { // Remove all old items. savedVehicles.MenuItems.Clear(); // Get all saved vehicles. SavedVehiclesDict = cf.GetSavedVehiclesDictionary(); // Loop through all saved vehicles and create a button for it, then add that button to the submenu. foreach (KeyValuePair <string, Dictionary <string, string> > savedVehicle in SavedVehiclesDict) { UIMenuItem vehBtn = new UIMenuItem(savedVehicle.Key.Substring(4), "Click to spawn this saved vehicle."); vehBtn.SetRightLabel($"({savedVehicle.Value["name"]})"); savedVehicles.AddItem(vehBtn); } // Sort the menu items (case IN-sensitive) by name. savedVehicles.MenuItems.Sort((pair1, pair2) => pair1.Text.ToString().ToLower().CompareTo(pair2.Text.ToString().ToLower())); // When a vehicle is selected... savedVehicles.OnItemSelect += (sender2, item2, index2) => { // Get the vehicle info. var vehInfo = SavedVehiclesDict["veh_" + item2.Text]; // Get the model hash. var model = vehInfo["model"]; // Spawn a vehicle using the hash, and pass on the vehicleInfo dictionary containing all saved vehicle mods. cf.SpawnVehicle((uint)Int64.Parse(model), MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, vehicleInfo: vehInfo); }; // Refresh the index of the page. savedVehicles.RefreshIndex(); // Update the scaleform. savedVehicles.UpdateScaleform(); } // Delete saved vehicle. else if (item == deleteSavedVehiclesBtn) { deleteSavedVehicles.MenuItems.Clear(); // Get the dictionary containing all saved vehicles. SavedVehiclesDict = cf.GetSavedVehiclesDictionary(); // Loop through the list and add all saved vehicles to the menu. foreach (KeyValuePair <string, Dictionary <string, string> > savedVehicle in SavedVehiclesDict) { UIMenuItem vehBtn = new UIMenuItem(savedVehicle.Key.Substring(4), "Are you sure you want to delete this saved vehicle? This action cannot be undone!"); vehBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Alert); vehBtn.SetRightLabel($"({savedVehicle.Value["name"]})"); deleteSavedVehicles.AddItem(vehBtn); } // Sort the menu items (case IN-sensitive) by name. deleteSavedVehicles.MenuItems.Sort((pair1, pair2) => pair1.Text.ToString().ToLower().CompareTo(pair2.Text.ToString().ToLower())); // Handle vehicle deletions deleteSavedVehicles.OnItemSelect += (sender2, item2, index2) => { var vehDictName = "veh_" + item2.Text; new StorageManager().DeleteSavedDictionary(vehDictName); deleteSavedVehicles.GoBack(); }; } }; #endregion // Add the submenus to the menu pool. MainMenu.Mp.Add(savedVehicles); MainMenu.Mp.Add(deleteSavedVehicles); }
public void AddMenuCook(UIMenu menu) { var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."); newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star); newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick); menu.AddItem(newitem); menu.OnItemSelect += (sender, item, index) => { if (item == newitem) { string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup."; Screen.ShowSubtitle(String.Format(output, dish)); } }; menu.OnIndexChange += (sender, index) => { if (sender.MenuItems[index] == newitem) { newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None); } }; var colorItem = new UIMenuItem("UIMenuItem with Colors", "~b~Look!!~r~I can be colored ~y~too!!~w~", Color.FromArgb(150, 185, 230, 185), Color.FromArgb(170, 174, 219, 242)); menu.AddItem(colorItem); var foods = new List <dynamic> { "Banana", "Apple", "Pizza", "Quartilicious", 0xF00D, // Dynamic! }; var BlankItem = new UIMenuSeparatorItem(); menu.AddItem(BlankItem); var colorListItem = new UIMenuListItem("Colored ListItem.. Really?", foods, 0, "~b~Look!!~r~I can be colored ~y~too!!~w~", Color.FromArgb(150, 185, 230, 185), Color.FromArgb(170, 174, 219, 242)); menu.AddItem(colorListItem); var SliderProgress = new UIMenuSliderProgressItem("Slider Progress Item", 10, 0); menu.AddItem(SliderProgress); var Progress = new UIMenuProgressItem("Progress Item", "descriptiom", 10, 0, true); menu.AddItem(Progress); var listPanelItem1 = new UIMenuListItem("Change Color", new List <object> { "Example", "example2" }, 0); var ColorPanel = new UIMenuColorPanel("Color Panel Example", UIMenuColorPanel.ColorPanelType.Hair); // you can choose between hair palette or makeup palette menu.AddItem(listPanelItem1); listPanelItem1.AddPanel(ColorPanel); var listPanelItem2 = new UIMenuListItem("Change Percentage", new List <object> { "Example", "example2" }, 0); var PercentagePanel = new UIMenuPercentagePanel("Percentage Panel Example", "0%", "100%"); // You can change every text in this Panel menu.AddItem(listPanelItem2); listPanelItem2.AddPanel(PercentagePanel); var listPanelItem3 = new UIMenuListItem("Change Grid Position", new List <object> { "Example", "example2" }, 0); var GridPanel = new UIMenuGridPanel("Up", "Left", "Right", "Down", new System.Drawing.PointF(.5f, .5f)); // you can choose the text in every position and where to place the starting position of the cirlce // the other 2 grids panel available are not listed as they work the same way but in only 2 direction (horizontally or vertically) // and to use them you must stream the stream folder provided with NativeUI project menu.AddItem(listPanelItem3); listPanelItem3.AddPanel(GridPanel); var listPanelItem4 = new UIMenuListItem("Look at Statistics", new List <object> { "Example", "example2" }, 0); var statistics = new UIMenuStatisticsPanel(); statistics.AddStatistics("Look at this!"); statistics.AddStatistics("I'm a statistic too!"); statistics.AddStatistics("Am i not?!"); //you can add as menu statistics you want statistics.SetPercentage(0, 10f); statistics.SetPercentage(1, 50f); statistics.SetPercentage(2, 100f); //and you can get / set their percentage menu.AddItem(listPanelItem4); listPanelItem4.AddPanel(statistics); // THERE ARE NO EVENTS FOR PANELS.. WHEN YOU CHANGE WHAT IS CHANGABLE THE LISTITEM WILL DO WHATEVER YOU TELL HIM TO DO menu.OnListChange += (sender, item, index) => { if (item == listPanelItem1) { Screen.ShowNotification("Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "..."); item.Description = "Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "..."; item.Parent.UpdateDescription(); // this is neat.. this will update the description of the item without refresh index.. try it by changing color } else if (item == listPanelItem2) { Screen.ShowSubtitle("Percentage = " + (item.Panels[0] as UIMenuPercentagePanel).Percentage + "..."); } else if (item == listPanelItem3) { Screen.ShowSubtitle("GridPosition = " + (item.Panels[0] as UIMenuGridPanel).CirclePosition + "..."); } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Create the menu. menu = new UIMenu(GetPlayerName(PlayerId()), "Misc Settings", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create the menu items. UIMenuItem tptowp = new UIMenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); UIMenuCheckboxItem speedKmh = new UIMenuCheckboxItem("Show Speed KM/H", ShowSpeedoKmh, "Show a speedometer on your screen indicating your speed in KM/h."); UIMenuCheckboxItem speedMph = new UIMenuCheckboxItem("Show Speed MPH", ShowSpeedoMph, "Show a speedometer on your screen indicating your speed in MPH."); UIMenuCheckboxItem coords = new UIMenuCheckboxItem("Show Coordinates", ShowCoordinates, "Show your current coordinates at the top of your screen."); UIMenuCheckboxItem hideRadar = new UIMenuCheckboxItem("Hide Radar", HideRadar, "Hide the radar/minimap."); UIMenuCheckboxItem hideHud = new UIMenuCheckboxItem("Hide Hud", HideHud, "Hide all hud elements."); UIMenuCheckboxItem showLocation = new UIMenuCheckboxItem("Location Display", ShowLocation, "Shows your current location and heading, as well as the nearest cross road. Just like PLD."); UIMenuItem saveSettings = new UIMenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu."); saveSettings.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuCheckboxItem joinQuitNotifs = new UIMenuCheckboxItem("Join / Quit Notifications", JoinQuitNotifications, "Receive notifications when someone joins or leaves the server."); UIMenuCheckboxItem deathNotifs = new UIMenuCheckboxItem("Death Notifications", DeathNotifications, "Receive notifications when someone dies or gets killed."); UIMenuCheckboxItem nightVision = new UIMenuCheckboxItem("Toggle Night Vision", false, "Enable or disable night vision."); UIMenuCheckboxItem thermalVision = new UIMenuCheckboxItem("Toggle Thermal Vision", false, "Enable or disable thermal vision."); UIMenuItem clearArea = new UIMenuItem("Clear Area", "Clears the area around your player (100 meters) of everything! Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up and reset."); UIMenuCheckboxItem lockCamX = new UIMenuCheckboxItem("Lock Camera Horizontal Rotation", false, "Locks your camera horizontal rotation. Could be useful in helicopters I guess."); UIMenuCheckboxItem lockCamY = new UIMenuCheckboxItem("Lock Camera Vertical Rotation", false, "Locks your camera vertical rotation. Could be useful in helicopters I guess."); UIMenu connectionSubmenu = new UIMenu(GetPlayerName(PlayerId()), "Connection Options", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; UIMenuItem connectionSubmenuBtn = new UIMenuItem("Connection Options", "Server connection/game quit options."); UIMenuItem quitSession = new UIMenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. " + "Use this if you need to have addons streamed but want to use the rockstar editor."); UIMenuItem quitGame = new UIMenuItem("Quit Game", "Exits the game after 5 seconds."); UIMenuItem disconnectFromServer = new UIMenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. " + "~r~This feature is not recommended, quit the game instead for a better experience."); connectionSubmenu.AddItem(quitSession); connectionSubmenu.AddItem(quitGame); connectionSubmenu.AddItem(disconnectFromServer); //UIMenuCheckboxItem locationBlips = new UIMenuCheckboxItem("Location Blips", ShowLocationBlips, "Shows blips on the map for some common locations."); //UIMenuCheckboxItem playerBlips = new UIMenuCheckboxItem("Show Player Blips", ShowPlayerBlips, "Shows blips on the map for all players."); MainMenu.Mp.Add(connectionSubmenu); connectionSubmenu.RefreshIndex(); connectionSubmenu.UpdateScaleform(); menu.BindMenuToItem(connectionSubmenu, connectionSubmenuBtn); connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { cf.QuitGame(); } else if (item == quitSession) { cf.QuitSession(); } else if (item == disconnectFromServer) { BaseScript.TriggerServerEvent("vMenu:DisconnectSelf"); } }; // Add menu items to the menu. if (cf.IsAllowed(Permission.MSTeleportToWp)) { menu.AddItem(tptowp); } // Always allowed menu.AddItem(speedKmh); menu.AddItem(speedMph); menu.AddItem(connectionSubmenuBtn); if (cf.IsAllowed(Permission.MSShowCoordinates)) { menu.AddItem(coords); } if (cf.IsAllowed(Permission.MSShowLocation)) { menu.AddItem(showLocation); } if (cf.IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddItem(deathNotifs); } if (cf.IsAllowed(Permission.MSDeathNotifs)) { menu.AddItem(joinQuitNotifs); } if (cf.IsAllowed(Permission.MSNightVision)) { menu.AddItem(nightVision); } if (cf.IsAllowed(Permission.MSThermalVision)) { menu.AddItem(thermalVision); } //if (cf.IsAllowed(Permission.MSLocationBlips)) //{ //menu.AddItem(locationBlips); //if (!MainMenu.EnableExperimentalFeatures) //{ //locationBlips.Enabled = false; //locationBlips.SetLeftBadge(UIMenuItem.BadgeStyle.Lock); //locationBlips.Description = "This experimental feature is not yet available, more details will be published on the forum thread soon."; //} //} //if (cf.IsAllowed(Permission.MSPlayerBlips)) //{ //menu.AddItem(playerBlips); //} if (cf.IsAllowed(Permission.MSClearArea)) { menu.AddItem(clearArea); } // Always allowed menu.AddItem(hideRadar); menu.AddItem(hideHud); menu.AddItem(lockCamX); menu.AddItem(lockCamY); menu.AddItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, _checked) => { if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == coords) { ShowCoordinates = _checked; } else if (item == hideHud) { HideHud = _checked; } else if (item == hideRadar) { HideRadar = _checked; } else if (item == showLocation) { ShowLocation = _checked; } else if (item == deathNotifs) { DeathNotifications = _checked; } else if (item == joinQuitNotifs) { JoinQuitNotifications = _checked; } else if (item == nightVision) { SetNightvision(_checked); } else if (item == thermalVision) { SetSeethrough(_checked); } else if (item == lockCamX) { LockCameraX = _checked; } else if (item == lockCamY) { LockCameraY = _checked; } //else if (item == locationBlips) //{ //ToggleBlips(_checked); //ShowLocationBlips = _checked; //} //else if (item == playerBlips) //{ //ShowPlayerBlips = _checked; //} }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { cf.TeleportToWp(); } // save settings else if (item == saveSettings) { UserDefaults.SaveSettings(); } // clear area else if (item == clearArea) { var pos = Game.PlayerPed.Position; ClearAreaOfEverything(pos.X, pos.Y, pos.Z, 100f, false, false, false, false); } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Create the menu. menu = new UIMenu(GetPlayerName(PlayerId()), "Misc Settings", true) { ScaleWithSafezone = false, MouseControlsEnabled = false, MouseEdgeEnabled = false, ControlDisablingEnabled = false }; // Create the menu items. UIMenuItem tptowp = new UIMenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); UIMenuCheckboxItem speedKmh = new UIMenuCheckboxItem("Show Speed KM/H", ShowSpeedoKmh, "Show a speedometer on your screen indicating your speed in KM/h."); UIMenuCheckboxItem speedMph = new UIMenuCheckboxItem("Show Speed MPH", ShowSpeedoMph, "Show a speedometer on your screen indicating your speed in MPH."); UIMenuCheckboxItem coords = new UIMenuCheckboxItem("Show Coordinates", ShowCoordinates, "Show your current coordinates at the top of your screen."); UIMenuCheckboxItem hideRadar = new UIMenuCheckboxItem("Hide Radar", HideRadar, "Hide the radar/minimap."); UIMenuCheckboxItem hideHud = new UIMenuCheckboxItem("Hide Hud", HideHud, "Hide all hud elements."); UIMenuCheckboxItem showLocation = new UIMenuCheckboxItem("Location Display", ShowLocation, "Shows your current location and heading, as well as the nearest cross road. Just like PLD."); UIMenuItem saveSettings = new UIMenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu."); saveSettings.SetRightBadge(UIMenuItem.BadgeStyle.Tick); UIMenuCheckboxItem joinQuitNotifs = new UIMenuCheckboxItem("Join / Quit Notifications", JoinQuitNotifications, "Receive notifications when someone joins or leaves the server."); UIMenuCheckboxItem deathNotifs = new UIMenuCheckboxItem("Death Notifications", DeathNotifications, "Receive notifications when someone dies or gets killed."); UIMenuCheckboxItem nightVision = new UIMenuCheckboxItem("Toggle Night Vision", false, "Enable or disable night vision."); UIMenuCheckboxItem thermalVision = new UIMenuCheckboxItem("Toggle Thermal Vision", false, "Enable or disable thermal vision."); UIMenuItem clearArea = new UIMenuItem("Clear Area", "Clears the area around your player (100 meters) of everything! Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up and reset."); UIMenuCheckboxItem lockCamX = new UIMenuCheckboxItem("Lock Camera Horizontal Rotation", false, "Locks your camera horizontal rotation. Could be useful in helicopters I guess."); UIMenuCheckboxItem lockCamY = new UIMenuCheckboxItem("Lock Camera Vertical Rotation", false, "Locks your camera vertical rotation. Could be useful in helicopters I guess."); // Add menu items to the menu. if (cf.IsAllowed(Permission.MSTeleportToWp)) { menu.AddItem(tptowp); } // Always allowed menu.AddItem(speedKmh); menu.AddItem(speedMph); if (cf.IsAllowed(Permission.MSShowCoordinates)) { menu.AddItem(coords); } if (cf.IsAllowed(Permission.MSShowLocation)) { menu.AddItem(showLocation); } if (cf.IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddItem(deathNotifs); } if (cf.IsAllowed(Permission.MSDeathNotifs)) { menu.AddItem(joinQuitNotifs); } if (cf.IsAllowed(Permission.MSNightVision)) { menu.AddItem(nightVision); } if (cf.IsAllowed(Permission.MSThermalVision)) { menu.AddItem(thermalVision); } if (cf.IsAllowed(Permission.MSClearArea)) { menu.AddItem(clearArea); } // Always allowed menu.AddItem(hideRadar); menu.AddItem(hideHud); menu.AddItem(lockCamX); menu.AddItem(lockCamY); menu.AddItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, _checked) => { if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == coords) { ShowCoordinates = _checked; } else if (item == hideHud) { HideHud = _checked; } else if (item == hideRadar) { HideRadar = _checked; } else if (item == showLocation) { ShowLocation = _checked; } else if (item == deathNotifs) { DeathNotifications = _checked; } else if (item == joinQuitNotifs) { JoinQuitNotifications = _checked; } else if (item == nightVision) { SetNightvision(_checked); } else if (item == thermalVision) { SetSeethrough(_checked); } else if (item == lockCamX) { LockCameraX = _checked; } else if (item == lockCamY) { LockCameraY = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { cf.TeleportToWp(); } // save settings else if (item == saveSettings) { UserDefaults.SaveSettingsAsync(); } // clear area else if (item == clearArea) { var pos = Game.PlayerPed.Position; ClearAreaOfEverything(pos.X, pos.Y, pos.Z, 100f, false, false, false, false); } }; }