Slideshow - Add support for texture selections (#8702)

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>
This commit is contained in:
TyroneMF 2021-11-28 01:11:46 +00:00 committed by GitHub
parent 8cea7f4007
commit 2f2280494f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 14 deletions

View File

@ -47,6 +47,12 @@ class CfgVehicles {
typeName = "NUMBER";
defaultValue = 0;
};
class Selection {
displayName = CSTRING(Selection_DisplayName);
description = CSTRING(Selection_Description);
typeName = "NUMBER";
defaultValue = 0;
};
};
class ModuleDescription {
description = CSTRING(Description);

View File

@ -9,6 +9,7 @@
* 2: Names <ARRAY>
* 3: Controller <OBJECT>
* 4: Current Slideshow <NUMBER>
* 5: Texture Selection <NUMBER> (default: 0)
*
* Return Value:
* List of actions <ARRAY>
@ -19,7 +20,7 @@
* Public: No
*/
params ["_objects", "_images", "_names", "_controller", "_currentSlideshow"];
params ["_objects", "_images", "_names", "_controller", "_currentSlideshow", ["_selection", 0]];
private _actions = [];
{
@ -30,15 +31,15 @@ private _actions = [];
_names select _forEachIndex,
"",
{
(_this select 2) params ["_objects", "_image", "_currentSlideshow"];
(_this select 2) params ["_objects", "_image", "_currentSlideshow", "_selection"];
{
_x setObjectTextureGlobal [0, _image]
_x setObjectTextureGlobal [_selection, _image]
} count _objects;
[QGVAR(slideChanged), [_image, _currentSlideshow]] call CBA_fnc_localEvent;
},
{true},
{},
[_objects, _x, _currentSlideshow]
[_objects, _x, _currentSlideshow, _selection]
] call EFUNC(interact_menu,createAction),
[],
_controller

View File

@ -9,17 +9,18 @@
* 2: State Variable Name <ARRAY>
* 3: Current Slideshow <NUMBER>
* 4: Duration <NUMBER> (0 disables automatic transitions)
* 5: Texture Selection <NUMBER>
*
* Return Value:
* None
*
* Example:
* [objects, images, "ace_slideshow_slideshow1", duration] call ace_slideshow_fnc_autoTransition
* [objects, images, "ace_slideshow_slideshow1", duration, selection] call ace_slideshow_fnc_autoTransition
*
* Public: No
*/
params ["_objects", "_images", "_varString", "_currentSlideshow", "_duration"];
params ["_objects", "_images", "_varString", "_currentSlideshow", "_duration", "_selection"];
// Get current slide number of this slideshow
private _currentSlide = missionNamespace getVariable [_varString, 0];
@ -34,11 +35,11 @@ private _image = _images select _currentSlide;
// Set slide
{
_x setObjectTextureGlobal [0, _image];
_x setObjectTextureGlobal [_selection, _image];
} count _objects;
[QGVAR(slideChanged), [_image, _currentSlideshow]] call CBA_fnc_localEvent;
// Log current slide and execute Next slide
TRACE_4("Auto-transition",_image,_currentSlide,count _images,_duration);
[FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration], _duration] call CBA_fnc_waitAndExecute;
[FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration, _selection], _duration] call CBA_fnc_waitAndExecute;

View File

@ -10,6 +10,7 @@
* 3: Action Names <ARRAY>
* 4: Slide Duration <NUMBER> (0 disables automatic transitions)
* 5: Set Name <STRING> (default: localized "Slides")
* 6: Texture Selection <NUMBER> (default: 0)
*
* Return Value:
* Slideshow ID <NUMBER>
@ -26,7 +27,8 @@ params [
["_images", [], [[]] ],
["_names", [], [[]] ],
["_duration", 0, [0]],
["_setName", localize LSTRING(Interaction), [""]]
["_setName", localize LSTRING(Interaction), [""]],
["_selection", 0, [0]]
];
// Verify data
@ -47,7 +49,7 @@ TRACE_5("Information",_objects,_controllers,_images,_names,_setName);
if (isServer) then {
// Default images on whiteboards (first image)
{
_x setObjectTextureGlobal [0, _images select 0];
_x setObjectTextureGlobal [_selection, _images select 0];
} count _objects;
};
@ -82,7 +84,7 @@ if (_duration == 0) then {
{},
{true},
{(_this select 2) call FUNC(addSlideActions)},
[_objects, _images, _names, _x, _currentSlideshow],
[_objects, _images, _names, _x, _currentSlideshow, _selection],
[0, 0, 0],
2
] call EFUNC(interact_menu,createAction);
@ -100,7 +102,7 @@ if (_duration == 0) then {
missionNamespace setVariable [_varString, 0];
// Automatic transitions handler
[FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration], _duration] call CBA_fnc_waitAndExecute;
[FUNC(autoTransition), [_objects, _images, _varString, _currentSlideshow, _duration, _selection], _duration] call CBA_fnc_waitAndExecute;
};
_currentSlideshow

View File

@ -32,6 +32,7 @@ private _images = [_logic getVariable ["Images", ""], false, false] call EFUNC(c
private _names = [_logic getVariable ["Names", ""], false, false] call EFUNC(common,parseList);
private _setName = _logic getVariable ["SetName", ""];
private _duration = _logic getVariable ["Duration", 0];
private _selection = _logic getVariable ["Selection", 0];
// Objects synced to the module
{
@ -40,6 +41,6 @@ private _duration = _logic getVariable ["Duration", 0];
} count (synchronizedObjects _logic);
// Prepare with actions
[_objects, _controllers, _images, _names, _duration, _setName] call FUNC(createSlideshow);
[_objects, _controllers, _images, _names, _duration, _setName, _selection] call FUNC(createSlideshow);
INFO_1("Slideshow Module Initialized on %1 Objects",(count _objects));

View File

@ -227,6 +227,12 @@
<Chinese>每張幻燈片顯示的時間。 預設:0 (自動換圖已禁用)</Chinese>
<Chinesesimp>每张幻灯片显示的时间。 预设:0 (自动换图已禁用)</Chinesesimp>
</Key>
<Key ID="STR_ACE_Slideshow_Selection_DisplayName">
<English>Texture Selection</English>
</Key>
<Key ID="STR_ACE_Slideshow_Selection_Description">
<English>Object texture selection. Default: 0</English>
</Key>
<Key ID="STR_ACE_Slideshow_Interaction">
<English>Slides</English>
<French>Diapositives</French>

View File

@ -40,13 +40,14 @@ Important notes:
3 | Action Names | Array | Required
4 | Slide Duration | Number | Optional (default: `0`, `0` disables automatic transitions)
5 | Set Name | String | Optional (default: localized `"Slides"`)
6 | Texture Selection | Number | Optional (default: `0`)
**R** | None | None | Return value
_Note: Set Name argument added in 3.9.1._
#### 2.1.1 Example
`[[object1, object2], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5, "My Slides"] call ace_slideshow_fnc_createSlideshow;`
`[[object1, object2], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5, "My Slides", 1] call ace_slideshow_fnc_createSlideshow;`
| Arguments | Explanation
---| --------- | -----------
@ -56,3 +57,4 @@ _Note: Set Name argument added in 3.9.1._
3 | `["Action1", "Action2"]` | Action names for interaction menu if automatic transitions are not enabled
4 | `5` | 5s slide duration before change to next image
5 | `"My Slides"` | Main interaction point name, for easier distinguishing of multiple slideshow sets
6 | `1` | Uses texture selection 1 for objects with multiple options