Fix multiple slideshows sub-actions, Add set name setting (#4904)

* Fix all slides being in multiple slideshows setup, Use private keyword

* Add setting for slides main interaction name

* Update Slideshow documentation

* Add not about new argument added in version
This commit is contained in:
jonpas
2017-02-24 14:08:18 +01:00
committed by GitHub
parent f1e8daad66
commit 1590948b92
6 changed files with 59 additions and 25 deletions

View File

@ -8,24 +8,25 @@
* 2: Image Paths <ARRAY>
* 3: Action Names <ARRAY>
* 4: Slide Duration <NUMBER> (0 disables automatic transitions)
* 5: Set Name <STRING> (default: localized "Slides")
*
* Return Value:
* None
*
* 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, "My Slides"] call ace_slideshow_fnc_createSlideshow
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_currentSlideshow", "_slidesAction", "_varString"];
params [
["_objects", [], [[]] ],
["_controllers", [], [[]] ],
["_images", [], [[]] ],
["_names", [], [[]] ],
["_duration", 0, [0]]
["_duration", 0, [0]],
["_setName", localize LSTRING(Interaction), [""]]
];
// Verify data
@ -41,7 +42,7 @@ if (_controllers isEqualTo []) then {
_controllers = _objects;
};
TRACE_4("Information",_objects,_controllers,_images,_names);
TRACE_5("Information",_objects,_controllers,_images,_names,_setName);
if (isServer) then {
// Default images on whiteboards (first image)
@ -53,7 +54,7 @@ if (isServer) then {
GVAR(slideshows) = GVAR(slideshows) + 1;
};
_currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets changed during execution of below code
private _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets changed during execution of below code
// If interaction menu module is not present, set default duration value
if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then {
@ -64,8 +65,22 @@ if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then {
// Add interactions if automatic transitions are disabled, else setup automatic transitions
if (_duration == 0) then {
{
if (_setName == "") then {
_setName = localize LSTRING(Interaction);
};
// 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);
private _slidesAction = [
format [QGVAR(slideshow%1), _currentSlideshow],
_setName,
"",
{},
{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;
@ -73,7 +88,7 @@ if (_duration == 0) then {
if !(isServer) exitWith {};
// Formatted GVAR string (multiple modules support)
_varString = format [QGVAR(slideshow%1), _currentSlideshow];
private _varString = format [QGVAR(slideshow%1), _currentSlideshow];
TRACE_1("Current Slide",_varString);
// Set formatted GVAR to first slide