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:
|
2016-01-29 00:19:02 +00:00
|
|
|
* 0: View Distance setting INDEX <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
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-12 20:09:59 +00:00
|
|
|
private ["_text", "_new_view_distance", "_view_distance_limit", "_object_view_distance_coeff"];
|
2015-05-14 16:25:41 +00:00
|
|
|
|
2015-08-04 02:24:30 +00:00
|
|
|
params ["_index_requested", "_show_prompt"];
|
2015-05-08 12:49:52 +00:00
|
|
|
|
2015-05-14 16:25:41 +00:00
|
|
|
_new_view_distance = [_index_requested] call FUNC(returnValue); // changes the setting index into an actual view distance value
|
|
|
|
_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); // changes the setting index into a coefficient.
|
2015-05-09 16:42:02 +00:00
|
|
|
_view_distance_limit = GVAR(limitViewDistance); // Grab the limit
|
2015-05-08 12:49:52 +00:00
|
|
|
|
2015-08-17 16:12:00 +00:00
|
|
|
TRACE_2("Limit",_new_view_distance,_view_distance_limit);
|
2015-05-19 17:48:29 +00:00
|
|
|
setViewDistance (_new_view_distance min _view_distance_limit);
|
|
|
|
|
2015-08-12 20:09:59 +00:00
|
|
|
if (typeName _object_view_distance_coeff == "SCALAR") then {
|
|
|
|
if (_object_view_distance_coeff > 0) then {
|
|
|
|
setObjectViewDistance (_object_view_distance_coeff * viewDistance);
|
|
|
|
} else {
|
|
|
|
// 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);
|
|
|
|
};
|
|
|
|
} 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
|
|
|
};
|
|
|
|
|
2015-05-14 18:16:02 +00:00
|
|
|
if (_show_prompt) then {
|
2015-08-12 20:09:59 +00:00
|
|
|
if (GVAR(objectViewDistanceCoeff) > 0) then {
|
|
|
|
// 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 {
|
2015-08-12 20:09:59 +00:00
|
|
|
_text = if (_new_view_distance <= _view_distance_limit) then {
|
|
|
|
format ["<t align='center'>%1 %2m", localize LSTRING(infotext), viewDistance];
|
|
|
|
} else {
|
|
|
|
format ["<t align='center'>%1 %2m", localize LSTRING(invalid), viewDistance];
|
|
|
|
};
|
|
|
|
_text = _text + format ["<br/><t align='center'>%1 %2%3</t>", localize LSTRING(objectinfotext), _object_view_distance_coeff * 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
|
|
|
};
|