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 @@ -2,6 +2,7 @@ PREP(addGroupIcons);
PREP(addModIcons);
PREP(declutterEmptyTree);
PREP(fixSideButtons);
PREP(handleCuratorMoveCamTo);
PREP(handleKeyDown);
PREP(handleLoad);
PREP(handleModeButtons);
Expand Down
41 changes: 41 additions & 0 deletions addons/editor/functions/fnc_handleCuratorMoveCamTo.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Handles the behaviour of the curatorMoveCamTo user action.
*
* Arguments:
* None
*
* Return Value:
* Key handled <BOOLEAN>
*
* Example:
* [] call zen_editor_fnc_handleCuratorMoveCamTo
*
* Public: No
*/

private _selectedObjects = SELECTED_OBJECTS;
if (count _selectedObjects == 0) exitWith {false};

private _selectedObject = _selectedObjects select 0;
private _objectPos = getPosWorld _selectedObject;
private _objectDir = getDir _selectedObject;
((0 boundingBoxReal _selectedObject) select 1) params ["", "_y", "_z"];
private _minDistance = 20;

// 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;
} else {
_minDistance = 0.5;
GVAR(curatorMovedCamTo) = nil;
};

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]);

true
6 changes: 6 additions & 0 deletions addons/editor/initKeybinds.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
};
}, {}, [DIK_F, [false, true, true]]] call CBA_fnc_addKeybind; // Default: CTRL + ALT + F

[ELSTRING(main,DisplayName), QGVAR(curatorMoveCamTo), ["str_usract_curator_move_cam", "str_controls_tooltips_curator_move_cam"], {
if (!isNull curatorCamera) then {
[] call FUNC(handleCuratorMoveCamTo)
};
}, {}, [DIK_F, [false, false, false]]] call CBA_fnc_addKeybind; // Default: F
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike adding a separate keybind. Let's use the KeyDown EH to override the vanilla keybind. If we want to make this optional, could add a setting like "Move Camera To Behaviour" - maybe 3 options: default, CQB mode, and CQB + alternative far view.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok. Should this code go in camera instead of editor?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think editor.

Copy link
Member Author

@ampersand38 ampersand38 Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the setting belong under camera? see settings screenshot up top

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Normally, all the keybind handling is in editor component but I guess with the setting, it would make more sense to be under camera. Not really sure what option is the best.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I've implemented everything in editor, with the setting using the camera category.


[ELSTRING(main,DisplayName), QGVAR(orientTerrainNormal), ["str_3den_display3den_entitymenu_setatl_text", LSTRING(OrientTerrainNormal_Description)], {
if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then {
{
Expand Down