From 64d6a172c7c30ea25a167cb670fb4c470693c569 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 26 Sep 2015 22:53:49 +0200 Subject: [PATCH 1/5] Improved public function parameter handling, Fixed issue with synchronized objects --- .../functions/fnc_createSlideshow.sqf | 25 +++++++++++-------- addons/slideshow/functions/fnc_moduleInit.sqf | 6 +++++ addons/slideshow/script_component.hpp | 3 +++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index bed2a2ae7f..2061dcf82e 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -10,7 +10,7 @@ * 4: Slide Duration (0 disables automatic transitions) * * Return Value: - * Parsed List + * None * * Example: * [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5] call ace_slideshow_fnc_createSlideshow @@ -20,18 +20,21 @@ #include "script_component.hpp" private ["_currentSlideshow", "_slidesAction", "_varString"]; -params ["_objects", "_controllers", "_images", "_names", "_duration"]; +params [ + ["_objects", [], []], + ["_controllers", [], []], + ["_images", [], []], + ["_names", [], []], + ["_duration", 0, 0] +]; // Verify data -if (count _images != count _names || {count _images == 0} || {count _names == 0}) exitWith { - ACE_LOGERROR("Slideshow Images or Names fields can NOT be empty and must have equal number of items!"); +if (_objects isEqualTo []) exitWith { + ACE_LOGERROR{"Slideshow Objects field may NOT be empty!"}; +}; +if (count _images != count _names || {_images isEqualTo []} || {_names isEqualTo []}) exitWith { + ACE_LOGERROR("Slideshow Images or Names fields may NOT be empty and must have equal number of items!"); }; - -// Objects synced to the module -{ - _objects pushBack _x; - nil -} count (synchronizedObjects _logic); // If no controllers use objects as controllers if (count _controllers == 0) then { @@ -54,7 +57,7 @@ _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets change // If interaction menu module is not present, set default duration value if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { - _duration = 5; + _duration = NOINTERACTMENU_DURATION; ACE_LOGINFO_1("Interaction Menu module not present, defaulting duration value to %1",_duration); }; diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf index 7da64cd3cc..83a82257b6 100644 --- a/addons/slideshow/functions/fnc_moduleInit.sqf +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -30,6 +30,12 @@ _images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList); _names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList); _duration = _logic getVariable ["Duration", 0]; +// Objects synced to the module +{ + _objects pushBack _x; + nil +} count (synchronizedObjects _logic); + // Prepare with actions [_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow); diff --git a/addons/slideshow/script_component.hpp b/addons/slideshow/script_component.hpp index 12f60ee1ab..3acd23c0ee 100644 --- a/addons/slideshow/script_component.hpp +++ b/addons/slideshow/script_component.hpp @@ -10,3 +10,6 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + + +#define NOINTERACTMENU_DURATION 5 From 4a5d6cade1925bcabee6c275ff6e82cff87af9ff Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 26 Sep 2015 22:54:31 +0200 Subject: [PATCH 2/5] Bracket to Brace --- addons/slideshow/functions/fnc_createSlideshow.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index 2061dcf82e..a1040d936f 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -30,7 +30,7 @@ params [ // Verify data if (_objects isEqualTo []) exitWith { - ACE_LOGERROR{"Slideshow Objects field may NOT be empty!"}; + ACE_LOGERROR("Slideshow Objects field may NOT be empty!"); }; if (count _images != count _names || {_images isEqualTo []} || {_names isEqualTo []}) exitWith { ACE_LOGERROR("Slideshow Images or Names fields may NOT be empty and must have equal number of items!"); From b7872868374ed63fd40809ca4cdd9ca2f57e8666 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 26 Sep 2015 23:02:18 +0200 Subject: [PATCH 3/5] Fixed allowed data types --- addons/slideshow/functions/fnc_createSlideshow.sqf | 10 +++++----- addons/slideshow/functions/fnc_moduleInit.sqf | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index a1040d936f..18cdfe5211 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -21,11 +21,11 @@ private ["_currentSlideshow", "_slidesAction", "_varString"]; params [ - ["_objects", [], []], - ["_controllers", [], []], - ["_images", [], []], - ["_names", [], []], - ["_duration", 0, 0] + ["_objects", [], [[]] ], + ["_controllers", [], [[]] ], + ["_images", [], [[]] ], + ["_names", [], [[]] ], + ["_duration", 0, [0]] ]; // Verify data diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf index 83a82257b6..f09dab678d 100644 --- a/addons/slideshow/functions/fnc_moduleInit.sqf +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -39,4 +39,4 @@ _duration = _logic getVariable ["Duration", 0]; // Prepare with actions [_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow); -ACE_LOGINFO_2("Slideshow Module Initialized for: %1 with Duration: %2", _objects, _duration); +ACE_LOGINFO_1("Slideshow Module Initialized on %1 Objects", count _objects); From 498dddcc2656ad4a67bf9f1744b7a70c76dad773 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 26 Sep 2015 23:06:35 +0200 Subject: [PATCH 4/5] Used isEqualTo --- addons/slideshow/functions/fnc_createSlideshow.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index 18cdfe5211..b480e4ac01 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -37,7 +37,7 @@ if (count _images != count _names || {_images isEqualTo []} || {_names isEqualTo }; // If no controllers use objects as controllers -if (count _controllers == 0) then { +if (_controllers isEqualTo []) then { _controllers = _objects; }; @@ -65,7 +65,7 @@ if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { 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); + _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); nil } count _controllers; From e4d8f13c89ad4011be7b054252f49ebf694153bc Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 28 Sep 2015 16:02:18 +0200 Subject: [PATCH 5/5] Change may to must in slideshow error log --- addons/slideshow/functions/fnc_createSlideshow.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index b480e4ac01..792905db0f 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -30,10 +30,10 @@ params [ // Verify data if (_objects isEqualTo []) exitWith { - ACE_LOGERROR("Slideshow Objects field may NOT be empty!"); + ACE_LOGERROR("Slideshow Objects field must NOT be empty!"); }; if (count _images != count _names || {_images isEqualTo []} || {_names isEqualTo []}) exitWith { - ACE_LOGERROR("Slideshow Images or Names fields may NOT be empty and must have equal number of items!"); + ACE_LOGERROR("Slideshow Images or Names fields must NOT be empty and must have equal number of items!"); }; // If no controllers use objects as controllers