Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slideshow - Add support for texture selections #8702

Merged
merged 7 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addons/slideshow/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions addons/slideshow/functions/fnc_addSlideActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -19,7 +20,7 @@
* Public: No
*/

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

private _actions = [];
{
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions addons/slideshow/functions/fnc_autoTransition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
10 changes: 6 additions & 4 deletions addons/slideshow/functions/fnc_createSlideshow.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -26,7 +27,8 @@ params [
["_images", [], [[]] ],
["_names", [], [[]] ],
["_duration", 0, [0]],
["_setName", localize LSTRING(Interaction), [""]]
["_setName", localize LSTRING(Interaction), [""]],
["_selection", 0, [0]]
];

// Verify data
Expand All @@ -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;
};

Expand Down Expand Up @@ -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);
Expand All @@ -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
3 changes: 2 additions & 1 deletion addons/slideshow/functions/fnc_moduleInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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));
6 changes: 6 additions & 0 deletions addons/slideshow/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion docs/wiki/framework/slideshow-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---| --------- | -----------
Expand All @@ -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