Merge pull request #2613 from jonpas/improveSlideshowParams

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

View File

@ -10,7 +10,7 @@
* 4: Slide Duration <NUMBER> (0 disables automatic transitions)
*
* Return Value:
* Parsed List <ARRAY>
* None
*
* Example:
* [[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"
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 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 (count _controllers == 0) then {
if (_controllers isEqualTo []) then {
_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 !(["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);
};
@ -62,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;

View File

@ -30,7 +30,13 @@ _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);
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
#include "\z\ace\addons\main\script_macros.hpp"
#define NOINTERACTMENU_DURATION 5