diff --git a/addons/slideshow/$PBOPREFIX$ b/addons/slideshow/$PBOPREFIX$ new file mode 100644 index 0000000000..78ced9578e --- /dev/null +++ b/addons/slideshow/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\slideshow \ No newline at end of file diff --git a/addons/slideshow/CfgEventHandlers.hpp b/addons/slideshow/CfgEventHandlers.hpp new file mode 100644 index 0000000000..b928bc2de6 --- /dev/null +++ b/addons/slideshow/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/slideshow/CfgVehicles.hpp b/addons/slideshow/CfgVehicles.hpp new file mode 100644 index 0000000000..96a69ed5b5 --- /dev/null +++ b/addons/slideshow/CfgVehicles.hpp @@ -0,0 +1,119 @@ +class CfgVehicles { + class ACE_Module; + class GVAR(module): ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE_missionModules"; + displayName = CSTRING(DisplayName); + function = QFUNC(moduleInit); + scope = 2; + isGlobal = 0; // Server only + isTriggerActivated = 0; + isDisposable = 0; + //icon = QUOTE(PATHTOF(UI\Icon_Module_Slideshow_ca.paa)); + class Arguments { + class Objects { + displayName = CSTRING(Objects_DisplayName); + description = CSTRING(Objects_Description); + typeName = "STRING"; + defaultValue = ""; + }; + class Controllers { + displayName = CSTRING(Controllers_DisplayName); + description = CSTRING(Controllers_Description); + typeName = "STRING"; + defaultValue = ""; + }; + class Images { + displayName = CSTRING(Images_DisplayName); + description = CSTRING(Images_Description); + typeName = "STRING"; + defaultValue = ""; + }; + class Names { + displayName = CSTRING(Names_DisplayName); + description = CSTRING(Names_Description); + typeName = "STRING"; + defaultValue = ""; + }; + }; + class ModuleDescription { + description = CSTRING(Description); + + // Every object in this must be initialized with GVAR(Slides) Action applied, as well as 2 of below macros + sync[] = {CLASSNAMES_OBJECTS, CLASSNAMES_BOTH, CLASSNAMES_CONTROLLERS}; + + #define MACRO_SYNC \ + optional = 1; \ + duplicate = 1; + #define OBJECT description = "Object"; + #define BOTH description = "Object AND Controller"; + #define CONTROLLER description = "Controller"; + + class Land_MapBoard_F {MACRO_SYNC OBJECT}; + + class Land_Laptop_unfolded_F {MACRO_SYNC BOTH}; + class Land_Laptop_device_F {MACRO_SYNC BOTH}; + class Land_PCSet_01_screen_F {MACRO_SYNC BOTH}; + + class Land_HandyCam_F {MACRO_SYNC CONTROLLER}; + class Land_MobilePhone_smart_F {MACRO_SYNC CONTROLLER}; + class Land_Tablet_01_F {MACRO_SYNC CONTROLLER}; + class Land_PCSet_01_keyboard_F {MACRO_SYNC CONTROLLER}; + class Land_PCSet_01_mouse_F {MACRO_SYNC CONTROLLER}; + class Land_GamingSet_01_controller_F {MACRO_SYNC CONTROLLER}; + }; + }; + + #define MACRO_SLIDES \ + class GVAR(Slides) { \ + displayName = CSTRING(Interaction); \ + condition = QUOTE(_this call FUNC(hasSlides)); \ + insertChildren = QUOTE(_this call DFUNC(addSlideActions)); \ + }; + + #define MACRO_INTERACT_INIT \ + XEH_ENABLED; \ + class ACE_Actions { \ + class ACE_MainActions { \ + displayName = ECSTRING(interaction,MainAction); \ + selection = ""; \ + condition = "true"; \ + distance = 2; \ + MACRO_SLIDES \ + }; \ + }; + + class ThingX; + class Land_MapBoard_F: ThingX { + MACRO_INTERACT_INIT + }; + + class Land_Laptop_F; + class Land_Laptop_unfolded_F: Land_Laptop_F { + MACRO_INTERACT_INIT + }; + //class Land_Laptop_device_F: Land_Laptop_unfolded_F; + + class Items_base_F; + class Land_PCSet_01_screen_F: Items_base_F { + MACRO_INTERACT_INIT + }; + class Land_HandyCam_F: Items_base_F { + MACRO_INTERACT_INIT + }; + class Land_MobilePhone_smart_F: Items_base_F { + MACRO_INTERACT_INIT + }; + class Land_Tablet_01_F: Items_base_F { + MACRO_INTERACT_INIT + }; + class Land_PCSet_01_keyboard_F: Items_base_F { + MACRO_INTERACT_INIT + }; + class Land_PCSet_01_mouse_F: Items_base_F { + MACRO_INTERACT_INIT + }; + class Land_GamingSet_01_controller_F: Items_base_F { + MACRO_INTERACT_INIT + }; +}; diff --git a/addons/slideshow/README.md b/addons/slideshow/README.md new file mode 100644 index 0000000000..58b22c1e17 --- /dev/null +++ b/addons/slideshow/README.md @@ -0,0 +1,10 @@ +ace_slideshow +=============== + +Adds ability to have slide-shows on them and control them with a controller (another object). + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Jonpas] (https://github.com/jonpas) diff --git a/addons/slideshow/XEH_preInit.sqf b/addons/slideshow/XEH_preInit.sqf new file mode 100644 index 0000000000..9461e27dd3 --- /dev/null +++ b/addons/slideshow/XEH_preInit.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(addSlideActions); +PREP(createSlideshow); +PREP(hasSlides); +PREP(makeList); +PREP(moduleInit); + +ADDON = true; diff --git a/addons/slideshow/config.cpp b/addons/slideshow/config.cpp new file mode 100644 index 0000000000..3af3bd5354 --- /dev/null +++ b/addons/slideshow/config.cpp @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[]= {"Jonpas", "DaC"}; + authorUrl = "https://github.com/jonpas"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/slideshow/functions/fnc_addSlideActions.sqf b/addons/slideshow/functions/fnc_addSlideActions.sqf new file mode 100644 index 0000000000..f722a9fa55 --- /dev/null +++ b/addons/slideshow/functions/fnc_addSlideActions.sqf @@ -0,0 +1,47 @@ +/* + * Author: Jonpas + * Adds controller slide actions. + * + * Arguments: + * 0: Controller + * + * Return Value: + * Children Actions + * + * 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 diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf new file mode 100644 index 0000000000..ad16acccb1 --- /dev/null +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -0,0 +1,57 @@ +/* + * Author: Jonpas, DaC + * Prepares necessary variables and default image. + * + * Arguments: + * 0: Objects + * 1: Controller Objects + * 2: Image Paths + * 3: Names + * + * Return Value: + * Parsed List + * + * 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; diff --git a/addons/slideshow/functions/fnc_hasSlides.sqf b/addons/slideshow/functions/fnc_hasSlides.sqf new file mode 100644 index 0000000000..d5661c2875 --- /dev/null +++ b/addons/slideshow/functions/fnc_hasSlides.sqf @@ -0,0 +1,20 @@ +/* + * Author: Jonpas + * Checks if object has slides. + * + * Arguments: + * 0: Object + * + * Return Value: + * Has Slides + * + * Example: + * [object] call ace_slideshow_fnc_hasSlides; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_object); + +(!isNil {_object getVariable [QGVAR(Slides), nil]}) diff --git a/addons/slideshow/functions/fnc_makeList.sqf b/addons/slideshow/functions/fnc_makeList.sqf new file mode 100644 index 0000000000..a104838e99 --- /dev/null +++ b/addons/slideshow/functions/fnc_makeList.sqf @@ -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 + * 1: Remove Whitespace + * 2: Check Nil + * + * Return Value: + * Parsed List + * + * 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 diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf new file mode 100644 index 0000000000..42d4040bb1 --- /dev/null +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -0,0 +1,38 @@ +/* + * Author: Jonpas + * Initializes the module. + * + * Arguments: + * 0: The module logic + * 1: Units + * 2: Activated + * + * 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]; diff --git a/addons/slideshow/functions/script_component.hpp b/addons/slideshow/functions/script_component.hpp new file mode 100644 index 0000000000..c4c2d6d966 --- /dev/null +++ b/addons/slideshow/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\slideshow\script_component.hpp" diff --git a/addons/slideshow/script_component.hpp b/addons/slideshow/script_component.hpp new file mode 100644 index 0000000000..50ed79e264 --- /dev/null +++ b/addons/slideshow/script_component.hpp @@ -0,0 +1,16 @@ +#define COMPONENT slideshow +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_SLIDESHOW + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_SLIDESHOW + #define DEBUG_SETTINGS DEBUG_SETTINGS_SLIDESHOW +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + +#define CLASSNAMES_OBJECTS "Land_MapBoard_F" +#define CLASSNAMES_BOTH "Land_Laptop_unfolded_F", "Land_Laptop_device_F", "Land_PCSet_01_screen_F" +#define CLASSNAMES_CONTROLLERS "Land_HandyCam_F", "Land_MobilePhone_smart_F", "Land_Tablet_01_F", "Land_PCSet_01_keyboard_F", "Land_PCSet_01_mouse_F", "Land_GamingSet_01_controller_F" diff --git a/addons/slideshow/stringtable.xml b/addons/slideshow/stringtable.xml new file mode 100644 index 0000000000..4755db4020 --- /dev/null +++ b/addons/slideshow/stringtable.xml @@ -0,0 +1,38 @@ + + + + + Slideshow + + + This module allows you to set up slide-shows on different objects. One module per image list. + + + Objects + + + Object names (can also be synchronized objects) slide-show will be displayed on, separated by commas if multiple. Reference INFO for object support. + + + Controllers + + + Controller object names (can also be synchronized objects), separated by commas if multiple. Reference INFO for object support. + + + Images + + + List of images that will be used for the slide-show, separated by commas, with full path correctly formatted (eg. images\image.paa). + + + Interaction Names + + + List of names that will be used for interaction entries, separated by commas, in order of images. + + + Slides + + + \ No newline at end of file