mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Replace selection dialog with interact children
This commit is contained in:
parent
efe57461b5
commit
d03e474075
@ -4,9 +4,9 @@
|
||||
class ACE_MainActions { \
|
||||
class GVAR(AttachVehicle) { \
|
||||
displayName = "$STR_ACE_Attach_AttachDetach"; \
|
||||
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canAttach))); \
|
||||
statement = QUOTE( [ARR_2(_player, _target)] call FUNC(openAttachUI);); \
|
||||
exceptions[] = {}; \
|
||||
condition = QUOTE(_this call FUNC(canAttach)); \
|
||||
insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions)); \
|
||||
exceptions[] = {"isNotDragging"}; \
|
||||
showDisabled = 0; \
|
||||
priority = 0; \
|
||||
icon = PATHTOF(UI\attach_ca.paa); \
|
||||
@ -14,9 +14,9 @@
|
||||
}; \
|
||||
class GVAR(DetachVehicle) { \
|
||||
displayName = "$STR_ACE_Attach_Detach"; \
|
||||
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canDetach))); \
|
||||
statement = QUOTE( [ARR_2(_player, _target)] call FUNC(detach) ); \
|
||||
exceptions[] = {}; \
|
||||
condition = QUOTE(_this call FUNC(canDetach)); \
|
||||
statement = QUOTE(_this call FUNC(detach) ); \
|
||||
exceptions[] = {"isNotDragging"}; \
|
||||
showDisabled = 0; \
|
||||
priority = 0; \
|
||||
icon = PATHTOF(UI\detach_ca.paa); \
|
||||
@ -55,18 +55,18 @@ class CfgVehicles {
|
||||
class ACE_Equipment {
|
||||
class GVAR(Attach) {
|
||||
displayName = "$STR_ACE_Attach_AttachDetach";
|
||||
condition = QUOTE(([ARR_2(_player, _player)] call FUNC(canAttach)));
|
||||
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(openAttachUI); );
|
||||
condition = QUOTE(_this call FUNC(canAttach));
|
||||
insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions));
|
||||
exceptions[] = {"isNotDragging"};
|
||||
showDisabled = 0;
|
||||
priority = 5;
|
||||
icon = PATHTOF(UI\attach_ca.paa);
|
||||
hotkey = "T";
|
||||
// hotkey = "T";
|
||||
};
|
||||
class GVAR(Detach) {
|
||||
displayName = "$STR_ACE_Attach_Detach";
|
||||
condition = QUOTE(([ARR_2(_player, _player)] call FUNC(canDetach)));
|
||||
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(detach) );
|
||||
condition = QUOTE(_this call FUNC(canDetach));
|
||||
statement = QUOTE(_this call FUNC(detach));
|
||||
exceptions[] = {"isNotDragging"};
|
||||
showDisabled = 0;
|
||||
priority = 5;
|
||||
|
@ -6,6 +6,7 @@ PREP(attach);
|
||||
PREP(canAttach);
|
||||
PREP(canDetach);
|
||||
PREP(detach);
|
||||
PREP(getChildrenAttachActions);
|
||||
PREP(openAttachUI);
|
||||
PREP(placeApprove);
|
||||
PREP(placeCancel);
|
||||
|
@ -3,9 +3,9 @@
|
||||
* Attach an item to the unit
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the attach (player) <OBJECT>
|
||||
* 1: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 2: Name of the attachable item <STRING>
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the attach (player) <OBJECT>
|
||||
* 2: Array containing a string of the attachable item <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
@ -17,12 +17,14 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_unit,_attachToVehicle,_itemName);
|
||||
PARAMS_3(_attachToVehicle,_unit,_args);
|
||||
|
||||
private ["_item", "_itemVehClass", "_onAtachText", "_selfAttachPosition"];
|
||||
|
||||
_itemName = [_args, 0, ""] call CBA_fnc_defaultParam;
|
||||
|
||||
//Sanity Check (_unit has item in inventory, not over attach limit)
|
||||
if !([_unit, _attachToVehicle, _itemName] call FUNC(canAttach)) exitWith {ERROR("Tried to attach, but check failed");};
|
||||
|
||||
private ["_itemVehClass", "_onAtachText", "_selfAttachPosition"];
|
||||
if ((_itemName == "") || {!(_this call FUNC(canAttach))}) exitWith {ERROR("Tried to attach, but check failed");};
|
||||
|
||||
_itemVehClass = "";
|
||||
_onAtachText = "";
|
||||
|
@ -3,9 +3,9 @@
|
||||
* Check if a unit can attach a specific item.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the attach (player) <OBJECT>
|
||||
* 1: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 2: Name of the attachable item <STRING><OPTIONAL>
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the attach (player) <OBJECT>
|
||||
* 2: Array empty or containing a string of the attachable item <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
@ -17,12 +17,16 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_attachToVehicle);
|
||||
DEFAULT_PARAM(2,_item,"");
|
||||
PARAMS_3(_attachToVehicle,_player,_args);
|
||||
|
||||
private ["_attachLimit", "_attachedObjects"];
|
||||
private ["_itemName", "_attachLimit", "_attachedObjects"];
|
||||
|
||||
_attachLimit = [10, 1] select (_unit == _attachToVehicle);
|
||||
_itemName = [_args, 0, ""] call CBA_fnc_defaultParam;
|
||||
_attachLimit = [6, 1] select (_player == _attachToVehicle);
|
||||
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
||||
|
||||
canStand _unit && {alive _attachToVehicle} && {count _attachedObjects < _attachLimit} && {_item in (itemsWithMagazines _unit + [""])}
|
||||
_ret = (canStand _player) && {alive _attachToVehicle} && {(count _attachedObjects) < _attachLimit} && {_itemName in ((itemsWithMagazines _player) + [""])};
|
||||
|
||||
systemChat format ["[%1] Checking = %2", _itemName, _ret ];
|
||||
x = _this;
|
||||
_ret
|
||||
|
@ -3,8 +3,8 @@
|
||||
* Check if a unit has an item attached and if it can remove that item.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the detaching (player) <STRING>
|
||||
* 1: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 0: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the detaching (player) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_attachToVehicle);
|
||||
PARAMS_2(_attachToVehicle,_unit);
|
||||
|
||||
private ["_attachedObjects", "_inRange"];
|
||||
|
||||
|
@ -3,20 +3,20 @@
|
||||
* Detach an item from a unit
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the attaching (player) <STRING>
|
||||
* 1: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 0: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the detaching (player) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
* [car, bob] call ace_attach_fnc_detach
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_attachToVehicle);
|
||||
PARAMS_2(_attachToVehicle,_unit);
|
||||
|
||||
private ["_attachedObjects", "_attachedItems"];
|
||||
|
||||
|
51
addons/attach/functions/fnc_getChildrenAttachActions.sqf
Normal file
51
addons/attach/functions/fnc_getChildrenAttachActions.sqf
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: Garth de Wet (LH), PabstMirror
|
||||
* Show the ammo counts for a static weapon.
|
||||
* Called from "insertChildren" on interact_menu
|
||||
*
|
||||
* Argument:
|
||||
* 0: Target <OBJECT>
|
||||
* 1: Player <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* ChildActiosn<ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [player, player] call ace_attach_fnc_getChildrenAttachActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_target,_player);
|
||||
|
||||
_listed = [];
|
||||
_actions = [];
|
||||
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_listed pushBack _x;
|
||||
_item = ConfigFile >> "CfgMagazines" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_displayName = getText(_item >> "displayName");
|
||||
_picture = getText(_item >> "picture");
|
||||
_action = [_x, _displayName, _picture, {_this call FUNC(attach)}, {_this call FUNC(canAttach)}, {}, [_x]] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _target];
|
||||
};
|
||||
};
|
||||
} forEach (magazines _player);
|
||||
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_listed pushBack _x;
|
||||
_item = ConfigFile >> "CfgWeapons" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_displayName = getText(_item >> "displayName");
|
||||
_picture = getText(_item >> "picture");
|
||||
_action = [_x, _displayName, _picture, {_this call FUNC(attach)}, {_this call FUNC(canAttach)}, {}, _x] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _target];
|
||||
};
|
||||
};
|
||||
} forEach (items _player);
|
||||
|
||||
_actions
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Author: Garth de Wet (LH)
|
||||
* Opens the UI for attaching objects.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <STRING>
|
||||
* 1: target <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actions", "_attachables", "_item"];
|
||||
|
||||
PARAMS_2(_unit,_target);
|
||||
|
||||
GVAR(attachTarget) = _target;
|
||||
_listed = [];
|
||||
_attachables = magazines _unit;
|
||||
_actions = [localize "STR_ACE_Attach_AttachDetach", localize "STR_ACE_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu);
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_item = ConfigFile >> "CfgMagazines" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_actions = [
|
||||
_actions,
|
||||
getText(_item >> "displayName"),
|
||||
getText(_item >> "picture"),
|
||||
_x
|
||||
] call EFUNC(interaction,addSelectableItem);
|
||||
};
|
||||
_listed pushBack _x;
|
||||
};
|
||||
} forEach _attachables;
|
||||
_attachables = items _unit;
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_item = ConfigFile >> "CfgWeapons" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_actions = [
|
||||
_actions,
|
||||
getText(_item >> "displayName"),
|
||||
getText(_item >> "picture"),
|
||||
_x
|
||||
] call EFUNC(interaction,addSelectableItem);
|
||||
};
|
||||
_listed pushBack _x;
|
||||
};
|
||||
} forEach _attachables;
|
||||
|
||||
[
|
||||
_actions,
|
||||
{
|
||||
[ACE_player, GVAR(attachTarget), _this] call FUNC(attach);
|
||||
call EFUNC(interaction,hideMenu);
|
||||
},
|
||||
{
|
||||
call EFUNC(interaction,hideMenu);
|
||||
}
|
||||
] call EFUNC(interaction,openSelectMenu);
|
@ -92,7 +92,7 @@ _closeInDistance = (_closeInMax + _closeInMin) / 2;
|
||||
deleteVehicle _setupObject;
|
||||
|
||||
//Checks
|
||||
if (((_startDistanceFromCenter - _closeInDistance) < 0.1) || {!([_placer,_attachToVehicle,_itemClassname] call FUNC(canAttach))}) exitWith {
|
||||
if (((_startDistanceFromCenter - _closeInDistance) < 0.1) || {!([_attachToVehicle, _placer, _itemClassname] call FUNC(canAttach))}) exitWith {
|
||||
TRACE_2("no valid spot found",_closeInDistance,_startDistanceFromCenter);
|
||||
[localize "STR_ACE_Attach_Failed"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user