Integrated new function into module

This commit is contained in:
SAM 2015-05-14 17:44:35 +02:00
parent 853333ac49
commit 3480168e05
3 changed files with 25 additions and 10 deletions

View File

@ -16,5 +16,12 @@ if (viewDistance > GVAR(limitViewDistance)) then {
};
},true] call ace_common_fnc_addEventHandler;
// Set the EH which waits for the Object View Distance coefficient to be changed, so that the effect is show immediately
["SettingChanged",{
if (_this select 0 == QGVAR(objectViewDistanceCoeff)) then {
[true] call FUNC(adaptViewDistance);
};
},true] call ace_common_fnc_addEventHandler;
// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle
["playerVehicleChanged",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler;

View File

@ -4,6 +4,7 @@ ADDON = false;
PREP(initModule);
PREP(returnValue);
PREP(returnObjectCoeff);
PREP(changeViewDistance);
PREP(adaptViewDistance);

View File

@ -18,25 +18,32 @@
#include "script_component.hpp"
private ["_text","_new_view_distance","_view_distance_limit"];
PARAMS_2(_index_requested,_prompt);
private ["_text","_new_view_distance","_view_distance_limit","_object_view_distance_coeff"];
PARAMS_2(_index_requested,_show_prompt);
_new_view_distance = [_index_requested] call FUNC(returnValue); // change the index into an actual view distance value
_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff);
_view_distance_limit = GVAR(limitViewDistance); // Grab the limit
if (_new_view_distance <= _view_distance_limit) then {
if (_prompt) then {
_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
[_text,1] call EFUNC(common,displayTextStructured);
if (_show_prompt) then {
//_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
_text = format ["View distance successfully changed to: %1, Object View Distance Coefficient is: %2",str(_new_view_distance),str(_object_view_distance_coeff)];
[_text,3] call EFUNC(common,displayTextStructured);
};
setViewDistance _new_view_distance;
setObjectViewDistance (0.8 * _new_view_distance); // maybe make this 0.8 a constant?
if (_object_view_distance_coeff > 0) then {
setObjectViewDistance (_object_view_distance_coeff * _new_view_distance);
};
}
else {
if (_prompt) then {
_text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)];
[_text,1] call EFUNC(common,displayTextStructured);
if (_show_prompt) then {
//_text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)];
_text = format ["That option is invalid! The limit is: %1, Object View Distance Coefficient is: %2",str(_view_distance_limit),str(_object_view_distance_coeff)];
[_text,3] call EFUNC(common,displayTextStructured);
setViewDistance _view_distance_limit;
setObjectViewDistance (0.8 * _view_distance_limit); // maybe make this 0.8 a constant?
if (_object_view_distance_coeff > 0) then {
setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit);
};
};
};