2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-06-27 02:11:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Jonpas, DaC
|
|
|
|
* Prepares necessary variables and default image.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Objects <ARRAY>
|
|
|
|
* 1: Controller Objects <ARRAY>
|
|
|
|
* 2: Image Paths <ARRAY>
|
2015-06-29 19:07:51 +00:00
|
|
|
* 3: Action Names <ARRAY>
|
2023-04-30 21:03:35 +00:00
|
|
|
* 4: Slide Duration, 0 disables automatic transitions <NUMBER>
|
2017-02-24 13:08:18 +00:00
|
|
|
* 5: Set Name <STRING> (default: localized "Slides")
|
2021-11-28 01:11:46 +00:00
|
|
|
* 6: Texture Selection <NUMBER> (default: 0)
|
2015-06-27 02:11:57 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2020-10-25 17:14:57 +00:00
|
|
|
* Slideshow ID <NUMBER>
|
2015-06-27 02:11:57 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2019-08-13 06:41:30 +00:00
|
|
|
* [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5, "My Slides"] call ace_slideshow_fnc_createSlideshow
|
2015-06-27 02:11:57 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
2015-09-26 20:53:49 +00:00
|
|
|
params [
|
2015-09-26 21:02:18 +00:00
|
|
|
["_objects", [], [[]] ],
|
|
|
|
["_controllers", [], [[]] ],
|
|
|
|
["_images", [], [[]] ],
|
|
|
|
["_names", [], [[]] ],
|
2017-02-24 13:08:18 +00:00
|
|
|
["_duration", 0, [0]],
|
2021-11-28 01:11:46 +00:00
|
|
|
["_setName", localize LSTRING(Interaction), [""]],
|
|
|
|
["_selection", 0, [0]]
|
2015-09-26 20:53:49 +00:00
|
|
|
];
|
2015-06-27 02:11:57 +00:00
|
|
|
|
2015-07-13 17:56:25 +00:00
|
|
|
// Verify data
|
2015-09-26 20:53:49 +00:00
|
|
|
if (_objects isEqualTo []) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
ERROR("Slideshow Objects field must NOT be empty!");
|
2015-09-26 20:53:49 +00:00
|
|
|
};
|
|
|
|
if (count _images != count _names || {_images isEqualTo []} || {_names isEqualTo []}) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
ERROR("Slideshow Images or Names fields must NOT be empty and must have equal number of items!");
|
2015-07-13 17:56:25 +00:00
|
|
|
};
|
2015-06-27 02:11:57 +00:00
|
|
|
|
|
|
|
// If no controllers use objects as controllers
|
2015-09-26 21:06:35 +00:00
|
|
|
if (_controllers isEqualTo []) then {
|
2015-06-27 02:11:57 +00:00
|
|
|
_controllers = _objects;
|
|
|
|
};
|
|
|
|
|
2017-02-24 13:08:18 +00:00
|
|
|
TRACE_5("Information",_objects,_controllers,_images,_names,_setName);
|
2015-06-27 02:11:57 +00:00
|
|
|
|
2015-08-06 22:32:12 +00:00
|
|
|
if (isServer) then {
|
2015-08-08 11:00:11 +00:00
|
|
|
// Default images on whiteboards (first image)
|
2015-08-06 22:32:12 +00:00
|
|
|
{
|
2021-11-28 01:11:46 +00:00
|
|
|
_x setObjectTextureGlobal [_selection, _images select 0];
|
2019-08-13 06:41:30 +00:00
|
|
|
} count _objects;
|
2015-08-06 22:32:12 +00:00
|
|
|
};
|
2015-06-27 02:11:57 +00:00
|
|
|
|
2018-03-17 17:12:33 +00:00
|
|
|
// Number of slideshows (multiple modules support)
|
|
|
|
GVAR(slideshows) = GVAR(slideshows) + 1;
|
|
|
|
|
2017-02-24 13:08:18 +00:00
|
|
|
private _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets changed during execution of below code
|
2015-06-29 19:54:40 +00:00
|
|
|
|
2015-08-06 22:32:12 +00:00
|
|
|
// If interaction menu module is not present, set default duration value
|
2015-08-07 17:36:10 +00:00
|
|
|
if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then {
|
2015-09-26 20:53:49 +00:00
|
|
|
_duration = NOINTERACTMENU_DURATION;
|
2024-02-05 17:04:24 +00:00
|
|
|
INFO_1("Interaction Menu module not present,defaulting duration value to %1",_duration);
|
2015-08-06 22:32:12 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 20:07:21 +00:00
|
|
|
// Add interactions if automatic transitions are disabled, else setup automatic transitions
|
|
|
|
if (_duration == 0) then {
|
2019-08-13 06:41:30 +00:00
|
|
|
|
|
|
|
// Reverse the arrays so that the interactions will be added in the right order
|
|
|
|
reverse _images;
|
|
|
|
reverse _names;
|
|
|
|
|
2015-07-13 20:07:21 +00:00
|
|
|
{
|
2017-02-24 13:08:18 +00:00
|
|
|
if (_setName == "") then {
|
|
|
|
_setName = localize LSTRING(Interaction);
|
|
|
|
};
|
|
|
|
|
2015-07-13 20:07:21 +00:00
|
|
|
// Add Slides sub-action and populate with images
|
2017-02-24 13:08:18 +00:00
|
|
|
private _slidesAction = [
|
|
|
|
format [QGVAR(slideshow%1), _currentSlideshow],
|
|
|
|
_setName,
|
|
|
|
"",
|
|
|
|
{},
|
|
|
|
{true},
|
|
|
|
{(_this select 2) call FUNC(addSlideActions)},
|
2021-11-28 01:11:46 +00:00
|
|
|
[_objects, _images, _names, _x, _currentSlideshow, _selection],
|
2017-02-24 13:08:18 +00:00
|
|
|
[0, 0, 0],
|
|
|
|
2
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
2015-07-13 20:07:21 +00:00
|
|
|
[_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject);
|
2015-08-07 10:11:34 +00:00
|
|
|
nil
|
|
|
|
} count _controllers;
|
2015-07-13 20:07:21 +00:00
|
|
|
} else {
|
2015-08-06 22:32:12 +00:00
|
|
|
if !(isServer) exitWith {};
|
|
|
|
|
2015-07-13 20:07:21 +00:00
|
|
|
// Formatted GVAR string (multiple modules support)
|
2017-02-24 13:08:18 +00:00
|
|
|
private _varString = format [QGVAR(slideshow%1), _currentSlideshow];
|
2015-07-13 20:07:21 +00:00
|
|
|
TRACE_1("Current Slide",_varString);
|
2015-06-29 19:07:51 +00:00
|
|
|
|
2015-07-13 20:07:21 +00:00
|
|
|
// Set formatted GVAR to first slide
|
|
|
|
missionNamespace setVariable [_varString, 0];
|
2015-06-29 19:07:51 +00:00
|
|
|
|
2015-07-13 20:07:21 +00:00
|
|
|
// Automatic transitions handler
|
2021-11-28 01:11:46 +00:00
|
|
|
[FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration, _selection], _duration] call CBA_fnc_waitAndExecute;
|
2015-07-13 20:07:21 +00:00
|
|
|
};
|
2020-10-25 17:14:57 +00:00
|
|
|
|
|
|
|
_currentSlideshow
|