Code cleanup of slideshow module

This commit is contained in:
Michael Braun
2015-08-07 12:11:34 +02:00
parent d636b4b5c7
commit fa56196fe3
5 changed files with 27 additions and 32 deletions

View File

@ -17,10 +17,11 @@
*
* Public: Yes
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_5(_objects,_controllers,_images,_names,_duration);
private ["_currentSlideshow", "_actionsObject", "_actionsClass", "_mainAction", "_slidesAction", "_varString"];
params ["_objects", "_controllers", "_images", "_names", "_duration"];
// Verify data
if (count _images != count _names || {count _images == 0} || {count _names == 0}) exitWith {
@ -30,7 +31,8 @@ if (count _images != count _names || {count _images == 0} || {count _names == 0}
// Objects synced to the module
{
_objects pushBack _x;
} forEach (synchronizedObjects _logic);
nil
} count (synchronizedObjects _logic);
// If no controllers use objects as controllers
if (count _controllers == 0) then {
@ -42,16 +44,14 @@ TRACE_4("Information",_objects,_controllers,_images,_names);
// Default images on whiteboards (first image)
{
_x setObjectTextureGlobal [0, _images select 0];
} forEach _objects;
} count _objects;
// Number of slideshows (multiple modules support)
GVAR(slideshows) = GVAR(slideshows) + 1;
private ["_currentSlideshow"];
_currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets changed during execution of below code
// Add interactions if automatic transitions are disabled, else setup automatic transitions
if (_duration == 0) then {
private ["_actionsObject", "_actionsClass", "_mainAction", "_slidesAction"];
{
// Add MainAction if one does not already exist
_actionsObject = _x getVariable [QEGVAR(interact_menu,actions), []];
@ -65,10 +65,10 @@ if (_duration == 0) then {
// 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);
[_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject);
} forEach _controllers;
nil
} count _controllers;
} else {
// Formatted GVAR string (multiple modules support)
private ["_varString"];
_varString = format [QGVAR(slideshow%1), _currentSlideshow];
TRACE_1("Current Slide",_varString);