mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Base Device Handler Framework
Multiple devices share Home/Ctrl-home keys
This commit is contained in:
parent
f103a19920
commit
f7ff4a2f36
@ -249,3 +249,39 @@ if(isMultiplayer && { time > 0 || isNull player } ) then {
|
||||
};
|
||||
}, 0, []] call cba_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
//Device Handler:
|
||||
GVAR(deviceKeyHandlingArray) = [];
|
||||
GVAR(deviceKeyCurrentIndex) = -1;
|
||||
|
||||
["ACE3 Equipment", QGVAR(openDevice), "Open Device", //(localize "STR_ACE_microdagr_toggleUnit"),
|
||||
{
|
||||
[] call FUNC(deviceKeyFindValidIndex);
|
||||
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
||||
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3);
|
||||
true;
|
||||
},
|
||||
{false},
|
||||
[0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key
|
||||
|
||||
["ACE3 Equipment", QGVAR(closeDevice), "Close Device", //(localize "STR_ACE_microdagr_toggleUnit"),
|
||||
{
|
||||
[] call FUNC(deviceKeyFindValidIndex);
|
||||
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
||||
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4);
|
||||
},
|
||||
{false},
|
||||
[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key
|
||||
|
||||
["ACE3 Equipment", QGVAR(cycleDevice), "Cycle Devices", //(localize "STR_ACE_microdagr_toggleUnit"),
|
||||
{
|
||||
systemChat "here";
|
||||
[1] call FUNC(deviceKeyFindValidIndex);
|
||||
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
|
||||
_displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0);
|
||||
_iconImage = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 1);
|
||||
systemChat str [_displayName, _iconImage];
|
||||
[_displayName, _iconImage] call FUNC(displayTextPicture);
|
||||
},
|
||||
{false},
|
||||
[0xC7, [true, false, false]], false] call cba_fnc_addKeybind; //SHIFT + Home Key
|
||||
|
@ -33,6 +33,8 @@ PREP(currentChannel);
|
||||
PREP(debug);
|
||||
PREP(debugModule);
|
||||
PREP(defineVariable);
|
||||
PREP(deviceKeyFindValidIndex);
|
||||
PREP(deviceKeyRegisterNew);
|
||||
PREP(disableAI);
|
||||
PREP(disableUserInput);
|
||||
PREP(displayIcon);
|
||||
|
13
addons/common/functions/fnc_deviceKeyFindValidIndex.sqf
Normal file
13
addons/common/functions/fnc_deviceKeyFindValidIndex.sqf
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
GVAR(deviceKeyCurrentIndex) = _validIndex;
|
6
addons/common/functions/fnc_deviceKeyRegisterNew.sqf
Normal file
6
addons/common/functions/fnc_deviceKeyRegisterNew.sqf
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
PARAMS_5(_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode);
|
||||
|
||||
GVAR(deviceKeyHandlingArray) pushBack [_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode];
|
||||
[] call FUNC(deviceKeyFindValidIndex);
|
@ -3,7 +3,24 @@
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
//Add Keybinds:
|
||||
_conditonCode = {
|
||||
("ACE_microDAGR" in (items ace_player))
|
||||
};
|
||||
_toggleCode = {
|
||||
if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
[] call FUNC(openDisplay); //toggle display mode
|
||||
true
|
||||
};
|
||||
_closeCode = {
|
||||
if (GVAR(currentShowMode) == DISPLAY_MODE_CLOSED) exitWith {false};
|
||||
[DISPLAY_MODE_CLOSED] call FUNC(openDisplay);
|
||||
true
|
||||
};
|
||||
|
||||
["Mdagr", "", _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew);
|
||||
|
||||
|
||||
/* //Add Keybinds:
|
||||
["ACE3 Equipment", QGVAR(openGPS), (localize "STR_ACE_microdagr_toggleUnit"),
|
||||
{
|
||||
// canInteractWith (can use on map)
|
||||
@ -29,7 +46,7 @@ if (!hasInterface) exitWith {};
|
||||
true;
|
||||
},
|
||||
{false},
|
||||
[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key
|
||||
[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key */
|
||||
|
||||
//Add Eventhandler:
|
||||
["RangerfinderData", {_this call FUNC(recieveRangefinderData)}] call EFUNC(common,addEventHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user