diff --git a/addons/editor/XEH_PREP.hpp b/addons/editor/XEH_PREP.hpp index ba8e181f0..6f8b6ec76 100644 --- a/addons/editor/XEH_PREP.hpp +++ b/addons/editor/XEH_PREP.hpp @@ -14,4 +14,5 @@ PREP(handleSearchKeyUp); PREP(handleSideButtons); PREP(handleTreeButtons); PREP(handleUnload); +PREP(moveCamToSelection); PREP(pingCurators); diff --git a/addons/editor/functions/fnc_handleKeyDown.sqf b/addons/editor/functions/fnc_handleKeyDown.sqf index 319ca3b59..196203e32 100644 --- a/addons/editor/functions/fnc_handleKeyDown.sqf +++ b/addons/editor/functions/fnc_handleKeyDown.sqf @@ -18,6 +18,17 @@ params ["_display", "_keyCode"]; +if ( + GVAR(moveCamToSelection) > 0 + && {inputAction "curatorLockCameraTo" == 0} + && {_keyCode in actionKeys "curatorMoveCamTo"} + && {count SELECTED_OBJECTS > 0} +) exitWith { + [] call FUNC(moveCamToSelection); + + true +}; + if (_keyCode in actionKeys "curatorPingView" && {!isNil QGVAR(pingTarget)} && {isNil QGVAR(pingViewed)}) exitWith { if (GVAR(pingTarget) isEqualType objNull) then { private _distance = 0.5 * sizeOf typeOf GVAR(pingTarget) max 25; diff --git a/addons/editor/functions/fnc_moveCamToSelection.sqf b/addons/editor/functions/fnc_moveCamToSelection.sqf new file mode 100644 index 000000000..f6b0becd6 --- /dev/null +++ b/addons/editor/functions/fnc_moveCamToSelection.sqf @@ -0,0 +1,53 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Moves the curator camera to the selected object. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call zen_editor_fnc_moveCamToSelection + * + * Public: No + */ + +#define FOCUS_ALT 1 +#define FOCUS_CQB 2 +#define FOCUS_ALTCQB 3 + +private _selectedObjects = SELECTED_OBJECTS; +if (count _selectedObjects == 0) exitWith {}; + +private _selectedObject = _selectedObjects select 0; +private _objectPos = getPosWorld _selectedObject; +private _objectDir = getDir _selectedObject; +((0 boundingBoxReal _selectedObject) select 1) params ["", "_y", "_z"]; + +private _minDistance = switch (GVAR(moveCamToSelection)) do { + case (FOCUS_ALT): { + 20 + }; + case (FOCUS_CQB): { + 0.5 + }; + case (FOCUS_ALTCQB): { + // Toggle between far and close views on subsequent activations with the same object selected + if (isNil QGVAR(curatorMovedCamTo) || {_selectedObject != GVAR(curatorMovedCamTo)}) then { + GVAR(curatorMovedCamTo) = _selectedObject; + 20 + } else { + GVAR(curatorMovedCamTo) = nil; + 0.5 + } + }; +}; + +private _curatorPos = _objectPos getPos [_minDistance max _y, _objectDir + 180]; +_curatorPos set [2, (_objectPos select 2) + (_minDistance max _z)]; +curatorCamera setPosASL _curatorPos; +curatorCamera setDir _objectDir; +curatorCamera setVectorUp (vectorDir curatorCamera vectorAdd [0, 0, 1 + 1 / _minDistance]); diff --git a/addons/editor/initSettings.sqf b/addons/editor/initSettings.sqf index 5fbe4fe59..1952d007e 100644 --- a/addons/editor/initSettings.sqf +++ b/addons/editor/initSettings.sqf @@ -78,3 +78,12 @@ true, true ] call CBA_fnc_addSetting; + +[ + QGVAR(moveCamToSelection), + "LIST", + ["str_usract_curator_move_cam", LSTRING(MoveCamToSelection_Description)], + [ELSTRING(main,DisplayName), ELSTRING(camera,DisplayName)], + [[0, 1, 2, 3], ["str_a3_cfgroles_default0", LSTRING(MoveCamToSelection_Alternate), LSTRING(MoveCamToSelection_CQB), LSTRING(MoveCamToSelection_AlternateCQB)], 3], + false +] call CBA_fnc_addSetting; diff --git a/addons/editor/stringtable.xml b/addons/editor/stringtable.xml index 307f0c062..a6e8f39c3 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -419,5 +419,20 @@ Makes selected AI units start or stop moving. Does not affect aiming or shooting. Similar to "Hold Position" in RTS games. + + Focus Object Mode + + + Behaviour for "Move camera to selected entity" with an object selected.\nDefault: Base game behaviour.\nAlternate: 20 m above and behind object.\nCQB: Top-rear of object bounding box, useful for units inside buildings.\nAlternate + CQB: Switch between views on subsequent activations. + + + Alternate + + + CQB + + + Alternate + CQB +