Skip to content

Commit

Permalink
Merge pull request #2051 from MikeMatrix/codeCleanupSlideshow
Browse files Browse the repository at this point in the history
Code cleanup of Slideshow module
  • Loading branch information
thojkooi committed Aug 8, 2015
2 parents a9ed105 + 8355558 commit 6b256a6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
12 changes: 6 additions & 6 deletions addons/slideshow/functions/fnc_addSlideActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
* 4: Current Slideshow <NUMBER>
*
* Return Value:
* None
* List of actions <ARRAY>
*
* Example:
* [[object], ["image"], ["name"], controller, 1] call ace_slideshow_fnc_addSlideActions
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

PARAMS_5(_objects,_images,_names,_controller,_currentSlideshow);
private "_actions";

params ["_objects", "_images", "_names", "_controller", "_currentSlideshow"];

private ["_actions"];
_actions = [];
{
_actions pushBack
Expand All @@ -32,10 +32,10 @@ _actions = [];
_names select _forEachIndex,
"",
{
EXPLODE_2_PVT(_this select 2,_objects,_image);
(_this select 2) params ["_objects", "_image"];
{
_x setObjectTextureGlobal [0, _image]
} forEach _objects;
} count _objects;
},
{true},
{},
Expand Down
22 changes: 9 additions & 13 deletions addons/slideshow/functions/fnc_autoTransition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@
*
* Arguments:
* 0: Objects <ARRAY>
* 1: Controller Objects <ARRAY>
* 2: Image Paths <ARRAY>
* 3: Action Names <ARRAY>
* 4: Duration <NUMBER> (0 disables automatic transitions)
* 1: Image Paths <ARRAY>
* 2: State Variable Name <ARRAY>
* 3: Duration <NUMBER> (0 disables automatic transitions)
*
* Return Value:
* Parsed List <ARRAY>
* None
*
* Example:
* [objects, controllers, images, actionNames, duration] call ace_slideshow_fnc_autoTransition
* [objects, images, "ace_slideshow_slideshow1", duration] call ace_slideshow_fnc_autoTransition
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

PARAMS_4(_objects,_images,_varString,_duration);
private "_currentSlide";

private ["_currentSlide"];
params ["_objects", "_images", "_varString", "_duration"];

// Get current slide number of this slideshow
_currentSlide = missionNamespace getVariable [_varString, 0];
Expand All @@ -36,10 +34,8 @@ missionNamespace setVariable [_varString, _currentSlide];
// Set slide
{
_x setObjectTextureGlobal [0, _images select _currentSlide];
} forEach _objects;
} count _objects;

// Log current slide and execute Next slide
TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration);


// Next slide
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
16 changes: 8 additions & 8 deletions addons/slideshow/functions/fnc_createSlideshow.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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), []];
Expand All @@ -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);

Expand Down
9 changes: 5 additions & 4 deletions addons/slideshow/functions/fnc_makeList.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

PARAMS_3(_list,_removeWhitespace,_checkNil);
params ["_list", "_removeWhitespace", "_checkNil"];

private ["_splittedList", "_listNoWhitespace", "_nilCheckPassedList"];

Expand All @@ -30,7 +30,8 @@ _listNoWhitespace = [];
if (_removeWhitespace) then {
{
_listNoWhitespace pushBack ([_x] call EFUNC(common,stringRemoveWhiteSpace));
} forEach _splittedList;
nil
} count _splittedList;
_list = _listNoWhitespace;
};

Expand All @@ -45,7 +46,7 @@ if (_checkNil) then {
_nilCheckPassedList = _nilCheckPassedList + "," + _x;
};
};
} forEach _list;
} count _list;

// Add Array characters and parse into array
_list = "[" + _nilCheckPassedList + "]";
Expand All @@ -54,4 +55,4 @@ if (_checkNil) then {

TRACE_4("Lists",_splittedList,_listNoWhitespace,_nilCheckPassedList,_list);

_list
_list // return
9 changes: 3 additions & 6 deletions addons/slideshow/functions/fnc_moduleInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

if !(isServer) exitWith {};

PARAMS_3(_logic,_units,_activated);

if !(_activated) exitWith {};

private ["_objects", "_controllers", "_images", "_names", "_duration"];

_logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
params [["_logic", objNull, [objNull]], "_units", "_activated"];

if !(_activated) exitWith {};
if (isNull _logic) exitWith {};

// Extract variables from logic
Expand Down

0 comments on commit 6b256a6

Please sign in to comment.