Skip to content

Commit

Permalink
Merge pull request #263 from Drift91/ReplaceSavedVehiclePrompt
Browse files Browse the repository at this point in the history
 Add confirmation prompt for replacing saved vehicle
  • Loading branch information
TomGrobbe authored Nov 3, 2021
2 parents 91c7d2a + d23485a commit 2a35718
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions vMenu/menus/SavedVehicles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class SavedVehicles
private Dictionary<MenuItem, KeyValuePair<string, VehicleInfo>> svMenuItems = new Dictionary<MenuItem, KeyValuePair<string, VehicleInfo>>();
private KeyValuePair<string, VehicleInfo> currentlySelectedVehicle = new KeyValuePair<string, VehicleInfo>();
private int deleteButtonPressedCount = 0;
private int replaceButtonPressedCount = 0;


/// <summary>
Expand Down Expand Up @@ -107,6 +108,8 @@ private void CreateMenu()
selectedVehicleMenu.RefreshIndex();
deleteButtonPressedCount = 0;
deleteVehicle.Label = "";
replaceButtonPressedCount = 0;
replaceVehicle.Label = "";
};

selectedVehicleMenu.OnItemSelect += async (sender, item, index) =>
Expand Down Expand Up @@ -153,13 +156,24 @@ private void CreateMenu()
{
if (Game.PlayerPed.IsInVehicle())
{
SaveVehicle(currentlySelectedVehicle.Key.Substring(4));
selectedVehicleMenu.GoBack();
Notify.Success("Your saved vehicle has been replaced with your current vehicle.");
if (replaceButtonPressedCount == 0)
{
replaceButtonPressedCount = 1;
item.Label = "Press again to confirm.";
Notify.Alert("Are you sure you want to replace this vehicle? Press the button again to confirm.");
}
else
{
replaceButtonPressedCount = 0;
item.Label = "";
SaveVehicle(currentlySelectedVehicle.Key.Substring(4));
selectedVehicleMenu.GoBack();
Notify.Success("Your saved vehicle has been replaced with your current vehicle.");
}
}
else
{
Notify.Error("You need to be in a vehicle before you can relplace your old vehicle.");
Notify.Error("You need to be in a vehicle before you can replace your old vehicle.");
}
}
else if (item == deleteVehicle)
Expand All @@ -185,6 +199,11 @@ private void CreateMenu()
deleteButtonPressedCount = 0;
deleteVehicle.Label = "";
}
if (item != replaceVehicle)
{
replaceButtonPressedCount = 0;
replaceVehicle.Label = "";
}
};
unavailableVehiclesMenu.InstructionalButtons.Add(Control.FrontendDelete, "Delete Vehicle!");

Expand Down

0 comments on commit 2a35718

Please sign in to comment.