private async void InitialiseMenu() { if (EditorMenu == null) { EditorMenu = new UIMenu(ScriptName, "Edit Track Width and Camber", new PointF(screenPosX * Screen.Width, screenPosY * Screen.Height)); { EditorMenu.MouseEdgeEnabled = false; EditorMenu.ControlDisablingEnabled = false; EditorMenu.MouseControlsEnabled = false; } } else { EditorMenu.Clear(); } frontOffsetGUI = AddDynamicFloatList(EditorMenu, "Front Track Width", -currentPreset.DefaultOffsetX[0], -currentPreset.OffsetX[0], FrontMaxOffset); rearOffsetGUI = AddDynamicFloatList(EditorMenu, "Rear Track Width", -currentPreset.DefaultOffsetX[currentPreset.FrontWheelsCount], -currentPreset.OffsetX[currentPreset.FrontWheelsCount], RearMaxOffset); frontRotationGUI = AddDynamicFloatList(EditorMenu, "Front Camber", currentPreset.DefaultRotationY[0], currentPreset.RotationY[0], FrontMaxCamber); rearRotationGUI = AddDynamicFloatList(EditorMenu, "Rear Camber", currentPreset.DefaultRotationY[currentPreset.FrontWheelsCount], currentPreset.RotationY[currentPreset.FrontWheelsCount], RearMaxCamber); AddMenuReset(EditorMenu); if (_menuPool == null) { _menuPool = new MenuPool(); { _menuPool.ResetCursorOnOpen = true; } _menuPool.Add(EditorMenu); } _menuPool.RefreshIndex(); await Delay(0); }
private string ChangeCallback(UIMenuDynamicListItem sender, UIMenuDynamicListItem.ChangeDirection direction) { int index = _selectedIndex; if (direction == UIMenuDynamicListItem.ChangeDirection.Right) { if (RemoteDeloreansHandler.TimeMachineCount > 0) { index++; if (index > RemoteDeloreansHandler.TimeMachineCount - 1) { index = 0; } } } else { if (RemoteDeloreansHandler.TimeMachineCount > 0) { index--; if (index < 0) { index = RemoteDeloreansHandler.TimeMachineCount - 1; } } } _selectedIndex = index; return(_selectedIndex.ToString()); }
public TrainMissionMenu() : base("Train Mission", "SELECT AN OPTION") { AddItem(SpawnTrain = new UIMenuItem("Spawn train")); AddItem(DeleteTrain = new UIMenuItem("Delete train")); AddItem(TrainMission = new UIMenuCheckboxItem("Toggle train mission", MissionHandler.TrainMission.IsPlaying, "Start (or stop) train mission.")); AddItem(PlayMusic = new UIMenuCheckboxItem("Play music", MissionHandler.TrainMission.PlayMusic, "If true, movie's soundtrack will be played in background.")); AddItem(TimeSpeed = new UIMenuDynamicListItem("Speed", "Set speed multipier of the mission. Lower the value, faster the speed and vice versa.", _speed.ToString(), ChangeCallback)); OnItemSelect += TrainMissionMenu_OnItemSelect; OnCheckboxChange += TrainMissionMenu_OnCheckboxChange; OnMenuOpen += TrainMissionMenu_OnMenuOpen; }
public RCMenu() : base(Game.GetLocalizedString("BTTFV_Menu_RCMenu"), Game.GetLocalizedString("BTTFV_Menu_RCMenu_Description")) { AddItem(Deloreans = new UIMenuDynamicListItem(Game.GetLocalizedString("BTTFV_Menu_RCMenu_Deloreans"), Game.GetLocalizedString("BTTFV_Menu_RCMenu_Deloreans_Description"), "0", ChangeCallback)); AddItem(FuelChamberDescription = new UIMenuCheckboxItem(Game.GetLocalizedString("BTTFV_Menu_RCMenu_FuelChamberFilled"), true, Game.GetLocalizedString("BTTFV_Menu_RCMenu_FuelChamberFilled_Description"))); AddItem(TimeCircuitsOnDescription = new UIMenuCheckboxItem(Game.GetLocalizedString("BTTFV_Menu_RCMenu_TimeCircuitsOn"), true, Game.GetLocalizedString("BTTFV_Menu_RCMenu_TimeCircuitsOn_Description"))); AddItem(DestinationTimeDescription = new UIMenuItem(Game.GetLocalizedString("BTTFV_Menu_RCMenu_DestinationTime"), Game.GetLocalizedString("BTTFV_Menu_RCMenu_DestinationTime_Description"))); statisticsMenu = Utils.AttachSubmenu(this, InteractionMenuManager.StatisticsMenu, Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu"), Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Description")); FuelChamberDescription.Enabled = false; TimeCircuitsOnDescription.Enabled = false; DestinationTimeDescription.Enabled = false; OnItemSelect += RCMenu_OnItemSelect; OnListChange += RCMenu_OnListChange; OnMenuClose += RCMenu_OnMenuClose; }
public StatisticsMenu() : base(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu"), Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Description")) { AddItem(Deloreans = new UIMenuDynamicListItem(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Deloreans"), Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Deloreans_Description"), "0", ChangeCallback)); AddItem(TypeDescription = new UIMenuListItem(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Type"), _listTypes, 0, Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Type_Description"))); AddItem(DestinationTimeDescription = new UIMenuItem(Game.GetLocalizedString("BTTFV_Menu_RCMenu_DestinationTime"), Game.GetLocalizedString("BTTFV_Menu_RCMenu_DestinationTime_Description"))); AddItem(LastTimeDescription = new UIMenuItem(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_LastTime"), Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_LastTime_Description"))); AddItem(Spawned = new UIMenuCheckboxItem(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Spawned"), false, Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_Spawned_Description"))); AddItem(ShowBlip = new UIMenuCheckboxItem(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_ShowBlip"), false, Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_ShowBlip_Description"))); AddItem(ForceReenter = new UIMenuItem(Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_ForceReenter"), Game.GetLocalizedString("BTTFV_Menu_StatisticsMenu_ForceReenter_Description"))); TypeDescription.Enabled = false; DestinationTimeDescription.Enabled = false; LastTimeDescription.Enabled = false; Spawned.Enabled = false; OnItemSelect += StatisticsMenu_OnItemSelect; OnListChange += StatisticsMenu_OnListChange; OnMenuClose += StatisticsMenu_OnMenuClose; OnCheckboxChange += StatisticsMenu_OnCheckboxChange; }
private string ChangeCallback(UIMenuDynamicListItem sender, UIMenuDynamicListItem.ChangeDirection direction) { switch (direction) { case UIMenuDynamicListItem.ChangeDirection.Left: if (_speed > 0.1f) { _speed -= 0.1f; } break; case UIMenuDynamicListItem.ChangeDirection.Right: _speed += 0.1f; break; } _speed = Convert.ToSingle(Math.Round(_speed, 1)); MissionHandler.TrainMission.TimeMultiplier = _speed; return(_speed.ToString()); }
private string ChangeCallback(UIMenuDynamicListItem sender, UIMenuDynamicListItem.ChangeDirection direction) { int index = _selectedIndex; if (direction == UIMenuDynamicListItem.ChangeDirection.Right) { if (DeloreanHandler.TimeMachineCount > 0) { index++; if (index > DeloreanHandler.TimeMachineCount - 1) { index = 0; } } } else { if (DeloreanHandler.TimeMachineCount > 0) { index--; if (index < 0) { index = DeloreanHandler.TimeMachineCount - 1; } } } _selectedIndex = index; if (!TrySelectCar(_selectedIndex)) { GTA.UI.Notification.Show(Game.GetLocalizedString("BTTFV_OutOfRange")); } return(_selectedIndex.ToString()); }
private UIMenuDynamicListItem AddDynamicFloatList(UIMenu menu, string name, float defaultValue, float value, float maxEditing) { var newitem = new UIMenuDynamicListItem(name, value.ToString("F3"), (sender, direction) => { var newvalue = value; float min = defaultValue - maxEditing; float max = defaultValue + maxEditing; //newvalue = (float)Math.Round(newvalue, 3); //min = (float)Math.Round(min, 3); //max = (float)Math.Round(max, 3); if (direction == UIMenuDynamicListItem.ChangeDirection.Left) { newvalue -= editingFactor; } else if (direction == UIMenuDynamicListItem.ChangeDirection.Right) { newvalue += editingFactor; } else { return(value.ToString("F3")); } if (newvalue < min) { CitizenFX.Core.UI.Screen.ShowNotification($"~o~Warning~w~: Min ~b~{name}~w~ value allowed is {min} for this vehicle"); } else if (newvalue > max) { CitizenFX.Core.UI.Screen.ShowNotification($"~o~Warning~w~: Max ~b~{name}~w~ value allowed is {max} for this vehicle"); } else { value = newvalue; if (sender == frontRotationGUI) { currentPreset.SetRotationFront(value); } else if (sender == rearRotationGUI) { currentPreset.SetRotationRear(value); } else if (sender == frontOffsetGUI) { currentPreset.SetOffsetFront(-value); } else if (sender == rearOffsetGUI) { currentPreset.SetOffsetRear(-value); } // Force one single refresh to update rendering at correct position after reset if (value == defaultValue) { RefreshVehicleUsingPreset(currentVehicle, currentPreset); } if (debug) { Debug.WriteLine($"{ScriptName}: Edited {sender.Text} => value:{value}"); } } return(value.ToString("F3")); }); menu.AddItem(newitem); return(newitem); }