Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>