2015-07-19 01:25:52 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike, voiper
|
|
|
|
* Handles the spectator UI compass
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Parameters <ANY>
|
|
|
|
* 1: PFH handle <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None <NIL>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-07-19 12:40:08 +00:00
|
|
|
* [ace_spectator_fnc_handleCompass, 0, _display] call CBA_fnc_addPerFrameHandler;
|
2015-07-19 01:25:52 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["_display"];
|
|
|
|
|
2015-07-24 18:02:27 +00:00
|
|
|
// Kill PFH when compass hidden (or display is closed)
|
|
|
|
if (isNil QGVAR(compHandler)) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
|
2015-07-19 12:40:08 +00:00
|
|
|
|
2015-07-19 01:25:52 +00:00
|
|
|
private ["_compass","_NE","_ES","_SW","_WN","_compassW","_degree","_heading","_offset","_positions","_sequence"];
|
|
|
|
|
|
|
|
_compass = _display displayCtrl IDC_COMP;
|
|
|
|
|
|
|
|
_NE = _compass controlsGroupCtrl IDC_COMP_0;
|
|
|
|
_ES = _compass controlsGroupCtrl IDC_COMP_90;
|
|
|
|
_SW = _compass controlsGroupCtrl IDC_COMP_180;
|
|
|
|
_WN = _compass controlsGroupCtrl IDC_COMP_270;
|
|
|
|
|
|
|
|
_compassW = (ctrlPosition _compass) select 2;
|
|
|
|
_degree = _compassW / 180;
|
|
|
|
|
|
|
|
// Get direction of screen rather than object (accounts for unit freelook)
|
|
|
|
_heading = (positionCameraToWorld [0,0,1]) vectorDiff (positionCameraToWorld [0,0,0]);
|
|
|
|
_heading = (((_heading select 0) atan2 (_heading select 1)) + 360) % 360;
|
|
|
|
_offset = -(_heading % 90) * _degree;
|
|
|
|
|
|
|
|
_positions = [
|
|
|
|
[_compassW * -0.5 + _offset, 0],
|
|
|
|
[_offset, 0],
|
|
|
|
[_compassW * 0.5 + _offset, 0],
|
|
|
|
[_compassW + _offset, 0]
|
|
|
|
];
|
|
|
|
|
|
|
|
_sequence = if (_heading < 90) then {
|
|
|
|
[_SW, _WN, _NE, _ES]
|
|
|
|
} else {
|
|
|
|
if (_heading < 180) then {
|
|
|
|
[_WN, _NE, _ES, _SW]
|
|
|
|
} else {
|
|
|
|
if (_heading < 270) then {
|
|
|
|
[_NE, _ES, _SW, _WN]
|
|
|
|
} else {
|
|
|
|
[_ES, _SW, _WN, _NE]
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
_x ctrlSetPosition (_positions select _forEachIndex);
|
|
|
|
_x ctrlCommit 0;
|
|
|
|
} forEach _sequence;
|