public Menu EditSpawnMenu(Menu parent, Map map, Spawn spawn) { MenuListItem spawnTypes = new MenuListItem("Set spawn type", Enum.GetNames(typeof(SpawnType)).ToList <string>(), 0); if (spawn.ID == -3) { spawn = new Spawn(-3, LocalPlayer.Character.Position, 0, "player", 0); } Menu spawnEditMenu = AddSubMenu(parent, "Edit spawn"); string name = spawn.ID == -3 ? "Create spawn" : spawn.SpawnType.ToString(); MenuItem spawnEditItem = AddMenuItem(parent, spawnEditMenu, name, "", "", true); spawnEditMenu.AddMenuItem(spawnTypes); MenuSliderItem slider = new MenuSliderItem("Slider", 0, 10, 0, false); spawnEditMenu.AddMenuItem(slider); // Add team here spawnEditMenu.AddMenuItem(new MenuItem("Save")); spawnEditMenu.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Save") { if (spawn.ID == -3) { var spawny = new Spawn(-1, LocalPlayer.Character.Position, (SpawnType)spawnTypes.ListIndex, "player", slider.Position); map.Spawns.Add(spawny); EditSpawnMenu(parent, map, spawny); spawnEditMenu.GoBack(); } else { spawn.SpawnType = (SpawnType)spawnTypes.ListIndex; parent.GetCurrentMenuItem().Text = spawn.SpawnType.ToString(); spawnEditMenu.GoBack(); } } }; return(spawnEditMenu); }
private static void ResetHairColors() { CurrentCharacter.Appearance.SetHairColor(0); CurrentCharacter.Appearance.SetHairHighlightColor(0); AppearanceMenu.RemoveMenuItem(AppearanceHairColors); AppearanceMenu.RemoveMenuItem(AppearanceHairHighlights); int updatedNumHairColors = API.GetNumHairColors(); AppearanceHairColors = new MenuSliderItem("Hair Colors", CurrentCharacter.Appearance.HairColor, updatedNumHairColors, 0); AppearanceHairHighlights = new MenuSliderItem("Hair Highlights", CurrentCharacter.Appearance.HairHighlightColor, updatedNumHairColors, 0); AppearanceMenu.AddMenuItem(AppearanceHairColors); AppearanceMenu.AddMenuItem(AppearanceHairHighlights); SetPedHairColor(0); SetPedHairHighlightColor(0); }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { MenuController.MenuAlignment = MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; if (MenuController.MenuAlignment != (MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left)) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } // Create the menu. menu = new Menu(Game.Player.Name, "Misc Settings"); teleportOptionsMenu = new Menu(Game.Player.Name, "Teleport Options"); developerToolsMenu = new Menu(Game.Player.Name, "Development Tools"); // teleport menu Menu teleportMenu = new Menu(Game.Player.Name, "Teleport Locations"); MenuItem teleportMenuBtn = new MenuItem("Teleport Locations", "Teleport to pre-configured locations, added by the server owner."); MenuController.AddSubmenu(menu, teleportMenu); MenuController.BindMenuItem(menu, teleportMenu, teleportMenuBtn); // keybind settings menu Menu keybindMenu = new Menu(Game.Player.Name, "Keybind Settings"); MenuItem keybindMenuBtn = new MenuItem("Keybind Settings", "Enable or disable keybinds for some options."); MenuController.AddSubmenu(menu, keybindMenu); MenuController.BindMenuItem(menu, keybindMenu, keybindMenuBtn); // keybind settings menu items MenuCheckboxItem kbTpToWaypoint = new MenuCheckboxItem("Teleport To Waypoint", "Teleport to your waypoint when pressing the keybind. By default, this keybind is set to ~r~F7~s~, server owners are able to change this however so ask them if you don't know what it is.", KbTpToWaypoint); MenuCheckboxItem kbDriftMode = new MenuCheckboxItem("Drift Mode", "Makes your vehicle have almost no traction while holding left shift on keyboard, or X on controller.", KbDriftMode); MenuCheckboxItem kbRecordKeys = new MenuCheckboxItem("Recording Controls", "Enables or disables the recording (gameplay recording for the Rockstar editor) hotkeys on both keyboard and controller.", KbRecordKeys); MenuCheckboxItem kbRadarKeys = new MenuCheckboxItem("Minimap Controls", "Press the Multiplayer Info (z on keyboard, down arrow on controller) key to switch between expanded radar and normal radar.", KbRadarKeys); MenuCheckboxItem kbPointKeysCheckbox = new MenuCheckboxItem("Finger Point Controls", "Enables the finger point toggle key. The default QWERTY keyboard mapping for this is 'B', or for controller quickly double tap the right analog stick.", KbPointKeys); MenuItem backBtn = new MenuItem("Back"); // Create the menu items. MenuCheckboxItem rightAlignMenu = new MenuCheckboxItem("Right Align Menu", "If you want vMenu to appear on the left side of your screen, disable this option. This option will be saved immediately. You don't need to click save preferences.", MiscRightAlignMenu); MenuCheckboxItem disablePms = new MenuCheckboxItem("Disable Private Messages", "Prevent others from sending you a private message via the Online Players menu. This also prevents you from sending messages to other players.", MiscDisablePrivateMessages); MenuCheckboxItem disableControllerKey = new MenuCheckboxItem("Disable Controller Support", "This disables the controller menu toggle key. This does NOT disable the navigation buttons.", MiscDisableControllerSupport); MenuCheckboxItem speedKmh = new MenuCheckboxItem("Show Speed KM/H", "Show a speedometer on your screen indicating your speed in KM/h.", ShowSpeedoKmh); MenuCheckboxItem speedMph = new MenuCheckboxItem("Show Speed MPH", "Show a speedometer on your screen indicating your speed in MPH.", ShowSpeedoMph); MenuCheckboxItem coords = new MenuCheckboxItem("Show Coordinates", "Show your current coordinates at the top of your screen.", ShowCoordinates); MenuCheckboxItem hideRadar = new MenuCheckboxItem("Hide Radar", "Hide the radar/minimap.", HideRadar); MenuCheckboxItem hideHud = new MenuCheckboxItem("Hide Hud", "Hide all hud elements.", HideHud); MenuCheckboxItem showLocation = new MenuCheckboxItem("Location Display", "Shows your current location and heading, as well as the nearest cross road. Similar like PLD. ~r~Warning: This feature (can) take(s) up to -4.6 FPS when running at 60 Hz.", ShowLocation) { LeftIcon = MenuItem.Icon.WARNING }; MenuCheckboxItem drawTime = new MenuCheckboxItem("Show Time On Screen", "Shows you the current time on screen.", DrawTimeOnScreen); MenuItem saveSettings = new MenuItem("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.") { RightIcon = MenuItem.Icon.TICK }; MenuItem exportData = new MenuItem("Export/Import Data", "Coming soon (TM): the ability to import and export your saved data."); MenuCheckboxItem joinQuitNotifs = new MenuCheckboxItem("Join / Quit Notifications", "Receive notifications when someone joins or leaves the server.", JoinQuitNotifications); MenuCheckboxItem deathNotifs = new MenuCheckboxItem("Death Notifications", "Receive notifications when someone dies or gets killed.", DeathNotifications); MenuCheckboxItem nightVision = new MenuCheckboxItem("Toggle Night Vision", "Enable or disable night vision.", false); MenuCheckboxItem thermalVision = new MenuCheckboxItem("Toggle Thermal Vision", "Enable or disable thermal vision.", false); MenuCheckboxItem vehModelDimensions = new MenuCheckboxItem("Show Vehicle Dimensions", "Draws the model outlines for every vehicle that's currently close to you.", ShowVehicleModelDimensions); MenuCheckboxItem propModelDimensions = new MenuCheckboxItem("Show Prop Dimensions", "Draws the model outlines for every prop that's currently close to you.", ShowPropModelDimensions); MenuCheckboxItem pedModelDimensions = new MenuCheckboxItem("Show Ped Dimensions", "Draws the model outlines for every ped that's currently close to you.", ShowPedModelDimensions); MenuCheckboxItem showEntityHandles = new MenuCheckboxItem("Show Entity Handles", "Draws the the entity handles for all close entities (you must enable the outline functions above for this to work).", ShowEntityHandles); MenuCheckboxItem showEntityModels = new MenuCheckboxItem("Show Entity Models", "Draws the the entity models for all close entities (you must enable the outline functions above for this to work).", ShowEntityModels); MenuSliderItem dimensionsDistanceSlider = new MenuSliderItem("Show Dimensions Radius", "Show entity model/handle/dimension draw range.", 0, 20, 20, false); MenuItem clearArea = new MenuItem("Clear Area", "Clears the area around your player (100 meters). Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up, fixed and reset to the default world state."); MenuCheckboxItem lockCamX = new MenuCheckboxItem("Lock Camera Horizontal Rotation", "Locks your camera horizontal rotation. Could be useful in helicopters I guess.", false); MenuCheckboxItem lockCamY = new MenuCheckboxItem("Lock Camera Vertical Rotation", "Locks your camera vertical rotation. Could be useful in helicopters I guess.", false); Menu connectionSubmenu = new Menu(Game.Player.Name, "Connection Options"); MenuItem connectionSubmenuBtn = new MenuItem("Connection Options", "Server connection/game quit options."); MenuItem quitSession = new MenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. ~r~Can not be used when you are the host."); MenuItem rejoinSession = new MenuItem("Re-join Session", "This may not work in all cases, but you can try to use this if you want to re-join the previous session after clicking 'Quit Session'."); MenuItem quitGame = new MenuItem("Quit Game", "Exits the game after 5 seconds."); MenuItem disconnectFromServer = new MenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. ~r~This feature is not recommended, quit the game completely instead and restart it for a better experience."); connectionSubmenu.AddMenuItem(quitSession); connectionSubmenu.AddMenuItem(rejoinSession); connectionSubmenu.AddMenuItem(quitGame); connectionSubmenu.AddMenuItem(disconnectFromServer); MenuCheckboxItem enableTimeCycle = new MenuCheckboxItem("Enable Timecycle Modifier", "Enable or disable the timecycle modifier from the list below.", TimecycleEnabled); List <string> timeCycleModifiersListData = TimeCycles.Timecycles.ToList(); for (var i = 0; i < timeCycleModifiersListData.Count; i++) { timeCycleModifiersListData[i] += $" ({i + 1}/{timeCycleModifiersListData.Count})"; } MenuListItem timeCycles = new MenuListItem("TM", timeCycleModifiersListData, MathUtil.Clamp(LastTimeCycleModifierIndex, 0, Math.Max(0, timeCycleModifiersListData.Count - 1)), "Select a timecycle modifier and enable the checkbox above."); MenuSliderItem timeCycleIntensity = new MenuSliderItem("Timecycle Modifier Intensity", "Set the timecycle modifier intensity.", 0, 20, LastTimeCycleModifierStrength, true); MenuCheckboxItem locationBlips = new MenuCheckboxItem("Location Blips", "Shows blips on the map for some common locations.", ShowLocationBlips); MenuCheckboxItem playerBlips = new MenuCheckboxItem("Show Player Blips", "Shows blips on the map for all players.", ShowPlayerBlips); MenuCheckboxItem playerNames = new MenuCheckboxItem("Show Player Names", "Enables or disables player overhead names.", MiscShowOverheadNames); MenuCheckboxItem respawnDefaultCharacter = new MenuCheckboxItem("Respawn As Default MP Character", "If you enable this, then you will (re)spawn as your default saved MP character. Note the server owner can globally disable this option. To set your default character, go to one of your saved MP Characters and click the 'Set As Default Character' button.", MiscRespawnDefaultCharacter); MenuCheckboxItem restorePlayerAppearance = new MenuCheckboxItem("Restore Player Appearance", "Restore your player's skin whenever you respawn after being dead. Re-joining a server will not restore your previous skin.", RestorePlayerAppearance); MenuCheckboxItem restorePlayerWeapons = new MenuCheckboxItem("Restore Player Weapons", "Restore your weapons whenever you respawn after being dead. Re-joining a server will not restore your previous weapons.", RestorePlayerWeapons); MenuController.AddSubmenu(menu, connectionSubmenu); MenuController.BindMenuItem(menu, connectionSubmenu, connectionSubmenuBtn); keybindMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == kbTpToWaypoint) { KbTpToWaypoint = _checked; } else if (item == kbDriftMode) { KbDriftMode = _checked; } else if (item == kbRecordKeys) { KbRecordKeys = _checked; } else if (item == kbRadarKeys) { KbRadarKeys = _checked; } else if (item == kbPointKeysCheckbox) { KbPointKeys = _checked; } }; keybindMenu.OnItemSelect += (sender, item, index) => { if (item == backBtn) { keybindMenu.GoBack(); } }; connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { QuitGame(); } else if (item == quitSession) { if (NetworkIsSessionActive()) { if (NetworkIsHost()) { Notify.Error("Sorry, you cannot leave the session when you are the host. This would prevent other players from joining/staying on the server."); } else { QuitSession(); } } else { Notify.Error("You are currently not in any session."); } } else if (item == rejoinSession) { if (NetworkIsSessionActive()) { Notify.Error("You are already connected to a session."); } else { Notify.Info("Attempting to re-join the session."); NetworkSessionHost(-1, 32, false); } } else if (item == disconnectFromServer) { RegisterCommand("disconnect", new Action <dynamic, dynamic, dynamic>((a, b, c) => { }), false); ExecuteCommand("disconnect"); } }; // Teleportation options if (IsAllowed(Permission.MSTeleportToWp) || IsAllowed(Permission.MSTeleportLocations) || IsAllowed(Permission.MSTeleportToCoord)) { MenuItem teleportOptionsMenuBtn = new MenuItem("Teleport Options", "Various teleport options.") { Label = "→→→" }; menu.AddMenuItem(teleportOptionsMenuBtn); MenuController.BindMenuItem(menu, teleportOptionsMenu, teleportOptionsMenuBtn); MenuItem tptowp = new MenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); MenuItem tpToCoord = new MenuItem("Teleport To Coords", "Enter x, y, z coordinates and you will be teleported to that location."); MenuItem saveLocationBtn = new MenuItem("Save Teleport Location", "Adds your current location to the teleport locations menu and saves it on the server."); teleportOptionsMenu.OnItemSelect += async(sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { TeleportToWp(); } else if (item == tpToCoord) { string x = await GetUserInput("Enter X coordinate."); if (string.IsNullOrEmpty(x)) { Notify.Error(CommonErrors.InvalidInput); return; } string y = await GetUserInput("Enter Y coordinate."); if (string.IsNullOrEmpty(y)) { Notify.Error(CommonErrors.InvalidInput); return; } string z = await GetUserInput("Enter Z coordinate."); if (string.IsNullOrEmpty(z)) { Notify.Error(CommonErrors.InvalidInput); return; } float posX = 0f; float posY = 0f; float posZ = 0f; if (!float.TryParse(x, out posX)) { if (int.TryParse(x, out int intX)) { posX = (float)intX; } else { Notify.Error("You did not enter a valid X coordinate."); return; } } if (!float.TryParse(y, out posY)) { if (int.TryParse(y, out int intY)) { posY = (float)intY; } else { Notify.Error("You did not enter a valid Y coordinate."); return; } } if (!float.TryParse(z, out posZ)) { if (int.TryParse(z, out int intZ)) { posZ = (float)intZ; } else { Notify.Error("You did not enter a valid Z coordinate."); return; } } await TeleportToCoords(new Vector3(posX, posY, posZ), true); } else if (item == saveLocationBtn) { SavePlayerLocationToLocationsFile(); } }; if (IsAllowed(Permission.MSTeleportToWp)) { teleportOptionsMenu.AddMenuItem(tptowp); keybindMenu.AddMenuItem(kbTpToWaypoint); } if (IsAllowed(Permission.MSTeleportToCoord)) { teleportOptionsMenu.AddMenuItem(tpToCoord); } if (IsAllowed(Permission.MSTeleportLocations)) { teleportOptionsMenu.AddMenuItem(teleportMenuBtn); MenuController.AddSubmenu(teleportOptionsMenu, teleportMenu); MenuController.BindMenuItem(teleportOptionsMenu, teleportMenu, teleportMenuBtn); teleportMenuBtn.Label = "→→→"; teleportMenu.OnMenuOpen += (sender) => { if (teleportMenu.Size != TpLocations.Count()) { teleportMenu.ClearMenuItems(); foreach (var location in TpLocations) { var x = Math.Round(location.coordinates.X, 2); var y = Math.Round(location.coordinates.Y, 2); var z = Math.Round(location.coordinates.Z, 2); var heading = Math.Round(location.heading, 2); MenuItem tpBtn = new MenuItem(location.name, $"Teleport to ~y~{location.name}~n~~s~x: ~y~{x}~n~~s~y: ~y~{y}~n~~s~z: ~y~{z}~n~~s~heading: ~y~{heading}") { ItemData = location }; teleportMenu.AddMenuItem(tpBtn); } } }; teleportMenu.OnItemSelect += async(sender, item, index) => { if (item.ItemData is vMenuShared.ConfigManager.TeleportLocation tl) { await TeleportToCoords(tl.coordinates, true); SetEntityHeading(Game.PlayerPed.Handle, tl.heading); SetGameplayCamRelativeHeading(0f); } }; if (IsAllowed(Permission.MSTeleportSaveLocation)) { teleportOptionsMenu.AddMenuItem(saveLocationBtn); } } } #region dev tools menu MenuItem devToolsBtn = new MenuItem("Developer Tools", "Various development/debug tools.") { Label = "→→→" }; menu.AddMenuItem(devToolsBtn); MenuController.AddSubmenu(menu, developerToolsMenu); MenuController.BindMenuItem(menu, developerToolsMenu, devToolsBtn); // clear area and coordinates if (IsAllowed(Permission.MSClearArea)) { developerToolsMenu.AddMenuItem(clearArea); } if (IsAllowed(Permission.MSShowCoordinates)) { developerToolsMenu.AddMenuItem(coords); } // model outlines if (!vMenuShared.ConfigManager.GetSettingsBool(vMenuShared.ConfigManager.Setting.vmenu_disable_entity_outlines_tool)) { developerToolsMenu.AddMenuItem(vehModelDimensions); developerToolsMenu.AddMenuItem(propModelDimensions); developerToolsMenu.AddMenuItem(pedModelDimensions); developerToolsMenu.AddMenuItem(showEntityHandles); developerToolsMenu.AddMenuItem(showEntityModels); developerToolsMenu.AddMenuItem(dimensionsDistanceSlider); } // timecycle modifiers developerToolsMenu.AddMenuItem(timeCycles); developerToolsMenu.AddMenuItem(enableTimeCycle); developerToolsMenu.AddMenuItem(timeCycleIntensity); developerToolsMenu.OnSliderPositionChange += (sender, item, oldPos, newPos, itemIndex) => { if (item == timeCycleIntensity) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)newPos / 20f); SetTimecycleModifierStrength(intensity); } UserDefaults.MiscLastTimeCycleModifierIndex = timeCycles.ListIndex; UserDefaults.MiscLastTimeCycleModifierStrength = timeCycleIntensity.Position; } else if (item == dimensionsDistanceSlider) { FunctionsController.entityRange = ((float)newPos / 20f) * 2000f; // max radius = 2000f; } }; developerToolsMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == timeCycles) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } UserDefaults.MiscLastTimeCycleModifierIndex = timeCycles.ListIndex; UserDefaults.MiscLastTimeCycleModifierStrength = timeCycleIntensity.Position; } }; developerToolsMenu.OnItemSelect += (sender, item, index) => { if (item == clearArea) { var pos = Game.PlayerPed.Position; BaseScript.TriggerServerEvent("vMenu:ClearArea", pos.X, pos.Y, pos.Z); } }; developerToolsMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == vehModelDimensions) { ShowVehicleModelDimensions = _checked; } else if (item == propModelDimensions) { ShowPropModelDimensions = _checked; } else if (item == pedModelDimensions) { ShowPedModelDimensions = _checked; } else if (item == showEntityHandles) { ShowEntityHandles = _checked; } else if (item == showEntityModels) { ShowEntityModels = _checked; } else if (item == enableTimeCycle) { TimecycleEnabled = _checked; ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } } else if (item == coords) { ShowCoordinates = _checked; } }; #endregion // Keybind options if (IsAllowed(Permission.MSDriftMode)) { keybindMenu.AddMenuItem(kbDriftMode); } // always allowed keybind menu options keybindMenu.AddMenuItem(kbRecordKeys); keybindMenu.AddMenuItem(kbRadarKeys); keybindMenu.AddMenuItem(kbPointKeysCheckbox); keybindMenu.AddMenuItem(backBtn); // Always allowed menu.AddMenuItem(rightAlignMenu); menu.AddMenuItem(disablePms); menu.AddMenuItem(disableControllerKey); menu.AddMenuItem(speedKmh); menu.AddMenuItem(speedMph); menu.AddMenuItem(keybindMenuBtn); keybindMenuBtn.Label = "→→→"; if (IsAllowed(Permission.MSConnectionMenu)) { menu.AddMenuItem(connectionSubmenuBtn); connectionSubmenuBtn.Label = "→→→"; } if (IsAllowed(Permission.MSShowLocation)) { menu.AddMenuItem(showLocation); } menu.AddMenuItem(drawTime); // always allowed if (IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddMenuItem(deathNotifs); } if (IsAllowed(Permission.MSDeathNotifs)) { menu.AddMenuItem(joinQuitNotifs); } if (IsAllowed(Permission.MSNightVision)) { menu.AddMenuItem(nightVision); } if (IsAllowed(Permission.MSThermalVision)) { menu.AddMenuItem(thermalVision); } if (IsAllowed(Permission.MSLocationBlips)) { menu.AddMenuItem(locationBlips); ToggleBlips(ShowLocationBlips); } if (IsAllowed(Permission.MSPlayerBlips)) { menu.AddMenuItem(playerBlips); } if (IsAllowed(Permission.MSOverheadNames)) { menu.AddMenuItem(playerNames); } // always allowed, it just won't do anything if the server owner disabled the feature, but players can still toggle it. menu.AddMenuItem(respawnDefaultCharacter); if (IsAllowed(Permission.MSRestoreAppearance)) { menu.AddMenuItem(restorePlayerAppearance); } if (IsAllowed(Permission.MSRestoreWeapons)) { menu.AddMenuItem(restorePlayerWeapons); } // Always allowed menu.AddMenuItem(hideRadar); menu.AddMenuItem(hideHud); menu.AddMenuItem(lockCamX); menu.AddMenuItem(lockCamY); menu.AddMenuItem(exportData); menu.AddMenuItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == rightAlignMenu) { MenuController.MenuAlignment = _checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = _checked; UserDefaults.MiscRightAlignMenu = MiscRightAlignMenu; if (MenuController.MenuAlignment != (_checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left)) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } } else if (item == disablePms) { MiscDisablePrivateMessages = _checked; } else if (item == disableControllerKey) { MiscDisableControllerSupport = _checked; MenuController.EnableMenuToggleKeyOnController = !_checked; } else if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == hideHud) { HideHud = _checked; DisplayHud(!_checked); } else if (item == hideRadar) { HideRadar = _checked; if (!_checked) { DisplayRadar(true); } } else if (item == showLocation) { ShowLocation = _checked; } else if (item == drawTime) { DrawTimeOnScreen = _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; } else if (item == playerNames) { MiscShowOverheadNames = _checked; } else if (item == respawnDefaultCharacter) { MiscRespawnDefaultCharacter = _checked; } else if (item == restorePlayerAppearance) { RestorePlayerAppearance = _checked; } else if (item == restorePlayerWeapons) { RestorePlayerWeapons = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // export data if (item == exportData) { var vehicles = GetSavedVehicles(); var normalPeds = StorageManager.GetSavedPeds(); var mpPeds = StorageManager.GetSavedMpPeds(); var weaponLoadouts = WeaponLoadouts.GetSavedWeapons(); //SetNuiFocus(true, true); //SendNuiMessage(JsonConvert.SerializeObject(new //var data = JsonConvert.SerializeObject(new //{ // saved_vehicles = vehicles, // normal_peds = normalPeds, // mp_characters = mpPeds, // weapon_loadouts = weaponLoadouts //}); //Debug.WriteLine(data.Length + "\n" + data); //TriggerServerEvent("test", data); } // save settings else if (item == saveSettings) { UserDefaults.SaveSettings(); } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { MenuController.MenuAlignment = MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; if (MenuController.MenuAlignment != (MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left)) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } // Create the menu. menu = new Menu(Game.Player.Name, "其它設定選單"); teleportOptionsMenu = new Menu(Game.Player.Name, "瞬移設定"); developerToolsMenu = new Menu(Game.Player.Name, "開發者工具"); // teleport menu Menu teleportMenu = new Menu(Game.Player.Name, "傳送地點"); MenuItem teleportMenuBtn = new MenuItem("傳送地點", "傳送到伺服器添加的預配位置"); MenuController.AddSubmenu(menu, teleportMenu); MenuController.BindMenuItem(menu, teleportMenu, teleportMenuBtn); // keybind settings menu Menu keybindMenu = new Menu(Game.Player.Name, "按鍵設定"); MenuItem keybindMenuBtn = new MenuItem("按鍵設定", "開啟或關閉鍵盤綁定"); MenuController.AddSubmenu(menu, keybindMenu); MenuController.BindMenuItem(menu, keybindMenu, keybindMenuBtn); // keybind settings menu items MenuCheckboxItem kbTpToWaypoint = new MenuCheckboxItem("傳送到導航點", "", KbTpToWaypoint); MenuCheckboxItem kbDriftMode = new MenuCheckboxItem("飄移模式", "按住鍵盤上的左移或者搖趕上的X鍵,能使車輛甩尾.", KbDriftMode); MenuCheckboxItem kbRecordKeys = new MenuCheckboxItem("錄影控制", "開啟或關閉用鍵盤和搖桿控制 (Rockstar 編輯器) 熱鍵.", KbRecordKeys); MenuCheckboxItem kbRadarKeys = new MenuCheckboxItem("小地圖控件", "按鍵盤上的z,控制器上的向下箭頭鍵在擴展雷達和普通雷達之間切換.", KbRadarKeys); MenuCheckboxItem kbPointKeysCheckbox = new MenuCheckboxItem("手指點控件", "", KbPointKeys); MenuItem backBtn = new MenuItem("返回"); // Create the menu items. MenuCheckboxItem rightAlignMenu = new MenuCheckboxItem("像右對齊選單", "", MiscRightAlignMenu); MenuCheckboxItem disablePms = new MenuCheckboxItem("禁用私人訊息", "阻止其它人通過 '線上模式'選單像您發送私人訊息.", MiscDisablePrivateMessages); MenuCheckboxItem disableControllerKey = new MenuCheckboxItem("禁止控制器選單", "這將禁用控制器選單切換鍵不會禁用導航按鈕.", MiscDisableControllerSupport); MenuCheckboxItem speedKmh = new MenuCheckboxItem("顯示儀表板KM/H", "視窗上顯示一個計速器,以KM/h為單位顯示速度", ShowSpeedoKmh); MenuCheckboxItem speedMph = new MenuCheckboxItem("顯示速度MPH", "視窗上顯示一個計速器,以MPH為單位顯示速度", ShowSpeedoMph); MenuCheckboxItem coords = new MenuCheckboxItem("顯示坐標", "視窗頂部顯示當前座標.", ShowCoordinates); MenuCheckboxItem hideRadar = new MenuCheckboxItem("隱藏雷達", "隱藏雷達/小地圖", HideRadar); MenuCheckboxItem hideHud = new MenuCheckboxItem("隱藏 Hud", "隱藏所有HUD元素.", HideHud); MenuCheckboxItem showLocation = new MenuCheckboxItem("位置顯示", "顯示您當前的位置和方向,以最近的交叉路口類似PLD. ~r~警告: 可能會降低FPS", ShowLocation) { LeftIcon = MenuItem.Icon.WARNING }; MenuCheckboxItem drawTime = new MenuCheckboxItem("顯示時間", "在視窗上顯示當前遊戲時間.", DrawTimeOnScreen); MenuItem saveSettings = new MenuItem("保存個人設置", "保存當前設置。 所有保存都在客戶端完成,如果重新安裝Windows,則會丟失設置。 使用vMenu在所有服務器之間共享設置.") { RightIcon = MenuItem.Icon.TICK }; MenuCheckboxItem joinQuitNotifs = new MenuCheckboxItem("加入/離開通知", "有人加入或者離開伺服器都會收到通知.", JoinQuitNotifications); MenuCheckboxItem deathNotifs = new MenuCheckboxItem("死亡通知", "有人死亡或者被殺都會收到通知.", DeathNotifications); MenuCheckboxItem nightVision = new MenuCheckboxItem("開關夜視鏡", "開啟或關閉夜視鏡功能.", false); MenuCheckboxItem thermalVision = new MenuCheckboxItem("開關熱感應", "開啟或關閉熱感應功能.", false); MenuCheckboxItem vehModelDimensions = new MenuCheckboxItem("顯示載具尺寸", "當前靠近您的每輛載具都會有模型輪廓", ShowVehicleModelDimensions); MenuCheckboxItem propModelDimensions = new MenuCheckboxItem("顯示道具尺寸", "當前靠近您的每個武器都會有道具輪廓", ShowPropModelDimensions); MenuCheckboxItem pedModelDimensions = new MenuCheckboxItem("顯示人物尺寸", "當前靠近您的每個人都會有人物輪廓.", ShowPedModelDimensions); MenuCheckboxItem showEntityHandles = new MenuCheckboxItem("顯示實體句炳", "繪製所有關閉實體的句炳 (必須啟用上面的功能,該功能才會有用).", ShowEntityHandles); MenuCheckboxItem showEntityModels = new MenuCheckboxItem("顯示實體模型", "繪製所有閉合實體的模型(必須啟用上面的功能,該功能才會有用).", ShowEntityModels); MenuSliderItem dimensionsDistanceSlider = new MenuSliderItem("顯示尺寸半徑", "顯示實體模型/手柄/尺寸繪製範圍.", 0, 20, 20, false); MenuItem clearArea = new MenuItem("清空地區", "清除你周圍區域(100米)所有物件除了人"); MenuCheckboxItem lockCamX = new MenuCheckboxItem("鎖定相機水平翻轉", "鎖定相機水平翻轉.", false); MenuCheckboxItem lockCamY = new MenuCheckboxItem("鎖定相機垂直翻轉", "鎖定相機垂直翻轉.", false); Menu connectionSubmenu = new Menu(Game.Player.Name, "連線選項"); MenuItem connectionSubmenuBtn = new MenuItem("連線選項", "伺服器連接/遊戲退出選項"); MenuItem quitSession = new MenuItem("退出連線", ""); MenuItem rejoinSession = new MenuItem("重新加入連線", ""); MenuItem quitGame = new MenuItem("退出遊戲", "五秒後退出遊戲"); MenuItem disconnectFromServer = new MenuItem("與伺服器段開連接", ""); connectionSubmenu.AddMenuItem(quitSession); connectionSubmenu.AddMenuItem(rejoinSession); connectionSubmenu.AddMenuItem(quitGame); connectionSubmenu.AddMenuItem(disconnectFromServer); MenuCheckboxItem enableTimeCycle = new MenuCheckboxItem("Enable Timecycle Modifier", "Enable or disable the timecycle modifier from the list below.", TimecycleEnabled); List <string> timeCycleModifiersListData = TimeCycles.Timecycles.ToList(); for (var i = 0; i < timeCycleModifiersListData.Count; i++) { timeCycleModifiersListData[i] += $" ({i + 1}/{timeCycleModifiersListData.Count})"; } MenuListItem timeCycles = new MenuListItem("TM", timeCycleModifiersListData, MathUtil.Clamp(LastTimeCycleModifierIndex, 0, Math.Max(0, timeCycleModifiersListData.Count - 1)), "選擇一個倒數計時啟用上面的複選框."); MenuSliderItem timeCycleIntensity = new MenuSliderItem("時間週期修改器強度", "設置時間週期修改器強度.", 0, 20, LastTimeCycleModifierStrength, true); MenuCheckboxItem locationBlips = new MenuCheckboxItem("位置提示", "在地圖上顯示位置提示.", ShowLocationBlips); MenuCheckboxItem playerBlips = new MenuCheckboxItem("顯示玩家提示", "在地圖上顯示玩家提示.", ShowPlayerBlips); MenuCheckboxItem playerNames = new MenuCheckboxItem("顯示玩家名字", "開啟或關閉玩家名字", MiscShowOverheadNames); MenuCheckboxItem respawnDefaultCharacter = new MenuCheckboxItem("重新生成為預設創建", "", MiscRespawnDefaultCharacter); MenuCheckboxItem restorePlayerAppearance = new MenuCheckboxItem("恢復玩家外觀", "死亡重生時恢復玩家的皮膚,重新加速伺服器時將不會恢復您以前的造型.", RestorePlayerAppearance); MenuCheckboxItem restorePlayerWeapons = new MenuCheckboxItem("恢復玩家武器", "死亡重生時恢復玩家的武器,重新加速伺服器時將不會恢復您以前的武器.", RestorePlayerWeapons); MenuController.AddSubmenu(menu, connectionSubmenu); MenuController.BindMenuItem(menu, connectionSubmenu, connectionSubmenuBtn); keybindMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == kbTpToWaypoint) { KbTpToWaypoint = _checked; } else if (item == kbDriftMode) { KbDriftMode = _checked; } else if (item == kbRecordKeys) { KbRecordKeys = _checked; } else if (item == kbRadarKeys) { KbRadarKeys = _checked; } else if (item == kbPointKeysCheckbox) { KbPointKeys = _checked; } }; keybindMenu.OnItemSelect += (sender, item, index) => { if (item == backBtn) { keybindMenu.GoBack(); } }; connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { QuitGame(); } else if (item == quitSession) { if (NetworkIsSessionActive()) { if (NetworkIsHost()) { Notify.Error("抱歉,您不能在主持人後退出戰局。 這將阻止其他玩家加入/停留在服務器上。"); } else { QuitSession(); } } else { Notify.Error("您目前沒有參加任何戰局."); } } else if (item == rejoinSession) { if (NetworkIsSessionActive()) { Notify.Error("您已經連接到戰局."); } else { Notify.Info("嘗試重新加入戰局."); NetworkSessionHost(-1, 32, false); } } else if (item == disconnectFromServer) { RegisterCommand("disconnect", new Action <dynamic, dynamic, dynamic>((a, b, c) => { }), false); ExecuteCommand("disconnect"); } }; // Teleportation options if (IsAllowed(Permission.MSTeleportToWp) || IsAllowed(Permission.MSTeleportLocations) || IsAllowed(Permission.MSTeleportToCoord)) { MenuItem teleportOptionsMenuBtn = new MenuItem("傳送選項", "各種傳送選擇.") { Label = "→→→" }; menu.AddMenuItem(teleportOptionsMenuBtn); MenuController.BindMenuItem(menu, teleportOptionsMenu, teleportOptionsMenuBtn); MenuItem tptowp = new MenuItem("傳送到導航點", "傳送到地圖上的導航點"); MenuItem tpToCoord = new MenuItem("傳送到座標", "輸入 x, y, z 座標 您將被傳誦到該位置"); MenuItem saveLocationBtn = new MenuItem("保存傳送位置", "將您當前的位置添加倒傳送位置選單中,並且保存到伺服器中"); teleportOptionsMenu.OnItemSelect += async(sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { TeleportToWp(); } else if (item == tpToCoord) { string x = await GetUserInput("輸入 X 座標."); if (string.IsNullOrEmpty(x)) { Notify.Error(CommonErrors.InvalidInput); return; } string y = await GetUserInput("輸入 Y 座標."); if (string.IsNullOrEmpty(y)) { Notify.Error(CommonErrors.InvalidInput); return; } string z = await GetUserInput("輸入 Z 座標."); if (string.IsNullOrEmpty(z)) { Notify.Error(CommonErrors.InvalidInput); return; } float posX = 0f; float posY = 0f; float posZ = 0f; if (!float.TryParse(x, out posX)) { if (int.TryParse(x, out int intX)) { posX = (float)intX; } else { Notify.Error("您輸入的不是一個有效的 X 座標."); return; } } if (!float.TryParse(y, out posY)) { if (int.TryParse(y, out int intY)) { posY = (float)intY; } else { Notify.Error("您輸入的不是一個有效的 Y 座標."); return; } } if (!float.TryParse(z, out posZ)) { if (int.TryParse(z, out int intZ)) { posZ = (float)intZ; } else { Notify.Error("您輸入的不是一個有效的 Z 座標."); return; } } await TeleportToCoords(new Vector3(posX, posY, posZ), true); } else if (item == saveLocationBtn) { SavePlayerLocationToLocationsFile(); } }; if (IsAllowed(Permission.MSTeleportToWp)) { teleportOptionsMenu.AddMenuItem(tptowp); keybindMenu.AddMenuItem(kbTpToWaypoint); } if (IsAllowed(Permission.MSTeleportToCoord)) { teleportOptionsMenu.AddMenuItem(tpToCoord); } if (IsAllowed(Permission.MSTeleportLocations)) { teleportOptionsMenu.AddMenuItem(teleportMenuBtn); MenuController.AddSubmenu(teleportOptionsMenu, teleportMenu); MenuController.BindMenuItem(teleportOptionsMenu, teleportMenu, teleportMenuBtn); teleportMenuBtn.Label = "→→→"; teleportMenu.OnMenuOpen += (sender) => { if (teleportMenu.Size != TpLocations.Count()) { teleportMenu.ClearMenuItems(); foreach (var location in TpLocations) { var x = Math.Round(location.coordinates.X, 2); var y = Math.Round(location.coordinates.Y, 2); var z = Math.Round(location.coordinates.Z, 2); var heading = Math.Round(location.heading, 2); MenuItem tpBtn = new MenuItem(location.name, $"已經傳送到 ~y~{location.name}~n~~s~x: ~y~{x}~n~~s~y: ~y~{y}~n~~s~z: ~y~{z}~n~~s~heading: ~y~{heading}") { ItemData = location }; teleportMenu.AddMenuItem(tpBtn); } } }; teleportMenu.OnItemSelect += async(sender, item, index) => { if (item.ItemData is vMenuShared.ConfigManager.TeleportLocation tl) { await TeleportToCoords(tl.coordinates, true); SetEntityHeading(Game.PlayerPed.Handle, tl.heading); SetGameplayCamRelativeHeading(0f); } }; if (IsAllowed(Permission.MSTeleportSaveLocation)) { teleportOptionsMenu.AddMenuItem(saveLocationBtn); } } } #region dev tools menu MenuItem devToolsBtn = new MenuItem("開發者選項", "各種開發/調試工具.") { Label = "→→→" }; menu.AddMenuItem(devToolsBtn); MenuController.AddSubmenu(menu, developerToolsMenu); MenuController.BindMenuItem(menu, developerToolsMenu, devToolsBtn); // clear area and coordinates if (IsAllowed(Permission.MSClearArea)) { developerToolsMenu.AddMenuItem(clearArea); } if (IsAllowed(Permission.MSShowCoordinates)) { developerToolsMenu.AddMenuItem(coords); } // model outlines if (!vMenuShared.ConfigManager.GetSettingsBool(vMenuShared.ConfigManager.Setting.vmenu_disable_entity_outlines_tool)) { developerToolsMenu.AddMenuItem(vehModelDimensions); developerToolsMenu.AddMenuItem(propModelDimensions); developerToolsMenu.AddMenuItem(pedModelDimensions); developerToolsMenu.AddMenuItem(showEntityHandles); developerToolsMenu.AddMenuItem(showEntityModels); developerToolsMenu.AddMenuItem(dimensionsDistanceSlider); } // timecycle modifiers developerToolsMenu.AddMenuItem(timeCycles); developerToolsMenu.AddMenuItem(enableTimeCycle); developerToolsMenu.AddMenuItem(timeCycleIntensity); developerToolsMenu.OnSliderPositionChange += (sender, item, oldPos, newPos, itemIndex) => { if (item == timeCycleIntensity) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)newPos / 20f); SetTimecycleModifierStrength(intensity); } UserDefaults.MiscLastTimeCycleModifierIndex = timeCycles.ListIndex; UserDefaults.MiscLastTimeCycleModifierStrength = timeCycleIntensity.Position; } else if (item == dimensionsDistanceSlider) { FunctionsController.entityRange = ((float)newPos / 20f) * 2000f; // max radius = 2000f; } }; developerToolsMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == timeCycles) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } UserDefaults.MiscLastTimeCycleModifierIndex = timeCycles.ListIndex; UserDefaults.MiscLastTimeCycleModifierStrength = timeCycleIntensity.Position; } }; developerToolsMenu.OnItemSelect += (sender, item, index) => { if (item == clearArea) { var pos = Game.PlayerPed.Position; BaseScript.TriggerServerEvent("vMenu:ClearArea", pos.X, pos.Y, pos.Z); } }; developerToolsMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == vehModelDimensions) { ShowVehicleModelDimensions = _checked; } else if (item == propModelDimensions) { ShowPropModelDimensions = _checked; } else if (item == pedModelDimensions) { ShowPedModelDimensions = _checked; } else if (item == showEntityHandles) { ShowEntityHandles = _checked; } else if (item == showEntityModels) { ShowEntityModels = _checked; } else if (item == enableTimeCycle) { TimecycleEnabled = _checked; ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } } else if (item == coords) { ShowCoordinates = _checked; } }; #endregion // Keybind options if (IsAllowed(Permission.MSDriftMode)) { keybindMenu.AddMenuItem(kbDriftMode); } // always allowed keybind menu options keybindMenu.AddMenuItem(kbRecordKeys); keybindMenu.AddMenuItem(kbRadarKeys); keybindMenu.AddMenuItem(kbPointKeysCheckbox); keybindMenu.AddMenuItem(backBtn); // Always allowed menu.AddMenuItem(rightAlignMenu); menu.AddMenuItem(disablePms); menu.AddMenuItem(disableControllerKey); menu.AddMenuItem(speedKmh); menu.AddMenuItem(speedMph); menu.AddMenuItem(keybindMenuBtn); keybindMenuBtn.Label = "→→→"; if (IsAllowed(Permission.MSConnectionMenu)) { menu.AddMenuItem(connectionSubmenuBtn); connectionSubmenuBtn.Label = "→→→"; } if (IsAllowed(Permission.MSShowLocation)) { menu.AddMenuItem(showLocation); } menu.AddMenuItem(drawTime); // always allowed if (IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddMenuItem(deathNotifs); } if (IsAllowed(Permission.MSDeathNotifs)) { menu.AddMenuItem(joinQuitNotifs); } if (IsAllowed(Permission.MSNightVision)) { menu.AddMenuItem(nightVision); } if (IsAllowed(Permission.MSThermalVision)) { menu.AddMenuItem(thermalVision); } if (IsAllowed(Permission.MSLocationBlips)) { menu.AddMenuItem(locationBlips); ToggleBlips(ShowLocationBlips); } if (IsAllowed(Permission.MSPlayerBlips)) { menu.AddMenuItem(playerBlips); } if (IsAllowed(Permission.MSOverheadNames)) { menu.AddMenuItem(playerNames); } // always allowed, it just won't do anything if the server owner disabled the feature, but players can still toggle it. menu.AddMenuItem(respawnDefaultCharacter); if (IsAllowed(Permission.MSRestoreAppearance)) { menu.AddMenuItem(restorePlayerAppearance); } if (IsAllowed(Permission.MSRestoreWeapons)) { menu.AddMenuItem(restorePlayerWeapons); } // Always allowed menu.AddMenuItem(hideRadar); menu.AddMenuItem(hideHud); menu.AddMenuItem(lockCamX); menu.AddMenuItem(lockCamY); menu.AddMenuItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == rightAlignMenu) { MenuController.MenuAlignment = _checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = _checked; UserDefaults.MiscRightAlignMenu = MiscRightAlignMenu; if (MenuController.MenuAlignment != (_checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left)) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } } else if (item == disablePms) { MiscDisablePrivateMessages = _checked; } else if (item == disableControllerKey) { MiscDisableControllerSupport = _checked; MenuController.EnableMenuToggleKeyOnController = !_checked; } else if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == hideHud) { HideHud = _checked; DisplayHud(!_checked); } else if (item == hideRadar) { HideRadar = _checked; if (!_checked) { DisplayRadar(true); } } else if (item == showLocation) { ShowLocation = _checked; } else if (item == drawTime) { DrawTimeOnScreen = _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; } else if (item == playerNames) { MiscShowOverheadNames = _checked; } else if (item == respawnDefaultCharacter) { MiscRespawnDefaultCharacter = _checked; } else if (item == restorePlayerAppearance) { RestorePlayerAppearance = _checked; } else if (item == restorePlayerWeapons) { RestorePlayerWeapons = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // save settings if (item == saveSettings) { UserDefaults.SaveSettings(); } }; }
public void EditMapMenu(Menu parent, ClientMap map) { Menu deleteMapMenu = AddSubMenu(parent, "Delete " + map.Name + "?"); deleteMapMenu.AddMenuItem(new MenuItem("Yes", "")); deleteMapMenu.AddMenuItem(new MenuItem("No", "")); deleteMapMenu.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Yes") { } if (_item.Text == "No") { deleteMapMenu.CloseMenu(); } }; parent.AddMenuItem(new MenuItem("Show/Hide")); parent.AddMenuItem(new MenuItem("Teleport to")); parent.AddMenuItem(new MenuItem("Set Map Name")); parent.AddMenuItem(new MenuItem("Set Gamemodes")); parent.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Show/Hide") { } if (_item.Text == "Teleport to") { } if (_item.Text == "Set Map Name") { ClientGlobals.SendNUIMessage("enable", "mapName"); } if (_item.Text == "Set Gamemodes") { ClientGlobals.SendNUIMessage("enable", "mapGamemode"); } if (_item.Text == "Save") { ClientGlobals.SendMap(map); parent.CloseMenu(); TriggerServerEvent("salty:netOpenMapGUI"); } }; Vector2 dimensions = new Vector2(100, 100); MenuSliderItem sliderOffset = new MenuSliderItem("Offset: 1", -25, 25, 1, false); MenuSliderItem sliderX = new MenuSliderItem("Centre X: ", -999999, 999999, (int)dimensions.X, false); MenuSliderItem sliderY = new MenuSliderItem("Centre Y: ", -999999, 999999, (int)dimensions.Y, false); MenuSliderItem sliderWidth = new MenuSliderItem("Width: ", -9999, 9999, (int)dimensions.X, false); MenuSliderItem sliderLength = new MenuSliderItem("Length: ", -9999, 9999, (int)dimensions.Y, false); parent.AddMenuItem(sliderOffset); parent.AddMenuItem(sliderX); parent.AddMenuItem(sliderY); parent.AddMenuItem(sliderWidth); parent.AddMenuItem(sliderLength); MenuItem deleteMapItem = AddMenuItem(parent, deleteMapMenu, "Delete Map", "Delete entire map", "", true); parent.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { if (_sliderItem == sliderOffset) { _sliderItem.Text = "Offset: " + _newPosition; } if (_sliderItem == sliderX) { map.Position.X += (_newPosition - _oldPosition) * sliderOffset.Position; _sliderItem.Text = "Centre X: " + map.Position.X; } if (_sliderItem == sliderY) { map.Position.Y += (_newPosition - _oldPosition) * sliderOffset.Position; _sliderItem.Text = "Centre Y: " + map.Position.Y; } if (_sliderItem == sliderWidth) { map.Size.X += (_newPosition - _oldPosition) * sliderOffset.Position; _sliderItem.Text = "Width: " + map.Size.X; } if (_sliderItem == sliderLength) { map.Size.Y += (_newPosition - _oldPosition) * sliderOffset.Position; _sliderItem.Text = "Length: " + map.Size.Y; } }; parent.OnMenuOpen += (_) => { ClientGlobals.LastSelectedMap = map; if (map.JustCreated) { map.Position = LocalPlayer.Character.Position; map.Size = new Vector3(0, 0, 0); map.Name = "unnamed" + Game.GameTime; } sliderX.Text = "Centre X: " + map.Position.X; sliderY.Text = "Centre Y: " + map.Position.Y; sliderWidth.Text = "Width: " + map.Size.X; sliderLength.Text = "Length: " + map.Size.Y; }; parent.OnMenuClose += (_) => { }; Menu playerSpawnMenu = AddSubMenu(parent, "Edit " + map.Name + " player spawns"); playerSpawnMenu.AddMenuItem(new MenuItem("Save")); MenuItem playerSpawnItem = AddMenuItem(parent, playerSpawnMenu, "Player Spawns", "Modify player spawn points", "", true); Menu addSpawnMenu = EditSpawnMenu(playerSpawnMenu, map, new Spawn(-3, LocalPlayer.Character.Position, 0, "player", 0)); foreach (var spawn in map.Spawns) { Menu editSpawnMenu = EditSpawnMenu(playerSpawnMenu, map, spawn); } playerSpawnMenu.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Save") { ClientGlobals.SendMap(map); playerSpawnMenu.CloseMenu(); TriggerServerEvent("salty:netOpenMapGUI"); } }; parent.AddMenuItem(new MenuItem("Save", "Saves new position and size")); }
public ExampleMenu() { // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly. // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; // Creating the first menu. Menu menu = new Menu("Main Menu", "Subtitle") { Visible = true }; MenuController.AddMenu(menu); // Adding a new button by directly creating one inline. You could also just store it and then add it but we don't need to do that in this example. menu.AddMenuItem(new MenuItem("Normal Button", "This is a simple button with a simple description. Scroll down for more button types!")); // Creating 3 sliders, showing off the 3 possible variations and custom colors. MenuSliderItem slider = new MenuSliderItem("Slider", 0, 10, 5, false); MenuSliderItem slider2 = new MenuSliderItem("Slider + Bar", 0, 10, 5, true) { BarColor = Color.FromArgb(255, 73, 233, 111), BackgroundColor = Color.FromArgb(255, 25, 100, 43) }; MenuSliderItem slider3 = new MenuSliderItem("Slider + Bar + Icons", "The icons are currently male/female because that's probably the most common use. But any icon can be used!", 0, 10, 5, true) { BarColor = Color.FromArgb(255, 255, 0, 0), BackgroundColor = Color.FromArgb(255, 100, 0, 0), SliderLeftIcon = MenuItem.Icon.MALE, SliderRightIcon = MenuItem.Icon.FEMALE }; // adding the sliders to the menu. menu.AddMenuItem(slider); menu.AddMenuItem(slider2); menu.AddMenuItem(slider3); // Creating 3 checkboxs, 2 different styles and one has a locked icon and it's 'not enabled' (not enabled meaning you can't toggle it). MenuCheckboxItem box = new MenuCheckboxItem("Checkbox - Style 1 (click me!)", "This checkbox can toggle the menu position! Try it out.", !menu.LeftAligned) { Style = MenuCheckboxItem.CheckboxStyle.Tick }; MenuCheckboxItem box2 = new MenuCheckboxItem("Checkbox - Style 2", "This checkbox does nothing right now.", true) { Style = MenuCheckboxItem.CheckboxStyle.Cross }; MenuCheckboxItem box3 = new MenuCheckboxItem("Checkbox (unchecked + locked)", "Make this menu right aligned. If you set this to false, then the menu will move to the left.", false) { Style = MenuCheckboxItem.CheckboxStyle.Cross, Enabled = false, LeftIcon = MenuItem.Icon.LOCK }; // Adding the checkboxes to the menu. menu.AddMenuItem(box); menu.AddMenuItem(box2); menu.AddMenuItem(box3); // List items (first the 3 special variants, then a normal one) List <string> colorList = new List <string>(); for (var i = 0; i < 64; i++) { colorList.Add($"Color #{i}"); } MenuListItem hairColors = new MenuListItem("Hair Color", colorList, 0, "Hair color pallete.") { ShowColorPanel = true }; // Also special List <string> makeupColorList = new List <string>(); for (var i = 0; i < 64; i++) { makeupColorList.Add($"Color #{i}"); } MenuListItem makeupColors = new MenuListItem("Makeup Color", makeupColorList, 0, "Makeup color pallete.") { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Makeup }; // Also special List <string> opacityList = new List <string>(); for (var i = 0; i < 11; i++) { opacityList.Add($"Opacity {i * 10}%"); } MenuListItem opacity = new MenuListItem("Opacity Panel", opacityList, 0, "Set an opacity for something.") { ShowOpacityPanel = true }; // Normal List <string> normalList = new List <string>() { "Item #1", "Item #2", "Item #3" }; MenuListItem normalListItem = new MenuListItem("Normal List Item", normalList, 0, "And another simple description for yet another simple (list) item. Nothing special about this one."); // Adding the lists to the menu. menu.AddMenuItem(hairColors); menu.AddMenuItem(makeupColors); menu.AddMenuItem(opacity); menu.AddMenuItem(normalListItem); // Creating a submenu, adding it to the menus list, and creating and binding a button for it. Menu submenu = new Menu("Submenu", "Secondary Menu"); MenuController.AddSubmenu(menu, submenu); MenuItem menuButton = new MenuItem("Submenu", "This button is bound to a submenu. Clicking it will take you to the submenu.") { Label = "→→→" }; menu.AddMenuItem(menuButton); MenuController.BindMenuItem(menu, submenu, menuButton); // Adding items with sprites left & right to the submenu. for (var i = 0; i < 30; i++) { var tmpItem = new MenuItem($"Icon Sprite #{i}", "This menu item has a left and right sprite, and some also have a right label! Very cool huh?!"); if (i % 4 == 0) { tmpItem.Label = "Wowzers"; } if (i % 7 == 0) { tmpItem.Label = "Snailsome!"; } tmpItem.LeftIcon = (MenuItem.Icon)i; tmpItem.RightIcon = (MenuItem.Icon)i; submenu.AddMenuItem(tmpItem); } // Instructional buttons setup for the second (submenu) menu. submenu.InstructionalButtons.Add(Control.CharacterWheel, "Right?!"); submenu.InstructionalButtons.Add(Control.CreatorLS, "Buttons"); submenu.InstructionalButtons.Add(Control.CursorScrollDown, "Cool"); submenu.InstructionalButtons.Add(Control.CreatorDelete, "Out!"); submenu.InstructionalButtons.Add(Control.Cover, "This"); submenu.InstructionalButtons.Add(Control.Context, "Check"); // Create a third menu without a banner. Menu menu3 = new Menu(null, "Only a subtitle, no banner."); // you can use AddSubmenu or AddMenu, both will work but if you want to link this menu from another menu, // you should use AddSubmenu. MenuController.AddSubmenu(menu, menu3); MenuItem thirdSubmenuBtn = new MenuItem("Another submenu", "This is just a submenu without a banner. No big deal.") { Label = "→→→" }; menu.AddMenuItem(thirdSubmenuBtn); MenuController.BindMenuItem(menu, menu3, thirdSubmenuBtn); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); /* ######################################################## # Event handlers ######################################################## */ menu.OnCheckboxChange += (_menu, _item, _index, _checked) => { // Code in here gets executed whenever a checkbox is toggled. Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]"); // If the align-menu checkbox is toggled, toggle the menu alignment. if (_item == box) { if (_checked) { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; } else { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; } } }; menu.OnItemSelect += (_menu, _item, _index) => { // Code in here would get executed whenever an item is pressed. Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]"); }; menu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { // Code in here would get executed whenever the up or down key is pressed and the index of the menu is changed. Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]"); }; menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed). Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); }; menu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) => { // Code in here would get executed whenever a list item is pressed. Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]"); }; menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { // Code in here would get executed whenever the position of a slider is changed (when left/right key is pressed). Debug.WriteLine($"OnSliderPositionChange: [{_menu}, {_sliderItem}, {_oldPosition}, {_newPosition}, {_itemIndex}]"); }; menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) => { // Code in here would get executed whenever a slider item is pressed. Debug.WriteLine($"OnSliderItemSelect: [{_menu}, {_sliderItem}, {_sliderPosition}, {_itemIndex}]"); }; menu.OnMenuClose += (_menu) => { // Code in here gets triggered whenever the menu is closed. Debug.WriteLine($"OnMenuClose: [{_menu}]"); }; menu.OnMenuOpen += (_menu) => { // Code in here gets triggered whenever the menu is opened. Debug.WriteLine($"OnMenuOpen: [{_menu}]"); }; }
private static void CreateMenu() { // Menu Settings MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MenuController.MenuToggleKey = (Control)(-1); // Generate Menu MenuController.AddMenu(MainMenu); MainMenu.AddMenuItem(ParentsMenuButton); MenuController.AddSubmenu(MainMenu, ParentsMenu); MenuController.BindMenuItem(MainMenu, ParentsMenu, ParentsMenuButton); MainMenu.AddMenuItem(FaceShapeMenuButton); MenuController.AddSubmenu(MainMenu, FaceShapeMenu); MenuController.BindMenuItem(MainMenu, FaceShapeMenu, FaceShapeMenuButton); MainMenu.AddMenuItem(AppearanceMenuButton); MenuController.AddSubmenu(MainMenu, AppearanceMenu); MenuController.BindMenuItem(MainMenu, AppearanceMenu, AppearanceMenuButton); MainMenu.AddMenuItem(FinishButton); // Generate Parents Menu ParentsMenu.AddMenuItem(ParentFatherFace); ParentsMenu.AddMenuItem(ParentMotherFace); ParentsMenu.AddMenuItem(ParentsMixBar); // Generate Shape Menu FaceShapeMenu.AddMenuItem(NoseWidth); FaceShapeMenu.AddMenuItem(NosePeakHeight); FaceShapeMenu.AddMenuItem(NosePeakLength); FaceShapeMenu.AddMenuItem(NoseBoneHeight); FaceShapeMenu.AddMenuItem(NosePeakLowering); FaceShapeMenu.AddMenuItem(NoseBoneTwist); FaceShapeMenu.AddMenuItem(EyeBrowHeight); FaceShapeMenu.AddMenuItem(EyeBrowLength); FaceShapeMenu.AddMenuItem(CheekBoneHeight); FaceShapeMenu.AddMenuItem(CheekBoneWidth); FaceShapeMenu.AddMenuItem(CheekWidth); FaceShapeMenu.AddMenuItem(EyeOpenings); FaceShapeMenu.AddMenuItem(LipThickness); FaceShapeMenu.AddMenuItem(JawBoneWidth); FaceShapeMenu.AddMenuItem(JawBoneLength); FaceShapeMenu.AddMenuItem(ChinBoneLowering); FaceShapeMenu.AddMenuItem(ChinBoneLength); FaceShapeMenu.AddMenuItem(ChinBoneWidth); FaceShapeMenu.AddMenuItem(ChinHole); FaceShapeMenu.AddMenuItem(NeckThickness); // Generate Appearance Menu if (Game.Player.Character.Gender == Gender.Male) { AppearanceHairStyles = new MenuSliderItem("Hair Styles", 0, 22, 0); } else { AppearanceHairStyles = new MenuSliderItem("Hair Styles", 0, 23, 0); } AppearanceMenu.AddMenuItem(AppearanceBlemishes); AppearanceMenu.AddMenuItem(AppearanceBlemishesOpacity); AppearanceMenu.AddMenuItem(AppearanceFacialHair); AppearanceMenu.AddMenuItem(AppearanceFacialHairOpacity); AppearanceMenu.AddMenuItem(AppearanceEyebrows); AppearanceMenu.AddMenuItem(AppearanceEyebrowsOpacity); AppearanceMenu.AddMenuItem(AppearanceAgeing); AppearanceMenu.AddMenuItem(AppearanceAgeingOpacity); AppearanceMenu.AddMenuItem(AppearanceComplexion); AppearanceMenu.AddMenuItem(AppearanceComplexionOpacity); AppearanceMenu.AddMenuItem(AppearanceSunDamage); AppearanceMenu.AddMenuItem(AppearanceSunDamageOpacity); AppearanceMenu.AddMenuItem(AppearanceHairStyles); AppearanceMenu.AddMenuItem(AppearanceHairColors); AppearanceMenu.AddMenuItem(AppearanceHairHighlights); //Check if the menu is on it's first opening if (firstOpen) { //Main Menu OnItemSelect MainMenu.OnItemSelect += (_menu, _item, _index) => { if (_item == FinishButton) { CurrentCharacter.SetNoLongerNew(); try { MainClient.TriggerServerEvent("Laced:FinishCharacterEditing", sessionKey, JsonConvert.SerializeObject(CurrentCharacter), new Action <string>((_characterString) => { MainClient.TriggerEvent("Laced:SpawnPlayerCharacter", sessionKey, _characterString); })); DisableCharacterModifier(); } catch (Exception _ex) { Utils.Throw(_ex); } } }; //Parents slider position change ParentsMenu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { if (_sliderItem == ParentFatherFace) { CurrentCharacter.SetParents(_newPosition, CurrentCharacter.Parents.Mother, CurrentCharacter.Parents.Mix); SetPedBlendData(); } else if (_sliderItem == ParentMotherFace) { CurrentCharacter.SetParents(CurrentCharacter.Parents.Father, _newPosition, CurrentCharacter.Parents.Mix); SetPedBlendData(); } else if (_sliderItem == ParentsMixBar) { CurrentCharacter.SetParents(CurrentCharacter.Parents.Father, CurrentCharacter.Parents.Mother, (float)((_newPosition / 10m) * 1m)); SetPedBlendData(); } }; //Shape Menu Items FaceShapeMenu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { if (_sliderItem == NoseWidth) { CurrentCharacter.FaceFeatures[0] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(0, CurrentCharacter.FaceFeatures[0]); } else if (_sliderItem == NosePeakHeight) { CurrentCharacter.FaceFeatures[1] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(1, CurrentCharacter.FaceFeatures[1]); } else if (_sliderItem == NosePeakLength) { CurrentCharacter.FaceFeatures[2] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(2, CurrentCharacter.FaceFeatures[2]); } else if (_sliderItem == NoseBoneHeight) { CurrentCharacter.FaceFeatures[3] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(3, CurrentCharacter.FaceFeatures[3]); } else if (_sliderItem == NosePeakLowering) { CurrentCharacter.FaceFeatures[4] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(4, CurrentCharacter.FaceFeatures[4]); } else if (_sliderItem == NoseBoneTwist) { CurrentCharacter.FaceFeatures[5] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(5, CurrentCharacter.FaceFeatures[5]); } else if (_sliderItem == EyeBrowHeight) { CurrentCharacter.FaceFeatures[6] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(6, CurrentCharacter.FaceFeatures[6]); } else if (_sliderItem == EyeBrowLength) { CurrentCharacter.FaceFeatures[7] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(7, CurrentCharacter.FaceFeatures[7]); } else if (_sliderItem == CheekBoneHeight) { CurrentCharacter.FaceFeatures[8] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(8, CurrentCharacter.FaceFeatures[8]); } else if (_sliderItem == CheekBoneWidth) { CurrentCharacter.FaceFeatures[9] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(9, CurrentCharacter.FaceFeatures[9]); } else if (_sliderItem == CheekWidth) { CurrentCharacter.FaceFeatures[10] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(10, CurrentCharacter.FaceFeatures[10]); } else if (_sliderItem == EyeOpenings) { CurrentCharacter.FaceFeatures[11] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(11, CurrentCharacter.FaceFeatures[11]); } else if (_sliderItem == LipThickness) { CurrentCharacter.FaceFeatures[12] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(12, CurrentCharacter.FaceFeatures[12]); } else if (_sliderItem == JawBoneWidth) { CurrentCharacter.FaceFeatures[13] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(13, CurrentCharacter.FaceFeatures[13]); } else if (_sliderItem == JawBoneLength) { CurrentCharacter.FaceFeatures[14] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(14, CurrentCharacter.FaceFeatures[14]); } else if (_sliderItem == ChinBoneLowering) { CurrentCharacter.FaceFeatures[15] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(15, CurrentCharacter.FaceFeatures[15]); } else if (_sliderItem == ChinBoneLength) { CurrentCharacter.FaceFeatures[16] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(16, CurrentCharacter.FaceFeatures[16]); } else if (_sliderItem == ChinBoneWidth) { CurrentCharacter.FaceFeatures[17] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(17, CurrentCharacter.FaceFeatures[17]); } else if (_sliderItem == ChinHole) { CurrentCharacter.FaceFeatures[18] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(18, CurrentCharacter.FaceFeatures[18]); } else if (_sliderItem == NeckThickness) { CurrentCharacter.FaceFeatures[19] = (float)((_newPosition / 10m) * 1m); SetPedFaceFeature(19, CurrentCharacter.FaceFeatures[19]); } }; //Appearance Menu OnSliderPositionChange AppearanceMenu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { if (_sliderItem == AppearanceHairStyles) { CurrentCharacter.Appearance.SetHairStyle(_newPosition); Game.Player.Character.Style[PedComponents.Hair].SetVariation(CurrentCharacter.Appearance.HairStyle, CurrentCharacter.Appearance.HairColor); ResetHairColors(); } else if (_sliderItem == AppearanceHairColors) { SetPedHairColor(_newPosition); } else if (_sliderItem == AppearanceHairHighlights) { SetPedHairHighlightColor(_newPosition); } else if (_sliderItem == AppearanceBlemishes) { SetOverlay(0, _newPosition, CurrentCharacter.Appearance.Overlays[0].Opacity); } else if (_sliderItem == AppearanceBlemishesOpacity) { SetOverlay(0, CurrentCharacter.Appearance.Overlays[0].Index, (float)((_newPosition / 10m) * 1m)); } else if (_sliderItem == AppearanceFacialHair) { SetOverlay(1, _newPosition, CurrentCharacter.Appearance.Overlays[1].Opacity, true); } else if (_sliderItem == AppearanceFacialHairOpacity) { SetOverlay(1, CurrentCharacter.Appearance.Overlays[1].Index, (float)((_newPosition / 10m) * 1m)); } else if (_sliderItem == AppearanceEyebrows) { SetOverlay(2, _newPosition, CurrentCharacter.Appearance.Overlays[2].Opacity, true); } else if (_sliderItem == AppearanceEyebrowsOpacity) { SetOverlay(2, CurrentCharacter.Appearance.Overlays[2].Index, (float)((_newPosition / 10m) * 1m)); } else if (_sliderItem == AppearanceAgeing) { SetOverlay(3, _newPosition, CurrentCharacter.Appearance.Overlays[3].Opacity, false); } else if (_sliderItem == AppearanceAgeingOpacity) { SetOverlay(3, CurrentCharacter.Appearance.Overlays[3].Index, (float)((_newPosition / 10m) * 1m)); } else if (_sliderItem == AppearanceComplexion) { SetOverlay(6, _newPosition, CurrentCharacter.Appearance.Overlays[6].Opacity); } else if (_sliderItem == AppearanceComplexionOpacity) { SetOverlay(6, CurrentCharacter.Appearance.Overlays[6].Index, (float)((_newPosition / 10m) * 1m)); } else if (_sliderItem == AppearanceSunDamage) { SetOverlay(7, _newPosition, CurrentCharacter.Appearance.Overlays[7].Opacity); } else if (_sliderItem == AppearanceSunDamageOpacity) { SetOverlay(7, CurrentCharacter.Appearance.Overlays[7].Index, (float)((_newPosition / 10m) * 1m)); } }; firstOpen = false; } MainClient.GetInstance().RegisterTickHandler(KeepMenuEnabled); }
public void AddEntityOneMenu() { MenuSliderItem entityOneHeading = new MenuSliderItem("Entity Heading", 0, 360, 180); menu.AddMenuItem(entityOneHeading); MenuSliderItem entityOneX = new MenuSliderItem("Entity Left / Right", -200, 200, 0); menu.AddMenuItem(entityOneX); MenuSliderItem entityOneY = new MenuSliderItem("Entity Forward / Backward", -200, 200, 0); menu.AddMenuItem(entityOneY); MenuSliderItem entityOneZ = new MenuSliderItem("Entity Up / Down", -200, 200, 0); menu.AddMenuItem(entityOneZ); menu.OnSliderPositionChange += (sender, item, oldPosition, newPosition, index) => { Vector3 currPos = GetEntityCoords(entityOne, true); if (item == entityOneHeading) { entityOneNewHeading = newPosition; SetEntityHeading(entityOne, newPosition); } else if (item == entityOneX) { entityOneNewX = ((newPosition - 100.0f) * 0.0005f); Vector3 newPos = GetOffsetFromEntityInWorldCoords(entityOne, lastX > entityOneNewX ? entityOneNewX : -entityOneNewX, 0.0f, 0.0f); SetEntityCoordsNoOffset(entityOne, newPos.X, newPos.Y, newPos.Z, false, false, false); lastX = entityOneNewX; } else if (item == entityOneY) { entityOneNewY = ((newPosition - 100.0f) * 0.0005f); Vector3 newPos = GetOffsetFromEntityInWorldCoords(entityOne, 0.0f, lastY > entityOneNewY ? entityOneNewY : -entityOneNewY, 0.0f); SetEntityCoordsNoOffset(entityOne, newPos.X, newPos.Y, newPos.Z, false, false, false); lastY = entityOneNewY; Debug.WriteLine(entityOneNewY.ToString()); } else if (item == entityOneZ) { entityOneNewZ = ((newPosition - 100.0f) * 0.0005f); Vector3 newPos = GetOffsetFromEntityInWorldCoords(entityOne, 0.0f, 0.0f, lastZ > entityOneNewZ ? entityOneNewZ : -entityOneNewZ); SetEntityCoordsNoOffset(entityOne, newPos.X, newPos.Y, newPos.Z, false, false, false); lastZ = entityOneNewZ; Debug.WriteLine(entityOneNewZ.ToString()); } FreezeEntityPosition(entityOne, true); SetEntityCollision(entityOne, false, true); if (IsEntityAttached(entityOne)) { DetachEntity(entityOne, true, true); FreezeEntityPosition(entityOne, false); SetEntityCollision(entityOne, true, true); } }; }
public MapMenu(Init instance, string name, string subtitle, Dictionary <string, Map> Maps) { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; Menu mapMenu = new Menu(name, subtitle) { Visible = true }; MenuController.AddMenu(mapMenu); foreach (var map in Maps.ToDictionary(x => x.Key, x => x.Value)) { Vector3 selectedVector = map.Value.SpawnPoints.ElementAt(0).Value[0]; int selectedTeam = map.Value.SpawnPoints.ElementAt(0).Key; Menu mapEditor = AddSubMenu(mapMenu, "Edit " + map.Key); MenuItem mapItem = AddMenuItem(mapMenu, mapEditor, map.Key, "Modify Map", ">>>", true); Menu playerSpawnMenu = AddSubMenu(mapEditor, "Edit " + map.Key + " player spawns"); Menu deleteMapMenu = AddSubMenu(mapEditor, "Delete " + map.Key + "?"); deleteMapMenu.AddMenuItem(new MenuItem("Yes", "")); deleteMapMenu.AddMenuItem(new MenuItem("No", "")); deleteMapMenu.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Yes") { TriggerServerEvent("salty::netModifyMap", "delete", map.Key); MenuController.CloseAllMenus(); TriggerServerEvent("salty::netSpawnPointGUI"); } if (_item.Text == "No") { deleteMapMenu.CloseMenu(); } }; mapEditor.AddMenuItem(new MenuItem("Show/Hide")); mapEditor.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Show/Hide") { if (instance.Maps[map.Key].isVisible) { instance.Maps[map.Key].ClearBlip(); } else { instance.Maps[map.Key].CreateBlip(); } } }; Menu modifyPosMenu = AddSubMenu(playerSpawnMenu, "Edit position"); MenuSliderItem sliderOffset = new MenuSliderItem("Offset", -25, 25, 0, false); MenuSliderItem sliderX = new MenuSliderItem("Centre X", -999999, 999999, (int)map.Value.Position.X, false); MenuSliderItem sliderY = new MenuSliderItem("Centre Y", -999999, 999999, (int)map.Value.Position.Y, false); MenuSliderItem sliderWidth = new MenuSliderItem("Width", -9999, 9999, (int)map.Value.Size.X, false); MenuSliderItem sliderLength = new MenuSliderItem("Length", -9999, 9999, (int)map.Value.Size.Y, false); mapEditor.AddMenuItem(sliderOffset); mapEditor.AddMenuItem(sliderX); mapEditor.AddMenuItem(sliderY); mapEditor.AddMenuItem(sliderWidth); mapEditor.AddMenuItem(sliderLength); MenuItem playerSpawnItem = AddMenuItem(mapEditor, playerSpawnMenu, "Player Spawns", "Modify player spawn points", ">>", true); MenuItem deleteMapItem = AddMenuItem(mapEditor, deleteMapMenu, "Delete Map", "Delete entire map", ">", true); modifyPosMenu.AddMenuItem(new MenuItem("Delete", "Deletes the selected position")); mapEditor.AddMenuItem(new MenuItem("Save", "Saves new position and size")); mapEditor.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { if (_sliderItem.Text == "Centre X") { map.Value.Position.X += (_newPosition - _oldPosition) * sliderOffset.Position; } if (_sliderItem.Text == "Centre Y") { map.Value.Position.Y += (_newPosition - _oldPosition) * sliderOffset.Position; } if (_sliderItem.Text == "Width") { map.Value.Size.X += (_newPosition - _oldPosition) * sliderOffset.Position; } if (_sliderItem.Text == "Length") { map.Value.Size.Y += (_newPosition - _oldPosition) * sliderOffset.Position; } }; mapEditor.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Save") { TriggerServerEvent("salty::netModifyMap", "edit", map.Key, 0, map.Value.Position, map.Value.Size); } }; modifyPosMenu.OnItemSelect += (_menu, _item, _index) => { if (_item.Text == "Delete") { TriggerServerEvent("salty::netModifyMapPos", "delete", map.Key, selectedTeam, selectedVector); MenuController.CloseAllMenus(); TriggerServerEvent("salty::netSpawnPointGUI"); } }; foreach (var spawns in map.Value.SpawnPoints.ToDictionary(x => x.Key, x => x.Value)) { foreach (var spawn in spawns.Value) { MenuItem playerPositionItem = AddMenuItem(playerSpawnMenu, modifyPosMenu, string.Format("{0} | {1}", spawns.Key.ToString(), spawn.ToString()), "Modify player spawn point", ">", true); } playerSpawnMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { string[] vector = _newItem.Text.Split('|'); selectedTeam = Convert.ToInt32(vector[0].Split(' ')[0]); selectedVector = BaseGamemode.StringToVector3(vector[1].Substring(1)); }; } mapMenu.OnMenuClose += (_menu) => { }; mapMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { }; } }
private void GenerateSubMenus() { #region Inhetirance menu Menu InheritanceMenu = new Menu("Inheritance", "Inheritance options"); MenuItem InheritanceMenuItem = new MenuItem("Inheritance", "Change your characters inheritance"); InheritanceMenu.ClearMenuItems(); MenuListItem Father = new MenuListItem("Father", Faces, InitialFatherFace); MenuListItem Mother = new MenuListItem("Mother", Faces, InitialMotherFace); MenuSliderItem ShapeMix = new MenuSliderItem("Head Shape Mix", "Select how much of your head shape should be inherited from your father or mother.", 0, 10, 5, true) { SliderLeftIcon = MenuItem.Icon.MALE, SliderRightIcon = MenuItem.Icon.FEMALE }; MenuSliderItem SkinMix = new MenuSliderItem("Body Skin Mix", "Select how much of your body skin tone should be inherited from your father or mother.", 0, 10, 5, true) { SliderLeftIcon = MenuItem.Icon.MALE, SliderRightIcon = MenuItem.Icon.FEMALE }; InheritanceMenu.AddMenuItem(Father); InheritanceMenu.AddMenuItem(Mother); InheritanceMenu.AddMenuItem(ShapeMix); InheritanceMenu.AddMenuItem(SkinMix); CCMenu.AddMenuItem(InheritanceMenuItem); MenuController.BindMenuItem(CCMenu, InheritanceMenu, InheritanceMenuItem); InheritanceMenu.OnListIndexChange += (menu, listItem, oldIndex, newIndex, itemIndex) => { SetPedHeadBlendData(GetPlayerPed(-1), Father.ListIndex, Mother.ListIndex, 0, Father.ListIndex, Mother.ListIndex, 0, mixValues[ShapeMix.Position], mixValues[SkinMix.Position], 0f, false); }; InheritanceMenu.OnSliderPositionChange += (menu, listItem, oldIndex, newIndex, itemIndex) => { SetPedHeadBlendData(GetPlayerPed(-1), Father.ListIndex, Mother.ListIndex, 0, Father.ListIndex, Mother.ListIndex, 0, mixValues[ShapeMix.Position], mixValues[SkinMix.Position], 0f, false); }; InheritanceMenu.OnMenuOpen += (menu) => SetFaceCam(); InheritanceMenu.OnMenuClose += (menu) => SetBodyCam(); #endregion #region Face Shape Menu FaceShape = new Menu("Face shape", "Face shape options"); MenuItem FaceShapeItem = new MenuItem("Face shape", "Tweak the details of your characters face"); FaceShape.ClearMenuItems(); for (int i = 0; i < 20; i++) { MenuSliderItem faceFeature = new MenuSliderItem(faceFeaturesNamesList[i], $"Set the {faceFeaturesNamesList[i]} face feature value.", 0, 20, 10, true); FaceShape.AddMenuItem(faceFeature); } FaceShape.OnSliderPositionChange += async(sender, sliderItem, oldPosition, newPosition, itemIndex) => { float value = faceFeaturesValuesList[newPosition]; SetPedFaceFeature(Game.PlayerPed.Handle, itemIndex, value); }; FaceShape.OnMenuOpen += (menu) => SetFaceCam(); FaceShape.OnMenuClose += (menu) => SetBodyCam(); CCMenu.AddMenuItem(FaceShapeItem); MenuController.BindMenuItem(CCMenu, FaceShape, FaceShapeItem); #endregion #region Appearance Menu AppearanceMenu = new Menu("Appearance", "Appearance options"); MenuItem AppearanceMenuItem = new MenuItem("Appearance", "Change your characters appearance"); AppearanceMenu.ClearMenuItems(); if (Gender == 0) { Hair = MaleHair; } else { Hair = FemaleHair; } #region MenuList MenuListItem HairStyle = new MenuListItem("Hair", MaleHair, InitialHairStyle); MenuListItem HairColour = new MenuListItem("Hair Colour", OverlayColours, InitialHairColour) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; MenuListItem HairHighlights = new MenuListItem("Hair Highlights", OverlayColours, InitialHairColour) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; AppearanceMenu.AddMenuItem(HairStyle); AppearanceMenu.AddMenuItem(HairColour); AppearanceMenu.AddMenuItem(HairHighlights); MenuListItem BlemishStyle = new MenuListItem("Blemish", Blemish, random.Next(0, GetNumHeadOverlayValues(0) - 1)); MenuListItem BlemishOpacity = new MenuListItem("Blemish Opacity", Opacity, 0) { ShowOpacityPanel = true }; AppearanceMenu.AddMenuItem(BlemishStyle); AppearanceMenu.AddMenuItem(BlemishOpacity); MenuListItem BeardStyle = new MenuListItem("Beard", BeardList, 1); MenuListItem BeardOpacity = new MenuListItem("Beard Opacity", Opacity, 0) { ShowOpacityPanel = true }; MenuListItem BeardColour = new MenuListItem("Beard Colour", OverlayColours, InitialHairColour) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; if (Gender == 0) { AppearanceMenu.AddMenuItem(BeardStyle); AppearanceMenu.AddMenuItem(BeardOpacity); AppearanceMenu.AddMenuItem(BeardColour); } MenuListItem EyebrowsStyle = new MenuListItem("Eyebrows", EyebrowsList, random.Next(0, EyebrowsList.Count())); MenuListItem EyebrowsOpacity = new MenuListItem("Eyebrow Opacity", Opacity, 8) { ShowOpacityPanel = true }; MenuListItem EyebrowsColour = new MenuListItem("Eyebrow Colour", OverlayColours, 0) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; AppearanceMenu.AddMenuItem(EyebrowsStyle); AppearanceMenu.AddMenuItem(EyebrowsOpacity); AppearanceMenu.AddMenuItem(EyebrowsColour); MenuListItem Ageing = new MenuListItem("Ageing", AgeingList, 4); MenuListItem AgeingOpacity = new MenuListItem("Ageing Opacity", Opacity, 0) { ShowOpacityPanel = true }; AppearanceMenu.AddMenuItem(Ageing); AppearanceMenu.AddMenuItem(AgeingOpacity); MenuListItem MakeupStyle = new MenuListItem("Makeup", MakeupList, 4); MenuListItem MakeupOpacity = new MenuListItem("Makeup Opacity", Opacity, 8) { ShowOpacityPanel = true }; MenuListItem MakeupColour = new MenuListItem("Makeup Colour", OverlayColours, 0) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; AppearanceMenu.AddMenuItem(MakeupStyle); AppearanceMenu.AddMenuItem(MakeupOpacity); AppearanceMenu.AddMenuItem(MakeupColour); MenuListItem BlushStyle = new MenuListItem("Blush", BlushList, 4); MenuListItem BlushOpacity = new MenuListItem("Blush Opacity", Opacity, 8) { ShowOpacityPanel = true }; MenuListItem BlushColour = new MenuListItem("Blush Colour", OverlayColours, 0) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; AppearanceMenu.AddMenuItem(BlushStyle); AppearanceMenu.AddMenuItem(BlushOpacity); AppearanceMenu.AddMenuItem(BlushColour); MenuListItem ComplexionStyle = new MenuListItem("Complexion", ComplexionList, 4); MenuListItem ComplexionOpacity = new MenuListItem("Complexion Opacity", Opacity, 0) { ShowOpacityPanel = true }; AppearanceMenu.AddMenuItem(ComplexionStyle); AppearanceMenu.AddMenuItem(ComplexionOpacity); MenuListItem SunDamageStyle = new MenuListItem("Sun Damage", SundamageList, 4); MenuListItem SunDamageOpacity = new MenuListItem("Sun Damage Opacity", Opacity, 0) { ShowOpacityPanel = true }; AppearanceMenu.AddMenuItem(SunDamageStyle); AppearanceMenu.AddMenuItem(SunDamageOpacity); MenuListItem LipstickStyle = new MenuListItem("Lipstick", LipstickList, 4); MenuListItem LipstickOpacity = new MenuListItem("Lipstick Opacity", Opacity, 0) { ShowOpacityPanel = true }; MenuListItem LipstickColour = new MenuListItem("Lipstick Colour", OverlayColours, 0) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; AppearanceMenu.AddMenuItem(LipstickStyle); AppearanceMenu.AddMenuItem(LipstickOpacity); AppearanceMenu.AddMenuItem(LipstickColour); MenuListItem MolesFrecklesStyle = new MenuListItem("Moles and Freckles", MolesFrecklesList, 4); MenuListItem MolesFrecklesOpacity = new MenuListItem("Moles and Freckles Opacity", Opacity, 0) { ShowOpacityPanel = true }; AppearanceMenu.AddMenuItem(MolesFrecklesStyle); AppearanceMenu.AddMenuItem(MolesFrecklesOpacity); MenuListItem ChestHairStyle = new MenuListItem("Chest Hair", ChestHairList, 1); MenuListItem ChestHairOpacity = new MenuListItem("Chest Hair Opacity", Opacity, 0) { ShowOpacityPanel = true }; MenuListItem ChestHairColour = new MenuListItem("Chest Hair Colour", OverlayColours, 0) { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Hair }; if (Gender == 0) { AppearanceMenu.AddMenuItem(ChestHairStyle); AppearanceMenu.AddMenuItem(ChestHairOpacity); AppearanceMenu.AddMenuItem(ChestHairColour); } MenuListItem BodyBlemishStyle = new MenuListItem("Body Blemish", BodyBlemishList, 4); MenuListItem BodyBlemishOpacity = new MenuListItem("Body Blemish Opacity", Opacity, 0) { ShowOpacityPanel = true }; AppearanceMenu.AddMenuItem(BodyBlemishStyle); AppearanceMenu.AddMenuItem(BodyBlemishOpacity); MenuListItem EyeColour = new MenuListItem("Eye Colour", EyeColours, InitialEyeColour); AppearanceMenu.AddMenuItem(EyeColour); CCMenu.AddMenuItem(AppearanceMenuItem); MenuController.BindMenuItem(CCMenu, AppearanceMenu, AppearanceMenuItem); #endregion AppearanceMenu.OnListIndexChange += async(menu, listItem, oldIndex, newIndex, itemIndex) => { switch (listItem.Text) { case "Hair": SetFaceCam(); SetPedComponentVariation(Game.PlayerPed.Handle, 2, HairStyle.ListIndex, 0, 1); break; case "Hair Colour": case "Hair Highlights": SetFaceCam(); SetPedHairColor(Game.PlayerPed.Handle, HairColour.ListIndex, HairHighlights.ListIndex); break; case "Blemish": case "Blemish Opacity": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 0, BlemishStyle.ListIndex, (float)BlemishOpacity.ListIndex / 10); break; case "Beard": case "Beard Opacity": case "Beard Colour": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 1, BeardStyle.ListIndex, (float)BeardOpacity.ListIndex / 10); SetPedHeadOverlayColor(Game.PlayerPed.Handle, 1, 1, BeardColour.ListIndex, BeardColour.ListIndex); break; case "Eyebrows": case "Eyebrow Opacity": case "Eyebrow Colour": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 2, EyebrowsStyle.ListIndex, (float)EyebrowsOpacity.ListIndex / 10); SetPedHeadOverlayColor(Game.PlayerPed.Handle, 2, 1, EyebrowsColour.ListIndex, EyebrowsColour.ListIndex); break; case "Ageing": case "Ageing Opacity": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 3, Ageing.ListIndex, (float)AgeingOpacity.ListIndex / 10); break; case "Makeup": case "Makeup Opacity": case "Makeup Colour": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 4, MakeupStyle.ListIndex, (float)MakeupOpacity.ListIndex / 10); SetPedHeadOverlayColor(Game.PlayerPed.Handle, 4, 1, MakeupColour.ListIndex, MakeupColour.ListIndex); break; case "Blush": case "Blush Opacity": case "Blush Colour": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 5, BlushStyle.ListIndex, (float)BlushOpacity.ListIndex / 10); SetPedHeadOverlayColor(Game.PlayerPed.Handle, 5, 1, BlushColour.ListIndex, BlushColour.ListIndex); break; case "Complexion": case "Complexion Opacity": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 6, ComplexionStyle.ListIndex, (float)ComplexionOpacity.ListIndex / 10); break; case "Sun Damage": case "Sun Damage Opacity": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 7, SunDamageStyle.ListIndex, (float)SunDamageOpacity.ListIndex / 10); break; case "Lipstick": case "Lipstick Opacity": case "Lipstick Colour": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 8, LipstickStyle.ListIndex, (float)LipstickOpacity.ListIndex / 10); SetPedHeadOverlayColor(Game.PlayerPed.Handle, 8, 1, LipstickColour.ListIndex, LipstickColour.ListIndex); break; case "Moles and Freckles": case "Moles and Freckles Opacity": SetFaceCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 9, MolesFrecklesStyle.ListIndex, (float)MolesFrecklesOpacity.ListIndex / 10); break; case "Chest Hair": case "Chest Hair Opacity": case "Chest Hair Colour": SetBodyCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 10, ChestHairStyle.ListIndex, (float)ChestHairOpacity.ListIndex / 10); SetPedHeadOverlayColor(Game.PlayerPed.Handle, 10, 1, ChestHairColour.ListIndex, ChestHairColour.ListIndex); break; case "Body Blemish": case "Body Blemish Opacity": SetBodyCam(); SetPedHeadOverlay(Game.PlayerPed.Handle, 11, BodyBlemishStyle.ListIndex, (float)BodyBlemishOpacity.ListIndex / 10); break; case "Eye Colour": SetFaceCam(); SetPedEyeColor(Game.PlayerPed.Handle, EyeColour.ListIndex); break; } }; AppearanceMenu.OnMenuClose += (menu) => SetBodyCam(); #endregion return; }
public ExampleMenu() { #if FIVEM // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly. // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; #endif // Creating the first menu. Menu menu = new Menu("Main Menu", "Subtitle"); MenuController.AddMenu(menu); // Adding a new button by directly creating one inline. You could also just store it and then add it but we don't need to do that in this example. menu.AddMenuItem(new MenuItem("Normal Button", "This is a simple button with a simple description. Scroll down for more button types!") { Enabled = false, LeftIcon = MenuItem.Icon.TICK }); #if FIVEM // Creating 3 sliders, showing off the 3 possible variations and custom colors. MenuSliderItem slider = new MenuSliderItem("Slider", 0, 10, 5, false); MenuSliderItem slider2 = new MenuSliderItem("Slider + Bar", 0, 10, 5, true) { BarColor = System.Drawing.Color.FromArgb(255, 73, 233, 111), BackgroundColor = System.Drawing.Color.FromArgb(255, 25, 100, 43) }; MenuSliderItem slider3 = new MenuSliderItem("Slider + Bar + Icons", "The icons are currently male/female because that's probably the most common use. But any icon can be used!", 0, 10, 5, true) { BarColor = System.Drawing.Color.FromArgb(255, 255, 0, 0), BackgroundColor = System.Drawing.Color.FromArgb(255, 100, 0, 0), SliderLeftIcon = MenuItem.Icon.MALE, SliderRightIcon = MenuItem.Icon.FEMALE }; // adding the sliders to the menu. menu.AddMenuItem(slider); menu.AddMenuItem(slider2); menu.AddMenuItem(slider3); #endif #if FIVEM // Creating 3 checkboxs, 2 different styles and one has a locked icon and it's 'not enabled' (not enabled meaning you can't toggle it). MenuCheckboxItem box = new MenuCheckboxItem("Checkbox - Style 1 (click me!)", "This checkbox can toggle the menu position! Try it out.", !menu.LeftAligned) { Style = MenuCheckboxItem.CheckboxStyle.Cross }; #endif MenuCheckboxItem box2 = new MenuCheckboxItem("Checkbox - Style 2", "This checkbox does nothing right now.", true) { Style = MenuCheckboxItem.CheckboxStyle.Tick }; MenuCheckboxItem box3 = new MenuCheckboxItem("Checkbox (unchecked + locked)", "Make this menu right aligned. If you set this to false, then the menu will move to the left.", false) { Enabled = false, LeftIcon = MenuItem.Icon.LOCK }; // Adding the checkboxes to the menu. #if FIVEM menu.AddMenuItem(box); #endif menu.AddMenuItem(box2); menu.AddMenuItem(box3); // Dynamic list item string ChangeCallback(MenuDynamicListItem item, bool left) { if (left) { return((int.Parse(item.CurrentItem) - 1).ToString()); } return((int.Parse(item.CurrentItem) + 1).ToString()); } MenuDynamicListItem dynList = new MenuDynamicListItem("Dynamic list item.", "0", new MenuDynamicListItem.ChangeItemCallback(ChangeCallback), "Description for this dynamic item. Pressing left will make the value smaller, pressing right will make the value bigger."); menu.AddMenuItem(dynList); #if FIVEM // List items (first the 3 special variants, then a normal one) List <string> colorList = new List <string>(); for (var i = 0; i < 64; i++) { colorList.Add($"Color #{i}"); } MenuListItem hairColors = new MenuListItem("Hair Color", colorList, 0, "Hair color pallete.") { ShowColorPanel = true }; // Also special List <string> makeupColorList = new List <string>(); for (var i = 0; i < 64; i++) { makeupColorList.Add($"Color #{i}"); } MenuListItem makeupColors = new MenuListItem("Makeup Color", makeupColorList, 0, "Makeup color pallete.") { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Makeup }; // Also special List <string> opacityList = new List <string>(); for (var i = 0; i < 11; i++) { opacityList.Add($"Opacity {i * 10}%"); } MenuListItem opacity = new MenuListItem("Opacity Panel", opacityList, 0, "Set an opacity for something.") { ShowOpacityPanel = true }; menu.AddMenuItem(hairColors); menu.AddMenuItem(makeupColors); menu.AddMenuItem(opacity); #endif // Normal List <string> normalList = new List <string>() { "Item #1", "Item #2", "Item #3" }; MenuListItem normalListItem = new MenuListItem("Normal List Item", normalList, 0, "And another simple description for yet another simple (list) item. Nothing special about this one."); // Adding the lists to the menu. menu.AddMenuItem(normalListItem); // Creating a submenu, adding it to the menus list, and creating and binding a button for it. Menu submenu = new Menu("Submenu", "Secondary Menu"); MenuController.AddSubmenu(menu, submenu); MenuItem menuButton = new MenuItem("Submenu", "This button is bound to a submenu. Clicking it will take you to the submenu.") { #if FIVEM Label = "→→→" #endif #if REDM RightIcon = MenuItem.Icon.ARROW_RIGHT #endif }; menu.AddMenuItem(menuButton); MenuController.BindMenuItem(menu, submenu, menuButton); #if FIVEM var herritageMenu = new HerritageMenu("Herritage"); herritageMenu.AddMenuItem(new MenuListItem("Father", ((Dad[])Enum.GetValues(typeof(Dad))).Select(c => c.ToString()).ToList(), 0, "Choose the father of your character.")); herritageMenu.AddMenuItem(new MenuListItem("Mother", ((Mum[])Enum.GetValues(typeof(Mum))).Select(c => c.ToString()).ToList(), 0, "Choose the mother of your character.")); menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { if (_listItem.Text == "Father") { (menu as HerritageMenu).CurrentDad = ((Dad)_itemIndex); } else if (_listItem.Text == "Mother") { (menu as HerritageMenu).CurrentMum = ((Mum)_itemIndex); } }; var bindmenu = new MenuItem("Héritage"); menu.AddMenuItem(bindmenu); MenuController.BindMenuItem(menu, herritageMenu, bindmenu); #endif // Adding items with sprites left & right to the submenu. for (var i = 0; i < Enum.GetValues(typeof(MenuItem.Icon)).Length; i++) { var tmpItem = new MenuItem($"Icon.{Enum.GetName(typeof(MenuItem.Icon), ((MenuItem.Icon)i))}", "This menu item has a left and right sprite. Press ~r~HOME~s~ to toggle the 'enabled' state on these items.") { Label = $"(#{i})", #if FIVEM #endif RightIcon = (MenuItem.Icon)i, LeftIcon = (MenuItem.Icon)i }; //var tmpItem2 = new MenuItem($"Icon.{Enum.GetName(typeof(MenuItem.Icon), ((MenuItem.Icon)i))}", "This menu item has a left and right sprite, and it's ~h~disabled~h~."); //tmpItem2.LeftIcon = (MenuItem.Icon)i; //tmpItem2.RightIcon = (MenuItem.Icon)i; //tmpItem2.Enabled = false; submenu.AddMenuItem(tmpItem); //submenu.AddMenuItem(tmpItem2); } submenu.ButtonPressHandlers.Add(new Menu.ButtonPressHandler(Control.FrontendSocialClubSecondary, Menu.ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((m, c) => { m.GetMenuItems().ForEach(a => a.Enabled = !a.Enabled); }), true)); #if FIVEM // Instructional buttons setup for the second (submenu) menu. submenu.InstructionalButtons.Add(Control.CharacterWheel, "Right?!"); submenu.InstructionalButtons.Add(Control.CursorScrollDown, "Cool"); submenu.InstructionalButtons.Add(Control.CreatorDelete, "Out!"); submenu.InstructionalButtons.Add(Control.Cover, "This"); submenu.InstructionalButtons.Add(Control.Context, "Check"); #endif // Create a third menu without a banner. Menu menu3 = new Menu(null, "Only a subtitle, no banner."); // you can use AddSubmenu or AddMenu, both will work but if you want to link this menu from another menu, // you should use AddSubmenu. MenuController.AddSubmenu(menu, menu3); MenuItem thirdSubmenuBtn = new MenuItem("Another submenu", "This is just a submenu without a banner. No big deal. This also has a very long description to test multiple lines and see if they work properly. Let's find out if it works as intended.") { #if FIVEM Label = "→→→" #endif #if REDM RightIcon = MenuItem.Icon.ARROW_RIGHT #endif }; menu.AddMenuItem(thirdSubmenuBtn); MenuController.BindMenuItem(menu, menu3, thirdSubmenuBtn); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!") { LeftIcon = MenuItem.Icon.TICK }); for (var i = 0; i < 10; i++) { menu.AddMenuItem(new MenuItem($"Item #{i + 1}.", "With an invisible description.")); } /* ######################################################## # Event handlers ######################################################## */ menu.OnCheckboxChange += (_menu, _item, _index, _checked) => { // Code in here gets executed whenever a checkbox is toggled. Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]"); #if FIVEM // If the align-menu checkbox is toggled, toggle the menu alignment. if (_item == box) { if (_checked) { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; } else { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; } } #endif }; menu.OnItemSelect += (_menu, _item, _index) => { // Code in here would get executed whenever an item is pressed. Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]"); }; menu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { // Code in here would get executed whenever the up or down key is pressed and the index of the menu is changed. Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]"); }; menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed). Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); }; menu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) => { // Code in here would get executed whenever a list item is pressed. Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]"); }; #if FIVEM menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { // Code in here would get executed whenever the position of a slider is changed (when left/right key is pressed). Debug.WriteLine($"OnSliderPositionChange: [{_menu}, {_sliderItem}, {_oldPosition}, {_newPosition}, {_itemIndex}]"); }; menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) => { // Code in here would get executed whenever a slider item is pressed. Debug.WriteLine($"OnSliderItemSelect: [{_menu}, {_sliderItem}, {_sliderPosition}, {_itemIndex}]"); }; #endif menu.OnMenuClose += (_menu) => { // Code in here gets triggered whenever the menu is closed. Debug.WriteLine($"OnMenuClose: [{_menu}]"); }; menu.OnMenuOpen += (_menu) => { // Code in here gets triggered whenever the menu is opened. Debug.WriteLine($"OnMenuOpen: [{_menu}]"); }; menu.OnDynamicListItemCurrentItemChange += (_menu, _dynamicListItem, _oldCurrentItem, _newCurrentItem) => { // Code in here would get executed whenever the value of the current item of a dynamic list item changes. Debug.WriteLine($"OnDynamicListItemCurrentItemChange: [{_menu}, {_dynamicListItem}, {_oldCurrentItem}, {_newCurrentItem}]"); }; menu.OnDynamicListItemSelect += (_menu, _dynamicListItem, _currentItem) => { // Code in here would get executed whenever a dynamic list item is pressed. Debug.WriteLine($"OnDynamicListItemSelect: [{_menu}, {_dynamicListItem}, {_currentItem}]"); }; //DelayedConstructor(); } //private async void DelayedConstructor() //{ // await Delay(1000); // MenuController.MainMenu.OpenMenu(); //} } }
public StmTools() { Tick += OnTick; RegisterCommand("stm", new Action <int, List <object>, string>(/*async*/ (src, args, raw) => { menu.OpenMenu(); } ), false); //Menu stuff MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; MenuController.MenuToggleKey = (Control)(-1); menu = new Menu("Stm Tools", "For all your pointless needs!"); MenuController.AddMenu(menu); MenuCheckboxItem menuCheckboxRainbow = new MenuCheckboxItem("Primary Rainbow Mode", "Enables cycling paint for primary zone on your current vehicle (while you're inside it).") { Enabled = true, LeftIcon = MenuItem.Icon.HEALTH_HEART, Style = MenuCheckboxItem.CheckboxStyle.Tick }; MenuCheckboxItem menuCheckboxRainbowSec = new MenuCheckboxItem("Secondary Rainbow Mode", "Enables cycling paint for secondary zone on your current vehicle (while you're inside it).") { Enabled = true, LeftIcon = MenuItem.Icon.HEALTH_HEART, Style = MenuCheckboxItem.CheckboxStyle.Tick }; MenuSliderItem sliderRainbowSaturation = new MenuSliderItem("Saturation", "Base Saturation value for the cycled colour", 0, 20, 20); MenuSliderItem sliderRainbowValue = new MenuSliderItem("Value", "Base Value... Value for the cycled colour. (Not lightness!)", 0, 20, 20); MenuSliderItem sliderRainbowRate = new MenuSliderItem("Speed", "Speed at which the colour cycles.", 1, 21, 11); MenuSliderItem sliderRainbowOffset = new MenuSliderItem("Secondary Offset", "How far off the hue for the secondary colour should be, relative to the primary.", 0, 36, 18); menu.AddMenuItem(menuCheckboxRainbow); menu.AddMenuItem(menuCheckboxRainbowSec); menu.AddMenuItem(sliderRainbowSaturation); menu.AddMenuItem(sliderRainbowValue); menu.AddMenuItem(sliderRainbowRate); menu.AddMenuItem(sliderRainbowOffset); menu.OnSliderPositionChange += Menu_OnSliderPositionChange; menu.OnCheckboxChange += Menu_OnCheckboxChange; void Menu_OnCheckboxChange(Menu menu, MenuCheckboxItem menuItem, int itemIndex, bool newCheckedState) { Debug.WriteLine($"Checkbox {menuItem.Label} set to {newCheckedState}"); if (menuItem == menuCheckboxRainbow) { doRainbowPri = newCheckedState; } if (menuItem == menuCheckboxRainbowSec) { doRainbowSec = newCheckedState; } } void Menu_OnSliderPositionChange(Menu menu, MenuSliderItem sliderItem, int oldPosition, int newPosition, int itemIndex) { Debug.WriteLine($"Slider {sliderItem.Label} moved to value {newPosition}"); if (sliderItem == sliderRainbowRate) { rainbowSlowRate = (-(float)newPosition + 21) * 10; } if (sliderItem == sliderRainbowSaturation) { rainbowSaturation = (float)newPosition / (float)sliderItem.Max; } if (sliderItem == sliderRainbowValue) { rainbowValue = (float)newPosition / (float)sliderItem.Max; } if (sliderItem == sliderRainbowOffset) { rainbowOffset = newPosition * 10; } } }
public static void CreateMenu() { //Creating face features Menu MenuController.AddMenu(FaceFeaturesMenu); #region face features menu foreach (MenuSliderItem item in FaceFeaturesMenu.GetMenuItems()) { if (Functions.IsEdidtingPed) { if (Functions.CurrentCharacter.FaceShapeFeatures.features == null) { Functions.CurrentCharacter.FaceShapeFeatures.features = new Dictionary <int, float>(); } else { if (Functions.CurrentCharacter.FaceShapeFeatures.features.ContainsKey(item.Index)) { item.Position = (int)(Functions.CurrentCharacter.FaceShapeFeatures.features[item.Index] * 10f) + 10; SetPedFaceFeature(Game.PlayerPed.Handle, item.Index, Functions.CurrentCharacter.FaceShapeFeatures.features[item.Index]); } else { item.Position = 10; SetPedFaceFeature(Game.PlayerPed.Handle, item.Index, 0f); } } } else { item.Position = 10; SetPedFaceFeature(Game.PlayerPed.Handle, item.Index, 0f); } } #endregion #region face shape data /* * Nose_Width * Nose_Peak_Hight * Nose_Peak_Lenght * Nose_Bone_High * Nose_Peak_Lowering * Nose_Bone_Twist * EyeBrown_High * EyeBrown_Forward * Cheeks_Bone_High * Cheeks_Bone_Width * Cheeks_Width * Eyes_Openning * Lips_Thickness * Jaw_Bone_Width 'Bone size to sides * Jaw_Bone_Back_Lenght 'Bone size to back * Chimp_Bone_Lowering 'Go Down * Chimp_Bone_Lenght 'Go forward * Chimp_Bone_Width * Chimp_Hole * Neck_Thikness */ List <float> faceFeaturesValuesList = new List <float>() { -1.0f, // 0 -0.9f, // 1 -0.8f, // 2 -0.7f, // 3 -0.6f, // 4 -0.5f, // 5 -0.4f, // 6 -0.3f, // 7 -0.2f, // 8 -0.1f, // 9 0.0f, // 10 0.1f, // 11 0.2f, // 12 0.3f, // 13 0.4f, // 14 0.5f, // 15 0.6f, // 16 0.7f, // 17 0.8f, // 18 0.9f, // 19 1.0f // 20 }; var faceFeaturesNamesList = new string[20] { "Nose Width", // 0 "Noes Peak Height", // 1 "Nose Peak Length", // 2 "Nose Bone Height", // 3 "Nose Peak Lowering", // 4 "Nose Bone Twist", // 5 "Eyebrows Height", // 6 "Eyebrows Depth", // 7 "Cheekbones Height", // 8 "Cheekbones Width", // 9 "Cheeks Width", // 10 "Eyes Opening", // 11 "Lips Thickness", // 12 "Jaw Bone Width", // 13 "Jaw Bone Depth/Length", // 14 "Chin Height", // 15 "Chin Depth/Length", // 16 "Chin Width", // 17 "Chin Hole Size", // 18 "Neck Thickness" // 19 }; for (int i = 0; i < 20; i++) { MenuSliderItem faceFeature = new MenuSliderItem(faceFeaturesNamesList[i], $"Set the {faceFeaturesNamesList[i]} face feature value.", 0, 20, 10, true); FaceFeaturesMenu.AddMenuItem(faceFeature); } FaceFeaturesMenu.OnSliderPositionChange += (sender, sliderItem, oldPosition, newPosition, itemIndex) => { if (Functions.CurrentCharacter.FaceShapeFeatures.features == null) { Functions.CurrentCharacter.FaceShapeFeatures.features = new Dictionary <int, float>(); } float value = faceFeaturesValuesList[newPosition]; Functions.CurrentCharacter.FaceShapeFeatures.features[itemIndex] = value; SetPedFaceFeature(Game.PlayerPed.Handle, itemIndex, value); }; #endregion }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { try { MenuController.MenuAlignment = MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; } catch (AspectRatioException) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } // Create the menu. menu = new Menu(Game.Player.Name, "Misc Settings"); teleportOptionsMenu = new Menu(Game.Player.Name, "Teleport Options"); developerToolsMenu = new Menu(Game.Player.Name, "Development Tools"); // teleport menu Menu teleportMenu = new Menu(Game.Player.Name, "Teleport Locations"); MenuItem teleportMenuBtn = new MenuItem("Teleport Locations", "Teleport to pre-configured locations, added by the server owner."); MenuController.AddSubmenu(menu, teleportMenu); MenuController.BindMenuItem(menu, teleportMenu, teleportMenuBtn); // keybind settings menu Menu keybindMenu = new Menu(Game.Player.Name, "Keybind Settings"); MenuItem keybindMenuBtn = new MenuItem("Keybind Settings", "Enable or disable keybinds for some options."); MenuController.AddSubmenu(menu, keybindMenu); MenuController.BindMenuItem(menu, keybindMenu, keybindMenuBtn); // keybind settings menu items MenuCheckboxItem kbTpToWaypoint = new MenuCheckboxItem("Teleport To Waypoint", "Teleport to your waypoint when pressing the keybind. By default, this keybind is set to ~r~F7~s~, server owners are able to change this however so ask them if you don't know what it is.", KbTpToWaypoint); MenuCheckboxItem kbDriftMode = new MenuCheckboxItem("Drift Mode", "Makes your vehicle have almost no traction while holding left shift on keyboard, or X on controller.", KbDriftMode); MenuCheckboxItem kbRecordKeys = new MenuCheckboxItem("Recording Controls", "Enables or disables the recording (gameplay recording for the Rockstar editor) hotkeys on both keyboard and controller.", KbRecordKeys); MenuCheckboxItem kbRadarKeys = new MenuCheckboxItem("Minimap Controls", "Press the Multiplayer Info (z on keyboard, down arrow on controller) key to switch between expanded radar and normal radar.", KbRadarKeys); MenuItem backBtn = new MenuItem("Back"); // Create the menu items. MenuItem tptowp = new MenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); MenuCheckboxItem rightAlignMenu = new MenuCheckboxItem("Right Align Menu", "If you want vMenu to appear on the left side of your screen, disable this option. This option will be saved immediately. You don't need to click save preferences.", MiscRightAlignMenu); MenuCheckboxItem disablePms = new MenuCheckboxItem("Disable Private Messages", "Prevent others from sending you a private message via the Online Players menu. This also prevents you from sending messages to other players.", MiscDisablePrivateMessages); MenuCheckboxItem speedKmh = new MenuCheckboxItem("Show Speed KM/H", "Show a speedometer on your screen indicating your speed in KM/h.", ShowSpeedoKmh); MenuCheckboxItem speedMph = new MenuCheckboxItem("Show Speed MPH", "Show a speedometer on your screen indicating your speed in MPH.", ShowSpeedoMph); MenuCheckboxItem coords = new MenuCheckboxItem("Show Coordinates", "Show your current coordinates at the top of your screen.", ShowCoordinates); MenuCheckboxItem hideRadar = new MenuCheckboxItem("Hide Radar", "Hide the radar/minimap.", HideRadar); MenuCheckboxItem hideHud = new MenuCheckboxItem("Hide Hud", "Hide all hud elements.", HideHud); MenuCheckboxItem showLocation = new MenuCheckboxItem("Location Display", "Shows your current location and heading, as well as the nearest cross road. Similar like PLD. ~r~Warning: This feature (can) take about 1.6 FPS when running at 60 Hz.", ShowLocation) { LeftIcon = MenuItem.Icon.WARNING }; MenuCheckboxItem drawTime = new MenuCheckboxItem("Show Time On Screen", "Shows you the current time on screen.", DrawTimeOnScreen); MenuItem saveSettings = new MenuItem("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.") { RightIcon = MenuItem.Icon.TICK }; MenuCheckboxItem joinQuitNotifs = new MenuCheckboxItem("Join / Quit Notifications", "Receive notifications when someone joins or leaves the server.", JoinQuitNotifications); MenuCheckboxItem deathNotifs = new MenuCheckboxItem("Death Notifications", "Receive notifications when someone dies or gets killed.", DeathNotifications); MenuCheckboxItem nightVision = new MenuCheckboxItem("Toggle Night Vision", "Enable or disable night vision.", false); MenuCheckboxItem thermalVision = new MenuCheckboxItem("Toggle Thermal Vision", "Enable or disable thermal vision.", false); MenuCheckboxItem vehModelDimensions = new MenuCheckboxItem("Show Vehicle Dimensions", "Draws the model outlines for every vehicle that's currently close to you.", ShowVehicleModelDimensions); MenuCheckboxItem propModelDimensions = new MenuCheckboxItem("Show Prop Dimensions", "Draws the model outlines for every prop that's currently close to you.", ShowPropModelDimensions); MenuCheckboxItem pedModelDimensions = new MenuCheckboxItem("Show Ped Dimensions", "Draws the model outlines for every ped that's currently close to you.", ShowPedModelDimensions); MenuCheckboxItem showEntityHandles = new MenuCheckboxItem("Show Entity Handles", "Draws the the entity handles for all close entities (you must enable the outline functions above for this to work).", ShowEntityHandles); MenuCheckboxItem showEntityModels = new MenuCheckboxItem("Show Entity Models", "Draws the the entity models for all close entities (you must enable the outline functions above for this to work).", ShowEntityModels); MenuSliderItem dimensionsDistanceSlider = new MenuSliderItem("Show Dimensions Radius", "Show entity model/handle/dimension draw range.", 0, 20, 20, false); MenuItem clearArea = new MenuItem("Clear Area", "Clears the area around your player (100 meters). Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up, fixed and reset to the default world state."); MenuCheckboxItem lockCamX = new MenuCheckboxItem("Lock Camera Horizontal Rotation", "Locks your camera horizontal rotation. Could be useful in helicopters I guess.", false); MenuCheckboxItem lockCamY = new MenuCheckboxItem("Lock Camera Vertical Rotation", "Locks your camera vertical rotation. Could be useful in helicopters I guess.", false); Menu connectionSubmenu = new Menu(Game.Player.Name, "Connection Options"); MenuItem connectionSubmenuBtn = new MenuItem("Connection Options", "Server connection/game quit options."); MenuItem quitSession = new MenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. ~r~Can not be used when you are the host."); MenuItem rejoinSession = new MenuItem("Re-join Session", "This may not work in all cases, but you can try to use this if you want to re-join the previous session after clicking 'Quit Session'."); MenuItem quitGame = new MenuItem("Quit Game", "Exits the game after 5 seconds."); MenuItem disconnectFromServer = new MenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. ~r~This feature is not recommended, quit the game completely instead and restart it for a better experience."); connectionSubmenu.AddMenuItem(quitSession); connectionSubmenu.AddMenuItem(rejoinSession); connectionSubmenu.AddMenuItem(quitGame); connectionSubmenu.AddMenuItem(disconnectFromServer); MenuCheckboxItem enableTimeCycle = new MenuCheckboxItem("Enable Timecycle Modifier", "Enable or disable the timecycle modifier from the list below.", TimecycleEnabled); List <string> timeCycleModifiersListData = TimeCycles.Timecycles.ToList(); for (var i = 0; i < timeCycleModifiersListData.Count; i++) { timeCycleModifiersListData[i] += $" ({i + 1}/{timeCycleModifiersListData.Count})"; } MenuListItem timeCycles = new MenuListItem("TM", timeCycleModifiersListData, 0, "Select a timecycle modifier and enable the checkbox above."); MenuSliderItem timeCycleIntensity = new MenuSliderItem("Timecycle Modifier Intensity", "Set the timecycle modifier intensity.", 0, 20, 20, true); MenuCheckboxItem locationBlips = new MenuCheckboxItem("Location Blips", "Shows blips on the map for some common locations.", ShowLocationBlips); MenuCheckboxItem playerBlips = new MenuCheckboxItem("Show Player Blips", "Shows blips on the map for all players.", ShowPlayerBlips); MenuCheckboxItem playerNames = new MenuCheckboxItem("Show Player Names", "Enables or disables player overhead names.", MiscShowOverheadNames); MenuCheckboxItem respawnDefaultCharacter = new MenuCheckboxItem("Respawn As Default MP Character", "If you enable this, then you will (re)spawn as your default saved MP character. Note the server owner can globally disable this option. To set your default character, go to one of your saved MP Characters and click the 'Set As Default Character' button.", MiscRespawnDefaultCharacter); MenuCheckboxItem restorePlayerAppearance = new MenuCheckboxItem("Restore Player Appearance", "Restore your player's skin whenever you respawn after being dead. Re-joining a server will not restore your previous skin.", RestorePlayerAppearance); MenuCheckboxItem restorePlayerWeapons = new MenuCheckboxItem("Restore Player Weapons", "Restore your weapons whenever you respawn after being dead. Re-joining a server will not restore your previous weapons.", RestorePlayerWeapons); MenuController.AddSubmenu(menu, connectionSubmenu); MenuController.BindMenuItem(menu, connectionSubmenu, connectionSubmenuBtn); keybindMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == kbTpToWaypoint) { KbTpToWaypoint = _checked; } else if (item == kbDriftMode) { KbDriftMode = _checked; } else if (item == kbRecordKeys) { KbRecordKeys = _checked; } else if (item == kbRadarKeys) { KbRadarKeys = _checked; } }; keybindMenu.OnItemSelect += (sender, item, index) => { if (item == backBtn) { keybindMenu.GoBack(); } }; connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { QuitGame(); } else if (item == quitSession) { if (NetworkIsSessionActive()) { if (NetworkIsHost()) { Notify.Error("Sorry, you cannot leave the session when you are the host. This would prevent other players from joining/staying on the server."); } else { QuitSession(); } } else { Notify.Error("You are currently not in any session."); } } else if (item == rejoinSession) { if (NetworkIsSessionActive()) { Notify.Error("You are already connected to a session."); } else { Notify.Info("Attempting to re-join the session."); NetworkSessionHost(-1, 32, false); } } else if (item == disconnectFromServer) { RegisterCommand("disconnect", new Action <dynamic, dynamic, dynamic>((a, b, c) => { }), false); ExecuteCommand("disconnect"); } }; // Teleportation options if (IsAllowed(Permission.MSTeleportToWp) || IsAllowed(Permission.MSTeleportLocations)) { MenuItem teleportOptionsMenuBtn = new MenuItem("Teleport Options", "Various teleport options.") { Label = "→→→" }; menu.AddMenuItem(teleportOptionsMenuBtn); MenuController.BindMenuItem(menu, teleportOptionsMenu, teleportOptionsMenuBtn); if (IsAllowed(Permission.MSTeleportToWp)) { teleportOptionsMenu.AddMenuItem(tptowp); keybindMenu.AddMenuItem(kbTpToWaypoint); teleportOptionsMenu.OnItemSelect += (sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { TeleportToWp(); } }; } if (IsAllowed(Permission.MSTeleportLocations)) { teleportOptionsMenu.AddMenuItem(teleportMenuBtn); MenuController.AddSubmenu(teleportOptionsMenu, teleportMenu); MenuController.BindMenuItem(teleportOptionsMenu, teleportMenu, teleportMenuBtn); teleportMenuBtn.Label = "→→→"; 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"]); MenuItem tpBtn = new MenuItem(name, $"Teleport to X: {(int)coordinates.X} Y: {(int)coordinates.Y} Z: {(int)coordinates.Z} HEADING: {(int)heading}."); teleportMenu.AddMenuItem(tpBtn); tpLocations.Add(coordinates); tpLocationsHeading.Add(heading); } teleportMenu.OnItemSelect += async(sender, item, index) => { await TeleportToCoords(tpLocations[index], true); SetEntityHeading(Game.PlayerPed.Handle, 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"); } } } } #region dev tools menu MenuItem devToolsBtn = new MenuItem("Developer Tools", "Various development/debug tools.") { Label = "→→→" }; menu.AddMenuItem(devToolsBtn); MenuController.AddSubmenu(menu, developerToolsMenu); MenuController.BindMenuItem(menu, developerToolsMenu, devToolsBtn); // clear area and coordinates if (IsAllowed(Permission.MSClearArea)) { developerToolsMenu.AddMenuItem(clearArea); } if (IsAllowed(Permission.MSShowCoordinates)) { developerToolsMenu.AddMenuItem(coords); } // model outlines if (!vMenuShared.ConfigManager.GetSettingsBool(vMenuShared.ConfigManager.Setting.vmenu_disable_entity_outlines_tool)) { developerToolsMenu.AddMenuItem(vehModelDimensions); developerToolsMenu.AddMenuItem(propModelDimensions); developerToolsMenu.AddMenuItem(pedModelDimensions); developerToolsMenu.AddMenuItem(showEntityHandles); developerToolsMenu.AddMenuItem(showEntityModels); developerToolsMenu.AddMenuItem(dimensionsDistanceSlider); } // timecycle modifiers developerToolsMenu.AddMenuItem(timeCycles); developerToolsMenu.AddMenuItem(enableTimeCycle); developerToolsMenu.AddMenuItem(timeCycleIntensity); developerToolsMenu.OnSliderPositionChange += (sender, item, oldPos, newPos, itemIndex) => { if (item == timeCycleIntensity) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)newPos / 20f); SetTimecycleModifierStrength(intensity); } } else if (item == dimensionsDistanceSlider) { FunctionsController.entityRange = ((float)newPos / 20f) * 2000f; // max radius = 2000f; } }; developerToolsMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == timeCycles) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } } }; developerToolsMenu.OnItemSelect += (sender, item, index) => { if (item == clearArea) { var pos = Game.PlayerPed.Position; BaseScript.TriggerServerEvent("vMenu:ClearArea", pos.X, pos.Y, pos.Z); } }; developerToolsMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == vehModelDimensions) { ShowVehicleModelDimensions = _checked; } else if (item == propModelDimensions) { ShowPropModelDimensions = _checked; } else if (item == pedModelDimensions) { ShowPedModelDimensions = _checked; } else if (item == showEntityHandles) { ShowEntityHandles = _checked; } else if (item == showEntityModels) { ShowEntityModels = _checked; } else if (item == enableTimeCycle) { TimecycleEnabled = _checked; ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } } else if (item == coords) { ShowCoordinates = _checked; } }; #endregion // Keybind options if (IsAllowed(Permission.MSDriftMode)) { keybindMenu.AddMenuItem(kbDriftMode); } // always allowed keybind menu options keybindMenu.AddMenuItem(kbRecordKeys); keybindMenu.AddMenuItem(kbRadarKeys); keybindMenu.AddMenuItem(backBtn); // Always allowed menu.AddMenuItem(rightAlignMenu); menu.AddMenuItem(disablePms); menu.AddMenuItem(speedKmh); menu.AddMenuItem(speedMph); //menu.AddMenuItem(vehModelDimensions); //menu.AddMenuItem(propModelDimensions); //menu.AddMenuItem(pedModelDimensions); //menu.AddMenuItem(showEntityHandles); menu.AddMenuItem(keybindMenuBtn); keybindMenuBtn.Label = "→→→"; if (IsAllowed(Permission.MSConnectionMenu)) { menu.AddMenuItem(connectionSubmenuBtn); connectionSubmenuBtn.Label = "→→→"; } //if (IsAllowed(Permission.MSShowCoordinates)) //{ // menu.AddMenuItem(coords); //} if (IsAllowed(Permission.MSShowLocation)) { menu.AddMenuItem(showLocation); } menu.AddMenuItem(drawTime); // always allowed if (IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddMenuItem(deathNotifs); } if (IsAllowed(Permission.MSDeathNotifs)) { menu.AddMenuItem(joinQuitNotifs); } if (IsAllowed(Permission.MSNightVision)) { menu.AddMenuItem(nightVision); } if (IsAllowed(Permission.MSThermalVision)) { menu.AddMenuItem(thermalVision); } if (IsAllowed(Permission.MSLocationBlips)) { menu.AddMenuItem(locationBlips); ToggleBlips(ShowLocationBlips); } if (IsAllowed(Permission.MSPlayerBlips)) { menu.AddMenuItem(playerBlips); } if (IsAllowed(Permission.MSOverheadNames)) { menu.AddMenuItem(playerNames); } //menu.AddMenuItem(enableTimeCycle); //menu.AddMenuItem(timeCycles); //menu.AddMenuItem(timeCycleIntensity); //if (IsAllowed(Permission.MSClearArea)) //{ // menu.AddMenuItem(clearArea); //} // always allowed, it just won't do anything if the server owner disabled the feature, but players can still toggle it. menu.AddMenuItem(respawnDefaultCharacter); if (IsAllowed(Permission.MSRestoreAppearance)) { menu.AddMenuItem(restorePlayerAppearance); } if (IsAllowed(Permission.MSRestoreWeapons)) { menu.AddMenuItem(restorePlayerWeapons); } // Always allowed menu.AddMenuItem(hideRadar); menu.AddMenuItem(hideHud); menu.AddMenuItem(lockCamX); menu.AddMenuItem(lockCamY); menu.AddMenuItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == rightAlignMenu) { try { MenuController.MenuAlignment = _checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = _checked; UserDefaults.MiscRightAlignMenu = MiscRightAlignMenu; } catch (AspectRatioException) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } } else if (item == disablePms) { MiscDisablePrivateMessages = _checked; } else if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == hideHud) { HideHud = _checked; DisplayHud(!_checked); } else if (item == hideRadar) { HideRadar = _checked; if (!_checked) { DisplayRadar(true); } } else if (item == showLocation) { ShowLocation = _checked; } else if (item == drawTime) { DrawTimeOnScreen = _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; } else if (item == playerNames) { MiscShowOverheadNames = _checked; } else if (item == respawnDefaultCharacter) { MiscRespawnDefaultCharacter = _checked; } else if (item == restorePlayerAppearance) { RestorePlayerAppearance = _checked; } else if (item == restorePlayerWeapons) { RestorePlayerWeapons = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // save settings if (item == saveSettings) { UserDefaults.SaveSettings(); } }; }