From 54a70f26b1e37d5d4ba553aab4153d7377dee6d7 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 18 Apr 2015 20:06:01 +0200 Subject: [PATCH] Moved to own function. --- addons/common/XEH_postInit.sqf | 1 + addons/common/XEH_preInit.sqf | 1 + .../functions/fnc_loadSettingsFromProfile.sqf | 29 +---------- .../fnc_loadSettingsLocalizedText.sqf | 48 +++++++++++++++++++ 4 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 addons/common/functions/fnc_loadSettingsLocalizedText.sqf diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index e470e91c95..a5fdb5bd76 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -4,6 +4,7 @@ // Load settings from profile if (hasInterface) then { call FUNC(loadSettingsFromProfile); + call FUNC(loadSettingsLocalizedText); }; // Listens for global "SettingChanged" events, to update the force status locally diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index b5382d0b5e..5cb3aedc44 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -119,6 +119,7 @@ PREP(loadPerson); PREP(loadPersonLocal); PREP(loadSettingsFromProfile); PREP(loadSettingsOnServer); +PREP(loadSettingsLocalizedText); PREP(map); PREP(moduleCheckPBOs); PREP(moduleLSDVehicles); diff --git a/addons/common/functions/fnc_loadSettingsFromProfile.sqf b/addons/common/functions/fnc_loadSettingsFromProfile.sqf index 1817e2f40e..7cb99e3400 100644 --- a/addons/common/functions/fnc_loadSettingsFromProfile.sqf +++ b/addons/common/functions/fnc_loadSettingsFromProfile.sqf @@ -13,28 +13,7 @@ */ #include "script_component.hpp" -private ["_parseConfigForDisplayNames", "_name", "_isClientSetable", "_isForced", "_profileValue"]; - -_parseConfigForDisplayNames = { - private "_optionEntry"; - _optionEntry = _this select 0; - if !(isClass _optionEntry) exitwith {false}; - _x set [3, getText (_optionEntry >> "displayName")]; - _x set [4, getText (_optionEntry >> "description")]; - - private "_values"; - _values = _x select 5; - { - private "_text"; - _text = _x; - if (((typeName _text) == "STRING") && {(count _text) > 1} && {(_text select [0,1]) == "$"}) then { - _text = localize (_text select [1, ((count _text) - 1)]); //chop off the leading $ - _values set [_forEachIndex, _text]; - }; - } forEach _values; - true; -}; - +private ["_name", "_isClientSetable", "_isForced", "_profileValue"]; // Iterate through settings { @@ -58,10 +37,4 @@ _parseConfigForDisplayNames = { }; }; - if !([configFile >> "ACE_Settings" >> _name] call _parseConfigForDisplayNames) then { - if !([configFile >> "ACE_ServerSettings" >> _name] call _parseConfigForDisplayNames) then { - [missionConfigFile >> "ACE_Settings" >> _name] call _parseConfigForDisplayNames; - }; - }; - } forEach GVAR(settings); diff --git a/addons/common/functions/fnc_loadSettingsLocalizedText.sqf b/addons/common/functions/fnc_loadSettingsLocalizedText.sqf new file mode 100644 index 0000000000..280a1e9907 --- /dev/null +++ b/addons/common/functions/fnc_loadSettingsLocalizedText.sqf @@ -0,0 +1,48 @@ +/* + * Author: Glowbal + * Parse all settings and load the localized displayName and description for all text + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +private ["_parseConfigForDisplayNames", "_name"]; + +_parseConfigForDisplayNames = { + private "_optionEntry"; + _optionEntry = _this select 0; + if !(isClass _optionEntry) exitwith {false}; + _x set [3, getText (_optionEntry >> "displayName")]; + _x set [4, getText (_optionEntry >> "description")]; + + private "_values"; + _values = _x select 5; + { + private "_text"; + _text = _x; + if (((typeName _text) == "STRING") && {(count _text) > 1} && {(_text select [0,1]) == "$"}) then { + _text = localize (_text select [1, ((count _text) - 1)]); //chop off the leading $ + _values set [_forEachIndex, _text]; + }; + } forEach _values; + true; +}; + + +// Iterate through settings +{ + _name = _x select 0; + + if !([configFile >> "ACE_Settings" >> _name] call _parseConfigForDisplayNames) then { + if !([configFile >> "ACE_ServerSettings" >> _name] call _parseConfigForDisplayNames) then { + [missionConfigFile >> "ACE_Settings" >> _name] call _parseConfigForDisplayNames; + }; + }; + +} forEach GVAR(settings);