mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Made object actions dynamic
This commit is contained in:
parent
4fa1c7dc0a
commit
b266effe5b
@ -44,87 +44,6 @@ class CfgVehicles {
|
||||
};
|
||||
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_FlatTV_01_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(canChangeSlides)); \
|
||||
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_FlatTV_01_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
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,6 @@ ADDON = false;
|
||||
|
||||
PREP(addSlideActions);
|
||||
PREP(autoTransition);
|
||||
PREP(canChangeSlides);
|
||||
PREP(createSlideshow);
|
||||
PREP(makeList);
|
||||
PREP(moduleInit);
|
||||
|
@ -3,37 +3,39 @@
|
||||
* Adds controller slide actions.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Controller <OBJECT>
|
||||
* 0: Objects <ARRAY>
|
||||
* 1: Images <ARRAY>
|
||||
* 2: Names <ARRAY>
|
||||
* 3: Controller <OBJECT>
|
||||
* 4: Current Slideshow <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Children Actions <ARRAY>
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [controller] call ace_slideshow_fnc_addSlideActions;
|
||||
* [[object], ["image"], ["name"], controller, 1] call ace_slideshow_fnc_addSlideActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_controller);
|
||||
|
||||
private ["_slides", "_actions"];
|
||||
|
||||
_slides = _controller getVariable QGVAR(slides);
|
||||
EXPLODE_3_PVT(_slides,_objects,_images,_names);
|
||||
PARAMS_5(_objects,_images,_names,_controller,_currentSlideshow);
|
||||
|
||||
private ["_actions"];
|
||||
_actions = [];
|
||||
{
|
||||
_actions pushBack
|
||||
[
|
||||
[
|
||||
format ["Slide_%1", _forEachIndex],
|
||||
format [QGVAR(slideshow%1_slide%2), _currentSlideshow, _forEachIndex + 1],
|
||||
_names select _forEachIndex,
|
||||
"",
|
||||
{
|
||||
EXPLODE_2_PVT(_this select 2,_objects,_image);
|
||||
{
|
||||
_x setObjectTextureGlobal [0, (_this select 2) select 1]
|
||||
} forEach ((_this select 2) select 0);
|
||||
_x setObjectTextureGlobal [0, _image]
|
||||
} forEach _objects;
|
||||
},
|
||||
{true},
|
||||
{},
|
||||
@ -44,4 +46,6 @@ _actions = [];
|
||||
];
|
||||
} forEach _images;
|
||||
|
||||
TRACE_1("Children actions",_actions);
|
||||
|
||||
_actions
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Checks if object has slides.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can Change Slides <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [object] call ace_slideshow_fnc_canChangeSlides;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_object);
|
||||
|
||||
private ["_slides"];
|
||||
_slides = _object getVariable [QGVAR(slides), nil];
|
||||
|
||||
(!isNil "_slides" && {_slides select 3 == 0})
|
@ -27,21 +27,9 @@ if (count _images != count _names || {count _images == 0} || {count _names == 0}
|
||||
diag_log "[ACE] ERROR: Slideshow Images or Names fields can NOT be empty and must have equal number of items!"
|
||||
};
|
||||
|
||||
// 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;
|
||||
};
|
||||
_objects pushBack _x;
|
||||
} forEach (synchronizedObjects _logic);
|
||||
|
||||
// If no controllers use objects as controllers
|
||||
@ -56,26 +44,32 @@ TRACE_4("Information",_objects,_controllers,_images,_names);
|
||||
_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, _duration], true];
|
||||
TRACE_1("Assigning Slides to controllers",_x);
|
||||
} forEach _controllers;
|
||||
|
||||
|
||||
// Exit if automatic transitions are disabled
|
||||
if (_duration == 0) exitWith {};
|
||||
|
||||
// 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
|
||||
|
||||
// Formatted GVAR string (multiple modules support)
|
||||
private ["_varString"];
|
||||
_varString = format [QGVAR(currentSlide%1), GVAR(slideshows)];
|
||||
TRACE_1("Current Slide",_varString);
|
||||
// Add interactions if automatic transitions are disabled, else setup automatic transitions
|
||||
if (_duration == 0) then {
|
||||
{
|
||||
// Add MainAction if one does not already exist
|
||||
//if !(main interaction already exist) then {
|
||||
_mainAction = ["ACE_MainActions", localize LESTRING(interaction,MainAction), "", {}, {true}] call EFUNC(interact_menu,createAction);
|
||||
[_x, 0, [], _mainAction] call EFUNC(interact_menu,addActionToObject);
|
||||
//};
|
||||
// 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];
|
||||
// Set formatted GVAR to first slide
|
||||
missionNamespace setVariable [_varString, 0];
|
||||
|
||||
// Automatic transitions handler
|
||||
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
|
||||
// Automatic transitions handler
|
||||
[FUNC(autoTransition), [_objects, _images, _varString, _duration], _duration] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
@ -10,7 +10,3 @@
|
||||
#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", "Land_FlatTV_01_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"
|
||||
|
@ -5,7 +5,7 @@
|
||||
<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.</English>
|
||||
<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>
|
||||
@ -17,7 +17,7 @@
|
||||
<English>Controllers</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Controllers_Description">
|
||||
<English>Controller object names (can also be synchronized objects), separated by commas if multiple. Reference INFO for object support.</English>
|
||||
<English>Controller object names, separated by commas if multiple.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Slideshow_Images_DisplayName">
|
||||
<English>Images</English>
|
||||
|
Loading…
Reference in New Issue
Block a user