Skip to content

Commit ce228a8

Browse files
committed
Use LemonUI
1 parent a0553dc commit ce228a8

File tree

3 files changed

+64
-51
lines changed

3 files changed

+64
-51
lines changed

ActivityGhosts/ActivityGhosts.cs

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@
1010
using GTA.Math;
1111
using GTA.Native;
1212
using GTA.UI;
13-
using NativeUI;
13+
using LemonUI;
14+
using LemonUI.Menus;
1415

1516
namespace ActivityGhosts
1617
{
1718
public class ActivityGhosts : Script
1819
{
19-
private List<Ghost> ghosts;
20+
private readonly List<Ghost> ghosts;
2021
private Blip start;
2122
private int lastTime;
2223
private Keys menuKey;
2324
public static PointF initialGPSPoint;
2425
public static int opacity;
2526
private bool showDate;
27+
private ObjectPool menuPool;
28+
private NativeMenu mainMenu;
29+
private NativeItem loadMenuItem;
30+
private NativeItem regroupMenuItem;
31+
private NativeItem deleteMenuItem;
2632

2733
public ActivityGhosts()
2834
{
@@ -132,45 +138,52 @@ private void LoadSettings()
132138

133139
private void CreateMenu()
134140
{
135-
var menuPool = new MenuPool();
136-
var mainMenu = new UIMenu("ActivityGhosts", "Ride with ghosts from previous activities");
141+
menuPool = new ObjectPool();
142+
mainMenu = new NativeMenu("ActivityGhosts");
137143
menuPool.Add(mainMenu);
138-
var loadMenuItem = new UIMenuItem("Load", "Load ghosts");
139-
loadMenuItem.Enabled = true;
140-
mainMenu.AddItem(loadMenuItem);
141-
var regroupMenuItem = new UIMenuItem("Regroup", "Regroup ghosts");
142-
regroupMenuItem.Enabled = false;
143-
mainMenu.AddItem(regroupMenuItem);
144-
var deleteMenuItem = new UIMenuItem("Delete", "Delete ghosts");
145-
deleteMenuItem.Enabled = false;
146-
mainMenu.AddItem(deleteMenuItem);
147-
mainMenu.OnItemSelect += (sender, item, index) =>
144+
loadMenuItem = new NativeItem("Load", "Load ghosts")
148145
{
149-
if (item == loadMenuItem && loadMenuItem.Enabled)
150-
{
151-
LoadGhosts();
152-
if (ghosts.Count > 0)
153-
{
154-
start = World.CreateBlip(Game.Player.Character.Position);
155-
start.Sprite = BlipSprite.RaceBike;
156-
loadMenuItem.Enabled = false;
157-
regroupMenuItem.Enabled = true;
158-
deleteMenuItem.Enabled = true;
159-
}
160-
}
161-
else if (item == regroupMenuItem && regroupMenuItem.Enabled)
162-
RegroupGhosts();
163-
else if (item == deleteMenuItem && deleteMenuItem.Enabled)
146+
Enabled = true
147+
};
148+
mainMenu.Add(loadMenuItem);
149+
loadMenuItem.Activated += (sender, itemArgs) =>
150+
{
151+
LoadGhosts();
152+
if (ghosts.Count > 0)
164153
{
165-
DeleteGhosts();
166-
loadMenuItem.Enabled = true;
167-
regroupMenuItem.Enabled = false;
168-
deleteMenuItem.Enabled = false;
154+
start = World.CreateBlip(Game.Player.Character.Position);
155+
start.Sprite = BlipSprite.RaceBike;
156+
loadMenuItem.Enabled = false;
157+
regroupMenuItem.Enabled = true;
158+
deleteMenuItem.Enabled = true;
169159
}
170160
mainMenu.Visible = false;
171161
};
172-
menuPool.RefreshIndex();
173-
Tick += (o, e) => menuPool.ProcessMenus();
162+
regroupMenuItem = new NativeItem("Regroup", "Regroup ghosts")
163+
{
164+
Enabled = false
165+
};
166+
mainMenu.Add(regroupMenuItem);
167+
regroupMenuItem.Activated += (sender, itemArgs) =>
168+
{
169+
RegroupGhosts();
170+
mainMenu.Visible = false;
171+
};
172+
deleteMenuItem = new NativeItem("Delete", "Delete ghosts")
173+
{
174+
Enabled = false
175+
};
176+
mainMenu.Add(deleteMenuItem);
177+
deleteMenuItem.Activated += (sender, itemArgs) =>
178+
{
179+
DeleteGhosts();
180+
loadMenuItem.Enabled = true;
181+
regroupMenuItem.Enabled = false;
182+
deleteMenuItem.Enabled = false;
183+
mainMenu.Visible = false;
184+
};
185+
menuPool.RefreshAll();
186+
Tick += (o, e) => menuPool.Process();
174187
KeyDown += (o, e) =>
175188
{
176189
if (e.KeyCode == menuKey)
@@ -181,24 +194,24 @@ private void CreateMenu()
181194

182195
public class Ghost
183196
{
184-
private List<GeoPoint> points;
185-
private Vehicle vehicle;
197+
private readonly List<GeoPoint> points;
198+
private readonly Vehicle vehicle;
186199
public Ped ped;
187200
public TextElement date;
188-
private Blip blip;
201+
private readonly Blip blip;
189202
private int index;
190203

191-
private VehicleDrivingFlags customDrivingStyle = VehicleDrivingFlags.AllowGoingWrongWay |
192-
VehicleDrivingFlags.AllowMedianCrossing |
193-
VehicleDrivingFlags.AvoidEmptyVehicles |
194-
VehicleDrivingFlags.AvoidObjects |
195-
VehicleDrivingFlags.AvoidPeds |
196-
VehicleDrivingFlags.AvoidVehicles |
197-
VehicleDrivingFlags.IgnorePathFinding;
204+
private readonly VehicleDrivingFlags customDrivingStyle = VehicleDrivingFlags.AllowGoingWrongWay |
205+
VehicleDrivingFlags.AllowMedianCrossing |
206+
VehicleDrivingFlags.AvoidEmptyVehicles |
207+
VehicleDrivingFlags.AvoidObjects |
208+
VehicleDrivingFlags.AvoidPeds |
209+
VehicleDrivingFlags.AvoidVehicles |
210+
VehicleDrivingFlags.IgnorePathFinding;
198211

199-
private string[] availableBicycles = { "BMX", "CRUISER", "FIXTER", "SCORCHER", "TRIBIKE", "TRIBIKE2", "TRIBIKE3" };
212+
private readonly string[] availableBicycles = { "BMX", "CRUISER", "FIXTER", "SCORCHER", "TRIBIKE", "TRIBIKE2", "TRIBIKE3" };
200213

201-
private string[] availableCyclists = { "a_m_y_cyclist_01", "a_m_y_roadcyc_01" };
214+
private readonly string[] availableCyclists = { "a_m_y_cyclist_01", "a_m_y_roadcyc_01" };
202215

203216
public Ghost(List<GeoPoint> pointList, string span)
204217
{

ActivityGhosts/ActivityGhosts.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
<Reference Include="Fit">
3535
<HintPath>D:\Grand Theft Auto V\Scripts\Fit.dll</HintPath>
3636
</Reference>
37-
<Reference Include="NativeUI">
38-
<HintPath>D:\Grand Theft Auto V\Scripts\NativeUI.dll</HintPath>
37+
<Reference Include="LemonUI.SHVDN3">
38+
<HintPath>D:\Grand Theft Auto V\Scripts\LemonUI.SHVDN3.dll</HintPath>
3939
</Reference>
4040
<Reference Include="ScriptHookVDotNet3">
4141
<HintPath>D:\Grand Theft Auto V\ScriptHookVDotNet3.dll</HintPath>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ https://github.com/oldnapalm/ActivityGhosts/releases/latest
1717

1818
## Requirements
1919
- [ScriptHookV](http://www.dev-c.com/gtav/scripthookv/)
20-
- [ScriptHookVDotNet](https://github.com/crosire/scripthookvdotnet/releases)
21-
- [NativeUI](https://github.com/Guad/NativeUI)
20+
- [ScriptHookVDotNet](https://github.com/crosire/scripthookvdotnet)
21+
- [LemonUI](https://github.com/justalemon/LemonUI)
2222
- [FIT](https://developer.garmin.com/fit/download/)

0 commit comments

Comments
 (0)