From fa56196fe33b252e9a19d121b1ff52855f641f43 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Fri, 7 Aug 2015 12:11:34 +0200 Subject: [PATCH 1/4] Code cleanup of slideshow module --- .../slideshow/functions/fnc_addSlideActions.sqf | 12 ++++++------ .../slideshow/functions/fnc_autoTransition.sqf | 13 +++++-------- .../slideshow/functions/fnc_createSlideshow.sqf | 16 ++++++++-------- addons/slideshow/functions/fnc_makeList.sqf | 9 +++++---- addons/slideshow/functions/fnc_moduleInit.sqf | 9 +++------ 5 files changed, 27 insertions(+), 32 deletions(-) diff --git a/addons/slideshow/functions/fnc_addSlideActions.sqf b/addons/slideshow/functions/fnc_addSlideActions.sqf index 80e9b387af..1ebba306b4 100644 --- a/addons/slideshow/functions/fnc_addSlideActions.sqf +++ b/addons/slideshow/functions/fnc_addSlideActions.sqf @@ -10,19 +10,19 @@ * 4: Current Slideshow * * Return Value: - * None + * List of actions * * Example: * [[object], ["image"], ["name"], controller, 1] call ace_slideshow_fnc_addSlideActions * * Public: No */ -//#define DEBUG_MODE_FULL #include "script_component.hpp" -PARAMS_5(_objects,_images,_names,_controller,_currentSlideshow); +private "_actions"; + +params ["_objects", "_images", "_names", "_controller", "_currentSlideshow"]; -private ["_actions"]; _actions = []; { _actions pushBack @@ -32,10 +32,10 @@ _actions = []; _names select _forEachIndex, "", { - EXPLODE_2_PVT(_this select 2,_objects,_image); + (_this select 2) params ["_objects", "_image"]; { _x setObjectTextureGlobal [0, _image] - } forEach _objects; + } count _objects; }, {true}, {}, diff --git a/addons/slideshow/functions/fnc_autoTransition.sqf b/addons/slideshow/functions/fnc_autoTransition.sqf index 639a0fb70b..539ecb4986 100644 --- a/addons/slideshow/functions/fnc_autoTransition.sqf +++ b/addons/slideshow/functions/fnc_autoTransition.sqf @@ -4,25 +4,23 @@ * * Arguments: * 0: Objects - * 1: Controller Objects * 2: Image Paths - * 3: Action Names + * 3: State Variable Name * 4: Duration (0 disables automatic transitions) * * Return Value: - * Parsed List + * None * * Example: - * [objects, controllers, images, actionNames, duration] call ace_slideshow_fnc_autoTransition + * [objects, images, "ace_slideshow_slideshow1", duration] call ace_slideshow_fnc_autoTransition * * Public: No */ -//#define DEBUG_MODE_FULL #include "script_component.hpp" -PARAMS_4(_objects,_images,_varString,_duration); +private "_currentSlide"; -private ["_currentSlide"]; +params ["_objects", "_images", "_varString", "_duration"]; // Get current slide number of this slideshow _currentSlide = missionNamespace getVariable [_varString, 0]; @@ -40,6 +38,5 @@ missionNamespace setVariable [_varString, _currentSlide]; TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration); - // Next slide [FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute); diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index debeac3340..6781716adb 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -17,10 +17,11 @@ * * Public: Yes */ -//#define DEBUG_MODE_FULL #include "script_component.hpp" -PARAMS_5(_objects,_controllers,_images,_names,_duration); +private ["_currentSlideshow", "_actionsObject", "_actionsClass", "_mainAction", "_slidesAction", "_varString"]; + +params ["_objects", "_controllers", "_images", "_names", "_duration"]; // Verify data if (count _images != count _names || {count _images == 0} || {count _names == 0}) exitWith { @@ -30,7 +31,8 @@ if (count _images != count _names || {count _images == 0} || {count _names == 0} // Objects synced to the module { _objects pushBack _x; -} forEach (synchronizedObjects _logic); + nil +} count (synchronizedObjects _logic); // If no controllers use objects as controllers if (count _controllers == 0) then { @@ -42,16 +44,14 @@ TRACE_4("Information",_objects,_controllers,_images,_names); // Default images on whiteboards (first image) { _x setObjectTextureGlobal [0, _images select 0]; -} forEach _objects; +} count _objects; // Number of slideshows (multiple modules support) GVAR(slideshows) = GVAR(slideshows) + 1; -private ["_currentSlideshow"]; _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets changed during execution of below code // Add interactions if automatic transitions are disabled, else setup automatic transitions if (_duration == 0) then { - private ["_actionsObject", "_actionsClass", "_mainAction", "_slidesAction"]; { // Add MainAction if one does not already exist _actionsObject = _x getVariable [QEGVAR(interact_menu,actions), []]; @@ -65,10 +65,10 @@ if (_duration == 0) then { // Add Slides sub-action and populate with images _slidesAction = [QGVAR(Slides), localize LSTRING(Interaction), "", {}, {true}, {(_this select 2) call FUNC(addSlideActions)}, [_objects,_images,_names,_x,_currentSlideshow], [0,0,0], 2] call EFUNC(interact_menu,createAction); [_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject); - } forEach _controllers; + nil + } count _controllers; } else { // Formatted GVAR string (multiple modules support) - private ["_varString"]; _varString = format [QGVAR(slideshow%1), _currentSlideshow]; TRACE_1("Current Slide",_varString); diff --git a/addons/slideshow/functions/fnc_makeList.sqf b/addons/slideshow/functions/fnc_makeList.sqf index 9ce4a723cc..8de87a2d96 100644 --- a/addons/slideshow/functions/fnc_makeList.sqf +++ b/addons/slideshow/functions/fnc_makeList.sqf @@ -18,7 +18,7 @@ //#define DEBUG_MODE_FULL #include "script_component.hpp" -PARAMS_3(_list,_removeWhitespace,_checkNil); +params ["_list", "_removeWhitespace", "_checkNil"]; private ["_splittedList", "_listNoWhitespace", "_nilCheckPassedList"]; @@ -30,7 +30,8 @@ _listNoWhitespace = []; if (_removeWhitespace) then { { _listNoWhitespace pushBack ([_x] call EFUNC(common,stringRemoveWhiteSpace)); - } forEach _splittedList; + nil + } count _splittedList; _list = _listNoWhitespace; }; @@ -45,7 +46,7 @@ if (_checkNil) then { _nilCheckPassedList = _nilCheckPassedList + "," + _x; }; }; - } forEach _list; + } count _list; // Add Array characters and parse into array _list = "[" + _nilCheckPassedList + "]"; @@ -54,4 +55,4 @@ if (_checkNil) then { TRACE_4("Lists",_splittedList,_listNoWhitespace,_nilCheckPassedList,_list); -_list +_list // return diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf index 50de48693e..419cb415e3 100644 --- a/addons/slideshow/functions/fnc_moduleInit.sqf +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -12,18 +12,15 @@ * * Public: No */ -//#define DEBUG_MODE_FULL #include "script_component.hpp" if !(isServer) exitWith {}; -PARAMS_3(_logic,_units,_activated); - -if !(_activated) exitWith {}; - private ["_objects", "_controllers", "_images", "_names", "_duration"]; -_logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param; +params [["_logic", objNull, [objNull]], "_units", "_activated"]; + +if !(_activated) exitWith {}; if (isNull _logic) exitWith {}; // Extract variables from logic From b2e7cf04c0a913a7caee8de6930b3dd503743467 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Fri, 7 Aug 2015 15:19:59 +0200 Subject: [PATCH 2/4] Fixed function argument documentation in slideshow --- addons/slideshow/functions/fnc_autoTransition.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/slideshow/functions/fnc_autoTransition.sqf b/addons/slideshow/functions/fnc_autoTransition.sqf index 539ecb4986..c754a2f6ff 100644 --- a/addons/slideshow/functions/fnc_autoTransition.sqf +++ b/addons/slideshow/functions/fnc_autoTransition.sqf @@ -4,9 +4,9 @@ * * Arguments: * 0: Objects - * 2: Image Paths - * 3: State Variable Name - * 4: Duration (0 disables automatic transitions) + * 1: Image Paths + * 2: State Variable Name + * 3: Duration (0 disables automatic transitions) * * Return Value: * None From 1cec4400b3957ca071c45b76bcbad149e4c7beaf Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Fri, 7 Aug 2015 15:44:41 +0200 Subject: [PATCH 3/4] Missing count replacement in slideshow module --- addons/slideshow/functions/fnc_autoTransition.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/slideshow/functions/fnc_autoTransition.sqf b/addons/slideshow/functions/fnc_autoTransition.sqf index c754a2f6ff..d482c8ce58 100644 --- a/addons/slideshow/functions/fnc_autoTransition.sqf +++ b/addons/slideshow/functions/fnc_autoTransition.sqf @@ -34,7 +34,7 @@ missionNamespace setVariable [_varString, _currentSlide]; // Set slide { _x setObjectTextureGlobal [0, _images select _currentSlide]; -} forEach _objects; +} count _objects; TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration); From 8355558db1fbebc5fcec496174e4ea4264738864 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Sat, 8 Aug 2015 01:18:48 +0200 Subject: [PATCH 4/4] Small readability improvement in slideshow --- addons/slideshow/functions/fnc_autoTransition.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/slideshow/functions/fnc_autoTransition.sqf b/addons/slideshow/functions/fnc_autoTransition.sqf index d482c8ce58..c8b03a707a 100644 --- a/addons/slideshow/functions/fnc_autoTransition.sqf +++ b/addons/slideshow/functions/fnc_autoTransition.sqf @@ -36,7 +36,6 @@ missionNamespace setVariable [_varString, _currentSlide]; _x setObjectTextureGlobal [0, _images select _currentSlide]; } count _objects; +// Log current slide and execute Next slide TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration); - -// Next slide [FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);