mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
add drop dragged object action
This commit is contained in:
parent
27404fed1b
commit
2da0eee1e2
@ -3,6 +3,7 @@
|
|||||||
ADDON = false;
|
ADDON = false;
|
||||||
|
|
||||||
PREP(canDrag);
|
PREP(canDrag);
|
||||||
|
PREP(canDrop);
|
||||||
PREP(dragObject);
|
PREP(dragObject);
|
||||||
PREP(dragObjectPFH);
|
PREP(dragObjectPFH);
|
||||||
PREP(dropObject);
|
PREP(dropObject);
|
||||||
|
1
addons/dragging/functions/fnc_canDrop.sqf
Normal file
1
addons/dragging/functions/fnc_canDrop.sqf
Normal file
@ -0,0 +1 @@
|
|||||||
|
true
|
@ -33,19 +33,29 @@ _position = _position vectorAdd [0, 0, _offset];
|
|||||||
_target attachTo [_unit, _position];
|
_target attachTo [_unit, _position];
|
||||||
_target setDir _direction;
|
_target setDir _direction;
|
||||||
|
|
||||||
// add scrollwheel action to release object
|
|
||||||
/*
|
|
||||||
_actionID = _unit getVariable ["AGM_Drag_ReleaseActionID", -1];
|
|
||||||
|
|
||||||
if (_actionID != -1) then {
|
|
||||||
_unit removeAction _actionID;
|
|
||||||
};
|
|
||||||
_actionID = _unit addAction [format ["<t color='#FF0000'>%1</t>", localize "STR_AGM_Drag_EndDrag"], "player call AGM_Drag_fnc_releaseObject;", nil, 20, false, true, "","player call AGM_Drag_fnc_isDraggingObject"];
|
|
||||||
|
|
||||||
_unit setVariable ["AGM_Drag_ReleaseActionID", _actionID];
|
|
||||||
*/
|
|
||||||
|
|
||||||
_unit setVariable [QGVAR(isDragging), true, true];
|
_unit setVariable [QGVAR(isDragging), true, true];
|
||||||
|
_unit setVariable [QGVAR(draggedObject), _target, true];
|
||||||
|
|
||||||
|
// add scrollwheel action to release object
|
||||||
|
private "_actionID";
|
||||||
|
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
||||||
|
|
||||||
|
if (_actionID != -1) then {
|
||||||
|
_unit removeAction _actionID;
|
||||||
|
};
|
||||||
|
|
||||||
|
_actionID = _unit addAction [
|
||||||
|
format ["<t color='#FF0000'>%1</t>", "STR_AGM_Drag_EndDrag"],
|
||||||
|
QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])] call FUNC(dropObject)),
|
||||||
|
nil,
|
||||||
|
20,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
"",
|
||||||
|
QUOTE(!isNull (_this getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)]))
|
||||||
|
];
|
||||||
|
|
||||||
|
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
|
||||||
|
|
||||||
// check everything
|
// check everything
|
||||||
[FUNC(dragObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
|
[FUNC(dragObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
@ -18,9 +18,7 @@ _unit = _this select 0;
|
|||||||
_target = _this select 1;
|
_target = _this select 1;
|
||||||
|
|
||||||
// remove scroll wheel action
|
// remove scroll wheel action
|
||||||
/*
|
_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]);
|
||||||
_this removeAction (_this getVariable ["AGM_Drag_ReleaseActionID", -1]);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// play release animation
|
// play release animation
|
||||||
_unit playAction "released";
|
_unit playAction "released";
|
||||||
@ -29,6 +27,7 @@ _unit playAction "released";
|
|||||||
detach _target;
|
detach _target;
|
||||||
|
|
||||||
_unit setVariable [QGVAR(isDragging), false, true];
|
_unit setVariable [QGVAR(isDragging), false, true];
|
||||||
|
_unit setVariable [QGVAR(draggedObject), objNull, true];
|
||||||
|
|
||||||
// make object accesable for other units
|
// make object accesable for other units
|
||||||
[objNull, _target, true] call EFUNC(common,claim);
|
[objNull, _target, true] call EFUNC(common,claim);
|
||||||
|
@ -48,10 +48,5 @@ if (_type in _initializedClasses) exitWith {};
|
|||||||
_initializedClasses pushBack _type;
|
_initializedClasses pushBack _type;
|
||||||
GVAR(initializedClasses) = _initializedClasses;
|
GVAR(initializedClasses) = _initializedClasses;
|
||||||
|
|
||||||
private ["_name", "_icon", "_selection", "_statement", "_condition"];
|
[_type, 0, ["ACE_MainActions", QGVAR(drag)], "drg", "", "", {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}, 2] call EFUNC(interact_menu,addClassAction);
|
||||||
|
[_type, 0, ["ACE_MainActions", QGVAR(drop)], "drp", "", "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}, 2] call EFUNC(interact_menu,addClassAction);
|
||||||
_name = "drag";
|
|
||||||
_icon = "";
|
|
||||||
_selection = "";
|
|
||||||
|
|
||||||
[_type, 0, ["ACE_MainActions", _name], _name, _icon, _selection, {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}, 2] call EFUNC(interact_menu,addClassAction);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user