mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Replaced PFH for waitAndExecute with PFH-like handling
This commit is contained in:
parent
9ee75dbb21
commit
bb3495468e
@ -3,6 +3,7 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(addSlideActions);
|
||||
PREP(autoTransition);
|
||||
PREP(canChangeSlides);
|
||||
PREP(createSlideshow);
|
||||
PREP(makeList);
|
||||
|
45
addons/slideshow/functions/fnc_autoTransition.sqf
Normal file
45
addons/slideshow/functions/fnc_autoTransition.sqf
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Handles automatic slide transitions using waitAndExecute in a PFH-like manner resulting in no performance loss
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Objects <ARRAY>
|
||||
* 1: Controller Objects <ARRAY>
|
||||
* 2: Image Paths <ARRAY>
|
||||
* 3: Action Names <ARRAY>
|
||||
* 4: Duration <NUMBER> (0 disables automatic transitions)
|
||||
*
|
||||
* Return Value:
|
||||
* Parsed List <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [objects, controllers, images, actionNames, duration] call ace_slideshow_fnc_autoTransition;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_4(_objects,_images,_varString,_duration);
|
||||
|
||||
private ["_currentSlide"];
|
||||
|
||||
// Get current slide number of this slideshow
|
||||
_currentSlide = missionNamespace getVariable [_varString, 0];
|
||||
|
||||
// Increment slide or return to first slide if reached end
|
||||
_currentSlide = (_currentSlide + 1) mod (count _images);
|
||||
|
||||
// Save slide back into global variable (PFH's local variables do not persist through PFH run)
|
||||
missionNamespace setVariable [_varString, _currentSlide];
|
||||
|
||||
// Set slide
|
||||
{
|
||||
_x setObjectTextureGlobal [0, _images select _currentSlide];
|
||||
} forEach _objects;
|
||||
|
||||
TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration);
|
||||
|
||||
|
||||
// Next slide
|
||||
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
|
@ -7,7 +7,7 @@
|
||||
* 1: Controller Objects <ARRAY>
|
||||
* 2: Image Paths <ARRAY>
|
||||
* 3: Action Names <ARRAY>
|
||||
* 4: Duration <NUMBER> (0 disables automatic transitions)
|
||||
* 4: Slide Duration <NUMBER> (0 disables automatic transitions)
|
||||
*
|
||||
* Return Value:
|
||||
* Parsed List <ARRAY>
|
||||
@ -58,31 +58,18 @@ TRACE_4("Information",_objects,_controllers,_images,_names);
|
||||
} forEach _controllers;
|
||||
|
||||
|
||||
// Exit if automatic transitions are not allowed
|
||||
// Exit if automatic transitions are disabled
|
||||
if (_duration == 0) exitWith {};
|
||||
|
||||
|
||||
// Number of slideshows and formatted global variable (multiple modules support)
|
||||
private ["_varString"];
|
||||
// Number of slideshows (multiple modules support)
|
||||
GVAR(slideshows) = GVAR(slideshows) + 1;
|
||||
|
||||
// Formatted GVAR string (multiple modules support)
|
||||
private ["_varString"];
|
||||
_varString = str format [QGVAR(currentSlide%1), GVAR(slideshows)];
|
||||
missionNamespace setVariable [_varString, 0]; // First slide
|
||||
|
||||
// Automatic transitions PFH
|
||||
[{
|
||||
EXPLODE_3_PVT(_this select 0,_objects,_images,_varString);
|
||||
// Set formatted GVAR to first slide
|
||||
missionNamespace setVariable [_varString, 0];
|
||||
|
||||
// Get current slide number of this slideshow
|
||||
_currentSlide = missionNamespace getVariable [_varString, 0];
|
||||
// Increment slide or return to first slide if reached end
|
||||
_currentSlide = (_currentSlide + 1) mod (count _images);
|
||||
// Save slide back into global variable (PFH's local variables do not persist through PFH run)
|
||||
missionNamespace setVariable [_varString, _currentSlide];
|
||||
|
||||
// Set slide
|
||||
{
|
||||
_x setObjectTextureGlobal [0, _images select _currentSlide];
|
||||
} forEach _objects;
|
||||
|
||||
TRACE_3("Auto-transition",_images select _currentSlide,_currentSlide,count _images);
|
||||
}, _duration, [_objects, _images, _varString]] call cba_fnc_addPerFrameHandler;
|
||||
// Automatic transitions handler
|
||||
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
|
||||
|
Loading…
Reference in New Issue
Block a user