diff --git a/addons/spottingscope/CfgEventHandlers.hpp b/addons/spottingscope/CfgEventHandlers.hpp index 13d369b097..b34b3ac099 100644 --- a/addons/spottingscope/CfgEventHandlers.hpp +++ b/addons/spottingscope/CfgEventHandlers.hpp @@ -7,13 +7,13 @@ class Extended_PreStart_EventHandlers { class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; class Extended_PostInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_postInit) ); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; diff --git a/addons/spottingscope/CfgVehicles.hpp b/addons/spottingscope/CfgVehicles.hpp index f45173ae31..f5747660db 100644 --- a/addons/spottingscope/CfgVehicles.hpp +++ b/addons/spottingscope/CfgVehicles.hpp @@ -68,6 +68,8 @@ class CfgVehicles { getOutAction = "GetOutLow"; class Turrets: Turrets { class MainTurret: MainTurret { + turretInfoType = QGVAR(RscUnitInfo_SpottingScope); + minTurn = -45; maxTurn = 45; initTurn = 0; @@ -78,7 +80,7 @@ class CfgVehicles { weapons[] = {}; magazines[] = {}; gunnerOpticsColor[] = {1,1,1,1}; - gunnerOpticsmodel = QPATHTOF(data\m144_optic.p3d); + gunnerOpticsmodel = "\A3\Weapons_F\empty"; //QPATHTOF(data\m144_optic.p3d); gunnerOpticsEffect[] = {"OpticsCHAbera1","OpticsBlur2"}; gunnerOutOpticsShowCursor = 0; gunnerOpticsShowCursor = 0; diff --git a/addons/spottingscope/RscInGameUI.hpp b/addons/spottingscope/RscInGameUI.hpp new file mode 100644 index 0000000000..6d5dad7b1f --- /dev/null +++ b/addons/spottingscope/RscInGameUI.hpp @@ -0,0 +1,68 @@ + +class RscOpticsValue; +class RscMapControl; +class RscText; + +class RscInGameUI { + class RscUnitInfo; + class GVAR(RscUnitInfo_SpottingScope): RscUnitInfo { + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); uinamespace setVariable [ARR_2(QUOTE(QUOTE(dlgSpottingScope)),_this select 0)]); + controls[] = {"CA_FOVMode","ScriptedReticleHelper","Body","Reticle","trippleHeadLeft","trippleHeadRight"}; // don't change this order + + class CA_FOVMode: RscOpticsValue { // idea by Taosenai. Apparently this can be used via isNil check to determine wheter the scope or the kolimator is used + idc = 154; + style = 2; + colorText[] = {0,0,0,0}; + x = 0; + y = 0; + w = 0; + h = 0; + }; + + class ScriptedReticleHelper: RscMapControl { + onDraw = QUOTE(ctrlParent (_this select 0) call FUNC(animateReticle)); + idc = -1; + w = 0; + h = 0; + }; + + class Reticle: RscText { + idc = IDC_RETICLE; + style = 48; + size = 0; + sizeEx = 1; + text = QPATHTOF(rsc\spotting_scope_body_co.paa); + colorText[] = {1,1,1,1}; + colorBackground[] = {0,0,0,0}; + x = POS_X; + y = POS_Y; + w = POS_W; + h = POS_H; + }; + + class Body: Reticle { + idc = IDC_BODY; + text = QPATHTOF(rsc\spotting_scope_reticle_co.paa); + x = POS_X; + y = POS_Y; + w = POS_W; + h = POS_H; + }; + + //These are just black side panels to cover the areas that the optics p3d doesn't cover + //It will ONLY effect tripple head users as (safezoneX == safeZoneXAbs) for everyone else + class trippleHeadLeft: RscText { + idc = IDC_BLACK_LEFT; + x = "safeZoneXAbs"; + Y = "safezoneY"; + W = "(safezoneX - safeZoneXAbs) * ((getResolution select 4)/(16/3))"; + H = "safeZoneH"; + colorBackground[] = {0,0,0,1}; + }; + + class trippleHeadRight: trippleHeadLeft { + idc = IDC_BLACK_RIGHT; + x = "safeZoneXAbs + safeZoneWAbs - (safezoneX - safeZoneXABS) * ((getResolution select 4)/(16/3))"; + }; + }; +}; diff --git a/addons/spottingscope/XEH_PREP.hpp b/addons/spottingscope/XEH_PREP.hpp index ebb99df96b..9839872360 100644 --- a/addons/spottingscope/XEH_PREP.hpp +++ b/addons/spottingscope/XEH_PREP.hpp @@ -1,3 +1,4 @@ PREP(pickup); PREP(place); +PREP(animateReticle); diff --git a/addons/spottingscope/config.cpp b/addons/spottingscope/config.cpp index a92f91ec50..f69e2d6fff 100644 --- a/addons/spottingscope/config.cpp +++ b/addons/spottingscope/config.cpp @@ -17,3 +17,5 @@ class CfgPatches { #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" #include "CfgMoves.hpp" + +#include "RscInGameUI.hpp" diff --git a/addons/spottingscope/data/PSO_ring.paa b/addons/spottingscope/data/PSO_ring.paa deleted file mode 100644 index e1502aa5e2..0000000000 Binary files a/addons/spottingscope/data/PSO_ring.paa and /dev/null differ diff --git a/addons/spottingscope/data/scopering.paa b/addons/spottingscope/data/scopering.paa deleted file mode 100644 index ecf236b025..0000000000 Binary files a/addons/spottingscope/data/scopering.paa and /dev/null differ diff --git a/addons/spottingscope/functions/fnc_animateReticle.sqf b/addons/spottingscope/functions/fnc_animateReticle.sqf new file mode 100644 index 0000000000..913a0bbd02 --- /dev/null +++ b/addons/spottingscope/functions/fnc_animateReticle.sqf @@ -0,0 +1,65 @@ +/* + * Author: commy2 + * Animate scripted reticle of spotting scope. + * + * Arguments: + * 0: Reticles RSC info display + * + * Return value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +disableSerialization; + +params ["_display"]; systemChat str _display; + +// check if optics are used +// hide all controls otherwise +private _isUsingOptic = ctrlShown (_display displayCtrl 154); + +(_display displayCtrl IDC_BLACK_LEFT) ctrlShow _isUsingOptic; +(_display displayCtrl IDC_BLACK_RIGHT) ctrlShow _isUsingOptic; + +// animate reticle +private _ctrlReticle = _display displayCtrl IDC_RETICLE; +private _ctrlBody = _display displayCtrl IDC_BODY; + +_ctrlReticle ctrlShow _isUsingOptic; +_ctrlBody ctrlShow _isUsingOptic; + + + +/* + +private _unit = call CBA_fnc_currentUnit; + +if (currentWeapon _unit != primaryWeapon _unit || {_scope != primaryWeaponItems _unit select 2}) exitWith { + _control ctrlShow false; + + [_this select 1] call CBA_fnc_removePerFrameHandler +}; + +if (cameraView != "GUNNER") exitWith { + _control ctrlShow false; +}; + +private ["_size", "_sizeX", "_sizeY"]; + +_size = ([0.5,0.5] distance worldToScreen positionCameraToWorld [0,1,1]) * (getResolution select 5); + +_sizeX = _size/4; +_sizeY = _sizeX*safezoneW/safezoneH; + +_control ctrlSetPosition [ + safezoneX+0.5*safezoneW-0.5*_sizeX, + safezoneY+0.5*safezoneH-0.5*_sizeY, + _sizeX, + _sizeY +]; +_control ctrlCommit 0; +_control ctrlShow true; + + diff --git a/addons/spottingscope/rsc/spotting_scope_body_co.paa b/addons/spottingscope/rsc/spotting_scope_body_co.paa new file mode 100644 index 0000000000..71e1984c6e Binary files /dev/null and b/addons/spottingscope/rsc/spotting_scope_body_co.paa differ diff --git a/addons/spottingscope/rsc/spotting_scope_reticle_co.paa b/addons/spottingscope/rsc/spotting_scope_reticle_co.paa new file mode 100644 index 0000000000..a2d299d937 Binary files /dev/null and b/addons/spottingscope/rsc/spotting_scope_reticle_co.paa differ diff --git a/addons/spottingscope/script_component.hpp b/addons/spottingscope/script_component.hpp index 48f14b7398..bb1484a2ad 100644 --- a/addons/spottingscope/script_component.hpp +++ b/addons/spottingscope/script_component.hpp @@ -15,3 +15,15 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + +#define IDC_RETICLE 10000 +#define IDC_BODY 10001 +#define IDC_BLACK_LEFT 10002 +#define IDC_BLACK_RIGHT 10003 + +#define SIZEX 0.75/(getResolution select 5) + +#define POS_X QUOTE(safezoneX + 0.5 * safezoneW - 0.5 * SIZEX) +#define POS_Y QUOTE(safezoneY + 0.5 * safezoneH - 0.5 * SIZEX * 4/3) +#define POS_W QUOTE(SIZEX) +#define POS_H QUOTE(SIZEX * 4/3)