Added automatic slide transitions with custom duration

This commit is contained in:
jonpas 2015-06-29 21:07:51 +02:00
parent 34b270d89d
commit 7e200afa04
7 changed files with 48 additions and 14 deletions

View File

@ -35,6 +35,12 @@ class CfgVehicles {
typeName = "STRING"; typeName = "STRING";
defaultValue = ""; defaultValue = "";
}; };
class Duration {
displayName = CSTRING(Duration_DisplayName);
description = CSTRING(Duration_Description);
typeName = "NUMBER";
defaultValue = 0;
};
}; };
class ModuleDescription { class ModuleDescription {
description = CSTRING(Description); description = CSTRING(Description);
@ -68,7 +74,7 @@ class CfgVehicles {
#define MACRO_SLIDES \ #define MACRO_SLIDES \
class GVAR(Slides) { \ class GVAR(Slides) { \
displayName = CSTRING(Interaction); \ displayName = CSTRING(Interaction); \
condition = QUOTE(_this call FUNC(hasSlides)); \ condition = QUOTE(_this call FUNC(canChangeSlides)); \
insertChildren = QUOTE(_this call DFUNC(addSlideActions)); \ insertChildren = QUOTE(_this call DFUNC(addSlideActions)); \
}; };

View File

@ -3,8 +3,8 @@
ADDON = false; ADDON = false;
PREP(addSlideActions); PREP(addSlideActions);
PREP(canChangeSlides);
PREP(createSlideshow); PREP(createSlideshow);
PREP(hasSlides);
PREP(makeList); PREP(makeList);
PREP(moduleInit); PREP(moduleInit);

View File

@ -19,7 +19,7 @@ PARAMS_1(_controller);
private ["_slides", "_actions"]; private ["_slides", "_actions"];
_slides = _controller getVariable QGVAR(Slides); _slides = _controller getVariable QGVAR(slides);
EXPLODE_3_PVT(_slides,_objects,_images,_names); EXPLODE_3_PVT(_slides,_objects,_images,_names);
_actions = []; _actions = [];

View File

@ -6,10 +6,10 @@
* 0: Object <OBJECT> * 0: Object <OBJECT>
* *
* Return Value: * Return Value:
* Has Slides <BOOL> * Can Change Slides <BOOL>
* *
* Example: * Example:
* [object] call ace_slideshow_fnc_hasSlides; * [object] call ace_slideshow_fnc_canChangeSlides;
* *
* Public: No * Public: No
*/ */
@ -17,4 +17,7 @@
PARAMS_1(_object); PARAMS_1(_object);
(!isNil {_object getVariable [QGVAR(Slides), nil]}) private ["_slides"];
_slides = _object getVariable [QGVAR(slides), nil];
(!isNil "_slides" && {_slides select 3 == 0})

View File

@ -6,20 +6,21 @@
* 0: Objects <ARRAY> * 0: Objects <ARRAY>
* 1: Controller Objects <ARRAY> * 1: Controller Objects <ARRAY>
* 2: Image Paths <ARRAY> * 2: Image Paths <ARRAY>
* 3: Names <ARRAY> * 3: Action Names <ARRAY>
* 4: Duration <NUMBER> (0 disables automatic transitions)
* *
* Return Value: * Return Value:
* Parsed List <ARRAY> * Parsed List <ARRAY>
* *
* Example: * Example:
* [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"]] call ace_slideshow_fnc_createSlideshow; * [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5] call ace_slideshow_fnc_createSlideshow;
* *
* Public: Yes * Public: Yes
*/ */
//#define DEBUG_MODE_FULL //#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_4(_objects,_controllers,_images,_names); PARAMS_5(_objects,_controllers,_images,_names,_duration);
// Add controllers to objects if they support it // Add controllers to objects if they support it
{ {
@ -52,6 +53,23 @@ TRACE_4("Information",_objects,_controllers,_images,_names);
// Set first image as default and set variable on controllers with necessary information // Set first image as default and set variable on controllers with necessary information
{ {
_x setVariable [QGVAR(Slides), [_objects, _images, _names], true]; _x setVariable [QGVAR(slides), [_objects, _images, _names, _duration], true];
TRACE_1("Assigning Slides to",_x); TRACE_1("Assigning Slides to controllers",_x);
} forEach _controllers; } forEach _controllers;
// Exit if automatic transitions are not allowed
if (_duration == 0) exitWith {};
// Automatic transitions
GVAR(currentSlide) = 0;
[{
EXPLODE_2_PVT(_this select 0,_objects,_images);
GVAR(currentSlide) = (GVAR(currentSlide) + 1) mod (count _images);
{
_x setObjectTextureGlobal [0, _images select GVAR(currentSlide)];
} forEach _objects;
TRACE_3("Auto-transition",_images select GVAR(currentSlide),GVAR(currentSlide),count _images);
}, _duration, [_objects, _images]] call cba_fnc_addPerFrameHandler;

View File

@ -21,7 +21,7 @@ PARAMS_3(_logic,_units,_activated);
if !(_activated) exitWith {}; if !(_activated) exitWith {};
private ["_objects", "_controllers", "_return", "_images", "_names", "_controller"]; private ["_objects", "_controllers", "_images", "_names", "_duration"];
_logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param; _logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
if (isNull _logic) exitWith {}; if (isNull _logic) exitWith {};
@ -31,8 +31,9 @@ _objects = [_logic getVariable ["Objects", ""], true, true] call FUNC(makeList);
_controllers = [_logic getVariable ["Controllers", ""], true, true] call FUNC(makeList); _controllers = [_logic getVariable ["Controllers", ""], true, true] call FUNC(makeList);
_images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList); _images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList);
_names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList); _names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList);
_duration = _logic getVariable ["Duration", ""];
// Prepare with actions // Prepare with actions
[_objects, _controllers, _images, _names] call FUNC(createSlideshow); [_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow);
diag_log text format ["[ACE]: Slideshow Module Initialized for: %1", _objects]; diag_log text format ["[ACE]: Slideshow Module Initialized for: %1 with Duration: %2", _objects, _duration];

View File

@ -31,6 +31,12 @@
<Key ID="STR_ACE_Slideshow_Names_Description"> <Key ID="STR_ACE_Slideshow_Names_Description">
<English>List of names that will be used for interaction entries, separated by commas, in order of images.</English> <English>List of names that will be used for interaction entries, separated by commas, in order of images.</English>
</Key> </Key>
<Key ID="STR_ACE_Slideshow_Duration_DisplayName">
<English>Slide Duration</English>
</Key>
<Key ID="STR_ACE_Slideshow_Duration_Description">
<English>Duration of each slide. Minor performance loss. Default: 0 (disabled)</English>
</Key>
<Key ID="STR_ACE_Slideshow_Interaction"> <Key ID="STR_ACE_Slideshow_Interaction">
<English>Slides</English> <English>Slides</English>
</Key> </Key>