Merge pull request #2613 from jonpas/improveSlideshowParams

Improved Slideshow API
This commit is contained in:
Glowbal
2015-09-28 16:38:00 +02:00
3 changed files with 26 additions and 14 deletions

View File

@ -10,7 +10,7 @@
* 4: Slide Duration <NUMBER> (0 disables automatic transitions) * 4: Slide Duration <NUMBER> (0 disables automatic transitions)
* *
* Return Value: * Return Value:
* Parsed List <ARRAY> * None
* *
* Example: * Example:
* [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5] call ace_slideshow_fnc_createSlideshow * [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5] call ace_slideshow_fnc_createSlideshow
@ -20,21 +20,24 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_currentSlideshow", "_slidesAction", "_varString"]; private ["_currentSlideshow", "_slidesAction", "_varString"];
params ["_objects", "_controllers", "_images", "_names", "_duration"]; params [
["_objects", [], [[]] ],
["_controllers", [], [[]] ],
["_images", [], [[]] ],
["_names", [], [[]] ],
["_duration", 0, [0]]
];
// Verify data // Verify data
if (count _images != count _names || {count _images == 0} || {count _names == 0}) exitWith { if (_objects isEqualTo []) exitWith {
ACE_LOGERROR("Slideshow Images or Names fields can NOT be empty and must have equal number of items!"); 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 must 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 no controllers use objects as controllers
if (count _controllers == 0) then { if (_controllers isEqualTo []) then {
_controllers = _objects; _controllers = _objects;
}; };
@ -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 interaction menu module is not present, set default duration value
if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { 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); ACE_LOGINFO_1("Interaction Menu module not present, defaulting duration value to %1",_duration);
}; };

View File

@ -30,7 +30,13 @@ _images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList);
_names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList); _names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList);
_duration = _logic getVariable ["Duration", 0]; _duration = _logic getVariable ["Duration", 0];
// Objects synced to the module
{
_objects pushBack _x;
nil
} count (synchronizedObjects _logic);
// Prepare with actions // Prepare with actions
[_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow); [_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);

View File

@ -10,3 +10,6 @@
#endif #endif
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#define NOINTERACTMENU_DURATION 5