add drop dragged object action

This commit is contained in:
commy2 2015-03-16 20:09:54 +01:00
parent 27404fed1b
commit 2da0eee1e2
5 changed files with 28 additions and 22 deletions

View File

@ -3,6 +3,7 @@
ADDON = false;
PREP(canDrag);
PREP(canDrop);
PREP(dragObject);
PREP(dragObjectPFH);
PREP(dropObject);

View File

@ -0,0 +1 @@
true

View File

@ -33,19 +33,29 @@ _position = _position vectorAdd [0, 0, _offset];
_target attachTo [_unit, _position];
_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(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
[FUNC(dragObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;

View File

@ -18,9 +18,7 @@ _unit = _this select 0;
_target = _this select 1;
// remove scroll wheel action
/*
_this removeAction (_this getVariable ["AGM_Drag_ReleaseActionID", -1]);
*/
_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]);
// play release animation
_unit playAction "released";
@ -29,6 +27,7 @@ _unit playAction "released";
detach _target;
_unit setVariable [QGVAR(isDragging), false, true];
_unit setVariable [QGVAR(draggedObject), objNull, true];
// make object accesable for other units
[objNull, _target, true] call EFUNC(common,claim);

View File

@ -48,10 +48,5 @@ if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses) = _initializedClasses;
private ["_name", "_icon", "_selection", "_statement", "_condition"];
_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);
[_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);