Skip to content

Commit

Permalink
Use LemonUI
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm committed Dec 21, 2021
1 parent a0553dc commit ce228a8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 51 deletions.
107 changes: 60 additions & 47 deletions ActivityGhosts/ActivityGhosts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ghost> ghosts;
private readonly List<Ghost> 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()
{
Expand Down Expand Up @@ -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)
Expand All @@ -181,24 +194,24 @@ private void CreateMenu()

public class Ghost
{
private List<GeoPoint> points;
private Vehicle vehicle;
private readonly List<GeoPoint> 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<GeoPoint> pointList, string span)
{
Expand Down
4 changes: 2 additions & 2 deletions ActivityGhosts/ActivityGhosts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<Reference Include="Fit">
<HintPath>D:\Grand Theft Auto V\Scripts\Fit.dll</HintPath>
</Reference>
<Reference Include="NativeUI">
<HintPath>D:\Grand Theft Auto V\Scripts\NativeUI.dll</HintPath>
<Reference Include="LemonUI.SHVDN3">
<HintPath>D:\Grand Theft Auto V\Scripts\LemonUI.SHVDN3.dll</HintPath>
</Reference>
<Reference Include="ScriptHookVDotNet3">
<HintPath>D:\Grand Theft Auto V\ScriptHookVDotNet3.dll</HintPath>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

0 comments on commit ce228a8

Please sign in to comment.