Skip to content
This repository was archived by the owner on Mar 2, 2019. It is now read-only.

Commit 1e57ede

Browse files
authored
Added support for all resolutions #3
1 parent 3009a10 commit 1e57ede

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

NativeUI/Utils.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
function FormatXWYH(Value, Value2)
2+
local W, H = GetScreenResolution()
3+
local XW = Value/W - ((Value / W) - (Value / 1920))
4+
local YH = Value2/H - ((Value2 / H) - (Value2 / 1080))
5+
return XW, YH
6+
end
7+
18
function math.round(num, numDecimalPlaces)
29
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
310
end
@@ -34,7 +41,10 @@ end
3441

3542
function IsMouseInBounds(X, Y, Width, Height)
3643
local Resolution = GetScreenResolutionMaintainRatio()
37-
local MX, MY = math.round(GetControlNormal(0, 239) * Resolution.Width), math.round(GetControlNormal(0, 240) * Resolution.Height)
44+
local MX, MY = math.round(GetControlNormal(0, 239) * 1920), math.round(GetControlNormal(0, 240) * 1080)
45+
MX, MY = FormatXWYH(MX, MY)
46+
X, Y = FormatXWYH(X, Y)
47+
Width, Height = FormatXWYH(Width, Height)
3848
return (MX >= X and MX <= X + Width) and (MY > Y and MY < Y + Height)
3949
end
4050

@@ -44,7 +54,7 @@ function GetSafeZoneBounds()
4454
SafeSize = (SafeSize * 100) - 90
4555
SafeSize = 10 - SafeSize
4656

47-
local W, H = GetActiveScreenResolution()
57+
local W, H = 1920, 1080
4858

4959
return {X = math.round(SafeSize * ((W/H) * 5.4)), Y = math.round(SafeSize * 5.4)}
5060
end

0 commit comments

Comments
 (0)