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 manual reticle night switch keybind #1141

Merged
merged 2 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions addons/accessory/XEH_preInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "XEH_PREP.sqf"

["CBA Accessory Functions", "MRT_SwitchItemNextClass_R", [LSTRING(railNext), LSTRING(railNext_tooltip)], {[1, "next"] call FUNC(switchAttachment)}, {}, [38, [false, true, false]]] call CBA_fnc_addKeybind; //default ctrl + L
["CBA Accessory Functions", "MRT_SwitchItemPrevClass_R", [LSTRING(railPrev), LSTRING(railPrev_tooltip)], {[1, "prev"] call FUNC(switchAttachment)}, {}, [38, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + L
["CBA Accessory Functions", "MRT_SwitchItemNextClass_O", [LSTRING(opticNext), LSTRING(opticNext_tooltip)], {[2, "next"] call FUNC(switchAttachment)}, {}, [181, [false, true, false]]] call CBA_fnc_addKeybind; //default ctlr + NUM-/
["CBA Accessory Functions", "MRT_SwitchItemPrevClass_O", [LSTRING(opticPrev), LSTRING(opticPrev_tooltip)], {[2, "prev"] call FUNC(switchAttachment)}, {}, [181, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + NUM-/
[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemNextClass_R", [LSTRING(railNext), LSTRING(railNext_tooltip)], {[1, "next"] call FUNC(switchAttachment)}, {}, [38, [false, true, false]]] call CBA_fnc_addKeybind; //default ctrl + L
[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemPrevClass_R", [LSTRING(railPrev), LSTRING(railPrev_tooltip)], {[1, "prev"] call FUNC(switchAttachment)}, {}, [38, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + L
[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemNextClass_O", [LSTRING(opticNext), LSTRING(opticNext_tooltip)], {[2, "next"] call FUNC(switchAttachment)}, {}, [181, [false, true, false]]] call CBA_fnc_addKeybind; //default ctlr + NUM-/
[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemPrevClass_O", [LSTRING(opticPrev), LSTRING(opticPrev_tooltip)], {[2, "prev"] call FUNC(switchAttachment)}, {}, [181, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + NUM-/
4 changes: 4 additions & 0 deletions addons/optics/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ if (configProperties [configFile >> "CBA_PIPItems"] isEqualTo [] && {

if (!hasInterface) exitWith {};

#include "initKeybinds.sqf"

QGVAR(pauseOpticLayer) cutText ["", "PLAIN"];

GVAR(camera) = objNull;
Expand All @@ -28,6 +30,8 @@ GVAR(OpticReticleDetailTextures) = [];
GVAR(OpticBodyTexture) = "";
GVAR(OpticBodyTextureNight) = "";
GVAR(ppEffects) = [];
GVAR(manualReticleNightSwitch) = false;
GVAR(useReticleNight) = false;

// Update optic info.
["weapon", {
Expand Down
8 changes: 7 additions & 1 deletion addons/optics/fnc_animateScriptedOptic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ _ctrlMagnification ctrlCommit 0;
private _dayOpacity = AMBIENT_BRIGHTNESS;
private _nightOpacity = [1,0] select (_dayOpacity == 1);

private _useReticleNight = GVAR(useReticleNight);

if (!GVAR(manualReticleNightSwitch)) then {
_useReticleNight = _dayOpacity < 0.5;
};

// Apply lighting and make layers visible.
private _texture = "";
private _detailScaleFactor = 1;
Expand All @@ -97,7 +103,7 @@ private _detailScaleFactor = 1;
_x params ["_zoomX", "_textureX", "_detailScaleFactorX", "_textureXNight"];

if (_zoom > _zoomX) then {
_texture = [_textureX, _textureXNight] select (_dayOpacity < 0.5);
_texture = [_textureX, _textureXNight] select _useReticleNight;
_detailScaleFactor = _detailScaleFactorX;
};
} forEach GVAR(OpticReticleDetailTextures);
Expand Down
2 changes: 2 additions & 0 deletions addons/optics/fnc_updateOpticInfo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ if (GVAR(OpticBodyTextureNight) isEqualTo "") then {
GVAR(OpticBodyTextureNight) = GVAR(OpticBodyTexture);
};

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

// zeroing distances
configProperties [configFile >> "CfgWeapons" >> _optic >> "ItemInfo" >> "OpticsModes"] findIf {
GVAR(ZeroingDistances) = getArray (_x >> "discreteDistance");
Expand Down
27 changes: 27 additions & 0 deletions addons/optics/initKeybinds.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
ELSTRING(common,WeaponsCategory),
QGVAR(ManualReticleNightSwitch),
[LSTRING(manual_reticle_switch), LSTRING(manual_reticle_switch_tooltip)],
{
if (GVAR(manualReticleNightSwitch)) then {
GVAR(useReticleNight) = !GVAR(useReticleNight);

// play sound
private _unit = call CBA_fnc_currentUnit;
private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand");

SOUND_RETICLE_SWITCH params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]];

// add file extension .wss as default
if !(toLower (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then {
_filename = format ["%1.wss", _filename];
};

playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance];

true
} else {false};
},
{},
[DIK_NUMPAD0, [false, false, false]]
] call CBA_fnc_addKeybind;
4 changes: 4 additions & 0 deletions addons/optics/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
#define DEBUG_SYNCHRONOUS
#include "\x\cba\addons\main\script_macros.hpp"

#include "\a3\ui_f\hpp\defineDIKCodes.inc"

#define PARSE(value) (call compile format ["%1", value])
#define AMBIENT_BRIGHTNESS (sunOrMoon * sunOrMoon * (1 - overcast * 0.25) + moonIntensity / 5 * (1 - overcast) min 1) // idea by Falke
#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]

// control ids
#define IDC_RETICLE 4000
#define IDC_BODY 4001
Expand Down
8 changes: 8 additions & 0 deletions addons/optics/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@
<Polish>Używaj optyki typu Obraz w obrazie (PIP)</Polish>
<Italian>Usa ottiche on Picture-in-Picture</Italian>
</Key>
<Key ID="STR_cba_optics_manual_reticle_switch">
<English>Toggle Reticle</English>
<German>Absehen umschalten</German>
</Key>
<Key ID="STR_cba_optics_manual_reticle_switch_tooltip">
<English>Manually switch the reticle of the optic.</English>
<German>Absehen der Optik manuell umschalten.</German>
</Key>
</Package>
</Project>