From b8759f9e485e7aaf75a3a972c6dc89a7be243301 Mon Sep 17 00:00:00 2001 From: Carmine Giugliano Date: Tue, 2 Jun 2020 20:08:03 +0200 Subject: [PATCH] prevent saving of empty presets --- .../Scripts/ClientPresetsScript.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/VStancer.Client/Scripts/ClientPresetsScript.cs b/VStancer.Client/Scripts/ClientPresetsScript.cs index b16037c..ef2d138 100644 --- a/VStancer.Client/Scripts/ClientPresetsScript.cs +++ b/VStancer.Client/Scripts/ClientPresetsScript.cs @@ -47,10 +47,25 @@ private void OnDeletePresetInvoked(string presetKey) private void OnSavePresetInvoked(string presetKey) { + var wheelPreset = _mainScript.WheelScript?.GetWheelPreset(); + var wheelModPreset = _mainScript.WheelModScript?.GetWheelModPreset(); + + if(wheelPreset == null && wheelModPreset == null) + { + Screen.ShowNotification($"~r~ERROR~w~ Nothing to save, be sure your vehicle is edited!"); + return; + } + + if (wheelPreset == null) + Screen.ShowNotification($"~y~WARNING~w~ The preset doesn't contain any wheel data."); + + if (wheelModPreset == null) + Screen.ShowNotification($"~y~WARNING~w~ The preset doesn't contain any wheel mod data."); + VStancerPreset preset = new VStancerPreset { - WheelPreset = _mainScript.WheelScript?.GetWheelPreset(), - WheelModPreset = _mainScript.WheelModScript?.GetWheelModPreset() + WheelPreset = wheelPreset, + WheelModPreset = wheelModPreset, }; if (Presets.Save(presetKey, preset))