Slideshow - Add "SlideChanged" event (#7954)

* Implement Events in slideshow framework.

* Update function header

* Pass correct agruments to next call of autoTransiton.

* Add return of slideshow ID

Return slideshow ID so it can be stored for later use with the events.

* Replace repeat code with variable. _image.

* Redundant comment removal

* Update addons/slideshow/functions/fnc_createSlideshow.sqf

Co-authored-by: jonpas <jonpas33@gmail.com>

Co-authored-by: jonpas <jonpas33@gmail.com>
This commit is contained in:
Walthzer 2020-10-25 18:14:57 +01:00 committed by GitHub
parent 8e999ae0cf
commit 84b18d3f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 9 deletions

View File

@ -159,6 +159,7 @@ Tuupertunut
Valentin Torikian <valentin.torikian@gmail.com> Valentin Torikian <valentin.torikian@gmail.com>
voiper voiper
VyMajoris(W-Cephei)<vycanismajoriscsa@gmail.com> VyMajoris(W-Cephei)<vycanismajoriscsa@gmail.com>
Walthzer <walthzer.69@gmail.com>
Winter <simon@agius-muscat.net> Winter <simon@agius-muscat.net>
xrufix xrufix
Zakant <Zakant@gmx.de> Zakant <Zakant@gmx.de>

View File

@ -30,14 +30,15 @@ private _actions = [];
_names select _forEachIndex, _names select _forEachIndex,
"", "",
{ {
(_this select 2) params ["_objects", "_image"]; (_this select 2) params ["_objects", "_image", "_currentSlideshow"];
{ {
_x setObjectTextureGlobal [0, _image] _x setObjectTextureGlobal [0, _image]
} count _objects; } count _objects;
[QGVAR(slideChanged), [_image, _currentSlideshow]] call CBA_fnc_localEvent;
}, },
{true}, {true},
{}, {},
[_objects, _x] [_objects, _x, _currentSlideshow]
] call EFUNC(interact_menu,createAction), ] call EFUNC(interact_menu,createAction),
[], [],
_controller _controller

View File

@ -7,7 +7,8 @@
* 0: Objects <ARRAY> * 0: Objects <ARRAY>
* 1: Image Paths <ARRAY> * 1: Image Paths <ARRAY>
* 2: State Variable Name <ARRAY> * 2: State Variable Name <ARRAY>
* 3: Duration <NUMBER> (0 disables automatic transitions) * 3: Current Slideshow <NUMBER>
* 4: Duration <NUMBER> (0 disables automatic transitions)
* *
* Return Value: * Return Value:
* None * None
@ -18,7 +19,7 @@
* Public: No * Public: No
*/ */
params ["_objects", "_images", "_varString", "_duration"]; params ["_objects", "_images", "_varString", "_currentSlideshow", "_duration"];
// Get current slide number of this slideshow // Get current slide number of this slideshow
private _currentSlide = missionNamespace getVariable [_varString, 0]; private _currentSlide = missionNamespace getVariable [_varString, 0];
@ -29,11 +30,15 @@ _currentSlide = (_currentSlide + 1) mod (count _images);
// Save slide back into global variable (PFH's local variables do not persist through PFH run) // Save slide back into global variable (PFH's local variables do not persist through PFH run)
missionNamespace setVariable [_varString, _currentSlide]; missionNamespace setVariable [_varString, _currentSlide];
private _image = _images select _currentSlide;
// Set slide // Set slide
{ {
_x setObjectTextureGlobal [0, _images select _currentSlide]; _x setObjectTextureGlobal [0, _image];
} count _objects; } count _objects;
[QGVAR(slideChanged), [_image, _currentSlideshow]] call CBA_fnc_localEvent;
// Log current slide and execute Next slide // Log current slide and execute Next slide
TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration); TRACE_4("Auto-transition",_image,_currentSlide,count _images,_duration);
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call CBA_fnc_waitAndExecute; [FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration], _duration] call CBA_fnc_waitAndExecute;

View File

@ -12,7 +12,7 @@
* 5: Set Name <STRING> (default: localized "Slides") * 5: Set Name <STRING> (default: localized "Slides")
* *
* Return Value: * Return Value:
* None * Slideshow ID <NUMBER>
* *
* Example: * Example:
* [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5, "My Slides"] 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
@ -100,5 +100,7 @@ if (_duration == 0) then {
missionNamespace setVariable [_varString, 0]; missionNamespace setVariable [_varString, 0];
// Automatic transitions handler // Automatic transitions handler
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call CBA_fnc_waitAndExecute; [FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration], _duration] call CBA_fnc_waitAndExecute;
}; };
_currentSlideshow