Skip to content

Commit

Permalink
Added property to get the safe zone size
Browse files Browse the repository at this point in the history
Closes #146
  • Loading branch information
justalemon committed Dec 16, 2023
1 parent 74ee5d2 commit 62b65cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
25 changes: 2 additions & 23 deletions LemonUI/ObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,7 @@ public class ObjectPool : IEnumerable<IProcessable>
/// <summary>
/// The last know Safezone size.
/// </summary>
#if FIVEM
private float lastKnownSafezone = API.GetSafeZoneSize();
#elif ALTV
private float lastKnownSafezone = Alt.Natives.GetSafeZoneSize();
#elif RAGEMP
private float lastKnownSafezone = Invoker.Invoke<float>(Natives.GetSafeZoneSize);
#elif RPH
private float lastKnownSafezone = NativeFunction.CallByHash<float>(0xBAF107B6BB2C97F0);
#elif SHVDN3 || SHVDNC
private float lastKnownSafezone = Function.Call<float>(Hash.GET_SAFE_ZONE_SIZE);
#endif
private float lastKnownSafezone = SafeZone.Size;
/// <summary>
/// The list of processable objects.
/// </summary>
Expand Down Expand Up @@ -112,18 +102,7 @@ private void DetectResolutionChanges()
private void DetectSafezoneChanges()
{
// Get the current Safezone size
#if FIVEM
float safezone = API.GetSafeZoneSize();
#elif ALTV
float safezone = Alt.Natives.GetSafeZoneSize();
#elif RAGEMP
float safezone = Invoker.Invoke<float>(Natives.GetSafeZoneSize);
#elif RPH
float safezone = NativeFunction.CallByHash<float>(0xBAF107B6BB2C97F0);
#elif SHVDN3 || SHVDNC
float safezone = Function.Call<float>(Hash.GET_SAFE_ZONE_SIZE);
#endif

float safezone = SafeZone.Size;
// If is not the same as the last one
if (lastKnownSafezone != safezone)
{
Expand Down
23 changes: 23 additions & 0 deletions LemonUI/Tools/SafeZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ public static class SafeZone
{
#region Properties

/// <summary>
/// The size of the safe zone.
/// </summary>
/// <remarks>
/// This property should not be used to manually calculate the safe zone. Use <see cref="GetPositionAt(System.Drawing.PointF,LemonUI.GFXAlignment,LemonUI.GFXAlignment)"/> to get the safe zone size.
/// </remarks>
public static float Size
{
get
{
#if ALTV
return Alt.Natives.GetSafeZoneSize();
#elif FIVEM
return API.GetSafeZoneSize();
#elif RAGEMP
return Invoker.Invoke<float>(Natives.GetSafeZoneSize);
#elif RPH
return NativeFunction.CallByHash<float>(0xBAF107B6BB2C97F0);
#elif SHVDN3 || SHVDNC
return Function.Call<float>(Hash.GET_SAFE_ZONE_SIZE);
#endif
}
}
/// <summary>
/// The top left corner after the safe zone.
/// </summary>
Expand Down

0 comments on commit 62b65cd

Please sign in to comment.