ACE3/addons/spectator/functions/fnc_handleToolbar.sqf

55 lines
1.9 KiB
Plaintext
Raw Normal View History

2015-07-19 15:35:53 +00:00
/*
* Author: Karel Moricky, SilentSpike
* Handles the spectator UI toolbar values and applies them to the camera
*
* Arguments:
* 0: Parameters <ANY>
* 1: PFH handle <NUMBER>
*
* Return Value:
* None <NIL>
*
* Example:
* [ace_spectator_fnc_handleToolbar, 0, _display] call CBA_fnc_addPerFrameHandler;
*
* Public: No
*/
#include "script_component.hpp"
params ["_display"];
2015-07-24 18:02:27 +00:00
// Kill PFH when toolbar hidden (or display is closed)
if (isNil QGVAR(toolHandler)) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
2015-07-19 15:35:53 +00:00
2015-07-21 16:10:04 +00:00
private ["_name","_vision","_fov","_speed","_mode","_time","_toolbar"];
2015-07-19 22:03:40 +00:00
_toolbar = _display displayCtrl IDC_TOOL;
2015-07-19 15:35:53 +00:00
// Find all tool values
if (GVAR(camMode) == 0) then {
2015-07-21 16:10:04 +00:00
_vision = if (GVAR(camVision) >= 0) then {localize LSTRING(VisionThermal)} else { [localize LSTRING(VisionNight), localize LSTRING(VisionNormal)] select (GVAR(camVision) < -1) };
2015-07-19 19:26:26 +00:00
_fov = format ["%1x", floor(GVAR(camZoom) * 100) * 0.01];
2015-07-20 22:02:24 +00:00
_speed = format ["%1 m/s", floor(GVAR(camSpeed) * 100) * 0.01];
2015-07-19 15:35:53 +00:00
} else {
2015-07-21 16:10:04 +00:00
_vision = format ["%1 m", floor(getPosASL GVAR(camUnit) select 2)];
2015-07-24 14:53:08 +00:00
_fov = [side group GVAR(camUnit)] call BIS_fnc_sideName;
2015-07-20 17:13:13 +00:00
_speed = format ["%1 km/h", floor(speed GVAR(camUnit)) max 0];
2015-07-19 15:35:53 +00:00
};
2015-07-22 13:57:38 +00:00
if (isNull GVAR(camUnit)) then {
_name = localize "STR_VOICE_MASK_NONE";
} else {
2015-07-24 16:13:03 +00:00
_name = GETVAR(GVAR(camUnit),GVAR(uName),"");
2015-07-22 13:57:38 +00:00
};
2015-07-20 17:13:13 +00:00
_mode = [localize LSTRING(ViewFree),localize LSTRING(ViewInternal),localize LSTRING(ViewExternal)] select GVAR(camMode);
2015-07-19 15:35:53 +00:00
_time = [daytime,"HH:MM"] call BIS_fnc_timeToString;
// Update the UI tools
(_toolbar controlsGroupCtrl IDC_TOOL_CLOCK) ctrlSetText _time;
2015-07-21 16:10:04 +00:00
(_toolbar controlsGroupCtrl IDC_TOOL_VISION) ctrlSetText _vision;
2015-07-19 15:35:53 +00:00
(_toolbar controlsGroupCtrl IDC_TOOL_FOV) ctrlSetText _fov;
(_toolbar controlsGroupCtrl IDC_TOOL_NAME) ctrlSetText _name;
(_toolbar controlsGroupCtrl IDC_TOOL_SPEED) ctrlSetText _speed;
(_toolbar controlsGroupCtrl IDC_TOOL_VIEW) ctrlSetText _mode;