diff --git a/ActivityGhosts/ActivityGhosts.cs b/ActivityGhosts/ActivityGhosts.cs index a299b20..ebf0a44 100644 --- a/ActivityGhosts/ActivityGhosts.cs +++ b/ActivityGhosts/ActivityGhosts.cs @@ -10,19 +10,25 @@ using GTA.Math; using GTA.Native; using GTA.UI; -using NativeUI; +using LemonUI; +using LemonUI.Menus; namespace ActivityGhosts { public class ActivityGhosts : Script { - private List ghosts; + private readonly List ghosts; private Blip start; private int lastTime; private Keys menuKey; public static PointF initialGPSPoint; public static int opacity; private bool showDate; + private ObjectPool menuPool; + private NativeMenu mainMenu; + private NativeItem loadMenuItem; + private NativeItem regroupMenuItem; + private NativeItem deleteMenuItem; public ActivityGhosts() { @@ -132,45 +138,52 @@ private void LoadSettings() private void CreateMenu() { - var menuPool = new MenuPool(); - var mainMenu = new UIMenu("ActivityGhosts", "Ride with ghosts from previous activities"); + menuPool = new ObjectPool(); + mainMenu = new NativeMenu("ActivityGhosts"); menuPool.Add(mainMenu); - var loadMenuItem = new UIMenuItem("Load", "Load ghosts"); - loadMenuItem.Enabled = true; - mainMenu.AddItem(loadMenuItem); - var regroupMenuItem = new UIMenuItem("Regroup", "Regroup ghosts"); - regroupMenuItem.Enabled = false; - mainMenu.AddItem(regroupMenuItem); - var deleteMenuItem = new UIMenuItem("Delete", "Delete ghosts"); - deleteMenuItem.Enabled = false; - mainMenu.AddItem(deleteMenuItem); - mainMenu.OnItemSelect += (sender, item, index) => + loadMenuItem = new NativeItem("Load", "Load ghosts") { - if (item == loadMenuItem && loadMenuItem.Enabled) - { - LoadGhosts(); - if (ghosts.Count > 0) - { - start = World.CreateBlip(Game.Player.Character.Position); - start.Sprite = BlipSprite.RaceBike; - loadMenuItem.Enabled = false; - regroupMenuItem.Enabled = true; - deleteMenuItem.Enabled = true; - } - } - else if (item == regroupMenuItem && regroupMenuItem.Enabled) - RegroupGhosts(); - else if (item == deleteMenuItem && deleteMenuItem.Enabled) + Enabled = true + }; + mainMenu.Add(loadMenuItem); + loadMenuItem.Activated += (sender, itemArgs) => + { + LoadGhosts(); + if (ghosts.Count > 0) { - DeleteGhosts(); - loadMenuItem.Enabled = true; - regroupMenuItem.Enabled = false; - deleteMenuItem.Enabled = false; + start = World.CreateBlip(Game.Player.Character.Position); + start.Sprite = BlipSprite.RaceBike; + loadMenuItem.Enabled = false; + regroupMenuItem.Enabled = true; + deleteMenuItem.Enabled = true; } mainMenu.Visible = false; }; - menuPool.RefreshIndex(); - Tick += (o, e) => menuPool.ProcessMenus(); + regroupMenuItem = new NativeItem("Regroup", "Regroup ghosts") + { + Enabled = false + }; + mainMenu.Add(regroupMenuItem); + regroupMenuItem.Activated += (sender, itemArgs) => + { + RegroupGhosts(); + mainMenu.Visible = false; + }; + deleteMenuItem = new NativeItem("Delete", "Delete ghosts") + { + Enabled = false + }; + mainMenu.Add(deleteMenuItem); + deleteMenuItem.Activated += (sender, itemArgs) => + { + DeleteGhosts(); + loadMenuItem.Enabled = true; + regroupMenuItem.Enabled = false; + deleteMenuItem.Enabled = false; + mainMenu.Visible = false; + }; + menuPool.RefreshAll(); + Tick += (o, e) => menuPool.Process(); KeyDown += (o, e) => { if (e.KeyCode == menuKey) @@ -181,24 +194,24 @@ private void CreateMenu() public class Ghost { - private List points; - private Vehicle vehicle; + private readonly List points; + private readonly Vehicle vehicle; public Ped ped; public TextElement date; - private Blip blip; + private readonly Blip blip; private int index; - private VehicleDrivingFlags customDrivingStyle = VehicleDrivingFlags.AllowGoingWrongWay | - VehicleDrivingFlags.AllowMedianCrossing | - VehicleDrivingFlags.AvoidEmptyVehicles | - VehicleDrivingFlags.AvoidObjects | - VehicleDrivingFlags.AvoidPeds | - VehicleDrivingFlags.AvoidVehicles | - VehicleDrivingFlags.IgnorePathFinding; + private readonly VehicleDrivingFlags customDrivingStyle = VehicleDrivingFlags.AllowGoingWrongWay | + VehicleDrivingFlags.AllowMedianCrossing | + VehicleDrivingFlags.AvoidEmptyVehicles | + VehicleDrivingFlags.AvoidObjects | + VehicleDrivingFlags.AvoidPeds | + VehicleDrivingFlags.AvoidVehicles | + VehicleDrivingFlags.IgnorePathFinding; - private string[] availableBicycles = { "BMX", "CRUISER", "FIXTER", "SCORCHER", "TRIBIKE", "TRIBIKE2", "TRIBIKE3" }; + private readonly string[] availableBicycles = { "BMX", "CRUISER", "FIXTER", "SCORCHER", "TRIBIKE", "TRIBIKE2", "TRIBIKE3" }; - private string[] availableCyclists = { "a_m_y_cyclist_01", "a_m_y_roadcyc_01" }; + private readonly string[] availableCyclists = { "a_m_y_cyclist_01", "a_m_y_roadcyc_01" }; public Ghost(List pointList, string span) { diff --git a/ActivityGhosts/ActivityGhosts.csproj b/ActivityGhosts/ActivityGhosts.csproj index 580ab69..83f6b10 100644 --- a/ActivityGhosts/ActivityGhosts.csproj +++ b/ActivityGhosts/ActivityGhosts.csproj @@ -34,8 +34,8 @@ D:\Grand Theft Auto V\Scripts\Fit.dll - - D:\Grand Theft Auto V\Scripts\NativeUI.dll + + D:\Grand Theft Auto V\Scripts\LemonUI.SHVDN3.dll D:\Grand Theft Auto V\ScriptHookVDotNet3.dll diff --git a/README.md b/README.md index 96a6bcc..e5b41ac 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,6 @@ https://github.com/oldnapalm/ActivityGhosts/releases/latest ## Requirements - [ScriptHookV](http://www.dev-c.com/gtav/scripthookv/) -- [ScriptHookVDotNet](https://github.com/crosire/scripthookvdotnet/releases) -- [NativeUI](https://github.com/Guad/NativeUI) +- [ScriptHookVDotNet](https://github.com/crosire/scripthookvdotnet) +- [LemonUI](https://github.com/justalemon/LemonUI) - [FIT](https://developer.garmin.com/fit/download/)