Dragging - Add possiblity to rotate a carried object (#7640)

* Add possiblity to rotate a carried object

* simplify the code by using cba_events_control instead of a custom set variable

* le ACE and don't save frames
This commit is contained in:
Jo David 2020-04-20 17:45:59 +02:00 committed by GitHub
parent 21c927195a
commit 3b15014099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 45 deletions

View File

@ -53,9 +53,3 @@ class Extended_Killed_EventHandlers {
};
};
};
class Extended_DisplayLoad_EventHandlers {
class RscDisplayMission {
ADDON = QUOTE(_this call COMPILE_FILE(XEH_missionDisplayLoad));
};
};

View File

@ -1,5 +0,0 @@
#include "script_component.hpp"
params ["_display"];
_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];

View File

@ -27,13 +27,16 @@ if (isNil "ACE_maxWeightCarry") then {
// handle waking up dragged unit and falling unconscious while dragging
["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler;
// display event handler
["MouseZChanged", {_this select 1 call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler;
//@todo Captivity?
//Add Keybind:
["ACE3 Common", QGVAR(drag), (localize LSTRING(DragKeybind)), {
if (!alive ACE_player) exitWith {false};
if !([ACE_player, objNull, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false};
// If we are drag/carrying something right now then just drop it:
if (ACE_player getVariable [QGVAR(isDragging), false]) exitWith {
[ACE_player, ACE_player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);

View File

@ -63,7 +63,7 @@ _unit setVariable [QGVAR(ReleaseActionID), [
if (_target isKindOf "CAManBase") then {
[localize LSTRING(Drop), "", ""] call EFUNC(interaction,showMouseHint);
} else {
[localize LSTRING(Drop), "", localize LSTRING(LowerRaise)] call EFUNC(interaction,showMouseHint);
[localize LSTRING(Drop), "", localize LSTRING(RaiseLowerRotate)] call EFUNC(interaction,showMouseHint);
};
// check everything

View File

@ -83,3 +83,6 @@ private _mass = _target getVariable [QGVAR(originalMass), 0];
if (_mass != 0) then {
[QEGVAR(common,setMass), [_target, _mass], _target] call CBA_fnc_targetEvent;
};
// reset temp direction
_target setVariable [QGVAR(carryDirection_temp), nil];

View File

@ -22,30 +22,42 @@ private _unit = ACE_player;
// EH is always assigned. Exit and don't overwrite input if not carrying
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {false};
// move carried item 15 cm per scroll interval
_scrollAmount = _scrollAmount * 0.15;
private _carriedItem = _unit getVariable [QGVAR(carriedObject), objNull];
//disabled for persons
if (_carriedItem isKindOf "CAManBase") exitWith {false};
private _position = getPosASL _carriedItem;
private _maxHeight = (_unit modelToWorldVisualWorld [0, 0, 0]) select 2;
if !(cba_events_control) then {
// raise/lower
_position set [2, ((_position select 2) + _scrollAmount min (_maxHeight + 1.5)) max _maxHeight];
// move carried item 15 cm per scroll interval
_scrollAmount = _scrollAmount * 0.15;
// move up/down object and reattach at current position
detach _carriedItem;
private _position = getPosASL _carriedItem;
private _maxHeight = (_unit modelToWorldVisualWorld [0, 0, 0]) select 2;
// Uses this method of selecting position because setPosATL did not have immediate effect
private _positionChange = _position vectorDiff (getPosASL _carriedItem);
private _selectionPosition = _unit worldToModel (ASLtoAGL getPosWorld _carriedItem);
_selectionPosition = _selectionPosition vectorAdd _positionChange;
_carriedItem attachTo [_unit, _selectionPosition];
_position set [2, ((_position select 2) + _scrollAmount min (_maxHeight + 1.5)) max _maxHeight];
//reset the carry direction
private _direction = _carriedItem getVariable [QGVAR(carryDirection), 0];
[QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent;
// move up/down object and reattach at current position
detach _carriedItem;
// Uses this method of selecting position because setPosATL did not have immediate effect
private _positionChange = _position vectorDiff (getPosASL _carriedItem);
private _selectionPosition = _unit worldToModel (ASLtoAGL getPosWorld _carriedItem);
_selectionPosition = _selectionPosition vectorAdd _positionChange;
_carriedItem attachTo [_unit, _selectionPosition];
//reset the carry direction
private _direction = _carriedItem getVariable [QGVAR(carryDirection_temp), _carriedItem getVariable [QGVAR(carryDirection), 0]];
[QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent;
} else {
// rotate
private _direction = _carriedItem getVariable [QGVAR(carryDirection_temp), _carriedItem getVariable [QGVAR(carryDirection), 0]];
_scrollAmount = _scrollAmount * 10;
_direction = _direction + _scrollAmount;
[QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent;
_carriedItem setVariable [QGVAR(carryDirection_temp), _direction];
};
true

View File

@ -86,21 +86,9 @@
<Chinesesimp>背起</Chinesesimp>
<Turkish>Taşı</Turkish>
</Key>
<Key ID="STR_ACE_Dragging_LowerRaise">
<English>Raise/Lower</English>
<German>Heben/Senken</German>
<Polish>Wyżej/Niżej</Polish>
<Portuguese>Levantar/Abaixar</Portuguese>
<Russian>Поднять/Опустить</Russian>
<Czech>Zvýšit/Snížit</Czech>
<Italian>Alza/Abbassa</Italian>
<Spanish>Subir/Bajar</Spanish>
<French>Lever/Baisser</French>
<Japanese>上げる/下げる</Japanese>
<Korean>높이기/낮추기</Korean>
<Chinese>提高/下降</Chinese>
<Chinesesimp>提高/下降</Chinesesimp>
<Turkish>Yukarı/Aşağı</Turkish>
<Key ID="STR_ACE_Dragging_RaiseLowerRotate">
<English>Raise/Lower | (Ctrl + Scroll) Rotate</English>
<German>Heben/Senken | (Strg + Scrollen) Drehen</German>
</Key>
</Package>
</Project>

View File

@ -8,7 +8,7 @@
* 0: Left click text <STRING>
* 1: Right click text <STRING>
* 2: Scroll text <STRING> (default: "")
* 2: Extra icon/text pairs <ARRAY> (default: [])
* 3: Extra icon/text pairs <ARRAY> (default: [])
*
* Return Value:
* None