ACE3/addons/arsenal/functions/fnc_handleMouse.sqf
Josuan Albin 1994e301fd More various ace arsenal fixes (#6192)
* Compile stats on preInit

* Remove uneeded check in add/removeStat

* Remove perf profiler vars

They aren't required anymore

* Fix case issue in verifyLoadout, remove uneeded line

* Fix ace arsenal cam not working porperly underwater

By removing those checks the cam is allowed to clip through objects and work properly underwater, sounds like features to me :D

* Fix gunbag behavior in ace arsenal

Switching between gunbags will keep the weapon, switching to another backpack then back to a gunbag will also keep the weapon.

* Fix text scaling in the searchbars and loadout name edit boxes

Also made the text bigger by default
2018-04-12 10:44:23 -05:00

69 lines
2.4 KiB
Plaintext

/*
* Author: Karel Moricky, modified by Alganthe
* Update the camera position and pitch/bank.
* Modernized a bit, modified to fit the rewrite.
*
* Arguments:
* 0: Not used
* 1: Arguments <ARRAY>
* 1.1: Mouse area control <CONTROL>
* 1.2: Mouse X position <SCALAR>
* 1.3: Mouse Y position <SCALAR>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
#include "..\defines.hpp"
params ["", "_args"];
_args params ["_control", "_mouseX", "_mouseY"];
GVAR(cameraPosition) params ["_distance", "_dirH", "_dirV", "_helperPos"];
GVAR(mouseButtonState) params ["_LMB", "_RMB"];
if (count _LMB > 0) then {
_LMB params ["_LMBcursorX", "_LMBcursorY"];
private _dX = [(_mouseX - _LMBcursorX), (_LMBcursorX - _mouseX)] select GVAR(camInverted);
private _dY = [(_mouseY -_LMBcursorY), (_LMBcursorY - _mouseY)] select GVAR(camInverted);
GVAR(mouseButtonState) set [0,[_mouseX,_mouseY]];
private _centerBox = boundingboxreal GVAR(center);
private _centerSizeBottom = _centerBox select 0 select 2;
private _centerSizeUp = _centerBox select 1 select 2;
private _centerSize = sqrt ([_centerBox select 0 select 0,_centerBox select 0 select 1] distance [_centerBox select 1 select 0,_centerBox select 1 select 1]);
_helperPos = [_helperPos, _dX * _centerSize, _dirH - 90] call bis_fnc_relpos;
_helperPos = [
[0,0,((_helperPos select 2) - _dY * _centerSize) max _centerSizeBottom min _centerSizeUp],
([0,0,0] distance2D _helperPos) min _centerSize,
[0,0,0] getDir _helperPos
] call bis_fnc_relpos;
_helperPos set [2,(_helperPos select 2) max ((boundingboxreal GVAR(center) select 0 select 2) + 0.2)];
GVAR(cameraPosition) set [3,_helperPos];
};
if (count _RMB > 0) then {
_RMB params ["_RMBcursorX", "_RMBcursorY"];
private _dX = (_RMBcursorX - _mouseX) * 0.75;
private _dY = (_RMBcursorY - _mouseY) * 0.75;
_helperPos = [
[0,0,_helperPos select 2],
[0,0,0] distance2D _helperPos,
([0,0,0] getDir _helperPos) - _dX * 360
] call bis_fnc_relpos;
GVAR(cameraPosition) set [1,(_dirH - _dX * 360)];
GVAR(cameraPosition) set [2,(_dirV - _dY * 100) max -89 min 89];
GVAR(cameraPosition) set [3,_helperPos];
GVAR(mouseButtonState) set [1,[_mouseX,_mouseY]];
};
if (!alive (GVAR(center)) || isnull GVAR(center)) then {
(ctrlParent _control) closeDisplay 2;
};