ACE3/addons/map/functions/fnc_compileFlashlightMenu.sqf

65 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-08-11 17:49:39 +00:00
/*
* Author: voiper
* Compile list of flashlight classnames and add to the "Flashlight" parent menu.
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Player <OBJECT>
* 3: Parameters <ARRAY>
*
* Return value:
* None
*
* Example:
* [_player, _player, []] call ace_map_fnc_compileFlashlightMenu;
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle", "_player", "_parameters"];
_actions = [];
_flashlights = [_player] call FUNC(getUnitFlashlights);
//add all carried flashlight menus and on/off submenu actions
{
2015-10-14 17:56:54 +00:00
private ["_cfg", "_displayName"," _icon", "_children", "_parentAction"];
_cfg = (configFile >> "CfgWeapons" >> _x);
_displayName = getText (_cfg >> "displayName");
_icon = getText (_cfg >> "picture");
2015-08-11 17:49:39 +00:00
_children = {
2015-10-14 17:56:54 +00:00
private ["_onAction", "_offAction"];
2015-08-11 17:49:39 +00:00
params ["_vehicle", "_player", "_flashlight"];
_onAction = [
(_flashlight + "_On"),
"On",
"",
{[_this select 2] call FUNC(switchFlashlight)},
{GVAR(flashlightInUse) != (_this select 2)},
{},
_flashlight
] call EFUNC(interact_menu,createAction);
_offAction = [
(_flashlight + "_Off"),
"Off",
"",
{[""] call FUNC(switchFlashlight)},
{GVAR(flashlightInUse) == (_this select 2)},
{},
_flashlight
] call EFUNC(interact_menu,createAction);
2015-10-14 17:56:54 +00:00
[[_onAction, [], _player], [_offAction, [], _player]]
2015-08-11 17:49:39 +00:00
};
_parentAction = [_x, _displayName, _icon, {true}, {true}, _children, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_parentAction, [], _player];
} forEach _flashlights;
2015-10-14 17:56:54 +00:00
_actions