Added Slideshow mission tool

This commit is contained in:
jonpas
2015-06-27 04:11:57 +02:00
parent 6bb235f38a
commit 77cb278f61
14 changed files with 437 additions and 0 deletions

View File

@ -0,0 +1,47 @@
/*
* Author: Jonpas
* Adds controller slide actions.
*
* Arguments:
* 0: Controller <OBJECT>
*
* Return Value:
* Children Actions <ARRAY>
*
* Example:
* [controller] call ace_slideshow_fnc_addSlideActions;
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_controller);
private ["_slides", "_actions"];
_slides = _controller getVariable QGVAR(Slides);
EXPLODE_3_PVT(_slides,_objects,_images,_names);
_actions = [];
{
_actions pushBack
[
[
format ["Slide_%1", _forEachIndex],
_names select _forEachIndex,
"",
{
{
_x setObjectTextureGlobal [0, (_this select 2) select 1]
} forEach ((_this select 2) select 0);
},
{true},
{},
[_objects,_x]
] call EFUNC(interact_menu,createAction),
[],
_controller
];
} forEach _images;
_actions

View File

@ -0,0 +1,57 @@
/*
* Author: Jonpas, DaC
* Prepares necessary variables and default image.
*
* Arguments:
* 0: Objects <ARRAY>
* 1: Controller Objects <ARRAY>
* 2: Image Paths <ARRAY>
* 3: Names <ARRAY>
*
* Return Value:
* Parsed List <ARRAY>
*
* Example:
* [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"]] call ace_slideshow_fnc_createSlideshow;
*
* Public: Yes
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_4(_objects,_controllers,_images,_names);
// Add controllers to objects if they support it
{
if (typeOf _x in [CLASSNAMES_OBJECTS, CLASSNAMES_BOTH]) then {
_objects pushBack _x;
};
} forEach _controllers;
// Objects synced to the module
{
if (typeOf _x in [CLASSNAMES_OBJECTS, CLASSNAMES_BOTH]) then {
_objects pushBack _x;
};
if (typeOf _x in [CLASSNAMES_BOTH, CLASSNAMES_CONTROLLERS]) then {
_controllers pushBack _x;
};
} forEach (synchronizedObjects _logic);
// If no controllers use objects as controllers
if (count _controllers == 0) then {
_controllers = _objects;
};
TRACE_4("Information",_objects,_controllers,_images,_names);
// Default images on whiteboards (first image)
{
_x setObjectTextureGlobal [0, _images select 0];
} forEach _objects;
// Set first image as default and set variable on controllers with necessary information
{
_x setVariable [QGVAR(Slides), [_objects, _images, _names], true];
TRACE_1("Assigning Slides to",_x);
} forEach _controllers;

View File

@ -0,0 +1,20 @@
/*
* Author: Jonpas
* Checks if object has slides.
*
* Arguments:
* 0: Object <OBJECT>
*
* Return Value:
* Has Slides <BOOL>
*
* Example:
* [object] call ace_slideshow_fnc_hasSlides;
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_object);
(!isNil {_object getVariable [QGVAR(Slides), nil]})

View File

@ -0,0 +1,58 @@
/*
* Author: Jonpas
* Makes a list from a string using comma as a delimiter, optionally remove whitespace and check each for object existence.
*
* Arguments:
* 0: Text <STRING>
* 1: Remove Whitespace <BOOL>
* 2: Check Nil <BOOL>
*
* Return Value:
* Parsed List <ARRAY>
*
* Example:
* ["text", true, false] call ace_slideshow_fnc_makeList;
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_3(_list,_removeWhitespace,_checkNil);
private ["_splittedList", "_listNoWhitespace", "_nilCheckPassedList"];
// Split using comma delimiter
_splittedList = [_list, ","] call BIS_fnc_splitString;
// Remove whitespace
_listNoWhitespace = [];
if (_removeWhitespace) then {
{
_x = [_x] call EFUNC(common,stringRemoveWhiteSpace);
_listNoWhitespace pushBack _x;
} forEach _splittedList;
_list = _listNoWhitespace;
};
// Check for object existence
_nilCheckPassedList = "";
if (_checkNil) then {
{
if !(isNil _x) then {
if (_nilCheckPassedList == "") then {
_nilCheckPassedList = _x;
} else {
_nilCheckPassedList = _nilCheckPassedList + "," + _x;
};
};
} forEach _list;
// Add Array characters and parse into array
_list = "[" + _nilCheckPassedList + "]";
_list = [] call compile _list;
};
TRACE_4("Lists",_splittedList,_listNoWhitespace,_nilCheckPassedList,_list);
_list

View File

@ -0,0 +1,38 @@
/*
* Author: Jonpas
* Initializes the module.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: Units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
if !(isServer) exitWith {};
PARAMS_3(_logic,_units,_activated);
if !(_activated) exitWith {};
private ["_objects", "_controllers", "_return", "_images", "_names", "_controller"];
_logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
if (isNull _logic) exitWith {};
// Extract variables from logic
_objects = [_logic getVariable ["Objects", ""], true, true] call FUNC(makeList);
_controllers = [_logic getVariable ["Controllers", ""], true, true] call FUNC(makeList);
_images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList);
_names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList);
// Prepare with actions
[_objects, _controllers, _images, _names] call FUNC(createSlideshow);
diag_log text format ["[TAC]: Slideshow Module Initialized for: %1", _objects];

View File

@ -0,0 +1 @@
#include "\z\ace\addons\slideshow\script_component.hpp"