Skip to content

Commit

Permalink
Scopes - Notify restart req. for enable & pressure settings (#9944)
Browse files Browse the repository at this point in the history
* Moved keybinds, made settings require restart

* Move keybinds
  • Loading branch information
johnb432 authored Apr 11, 2024
1 parent 2b5ea16 commit bcf1133
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 101 deletions.
101 changes: 3 additions & 98 deletions addons/scopes/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

if (!hasInterface) exitWith {};

// Add keybinds
#include "initKeybinds.inc.sqf"

GVAR(Optics) = ["", "", ""];
GVAR(Guns) = ["", "", ""];
GVAR(canAdjustElevation) = [false, false, false];
Expand Down Expand Up @@ -41,104 +44,6 @@ GVAR(scopeAdjust) = [[[0,0],0,[0,0],0], [[0,0],0,[0,0],0], [[0,0],0,[0,0],0]];
};
}] call CBA_fnc_addPlayerEventHandler;

// Add keybinds
["ACE3 Scope Adjustment", QGVAR(AdjustUpMinor), localize LSTRING(AdjustUpMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_UP, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [false, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustDownMinor), localize LSTRING(AdjustDownMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_DOWN, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [false, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustLeftMinor), localize LSTRING(AdjustLeftMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_LEFT, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [false, true, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustRightMinor), localize LSTRING(AdjustRightMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_RIGHT, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [false, true, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustUpMajor), localize LSTRING(AdjustUpMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_UP, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [true, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustDownMajor), localize LSTRING(AdjustDownMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_DOWN, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [true, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustLeftMajor), localize LSTRING(AdjustLeftMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_LEFT, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [true, true, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustRightMajor), localize LSTRING(AdjustRightMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_RIGHT, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [true, true, false]], true] call CBA_fnc_addKeybind;


// Register fire event handler
["ace_firedPlayer", LINKFUNC(firedEH)] call CBA_fnc_addEventHandler;
["ace_firedPlayerNonLocal", LINKFUNC(firedEH)] call CBA_fnc_addEventHandler;
Expand Down
3 changes: 2 additions & 1 deletion addons/scopes/functions/fnc_adjustScope.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
* Public: No
*/

if (!GVAR(enabled)) exitWith {false};

params ["_unit", "_turretAndDirection", "_majorStep"];
TRACE_3("adjustScope",_unit,_turretAndDirection,_majorStep);

if (!(_unit isKindOf "Man")) exitWith {false};
if (currentMuzzle _unit != currentWeapon _unit) exitWith {false};
if (!GVAR(enabled)) exitWith {false};

private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
if (_weaponIndex < 0) exitWith {false};
Expand Down
95 changes: 95 additions & 0 deletions addons/scopes/initKeybinds.inc.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
["ACE3 Scope Adjustment", QGVAR(AdjustUpMinor), LLSTRING(AdjustUpMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_UP, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [false, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustDownMinor), LLSTRING(AdjustDownMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_DOWN, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [false, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustLeftMinor), LLSTRING(AdjustLeftMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_LEFT, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [false, true, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustRightMinor), LLSTRING(AdjustRightMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_RIGHT, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [false, true, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustUpMajor), LLSTRING(AdjustUpMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_UP, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [true, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustDownMajor), LLSTRING(AdjustDownMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, ELEVATION_DOWN, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [true, false, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustLeftMajor), LLSTRING(AdjustLeftMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_LEFT, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [true, true, false]], true] call CBA_fnc_addKeybind;

["ACE3 Scope Adjustment", QGVAR(AdjustRightMajor), LLSTRING(AdjustRightMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};

[ACE_player] call FUNC(inventoryCheck);

// Statement
[ACE_player, WINDAGE_RIGHT, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [true, true, false]], true] call CBA_fnc_addKeybind;
8 changes: 6 additions & 2 deletions addons/scopes/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ private _category = format ["ACE %1", localize LSTRING(DisplayName)];
[LSTRING(enabled_displayName), LSTRING(enabled_description)],
_category,
true,
1
1,
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_fnc_addSetting;

[
Expand Down Expand Up @@ -69,7 +71,9 @@ private _category = format ["ACE %1", localize LSTRING(DisplayName)];
[LSTRING(deduceBarometricPressureFromTerrainAltitude_displayName), LSTRING(deduceBarometricPressureFromTerrainAltitude_description)],
_category,
false,
1
1,
{[QGVAR(deduceBarometricPressureFromTerrainAltitude), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_fnc_addSetting;

[
Expand Down

0 comments on commit bcf1133

Please sign in to comment.