Skip to content

Commit

Permalink
prevent saving of empty presets
Browse files Browse the repository at this point in the history
  • Loading branch information
carmineos committed Jun 2, 2020
1 parent 69638fa commit b8759f9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions VStancer.Client/Scripts/ClientPresetsScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b8759f9

Please sign in to comment.