mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
commit
04e137090b
1
addons/slideshow/$PBOPREFIX$
Normal file
1
addons/slideshow/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\slideshow
|
5
addons/slideshow/CfgEventHandlers.hpp
Normal file
5
addons/slideshow/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
49
addons/slideshow/CfgVehicles.hpp
Normal file
49
addons/slideshow/CfgVehicles.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
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 Duration {
|
||||
displayName = CSTRING(Duration_DisplayName);
|
||||
description = CSTRING(Duration_Description);
|
||||
typeName = "NUMBER";
|
||||
defaultValue = 0;
|
||||
};
|
||||
};
|
||||
class ModuleDescription {
|
||||
description = CSTRING(Description);
|
||||
};
|
||||
};
|
||||
};
|
10
addons/slideshow/README.md
Normal file
10
addons/slideshow/README.md
Normal file
@ -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)
|
BIN
addons/slideshow/UI/Icon_Module_Slideshow_ca.paa
Normal file
BIN
addons/slideshow/UI/Icon_Module_Slideshow_ca.paa
Normal file
Binary file not shown.
13
addons/slideshow/XEH_preInit.sqf
Normal file
13
addons/slideshow/XEH_preInit.sqf
Normal file
@ -0,0 +1,13 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(addSlideActions);
|
||||
PREP(autoTransition);
|
||||
PREP(createSlideshow);
|
||||
PREP(makeList);
|
||||
PREP(moduleInit);
|
||||
|
||||
GVAR(slideshows) = 0;
|
||||
|
||||
ADDON = true;
|
16
addons/slideshow/config.cpp
Normal file
16
addons/slideshow/config.cpp
Normal file
@ -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"
|
51
addons/slideshow/functions/fnc_addSlideActions.sqf
Normal file
51
addons/slideshow/functions/fnc_addSlideActions.sqf
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Adds controller slide actions.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Objects <ARRAY>
|
||||
* 1: Images <ARRAY>
|
||||
* 2: Names <ARRAY>
|
||||
* 3: Controller <OBJECT>
|
||||
* 4: Current Slideshow <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* 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"];
|
||||
_actions = [];
|
||||
{
|
||||
_actions pushBack
|
||||
[
|
||||
[
|
||||
format [QGVAR(slideshow%1_slide%2), _currentSlideshow, _forEachIndex + 1],
|
||||
_names select _forEachIndex,
|
||||
"",
|
||||
{
|
||||
EXPLODE_2_PVT(_this select 2,_objects,_image);
|
||||
{
|
||||
_x setObjectTextureGlobal [0, _image]
|
||||
} forEach _objects;
|
||||
},
|
||||
{true},
|
||||
{},
|
||||
[_objects, _x]
|
||||
] call EFUNC(interact_menu,createAction),
|
||||
[],
|
||||
_controller
|
||||
];
|
||||
} forEach _images;
|
||||
|
||||
TRACE_1("Children actions",_actions);
|
||||
|
||||
_actions
|
45
addons/slideshow/functions/fnc_autoTransition.sqf
Normal file
45
addons/slideshow/functions/fnc_autoTransition.sqf
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Handles automatic slide transitions using waitAndExecute in a PFH-like manner resulting in no performance loss.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Objects <ARRAY>
|
||||
* 1: Controller Objects <ARRAY>
|
||||
* 2: Image Paths <ARRAY>
|
||||
* 3: Action Names <ARRAY>
|
||||
* 4: Duration <NUMBER> (0 disables automatic transitions)
|
||||
*
|
||||
* Return Value:
|
||||
* Parsed List <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [objects, controllers, images, actionNames, duration] call ace_slideshow_fnc_autoTransition
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_4(_objects,_images,_varString,_duration);
|
||||
|
||||
private ["_currentSlide"];
|
||||
|
||||
// Get current slide number of this slideshow
|
||||
_currentSlide = missionNamespace getVariable [_varString, 0];
|
||||
|
||||
// Increment slide or return to first slide if reached end
|
||||
_currentSlide = (_currentSlide + 1) mod (count _images);
|
||||
|
||||
// Save slide back into global variable (PFH's local variables do not persist through PFH run)
|
||||
missionNamespace setVariable [_varString, _currentSlide];
|
||||
|
||||
// Set slide
|
||||
{
|
||||
_x setObjectTextureGlobal [0, _images select _currentSlide];
|
||||
} forEach _objects;
|
||||
|
||||
TRACE_4("Auto-transition",_images select _currentSlide,_currentSlide,count _images,_duration);
|
||||
|
||||
|
||||
// Next slide
|
||||
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
|
80
addons/slideshow/functions/fnc_createSlideshow.sqf
Normal file
80
addons/slideshow/functions/fnc_createSlideshow.sqf
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Author: Jonpas, DaC
|
||||
* Prepares necessary variables and default image.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Objects <ARRAY>
|
||||
* 1: Controller Objects <ARRAY>
|
||||
* 2: Image Paths <ARRAY>
|
||||
* 3: Action Names <ARRAY>
|
||||
* 4: Slide Duration <NUMBER> (0 disables automatic transitions)
|
||||
*
|
||||
* Return Value:
|
||||
* Parsed List <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5] call ace_slideshow_fnc_createSlideshow
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_5(_objects,_controllers,_images,_names,_duration);
|
||||
|
||||
// Verify data
|
||||
if (count _images != count _names || {count _images == 0} || {count _names == 0}) exitWith {
|
||||
diag_log "[ACE] ERROR: Slideshow Images or Names fields can NOT be empty and must have equal number of items!"
|
||||
};
|
||||
|
||||
// Objects synced to the module
|
||||
{
|
||||
_objects 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;
|
||||
|
||||
// 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), []];
|
||||
_actionsClass = missionNamespace getVariable [format [QEGVAR(interact_menu,Act_%1), typeOf _x], []];
|
||||
if (count _actionsObject == 0 && {count _actionsClass == 0}) then {
|
||||
_mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call EFUNC(interact_menu,createAction);
|
||||
[_x, 0, [], _mainAction] call EFUNC(interact_menu,addActionToObject);
|
||||
TRACE_2("Adding ACE_MainActions",_actionsObject,_actionsClass);
|
||||
};
|
||||
|
||||
// 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;
|
||||
} else {
|
||||
// Formatted GVAR string (multiple modules support)
|
||||
private ["_varString"];
|
||||
_varString = format [QGVAR(slideshow%1), _currentSlideshow];
|
||||
TRACE_1("Current Slide",_varString);
|
||||
|
||||
// Set formatted GVAR to first slide
|
||||
missionNamespace setVariable [_varString, 0];
|
||||
|
||||
// Automatic transitions handler
|
||||
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
|
||||
};
|
57
addons/slideshow/functions/fnc_makeList.sqf
Normal file
57
addons/slideshow/functions/fnc_makeList.sqf
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 {
|
||||
{
|
||||
_listNoWhitespace pushBack ([_x] call EFUNC(common,stringRemoveWhiteSpace));
|
||||
} 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
|
39
addons/slideshow/functions/fnc_moduleInit.sqf
Normal file
39
addons/slideshow/functions/fnc_moduleInit.sqf
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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", "_images", "_names", "_duration"];
|
||||
|
||||
_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);
|
||||
_duration = _logic getVariable ["Duration", 0];
|
||||
|
||||
// Prepare with actions
|
||||
[_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow);
|
||||
|
||||
diag_log text format ["[ACE]: Slideshow Module Initialized for: %1 with Duration: %2", _objects, _duration];
|
1
addons/slideshow/functions/script_component.hpp
Normal file
1
addons/slideshow/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\slideshow\script_component.hpp"
|
12
addons/slideshow/script_component.hpp
Normal file
12
addons/slideshow/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#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"
|
44
addons/slideshow/stringtable.xml
Normal file
44
addons/slideshow/stringtable.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="Slideshow">
|
||||
<Key ID="STR_ACE_Slideshow_DisplayName">
|
||||
<English>Slideshow</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Description">
|
||||
<English>This module allows you to set up slide-shows on different objects. One module per image list. Only objects with hiddenSelection 0 are supported.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Objects_DisplayName">
|
||||
<English>Objects</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Objects_Description">
|
||||
<English>Object names (can also be synchronized objects) slide-show will be displayed on, separated by commas if multiple. Reference INFO for object support.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Controllers_DisplayName">
|
||||
<English>Controllers</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Controllers_Description">
|
||||
<English>Controller object names, separated by commas if multiple.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Images_DisplayName">
|
||||
<English>Images</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Images_Description">
|
||||
<English>List of images that will be used for the slide-show, separated by commas, with full path correctly formatted (eg. images\image.paa).</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Names_DisplayName">
|
||||
<English>Interaction Names</English>
|
||||
</Key>
|
||||
<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>
|
||||
</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. Default: 0 (Automatic Transitions Disabled)</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Interaction">
|
||||
<English>Slides</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
Binary file not shown.
BIN
extras/assets/icons/png/Icon_Module/Icon_Module_Slideshow_ca.png
Normal file
BIN
extras/assets/icons/png/Icon_Module/Icon_Module_Slideshow_ca.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Loading…
Reference in New Issue
Block a user