2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-05-08 07:28:48 +00:00
|
|
|
/*
|
|
|
|
* Author: Winter
|
|
|
|
* Sets the player's current view distance according to allowed values.
|
2015-05-14 18:16:02 +00:00
|
|
|
*
|
2015-05-08 07:28:48 +00:00
|
|
|
* Arguments:
|
2021-10-11 20:48:30 +00:00
|
|
|
* 0: View Distance setting <NUMBER>
|
2015-05-10 10:00:19 +00:00
|
|
|
* 1: Show Prompt <BOOL>
|
2015-05-08 07:28:48 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-08-12 18:16:01 +00:00
|
|
|
* [] call ace_viewdistance_fnc_changeViewDistance
|
2015-05-08 07:28:48 +00:00
|
|
|
*
|
2015-05-14 16:25:41 +00:00
|
|
|
* Public: No
|
2015-05-08 07:28:48 +00:00
|
|
|
*/
|
|
|
|
|
2021-10-11 20:48:30 +00:00
|
|
|
params ["_viewDistance", "_showPrompt"];
|
|
|
|
|
|
|
|
if (_viewDistance == 0) then { // Video Settings
|
|
|
|
_viewDistance = viewDistance;
|
|
|
|
};
|
2015-05-14 16:25:41 +00:00
|
|
|
|
2016-04-14 11:52:20 +00:00
|
|
|
private _objectViewDistanceCoeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); // changes the setting index into a coefficient.
|
|
|
|
private _viewDistanceLimit = GVAR(limitViewDistance); // Grab the limit
|
2015-05-08 12:49:52 +00:00
|
|
|
|
2021-10-11 20:48:30 +00:00
|
|
|
TRACE_3("Limit",_viewDistance,_viewDistanceLimit,_showPrompt);
|
|
|
|
setViewDistance (_viewDistance min _viewDistanceLimit);
|
2015-05-08 12:49:52 +00:00
|
|
|
|
2016-04-14 11:52:20 +00:00
|
|
|
if (_objectViewDistanceCoeff isEqualType 0) then {
|
|
|
|
if (_objectViewDistanceCoeff > 0) then {
|
|
|
|
setObjectViewDistance (_objectViewDistanceCoeff * viewDistance);
|
2015-08-12 20:09:59 +00:00
|
|
|
} else {
|
2019-08-14 15:42:01 +00:00
|
|
|
if (!isNil QGVAR(fovBasedPFHminimalViewDistance)) then {
|
|
|
|
// Restore correct view distance when changing from FoV Based to Off
|
|
|
|
// Restoring directly inside PFH's self-exit resulted in the need of selecting another option to take effect
|
|
|
|
setObjectViewDistance GVAR(fovBasedPFHminimalViewDistance);
|
|
|
|
};
|
2015-08-12 20:09:59 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (isNil QGVAR(fovBasedPFHminimalViewDistance)) then {
|
|
|
|
GVAR(fovBasedPFHminimalViewDistance) = getObjectViewDistance select 0; // Minimal view distance holder and PFH isRunning variable
|
|
|
|
[FUNC(setFovBasedOvdPFH), 0, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
};
|
2015-05-19 17:48:29 +00:00
|
|
|
};
|
|
|
|
|
2016-04-14 11:52:20 +00:00
|
|
|
if (_showPrompt) then {
|
2015-08-12 20:09:59 +00:00
|
|
|
if (GVAR(objectViewDistanceCoeff) > 0) then {
|
2016-04-14 11:52:20 +00:00
|
|
|
private _text = "";
|
2015-08-12 20:09:59 +00:00
|
|
|
// FoV Based or %
|
|
|
|
if (GVAR(objectViewDistanceCoeff) == 6) then {
|
|
|
|
_text = format ["<t align='center'>%1 %2<br/>Min. %3<br/>Max. %4</t>", localize LSTRING(objectinfotext), localize LSTRING(object_fovBased), GVAR(fovBasedPFHminimalViewDistance), viewDistance];
|
2015-05-14 18:16:02 +00:00
|
|
|
} else {
|
2016-04-14 11:52:20 +00:00
|
|
|
_text = [
|
|
|
|
format ["<t align='center'>%1 %2m", localize LSTRING(invalid), viewDistance],
|
|
|
|
format ["<t align='center'>%1 %2m", localize LSTRING(infotext), viewDistance]
|
2021-10-11 20:48:30 +00:00
|
|
|
] select (_viewDistance <= _viewDistanceLimit);
|
2016-04-14 11:52:20 +00:00
|
|
|
_text = _text + format ["<br/><t align='center'>%1 %2%3</t>", localize LSTRING(objectinfotext), _objectViewDistanceCoeff * 100, "%"];
|
2015-05-14 18:16:02 +00:00
|
|
|
};
|
2015-08-12 20:09:59 +00:00
|
|
|
[parseText _text, 2] call EFUNC(common,displayTextStructured);
|
2015-05-10 10:00:19 +00:00
|
|
|
};
|
2015-05-14 18:16:02 +00:00
|
|
|
};
|