Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optics reticleSafezoneSize config entry #1142

Merged
merged 2 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions addons/optics/RscInGameUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ class RscInGameUI {
// 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";
x = safezoneXAbs;
y = safezoneY;
w = THIRD_SCREEN_WIDTH;
h = safezoneH;
colorBackground[] = {0,0,0,1};
};

class TrippleHeadRight: TrippleHeadLeft {
idc = IDC_BLACK_RIGHT;
x = "safeZoneXAbs + safeZoneWAbs - (safeZoneX - safeZoneXAbs) * ((getResolution select 4)/(16/3))";
x = safezoneXAbs + safezoneWAbs - THIRD_SCREEN_WIDTH;
};

class Magnification: CA_Zeroing {
Expand Down Expand Up @@ -87,10 +87,10 @@ class RscInGameUI {

class ReticleSafeZone: RscControlsGroupNoScrollbars {
idc = IDC_RETICLE_SAFEZONE;
x = RETICLE_SAFEZONE_LEFT;
y = RETICLE_SAFEZONE_TOP;
w = RETICLE_SAFEZONE_WIDTH;
h = RETICLE_SAFEZONE_HEIGHT;
x = RETICLE_SAFEZONE_DEFAULT_LEFT;
y = RETICLE_SAFEZONE_DEFAULT_TOP;
w = RETICLE_SAFEZONE_DEFAULT_WIDTH;
h = RETICLE_SAFEZONE_DEFAULT_HEIGHT;

class controls {
class Reticle: Reticle {};
Expand Down
2 changes: 2 additions & 0 deletions addons/optics/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ GVAR(OpticBodyTextureNight) = "";
GVAR(ppEffects) = [];
GVAR(manualReticleNightSwitch) = false;
GVAR(useReticleNight) = false;
GVAR(reticleSafezoneSize) = RETICLE_SAFEZONE_DEFAULT_SIZE;
GVAR(hidePeripheralVision) = false;

// Update optic info.
["weapon", {
Expand Down
7 changes: 4 additions & 3 deletions addons/optics/fnc_animateScriptedOptic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private _ctrlBodyNight = _display displayCtrl IDC_BODY_NIGHT;
private _ctrlBlackScope = _display displayCtrl IDC_BLACK_SCOPE;
private _ctrlBlackLeft = _display displayCtrl IDC_BLACK_LEFT;
private _ctrlBlackRight = _display displayCtrl IDC_BLACK_RIGHT;
private _ctrlReticleSafezone = _display displayCtrl IDC_RETICLE_SAFEZONE;
private _ctrlZeroing = _display displayCtrl 168;
private _ctrlMagnification = _display displayCtrl IDC_MAGNIFICATION;

Expand Down Expand Up @@ -124,12 +125,12 @@ if (_zoom >= 1) then {

GVAR(ReticleAdjust) set [2, _zoom];
private _reticleAdjust = linearConversion GVAR(ReticleAdjust);

private _sizeReticle = _reticleAdjust * _detailScaleFactor;
ctrlPosition _ctrlReticleSafezone params ["_reticleSafeZonePositionLeft", "_reticleSafeZonePositionTop"];

private _positionReticle = [
POS_X(_sizeReticle) - RETICLE_SAFEZONE_LEFT,
POS_Y(_sizeReticle) - RETICLE_SAFEZONE_TOP,
POS_X(_sizeReticle) - _reticleSafeZonePositionLeft,
POS_Y(_sizeReticle) - _reticleSafeZonePositionTop,
POS_W(_sizeReticle),
POS_H(_sizeReticle)
];
Expand Down
16 changes: 7 additions & 9 deletions addons/optics/fnc_animateScriptedOpticRecoil.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private _ctrlBodyNight = _display displayCtrl IDC_BODY_NIGHT;
private _ctrlBlackScope = _display displayCtrl IDC_BLACK_SCOPE;
private _ctrlBlackLeft = _display displayCtrl IDC_BLACK_LEFT;
private _ctrlBlackRight = _display displayCtrl IDC_BLACK_RIGHT;
private _ctrlReticleSafezone = _display displayCtrl IDC_RETICLE_SAFEZONE;

// Reduce the reticle movement as the player drops into lower, supported stances.
private _recoilCoef = SCOPE_RECOIL_COEF;
Expand All @@ -60,21 +61,18 @@ private _sizeBody = GVAR(OpticBodyTextureSize);

// Create and commit recoil effect.
private _reticleAdjust = 1;
private _reticleSafeZoneOffsetLeft = 0;
private _reticleSafeZoneOffsetTop = 0;
ctrlPosition _ctrlReticleSafezone params ["_reticleSafeZonePositionLeft", "_reticleSafeZonePositionTop"];

if (!isNull (_display displayCtrl IDC_RETICLE_SAFEZONE)) then {
if (!isNull _ctrlReticleSafezone) then {
_reticleAdjust = linearConversion GVAR(ReticleAdjust);
_reticleSafeZoneOffsetLeft = - RETICLE_SAFEZONE_LEFT;
_reticleSafeZoneOffsetTop = - RETICLE_SAFEZONE_TOP;
};

private _detailScaleFactor = _display getVariable [QGVAR(DetailScaleFactor), 1];
private _size = _reticleAdjust * _detailScaleFactor + _recoilScope;

private _positionReticle = [
POS_X(_size + _reticleShiftX) + _reticleSafeZoneOffsetLeft,
POS_Y(_size + _reticleShiftY) + _reticleSafeZoneOffsetTop,
POS_X(_size + _reticleShiftX) - _reticleSafeZonePositionLeft,
POS_Y(_size + _reticleShiftY) - _reticleSafeZonePositionTop,
POS_W(_size),
POS_H(_size)
];
Expand All @@ -101,8 +99,8 @@ _ctrlBodyNight ctrlCommit 0;
private _sizeReticle = _reticleAdjust * _detailScaleFactor;

_positionReticle = [
POS_X(_sizeReticle) + _reticleSafeZoneOffsetLeft,
POS_Y(_sizeReticle) + _reticleSafeZoneOffsetTop,
POS_X(_sizeReticle) - _reticleSafeZonePositionLeft,
POS_Y(_sizeReticle) - _reticleSafeZonePositionTop,
POS_W(_sizeReticle),
POS_H(_sizeReticle)
];
Expand Down
29 changes: 26 additions & 3 deletions addons/optics/fnc_loadScriptedOptic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Description:

Parameters:
_display - CBA weapon info display <DISPLAY>
_init - Begin draw script, true when called from onLoad event <BOOLEAN>

Returns:
Nothing.
Expand All @@ -20,9 +21,9 @@ Author:
commy2
---------------------------------------------------------------------------- */

params [["_display", displayNull], ["_initDisplay", false]];
params [["_display", displayNull], ["_init", false]];

if (_initDisplay) then {
if (_init) then {
private _unit = call CBA_fnc_currentUnit;

_unit call FUNC(updateOpticInfo);
Expand All @@ -35,6 +36,7 @@ private _ctrlBodyNight = _display displayCtrl IDC_BODY_NIGHT;
private _ctrlBlackScope = _display displayCtrl IDC_BLACK_SCOPE;
private _ctrlBlackLeft = _display displayCtrl IDC_BLACK_LEFT;
private _ctrlBlackRight = _display displayCtrl IDC_BLACK_RIGHT;
private _ctrlReticleSafezone = _display displayCtrl IDC_RETICLE_SAFEZONE;
private _ctrlMagnification = _display displayCtrl IDC_MAGNIFICATION;

_ctrlRedDot ctrlShow false;
Expand Down Expand Up @@ -72,7 +74,28 @@ _ctrlBodyNight ctrlSetText GVAR(OpticBodyTextureNight);
_ctrlBodyNight ctrlSetPosition _bodyPosition;
_ctrlBodyNight ctrlCommit 0;

if (_initDisplay) then {
_ctrlReticleSafezone ctrlSetPosition [
POS_X(GVAR(reticleSafezoneSize)),
POS_Y(GVAR(reticleSafezoneSize)),
POS_W(GVAR(reticleSafezoneSize)),
POS_H(GVAR(reticleSafezoneSize))
];
_ctrlReticleSafezone ctrlCommit 0;

private _width = THIRD_SCREEN_WIDTH;

if (GVAR(hidePeripheralVision)) then {
_width = 0.5 - (_bodyPosition select 2)/2 - safezoneXAbs;
};

_ctrlBlackLeft ctrlSetPositionW _width;
_ctrlBlackLeft ctrlCommit 0;

_ctrlBlackRight ctrlSetPositionW _width;
_ctrlBlackRight ctrlSetPositionX (safezoneXAbs + safezoneWAbs - _width);
_ctrlBlackRight ctrlCommit 0;

if (_init) then {
[missionNamespace, "Draw3D", {
if (isNull _thisArgs) exitWith {
removeMissionEventHandler ["Draw3D", _thisId];
Expand Down
8 changes: 8 additions & 0 deletions addons/optics/fnc_updateOpticInfo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ if (GVAR(OpticBodyTextureNight) isEqualTo "") then {

GVAR(manualReticleNightSwitch) = getNumber (_config >> "manualReticleNightSwitch") != 0;

GVAR(reticleSafezoneSize) = RETICLE_SAFEZONE_DEFAULT_SIZE;

if (isNumber (_config >> "reticleSafezoneSize")) then {
GVAR(reticleSafezoneSize) = getNumber (_config >> "reticleSafezoneSize");
};

GVAR(hidePeripheralVision) = getNumber (_config >> "hidePeripheralVision") != 0;

// zeroing distances
configProperties [configFile >> "CfgWeapons" >> _optic >> "ItemInfo" >> "OpticsModes"] findIf {
GVAR(ZeroingDistances) = getArray (_x >> "discreteDistance");
Expand Down
11 changes: 6 additions & 5 deletions addons/optics/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define WEAPON_MAGAZINES(unit,weapon) (weaponsItems (unit) select {_x select 0 == (weapon)} param [0, []] select {_x isEqualType []})

#define SOUND_RETICLE_SWITCH ["A3\Sounds_F\arsenal\weapons\UGL\Firemode_ugl",0.31622776,1,5]
#define THIRD_SCREEN_WIDTH ((safezoneX - safezoneXAbs) * ((getResolution select 4)/(16/3)))

// control ids
#define IDC_RETICLE 4000
Expand All @@ -44,11 +45,11 @@
#define POS_X(size) (0.5 - 0.5 * POS_W(size))
#define POS_Y(size) (0.5 - 0.5 * POS_H(size))

#define RETICLE_SAFEZONE_SIZE 0.84
#define RETICLE_SAFEZONE_WIDTH POS_W(RETICLE_SAFEZONE_SIZE)
#define RETICLE_SAFEZONE_HEIGHT POS_H(RETICLE_SAFEZONE_SIZE)
#define RETICLE_SAFEZONE_LEFT POS_X(RETICLE_SAFEZONE_SIZE)
#define RETICLE_SAFEZONE_TOP POS_Y(RETICLE_SAFEZONE_SIZE)
#define RETICLE_SAFEZONE_DEFAULT_SIZE 0.84
#define RETICLE_SAFEZONE_DEFAULT_WIDTH POS_W(RETICLE_SAFEZONE_DEFAULT_SIZE)
#define RETICLE_SAFEZONE_DEFAULT_HEIGHT POS_H(RETICLE_SAFEZONE_DEFAULT_SIZE)
#define RETICLE_SAFEZONE_DEFAULT_LEFT POS_X(RETICLE_SAFEZONE_DEFAULT_SIZE)
#define RETICLE_SAFEZONE_DEFAULT_TOP POS_Y(RETICLE_SAFEZONE_DEFAULT_SIZE)

// scope animation config
#define SCOPE_RECOIL_COEF 1
Expand Down