@@ -256,3 +256,46 @@ function ConvertResolutionCoordsToScreenCoords(x, y)
256
256
local normalizedY = math.max (0.0 , math.min (1.0 , y / h ))
257
257
return vector2 (normalizedX , normalizedY )
258
258
end
259
+
260
+ --- Converts player's current screen resolution size into scaleform size (1280 x 720)
261
+ --- @param realWidth number
262
+ --- @param realHeight number
263
+ --- @return vector2
264
+ function ConvertResolutionSizeToScaleformSize (realWidth , realHeight )
265
+ local x , y = GetActiveScreenResolution ()
266
+ return vector2 (realWidth / x * 1280 , realHeight / y * 720 )
267
+ end
268
+
269
+ --- Converts scaleform size (1280 x 720) into player's current screen resolution size
270
+ --- @param scaleformWidth number
271
+ --- @param scaleformHeight number
272
+ --- @return vector2
273
+ function ConvertScaleformSizeToResolutionSize (scaleformWidth , scaleformHeight )
274
+ local x , y = GetActiveScreenResolution ()
275
+ return vector2 (scaleformWidth / 1280 * x , scaleformHeight / 720 * y )
276
+ end
277
+
278
+ --- Converts screen size (0.0 - 1.0) into scaleform size (1280 x 720)
279
+ --- @param scWidth number
280
+ --- @param scHeight number
281
+ --- @return vector2
282
+ function ConvertScreenSizeToScaleformSize (scWidth , scHeight )
283
+ return vector2 (scWidth * 1280 , scHeight * 720 )
284
+ end
285
+
286
+ --- Converts scaleform size (1280 x 720) into screen size (0.0 - 1.0)
287
+ --- @param scaleformWidth number
288
+ --- @param scaleformHeight number
289
+ --- @return vector2
290
+ function ConvertScaleformSizeToScreenSize (scaleformWidth , scaleformHeight )
291
+ -- Normalize size to 0.0 - 1.0 range
292
+ local w , h = GetActualScreenResolution ()
293
+ return vector2 ((scaleformWidth / w ) * 2.0 - 1.0 , (scaleformHeight / h ) * 2.0 - 1.0 )
294
+ end
295
+
296
+ function ConvertResolutionSizeToScreenSize (width , height )
297
+ local w , h = GetActualScreenResolution ()
298
+ local normalizedWidth = math.max (0.0 , math.min (1.0 , width / w ))
299
+ local normalizedHeight = math.max (0.0 , math.min (1.0 , height / h ))
300
+ return vector2 (normalizedWidth , normalizedHeight )
301
+ end
0 commit comments