diff --git a/LemonUI/ObjectPool.cs b/LemonUI/ObjectPool.cs index 4405dd4..9935d25 100644 --- a/LemonUI/ObjectPool.cs +++ b/LemonUI/ObjectPool.cs @@ -15,6 +15,7 @@ using System.Collections; using System.Collections.Generic; using System.Drawing; +using LemonUI.Tools; namespace LemonUI { @@ -28,17 +29,7 @@ public class ObjectPool : IEnumerable /// /// The last known resolution by the object pool. /// -#if FIVEM - private SizeF lastKnownResolution = CitizenFX.Core.UI.Screen.Resolution; -#elif ALTV - private SizeF lastKnownResolution = Screen.Resolution; -#elif RAGEMP - private SizeF lastKnownResolution = new SizeF(Game.ScreenResolution.Width, Game.ScreenResolution.Height); -#elif RPH - private SizeF lastKnownResolution = Game.Resolution; -#elif SHVDN3 || SHVDNC - private SizeF lastKnownResolution = GTA.UI.Screen.Resolution; -#endif + private SizeF lastKnownResolution = GameScreen.AbsoluteResolution; /// /// The last know Safezone size. /// @@ -53,7 +44,6 @@ public class ObjectPool : IEnumerable #elif SHVDN3 || SHVDNC private float lastKnownSafezone = Function.Call(Hash.GET_SAFE_ZONE_SIZE); #endif - /// /// The list of processable objects. /// @@ -104,18 +94,7 @@ public bool AreAnyVisible private void DetectResolutionChanges() { // Get the current resolution -#if FIVEM - SizeF resolution = CitizenFX.Core.UI.Screen.Resolution; -#elif ALTV - SizeF resolution = Screen.Resolution; -#elif RAGEMP - ScreenResolutionType raw = Game.ScreenResolution; - SizeF resolution = new SizeF(raw.Width, raw.Height); -#elif RPH - SizeF resolution = Game.Resolution; -#elif SHVDN3 || SHVDNC - SizeF resolution = GTA.UI.Screen.Resolution; -#endif + SizeF resolution = GameScreen.AbsoluteResolution; // If the old res does not matches the current one if (lastKnownResolution != resolution) { diff --git a/LemonUI/Screen.cs b/LemonUI/Screen.cs index 639c260..b7c893d 100644 --- a/LemonUI/Screen.cs +++ b/LemonUI/Screen.cs @@ -34,20 +34,11 @@ public static class Screen /// The Aspect Ratio of the screen resolution. /// public static float AspectRatio => GameScreen.AspectRatio; - #if ALTV /// - /// Gets the actual Screen resolution the game is being rendered at + /// Gets the actual Screen resolution the game is being rendered at. /// - public static Size Resolution - { - get - { - int height = 0, width = 0; - Alt.Natives.GetActualScreenResolution(ref width, ref height); - return new Size(width, height); - } - } + public static Size Resolution => GameScreen.AbsoluteResolution.ToSize(); #endif /// /// The location of the cursor on screen between 0 and 1. diff --git a/LemonUI/Tools/GameScreen.cs b/LemonUI/Tools/GameScreen.cs index 5556d59..4315cf5 100644 --- a/LemonUI/Tools/GameScreen.cs +++ b/LemonUI/Tools/GameScreen.cs @@ -4,6 +4,7 @@ using CitizenFX.Core.UI; #elif RAGEMP using RAGE.Game; +using RAGE.NUI; #elif RPH using Rage; using Rage.Native; @@ -26,6 +27,29 @@ public static class GameScreen { #region Properties + /// + /// Gets the actual Screen resolution the game is being rendered at. + /// + public static SizeF AbsoluteResolution + { + get + { +#if ALTV + int height = 0, width = 0; + Alt.Natives.GetActualScreenResolution(ref width, ref height); + return new SizeF(width, height); +#elif FIVEM + return CitizenFX.Core.UI.Screen.Resolution; +#elif RAGEMP + ScreenResolutionType raw = Game.ScreenResolution; + return new SizeF(raw.Width, raw.Height); +#elif RPH + return Game.Resolution; +#elif SHVDN3 || SHVDNC + return GTA.UI.Screen.Resolution; +#endif + } + } /// /// The Aspect Ratio of the screen. ///