-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move ui functions to ui component, simplify (#944)
* move ui functions to ui component, simplify * fix getAspectRatio * optimize getFOV * travis etc. canot handle # * remove whitespace
- Loading branch information
Showing
8 changed files
with
131 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getAspectRatio | ||
Description: | ||
Used to determine the Aspect ratio of the screen. | ||
Parameters: | ||
_output - string with one of ["ARRAY","NUMBER","STRING"] | ||
Returns: | ||
array, string or number of screenratio i.e. [16,9] or "16:9" or 1.333 .. | ||
Examples: | ||
(begin example) | ||
_ratio = "STRING" call CBA_fnc_getAspectRatio; | ||
_ratio = "ARRAY" call CBA_fnc_getAspectRatio; | ||
_ratio = "NUMBER" call CBA_fnc_getAspectRatio; | ||
(end) | ||
Author: | ||
commy2 | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(getAspectRatio); | ||
|
||
#define ASPECT_RATIOS ["1.33", "1.25", "1.78", "1.60", "4.00"] | ||
#define ASPECT_RATIOS_NAMES ["4:3", "5:4", "16:9", "16:10", "12:3"] | ||
#define ASPECT_RATIOS_ARRAYS [[4,3], [5,4], [16,9], [16,10], [12,3]] | ||
|
||
params [["_returnType", "STRING", [""]]]; | ||
|
||
private _aspectRatio = getResolution select 4; | ||
|
||
if (_returnType == "NUMBER") exitWith { | ||
_aspectRatio / (4/3) // return | ||
}; | ||
|
||
_aspectRatio = ASPECT_RATIOS find (_aspectRatio toFixed 2); | ||
|
||
if (_returnType == "STRING") exitWith { | ||
ASPECT_RATIOS_NAMES param [_aspectRatio, "error"] // return | ||
}; | ||
|
||
if (_returnType == "ARRAY") exitWith { | ||
ASPECT_RATIOS_ARRAYS param [_aspectRatio, [-1, -1]] // return | ||
}; | ||
|
||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getFov | ||
Description: | ||
Get current camera's vertical field of view in radians and zoom. | ||
Zoom is relative to specified config FOV, defaults to 0.75 (vehicle driver initFov). | ||
Parameters: | ||
(optional) base config fov value corresponding to 1x zoom, defaults to 0.75. | ||
Examples: | ||
(begin example) | ||
private _fieldOfView = [] call CBA_fnc_getFov select 0; | ||
private _zoom = 0.75 call CBA_fnc_getFov select 1; | ||
(end) | ||
Returns: | ||
Array [fov,zoom] | ||
Authors: | ||
q1184 (original code and calculation method) | ||
ceeeb (improved code and new zoom calculation method) | ||
streamlined by commy2 | ||
---------------------------------------------------------------------------- */ | ||
|
||
params [["_baseFOV", 0.75, [0]]]; | ||
|
||
private _trigRatio = safeZoneW / 2 / ((worldToScreen positionCameraToWorld [10000, 0, 10000] select 0) - 0.5); | ||
|
||
[ | ||
rad (2 * atan _trigRatio / (getResolution select 4)), | ||
_baseFOV * (safeZoneW / safeZoneH) / _trigRatio | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getUISize | ||
Description: | ||
Used to determine the UI size of the screen. | ||
Parameters: | ||
_output - the desired output format, either "NUMBER" or "STRING". | ||
Returns: | ||
If the desired output format is | ||
"NUMBER": an index into ["verysmall","small","normal","large","verylarge"] | ||
"STRING": one of "verysmall", "small", "normal", "large" or "verylarge" | ||
If an error occurs, the function returns either the number -1 or | ||
the string "error", depending on the desired output format. | ||
Examples: | ||
(begin example) | ||
_uiSize = "STRING" call CBA_fnc_getUISize; | ||
(end) | ||
Author: | ||
commy2 | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(getUISize); | ||
|
||
#define UI_SCALES [0.47, 0.55, 0.7, 0.85, 1] | ||
#define UI_SCALES_NAMES ["verysmall", "small", "normal", "large", "verylarge"] | ||
|
||
params [["_returnType", "STRING", [""]]]; | ||
|
||
private _uiScale = getResolution select 5; | ||
|
||
if (_returnType == "STRING") exitWith { | ||
UI_SCALES_NAMES param [UI_SCALES find _uiScale, "error"] // return | ||
}; | ||
|
||
if (_returnType == "NUMBER") exitWith { | ||
UI_SCALES find _uiScale // return | ||
}; | ||
|
||
nil |