diff --git a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf index 431761bae1..f9ac89a30b 100644 --- a/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf +++ b/addons/common/functions/fnc_deviceKeyFindValidIndex.sqf @@ -6,7 +6,7 @@ * 0: Offset from currentIndex (use 1 to find next valid) * * Return Value: - * Nothing + * The new index (-1 if no valid) * * Example: * [] call ace_common_fnc_deviceKeyFindValidIndex @@ -18,10 +18,15 @@ DEFAULT_PARAM(0,_offsetBy,0); _validIndex = -1; -for "_offset" from _offsetBy to ((count GVAR(deviceKeyHandlingArray)) - 1 + _offsetBy) do { - _realIndex = (GVAR(deviceKeyCurrentIndex) + _offset) % (count GVAR(deviceKeyHandlingArray)); - if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { - _validIndex = _realIndex; +if ((count GVAR(deviceKeyHandlingArray)) > 0) then { + if (GVAR(deviceKeyCurrentIndex) == -1) then {GVAR(deviceKeyCurrentIndex) = 0;}; + for "_offset" from _offsetBy to ((count GVAR(deviceKeyHandlingArray)) - 1 + _offsetBy) do { + _realIndex = (GVAR(deviceKeyCurrentIndex) + _offset) % (count GVAR(deviceKeyHandlingArray)); + if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith { + _validIndex = _realIndex; + }; }; }; + GVAR(deviceKeyCurrentIndex) = _validIndex; +_validIndex diff --git a/addons/kestrel4500/initKeybinds.sqf b/addons/kestrel4500/initKeybinds.sqf index f910bdf552..9096b7c897 100644 --- a/addons/kestrel4500/initKeybinds.sqf +++ b/addons/kestrel4500/initKeybinds.sqf @@ -1,5 +1,9 @@ -["ACE3 Equipment", QGVAR(KestrelDialogKey), localize "STR_ACE_Kestrel4500_KestrelDialogKey", -{ +//Add deviceKey entry: +private ["_conditonCode", "_toggleCode", "_closeCode"]; +_conditonCode = { + [] call FUNC(canShow); +}; +_toggleCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; if(GVAR(Kestrel4500)) exitWith { false }; @@ -7,18 +11,13 @@ // Statement [] call FUNC(createKestrelDialog); false -}, -{false}, -[0, [false, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key) - -["ACE3 Equipment", QGVAR(DisplayKestrelKey), localize "STR_ACE_Kestrel4500_DisplayKestrelKey", -{ +}; +_closeCode = { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Statement [] call FUNC(displayKestrel); false -}, -{false}, -[0, [true, false, false]], false, 0] call CBA_fnc_addKeybind; // (empty default key) +}; +[(localize "STR_ACE_Kestrel_Name"), QUOTE(PATHTOF(UI\Kestrel4500.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew); \ No newline at end of file