Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Move camera to object #709

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions addons/editor/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ PREP(handleSearchKeyUp);
PREP(handleSideButtons);
PREP(handleTreeButtons);
PREP(handleUnload);
PREP(moveCamToSelection);
PREP(pingCurators);
11 changes: 11 additions & 0 deletions addons/editor/functions/fnc_handleKeyDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
53 changes: 53 additions & 0 deletions addons/editor/functions/fnc_moveCamToSelection.sqf
Original file line number Diff line number Diff line change
@@ -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]);
9 changes: 9 additions & 0 deletions addons/editor/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
15 changes: 15 additions & 0 deletions addons/editor/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,5 +419,20 @@
<Key ID="STR_ZEN_Editor_ToggleAIPath_Description">
<English>Makes selected AI units start or stop moving. Does not affect aiming or shooting. Similar to "Hold Position" in RTS games.</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveCamToSelection">
<English>Focus Object Mode</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveCamToSelection_Description">
<English>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.</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveCamToSelection_Alternate">
<English>Alternate</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveCamToSelection_CQB">
<English>CQB</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveCamToSelection_AlternateCQB">
<English>Alternate + CQB</English>
</Key>
</Package>
</Project>
Loading