diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 6fdf99113c..705e8e8b4b 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -144,6 +144,7 @@ PREP(numberToDigitsString); PREP(numberToString); PREP(onAnswerRequest); PREP(owned); +PREP(parseList); PREP(player); PREP(playerSide); PREP(positionToASL); diff --git a/addons/common/functions/fnc_assignObjectsInList.sqf b/addons/common/functions/fnc_assignObjectsInList.sqf index 0d10066d01..89c8a3352d 100644 --- a/addons/common/functions/fnc_assignObjectsInList.sqf +++ b/addons/common/functions/fnc_assignObjectsInList.sqf @@ -4,47 +4,36 @@ * Used by moduleAssign* within various parts of the ACE3 project. * * Arguments: - * 0: list - * 1: variableName - * 2: value + * 0: List + * 1: Variable Name + * 2: Value * 3: Global * * Return Value: - * None + * None + * + * Example: + * ["text", "variable", value, true] call ace_common_fnc_assignObjectsInList * * Public: No */ - +#define DEBUG_MODE_FULL #include "script_component.hpp" -private ["_splittedList", "_nilCheckPassedList"]; params ["_list", "_variable", "_setting", "_global"]; if (typeName _list == "STRING") then { - _splittedList = [_list, ","] call BIS_fnc_splitString; - _nilCheckPassedList = ""; - { - _x = [_x] call FUNC(stringRemoveWhiteSpace); - if !(isnil _x) then { - if (_nilCheckPassedList == "") then { - _nilCheckPassedList = _x; - } else { - _nilCheckPassedList = _nilCheckPassedList + ","+ _x; - }; - }; - }foreach _splittedList; - - _list = [] call compile format["[%1]",_nilCheckPassedList]; + _list = [_list, true, true] call FUNC(parseList); + TRACE_1("Parsed",_list) }; { - if (!isnil "_x") then { + if (!isNil "_x") then { if (typeName _x == typeName objNull) then { if (local _x) then { - _x setvariable [_variable, _setting, _global]; + _x setVariable [_variable, _setting, _global]; + TRACE_4("Set variable",_x,_variable,_setting,_global); }; }; }; -}foreach _list; - -true +} count _list; diff --git a/addons/common/functions/fnc_parseList.sqf b/addons/common/functions/fnc_parseList.sqf new file mode 100644 index 0000000000..20630e1109 --- /dev/null +++ b/addons/common/functions/fnc_parseList.sqf @@ -0,0 +1,61 @@ +/* + * Author: Jonpas + * Makes a list from a string using comma as a delimiter, optionally trim or remove whitespace and check each for object existence. + * + * Arguments: + * 0: List + * 1: Remove or Trim Whitespace (default: false (trim)) + * 2: Check Nil (default: false) + * + * Return Value: + * Parsed List + * + * Example: + * ["text", true, false] call ace_common_fnc_parseList + * + * Public: No + */ +#define DEBUG_MODE_FULL +#include "script_component.hpp" + +private ["_splittedList", "_whitespaceList", "_nilCheckedList"]; +params ["_list", ["_removeWhitespace", false], ["_checkNil", false]]; + + +// Split using comma delimiter +_splittedList = [_list, ","] call BIS_fnc_splitString; + + +// Remove or Trim Whitespace +_whitespaceList = []; +{ + if (_removeWhitespace) then { + _whitespaceList pushBack ([_x] call FUNC(stringRemoveWhiteSpace)); + } else { + _whitespaceList pushBack ([_x] call CBA_fnc_trim); + }; + nil +} count _splittedList; +_list = _whitespaceList; + + +// Check for object existence +_nilCheckedList = ""; +if (_checkNil) then { + { + if !(isNil _x) then { + if (_nilCheckedList == "") then { + _nilCheckedList = _x; + } else { + _nilCheckedList = _nilCheckedList + "," + _x; + }; + }; + } count _list; + + // Add Array characters and parse into array + _list = [] call compile format ["[%1]", _nilCheckedList]; +}; + +TRACE_4("Lists",_splittedList,_whitespaceList,_nilCheckedList,_list); + +_list diff --git a/addons/slideshow/XEH_preInit.sqf b/addons/slideshow/XEH_preInit.sqf index 0f9e270896..152c02ec77 100644 --- a/addons/slideshow/XEH_preInit.sqf +++ b/addons/slideshow/XEH_preInit.sqf @@ -5,7 +5,6 @@ ADDON = false; PREP(addSlideActions); PREP(autoTransition); PREP(createSlideshow); -PREP(makeList); PREP(moduleInit); GVAR(slideshows) = 0; diff --git a/addons/slideshow/functions/fnc_makeList.sqf b/addons/slideshow/functions/fnc_makeList.sqf deleted file mode 100644 index 6736fabbdb..0000000000 --- a/addons/slideshow/functions/fnc_makeList.sqf +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Author: Jonpas - * Makes a list from a string using comma as a delimiter, optionally remove whitespace and check each for object existence. - * - * Arguments: - * 0: Text - * 1: Trim Whitespace - * 2: Check Nil - * - * Return Value: - * Parsed List - * - * Example: - * ["text", true, false] call ace_slideshow_fnc_makeList - * - * Public: No - */ -#include "script_component.hpp" - -params ["_list", "_trimWhitespace", "_checkNil"]; - -private ["_splittedList", "_listTrimmedWhitespace", "_nilCheckPassedList"]; - -// Split using comma delimiter -_splittedList = [_list, ","] call BIS_fnc_splitString; - -// Remove whitespace -_listTrimmedWhitespace = []; -if (_trimWhitespace) then { - { - _listTrimmedWhitespace pushBack ([_x] call CBA_fnc_trim); - nil - } count _splittedList; - _list = _listTrimmedWhitespace; -}; - -// Check for object existence -_nilCheckPassedList = ""; -if (_checkNil) then { - { - if !(isNil _x) then { - if (_nilCheckPassedList == "") then { - _nilCheckPassedList = _x; - } else { - _nilCheckPassedList = _nilCheckPassedList + "," + _x; - }; - }; - } count _list; - - // Add Array characters and parse into array - _list = "[" + _nilCheckPassedList + "]"; - _list = [] call compile _list; -}; - -TRACE_4("Lists",_splittedList,_listTrimmedWhitespace,_nilCheckPassedList,_list); - -_list // return diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf index da1724dfcc..e4f7fbb56c 100644 --- a/addons/slideshow/functions/fnc_moduleInit.sqf +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -25,10 +25,10 @@ if !(_activated) exitWith {}; if (isNull _logic) exitWith {}; // Extract variables from logic -_objects = [_logic getVariable ["Objects", ""], true, true] call FUNC(makeList); -_controllers = [_logic getVariable ["Controllers", ""], true, true] call FUNC(makeList); -_images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList); -_names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList); +_objects = [_logic getVariable ["Objects", ""], true, true] call EFUNC(common,parseList); +_controllers = [_logic getVariable ["Controllers", ""], true, true] call EFUNC(common,parseList); +_images = [_logic getVariable ["Images", ""], false, false] call EFUNC(common,parseList); +_names = [_logic getVariable ["Names", ""], false, false] call EFUNC(common,parseList); _duration = _logic getVariable ["Duration", 0]; // Prepare with actions