2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-06-12 04:08:55 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Helper function for updating the 2d and 3d scope controls
|
|
|
|
* Called from a dummy map controls onDraw.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Display (RscInGameUI for a weapon) <DISPLAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2016-06-12 04:08:55 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ACE_RscWeapon_Arco's Display] call ace_optics_fnc_onDrawScope2D
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-03 20:30:29 +00:00
|
|
|
|
|
|
|
disableSerialization;
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
params ["_display"];
|
2015-04-03 20:30:29 +00:00
|
|
|
|
|
|
|
// @todo, all weapon types
|
2016-06-12 04:08:55 +00:00
|
|
|
private _optic = (primaryWeaponItems ACE_player) select 2;
|
|
|
|
private _isPIP = (getText (configFile >> "CfgWeapons" >> _optic >> "ItemInfo" >> "modelOptics")) == QPATHTOF(models\ace_optics_pip.p3d);
|
2015-05-27 16:28:06 +00:00
|
|
|
|
|
|
|
if (_isPIP) then {
|
2016-06-12 04:08:55 +00:00
|
|
|
GVAR(pipLastFrame) = diag_frameno;
|
|
|
|
if (isNull GVAR(camera)) then {
|
|
|
|
if ((({_x != GVAR(camera)} count allMissionObjects "camera") > 0) || {!isNull curatorCamera}) exitWith {
|
|
|
|
TRACE_1("waiting for feature camera to end",GVAR(camera));
|
|
|
|
};
|
2016-06-12 06:53:03 +00:00
|
|
|
|
2016-06-12 04:08:55 +00:00
|
|
|
// PiP technique by BadBenson
|
2017-08-29 22:47:01 +00:00
|
|
|
GVAR(camera) = "camera" camCreate positionCameraToWorld [0, 0, 0];
|
2016-06-12 04:08:55 +00:00
|
|
|
GVAR(camera) camSetFov 0.7;
|
|
|
|
GVAR(camera) camSetTarget ACE_player;
|
|
|
|
GVAR(camera) camCommit 1;
|
|
|
|
|
2016-07-20 04:15:18 +00:00
|
|
|
QGVAR(rendertarget0) setPiPEffect [0];
|
|
|
|
GVAR(camera) cameraEffect ["INTERNAL", "BACK", QGVAR(rendertarget0)];
|
2016-06-12 04:08:55 +00:00
|
|
|
|
|
|
|
TRACE_2("created new pip camera",GVAR(camera),isNull GVAR(camera));
|
2016-06-12 06:53:03 +00:00
|
|
|
|
2017-08-29 22:47:01 +00:00
|
|
|
// Start a waitUntil to handle destruction after GVAR(pipLastFrame) is no longer updated
|
2016-06-12 04:08:55 +00:00
|
|
|
[{
|
|
|
|
(abs (diag_frameno - GVAR(pipLastFrame))) > 1
|
|
|
|
}, {
|
|
|
|
GVAR(camera) cameraEffect ["TERMINATE", "BACK"];
|
|
|
|
camDestroy GVAR(camera);
|
|
|
|
TRACE_2("destroyed pip camera",GVAR(camera),isNull GVAR(camera));
|
|
|
|
}, []] call CBA_fnc_waitUntilAndExecute;
|
|
|
|
};
|
2016-06-12 06:53:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//If we are not zoomed into the actual scope (not collimator)
|
|
|
|
if (!ctrlShown (_display displayCtrl 154)) exitWith {
|
|
|
|
(_display displayCtrl 1713001) ctrlShow false;
|
|
|
|
(_display displayCtrl 1713002) ctrlShow false;
|
|
|
|
(_display displayCtrl 1713005) ctrlShow false;
|
|
|
|
(_display displayCtrl 1713006) ctrlShow false;
|
|
|
|
(_display displayCtrl 1713010) ctrlShow false;
|
|
|
|
(_display displayCtrl 1713011) ctrlShow false;
|
|
|
|
};
|
2016-06-12 04:08:55 +00:00
|
|
|
|
2016-06-12 06:53:03 +00:00
|
|
|
if (_isPIP) then {
|
2017-08-29 22:47:01 +00:00
|
|
|
GVAR(camera) setPosATL positionCameraToWorld [0, 0, 0.4];
|
|
|
|
GVAR(camera) camPrepareTarget positionCameraToWorld [0, 0, 50];
|
2015-05-27 16:28:06 +00:00
|
|
|
GVAR(camera) camCommitPrepared 0;
|
|
|
|
|
|
|
|
// @todo, check if that needs to be done at all
|
|
|
|
if (cameraView == "GUNNER") then {
|
|
|
|
GVAR(camera) camsetFOV 0.7;
|
|
|
|
GVAR(camera) camcommit 0;
|
|
|
|
} else {
|
|
|
|
GVAR(camera) camsetFOV 0.01;
|
|
|
|
GVAR(camera) camcommit 0;
|
|
|
|
};
|
|
|
|
};
|
2015-04-03 20:30:29 +00:00
|
|
|
|
2017-08-29 22:47:01 +00:00
|
|
|
// Calculate lighting
|
2016-06-12 04:08:55 +00:00
|
|
|
private _dayOpacity = call EFUNC(common,ambientBrightness);
|
2017-08-29 22:47:01 +00:00
|
|
|
private _nightOpacity = [1, 0] select (_dayOpacity == 1);
|
2015-04-03 20:30:29 +00:00
|
|
|
|
|
|
|
// Apply lighting and make layers visible
|
2017-08-29 22:47:01 +00:00
|
|
|
(_display displayCtrl 1713001) ctrlSetTextColor [1, 1, 1, 1];
|
|
|
|
(_display displayCtrl 1713002) ctrlSetTextColor [1, 1, 1, [0, 1] select (_dayOpacity < 0.5)];
|
|
|
|
(_display displayCtrl 1713005) ctrlSetTextColor [1, 1, 1, _dayOpacity];
|
|
|
|
(_display displayCtrl 1713006) ctrlSetTextColor [1, 1, 1, _nightOpacity];
|
2015-04-03 20:30:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
(_display displayCtrl 1713001) ctrlCommit 0;
|
|
|
|
(_display displayCtrl 1713002) ctrlCommit 0;
|
|
|
|
(_display displayCtrl 1713005) ctrlCommit 0;
|
|
|
|
(_display displayCtrl 1713006) ctrlCommit 0;
|
2015-05-27 16:28:06 +00:00
|
|
|
*/
|
2015-04-03 20:30:29 +00:00
|
|
|
|
|
|
|
(_display displayCtrl 1713001) ctrlShow true;
|
|
|
|
(_display displayCtrl 1713002) ctrlShow true;
|
|
|
|
(_display displayCtrl 1713005) ctrlShow true;
|
|
|
|
(_display displayCtrl 1713006) ctrlShow true;
|
2015-05-27 16:28:06 +00:00
|
|
|
(_display displayCtrl 1713010) ctrlShow _isPIP;
|
|
|
|
(_display displayCtrl 1713011) ctrlShow _isPIP;
|