From 3480168e05e900af0cdb1e346b0f780cccb32ed5 Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 17:44:35 +0200 Subject: [PATCH 1/2] Integrated new function into module --- addons/viewdistance/XEH_postInit.sqf | 7 +++++ addons/viewdistance/XEH_preInit.sqf | 1 + .../functions/fnc_changeViewDistance.sqf | 27 ++++++++++++------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index d3924666c2..6c4f41d374 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -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; \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index a55e0a3075..a68416cada 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -4,6 +4,7 @@ ADDON = false; PREP(initModule); PREP(returnValue); +PREP(returnObjectCoeff); PREP(changeViewDistance); PREP(adaptViewDistance); diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index bf5f610c0d..9aab955db8 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -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); + }; }; }; \ No newline at end of file From 8c7d752fcc6f41067208a26fa0ec0eb366e159c6 Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 18:25:41 +0200 Subject: [PATCH 2/2] Made final adjustments Centred prompts, fixed erroneous if statement, adjusted function headers. --- .../functions/fnc_adaptViewDistance.sqf | 2 +- .../functions/fnc_changeViewDistance.sqf | 25 +++++++++---------- .../functions/fnc_returnObjectCoeff.sqf | 14 +++++------ .../functions/fnc_returnValue.sqf | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf index c81b522747..5012b40c93 100644 --- a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf @@ -12,7 +12,7 @@ * Example: * [] call ace_viewdistance_fnc_adaptViewDistance; * - * Public: Yes + * Public: No */ #include "script_component.hpp" diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 9aab955db8..61b568bc2a 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -13,23 +13,23 @@ * Example: * [] call ace_viewdistance_fnc_changeViewDistance; * - * Public: Yes + * Public: No */ #include "script_component.hpp" 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); +_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. _view_distance_limit = GVAR(limitViewDistance); // Grab the limit if (_new_view_distance <= _view_distance_limit) then { 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); + _text = parseText format ["View Distance: %1
Object View Distance Coefficient: %2
",str(_new_view_distance),str(_object_view_distance_coeff)]; + [_text,2] call EFUNC(common,displayTextStructured); }; setViewDistance _new_view_distance; if (_object_view_distance_coeff > 0) then { @@ -38,12 +38,11 @@ if (_new_view_distance <= _view_distance_limit) then { } else { 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; - if (_object_view_distance_coeff > 0) then { - setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit); - }; + _text = parseText format ["That option is invalid! The limit is: %1
Object View Distance Coefficient: %2
",str(_view_distance_limit),str(_object_view_distance_coeff)]; + [_text,2] call EFUNC(common,displayTextStructured); + }; + setViewDistance _view_distance_limit; + if (_object_view_distance_coeff > 0) then { + setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit); }; }; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf index 476478a448..145b8ae9e6 100644 --- a/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf +++ b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf @@ -22,13 +22,13 @@ PARAMS_1(_index); private ["_return"]; _return = switch (_index) do { - case 0: {0.00}; // Off - case 1: {0.20}; // Very Low - case 2: {0.40}; // Low - case 3: {0.60}; // Medium - case 4: {0.80}; // High - case 5: {1.00}; // Very High - default {0.50}; // something broke if this returns + case 0: {0.00}; // Off + case 1: {0.20}; // Very Low + case 2: {0.40}; // Low + case 3: {0.60}; // Medium + case 4: {0.80}; // High + case 5: {1.00}; // Very High + default {0.50}; // something broke if this returns }; _return; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnValue.sqf b/addons/viewdistance/functions/fnc_returnValue.sqf index 80e82feee2..9d4725c72e 100644 --- a/addons/viewdistance/functions/fnc_returnValue.sqf +++ b/addons/viewdistance/functions/fnc_returnValue.sqf @@ -12,7 +12,7 @@ * Example: * [2] call ace_viewdistance_fnc_returnViewDistanceValue; * - * Public: Yes + * Public: No */ #include "script_component.hpp"