private async void GUI_MenuResetPresetButtonPressed(object sender, EventArgs e) { CurrentPreset.Reset(); RemoveDecorators(CurrentVehicle); RefreshVehicleUsingPreset(CurrentVehicle, CurrentPreset); await Delay(200); PresetChanged?.Invoke(this, EventArgs.Empty); }
public void UsePreviousInput() { for (var i = 1; i <= 6; i++) { var prevInput = (int)Input - i; if (prevInput > 5) { prevInput = 0; } if (prevInput < 0) { prevInput = 5; } if (CurrentPreset.IsInputUsed(prevInput + 1)) { Input = prevInput; return; } } }
public void UseNextInput() { for (var i = 1; i <= 6; i++) { var nextInput = (int)Input + i; if (nextInput > 5) { nextInput = 0; } if (nextInput < 0) { nextInput = 5; } if (CurrentPreset.IsInputUsed(nextInput + 1)) { Input = nextInput; return; } } }
/// <summary> /// Default constructor /// </summary> public HandlingEditor() { ResourceName = GetCurrentResourceName(); CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Script by Neos7"); LoadConfig(); ReadFieldInfo(); ServerPresets = new Dictionary <string, HandlingPreset>(); ReadServerPresets(); RegisterDecorators(); ReadVehiclePermissions(); CurrentTime = GetGameTimer(); LastTime = CurrentTime; CurrentPreset = null; CurrentVehicle = -1; Vehicles = Enumerable.Empty <int>(); #region Register Commands RegisterCommand("handling_range", new Action <int, dynamic>((source, args) => { if (args.Count < 1) { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Missing float argument"); return; } if (float.TryParse(args[0], out float value)) { ScriptRange = value; CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Received new {nameof(ScriptRange)} value {value}"); } else { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Error parsing {args[0]} as float"); } }), false); RegisterCommand("handling_debug", new Action <int, dynamic>((source, args) => { if (args.Count < 1) { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Missing bool argument"); return; } if (bool.TryParse(args[0], out bool value)) { Debug = value; CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Received new {nameof(Debug)} value {value}"); } else { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Error parsing {args[0]} as bool"); } }), false); RegisterCommand("handling_decorators", new Action <int, dynamic>((source, args) => { if (args.Count < 1) { PrintDecorators(CurrentVehicle); } else { if (int.TryParse(args[0], out int value)) { PrintDecorators(value); } else { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Error parsing {args[0]} as int"); } } }), false); RegisterCommand("handling_print", new Action <int, dynamic>((source, args) => { PrintVehiclesWithDecorators(Vehicles); }), false); RegisterCommand("handling_preset", new Action <int, dynamic>((source, args) => { if (CurrentPreset != null) { CitizenFX.Core.Debug.WriteLine(CurrentPreset.ToString()); } else { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Current preset doesn't exist"); } }), false); RegisterCommand("handling_xml", new Action <int, dynamic>((source, args) => { if (CurrentPreset != null) { CitizenFX.Core.Debug.WriteLine(GetXmlFromPreset(CurrentPreset).OuterXml); } else { CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Current preset doesn't exist"); } }), false); #endregion #region GUI Event Handling HandlingMenu.MenuApplyPersonalPresetButtonPressed += GUI_MenuApplyPersonalPresetButtonPressed; HandlingMenu.MenuApplyServerPresetButtonPressed += GUI_MenuApplyServerPresetButtonPressed; HandlingMenu.MenuSavePersonalPresetButtonPressed += GUI_MenuSavePersonalPresetButtonPressed; HandlingMenu.MenuDeletePersonalPresetButtonPressed += GUI_MenuDeletePersonalPresetButtonPressed; HandlingMenu.MenuResetPresetButtonPressed += GUI_MenuResetPresetButtonPressed; HandlingMenu.MenuPresetValueChanged += GUI_MenuPresetValueChanged; #endregion Tick += GetCurrentVehicle; Tick += ScriptTask; }