Skip to content

Commit 1f5ffcc

Browse files
Timi007jonpas
andauthored
Intercom - Add keybinds for fast switch of FFCS Work Knob (#1384)
Co-authored-by: jonpas <jonpas33@gmail.com>
1 parent 2c4d9c4 commit 1f5ffcc

File tree

9 files changed

+188
-77
lines changed

9 files changed

+188
-77
lines changed

addons/sys_intercom/XEH_PREP.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PREP_FOLDER(vic3);
44
PREP(configIntercom);
55
PREP(configIntercomStations);
66
PREP(enterVehicle);
7+
PREP(getFirstConnectedIntercom);
78
PREP(getStationVariableName);
89
PREP(getStationConfiguration);
910
PREP(getVolumeIntercomUnit);
@@ -45,6 +46,7 @@ PREP(updateVehicleInfoText);
4546

4647
// Keybinding
4748
PREP(switchIntercomFast);
49+
PREP(switchWorkKnobFast);
4850
PREP(handlePttKeyPress);
4951
PREP(handlePttKeyPressUp);
5052

addons/sys_intercom/XEH_postInit.sqf

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "script_component.hpp"
22
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
33

4+
LOAD_SOUND(Acre_GenericClick);
5+
46
private _addClassEH = {
57
["Tank", "init", FUNC(initVehicleIntercom), nil, nil, true] call CBA_fnc_addClassEventHandler;
68
["Car_F", "init", FUNC(initVehicleIntercom), nil, nil, true] call CBA_fnc_addClassEventHandler;
@@ -20,35 +22,44 @@ if (didJIP) then {
2022
if (!hasInterface) exitWith {};
2123

2224
// Keybinds - Intercom
23-
["ACRE2", "IntercomPTTKey", [localize LSTRING(intercomPttKey), localize LSTRING(intercomPttKey_description)], {
25+
private _category = ["ACRE2", LLSTRING(intercom)];
26+
[_category, "IntercomPTTKey", [LLSTRING(intercomPttKey), LLSTRING(intercomPttKey_description)], {
2427
[ACTION_INTERCOM_PTT] call FUNC(handlePttKeyPress)
2528
}, {
2629
[ACTION_INTERCOM_PTT] call FUNC(handlePttKeyPressUp)
2730
}] call CBA_fnc_addKeybind;
2831

29-
["ACRE2", "IntercomBroadcastKey", [localize LSTRING(intercomBroadcastKey), localize LSTRING(intercomBroadcastKey_description)], {
32+
[_category, "IntercomBroadcastKey", [LLSTRING(intercomBroadcastKey), LLSTRING(intercomBroadcastKey_description)], {
3033
[ACTION_BROADCAST] call FUNC(handlePttKeyPress)
3134
}, {
3235
[ACTION_BROADCAST] call FUNC(handlePttKeyPressUp)
3336
}] call CBA_fnc_addKeybind;
3437

35-
["ACRE2", "PreviousIntercom", [localize LSTRING(previousIntercomKey), localize LSTRING(previousIntercomKey_description)], "", {
38+
[_category, "PreviousIntercom", [LLSTRING(previousIntercomKey), LLSTRING(previousIntercomKey_description)], "", {
3639
[-1, true] call FUNC(switchIntercomFast)
3740
}, [DIK_COMMA, [true, false, false]]] call CBA_fnc_addKeybind;
3841

39-
["ACRE2", "NextIntercom", [localize LSTRING(nextIntercomKey), localize LSTRING(nextIntercomKey_description)], "", {
42+
[_category, "NextIntercom", [LLSTRING(nextIntercomKey), LLSTRING(nextIntercomKey_description)], "", {
4043
[1, true] call FUNC(switchIntercomFast)
4144
}, [DIK_COMMA, [false, true, false]]] call CBA_fnc_addKeybind;
4245

43-
["ACRE2", "AddPreviousIntercom", [localize LSTRING(addPreviousIntercomKey), localize LSTRING(addPreviousIntercomKey_description)], "", {
46+
[_category, "AddPreviousIntercom", [LLSTRING(addPreviousIntercomKey), LLSTRING(addPreviousIntercomKey_description)], "", {
4447
[-1, false] call FUNC(switchIntercomFast)
4548
}, [DIK_COMMA, [true, false, true]]] call CBA_fnc_addKeybind;
4649

47-
["ACRE2", "AddNextIntercom", [localize LSTRING(addNextIntercomKey), localize LSTRING(addNextIntercomKey_description)], "", {
50+
[_category, "AddNextIntercom", [LLSTRING(addNextIntercomKey), LLSTRING(addNextIntercomKey_description)], "", {
4851
[1, false] call FUNC(switchIntercomFast)
4952
}, [DIK_COMMA, [false, true, true]]] call CBA_fnc_addKeybind;
5053

51-
["ACRE2", QGVAR(openGui), localize LSTRING(openGui), {
54+
[_category, QGVAR(previousWorkKnob), [LLSTRING(previousWorkKnobKey), LLSTRING(previousWorkKnobKey_description)], {
55+
[-1, true] call FUNC(switchWorkKnobFast)
56+
}, "", [DIK_Q, [false, true, false]]] call CBA_fnc_addKeybind;
57+
58+
[_category, QGVAR(nextWorkKnob), [LLSTRING(nextWorkKnobKey), LLSTRING(nextWorkKnobKey_description)], {
59+
[1, true] call FUNC(switchWorkKnobFast)
60+
}, "", [DIK_E, [false, true, false]]] call CBA_fnc_addKeybind;
61+
62+
[_category, QGVAR(openGui), LLSTRING(openGui), {
5263
[-1] call FUNC(openGui)
5364
}, "", [DIK_TAB, [true, true, false]]] call CBA_fnc_addKeybind;
5465

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Returns the first connected intercom network.
5+
*
6+
* Arguments:
7+
* 0: Vehicle <OBJECT>
8+
*
9+
* Return Value:
10+
* Intercom network or -1 if no connected intercom network exist <NUMBER>
11+
*
12+
* Example:
13+
* [vehicle acre_player] call acre_sys_intercom_fnc_getFirstConnectedIntercom
14+
*
15+
* Public: No
16+
*/
17+
18+
params ["_vehicle"];
19+
20+
private _intercomNames = _vehicle getVariable [QGVAR(intercomNames), []];
21+
22+
if (_vehicle isEqualTo acre_player || {_intercomNames isEqualTo []}) exitWith {-1};
23+
24+
private _activeIntercom = -1;
25+
{
26+
private _connectionStatus = [_vehicle, acre_player, _forEachIndex, INTERCOM_STATIONSTATUS_CONNECTION] call FUNC(getStationConfiguration);
27+
if (_connectionStatus > INTERCOM_DISCONNECTED) exitWith {
28+
_activeIntercom = _forEachIndex;
29+
}
30+
} forEach _intercomNames;
31+
32+
_activeIntercom

addons/sys_intercom/fnc_openGui.sqf

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,19 @@ if (GVAR(guiOpened)) exitWith {
2424
};
2525

2626
private _vehicle = vehicle acre_player;
27-
private _intercomNames = _vehicle getVariable [QGVAR(intercomNames), []];
2827

29-
if (_vehicle isEqualTo acre_player || {_intercomNames isEqualTo []}) exitWith {false};
28+
if (_vehicle isEqualTo acre_player) exitWith {false};
3029

3130
if (_intercomNetwork != -1) then {
3231
GVAR(activeIntercom) = _intercomNetwork;
3332
} else {
34-
private _getActiveIntercom = {
35-
params ["_vehicle"];
36-
37-
private _activeIntercom = -1;
38-
{
39-
private _connectionStatus = [_vehicle, acre_player, _forEachIndex, INTERCOM_STATIONSTATUS_CONNECTION] call FUNC(getStationConfiguration);
40-
if (_connectionStatus > INTERCOM_DISCONNECTED) exitWith {
41-
_activeIntercom = _forEachIndex;
42-
}
43-
} forEach _intercomNames;
44-
45-
_activeIntercom;
46-
};
47-
4833
if (GVAR(activeIntercom) != -1) then {
4934
private _connectionStatus = [_vehicle, acre_player, GVAR(activeIntercom), INTERCOM_STATIONSTATUS_CONNECTION] call FUNC(getStationConfiguration);
5035
if (_connectionStatus == INTERCOM_DISCONNECTED) then {
51-
GVAR(activeIntercom) = [_vehicle] call _getActiveIntercom;
36+
GVAR(activeIntercom) = [_vehicle] call FUNC(getFirstConnectedIntercom);
5237
};
5338
} else {
54-
GVAR(activeIntercom) = [_vehicle] call _getActiveIntercom;
39+
GVAR(activeIntercom) = [_vehicle] call FUNC(getFirstConnectedIntercom);
5540
};
5641
};
5742

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Handles the work knob switching keybind.
5+
*
6+
* Arguments:
7+
* 0: Work knob switch amount (expected -1 or 1) <NUMBER>
8+
* 1: Play sound <BOOL> (default: false)
9+
*
10+
* Return Value:
11+
* Handled <BOOL>
12+
*
13+
* Example:
14+
* [1, true] call acre_sys_intercom_fnc_switchWorkKnobFast
15+
*
16+
* Public: No
17+
*/
18+
19+
params ["_dir", ["_playSound", false, [false]]];
20+
21+
private _vehicle = vehicle acre_player;
22+
private _intercomNetwork = [_vehicle] call FUNC(getFirstConnectedIntercom);
23+
if (_intercomNetwork < 0) exitWith {false};
24+
25+
private _workPos = [_vehicle, acre_player, _intercomNetwork, INTERCOM_STATIONSTATUS_WORKKNOB] call FUNC(getStationConfiguration);
26+
private _success = [_intercomNetwork, _workPos + _dir] call FUNC(vic3ffcsSetWork);
27+
28+
if (!_success) exitWith {false};
29+
30+
if (_playSound) then {
31+
["Acre_GenericClick", [0,0,0], [0,0,0], 1, false] call EFUNC(sys_sounds,playSound);
32+
};
33+
34+
true

addons/sys_intercom/stringtable.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,5 +633,21 @@
633633
<Chinesesimp>只发送</Chinesesimp>
634634
<Turkish>Sadece İletme</Turkish>
635635
</Key>
636+
<Key ID="STR_ACRE_sys_intercom_previousWorkKnobKey">
637+
<English>Previous Work Knob Position</English>
638+
<German>Vorherige Work-Knopfposition</German>
639+
</Key>
640+
<Key ID="STR_ACRE_sys_intercom_previousWorkKnobKey_description">
641+
<English>Switches to the previous radio rack and sets it as the transmitting radio within the first connected intercom network.</English>
642+
<German>Setzt das vorherige Fahrzeugfunkgerät als sendendes Funkgerät im ersten verbundenen Bordfunknetzwerk.</German>
643+
</Key>
644+
<Key ID="STR_ACRE_sys_intercom_nextWorkKnobKey">
645+
<English>Next Work Knob Position</English>
646+
<German>Nächste Work-Knopfposition</German>
647+
</Key>
648+
<Key ID="STR_ACRE_sys_intercom_nextWorkKnobKey_description">
649+
<English>Switches to the next radio rack and sets it as the transmitting radio within the first connected intercom network.</English>
650+
<German>Setzt das nächste Fahrzeugfunkgerät als sendendes Funkgerät im ersten verbundenen Bordfunknetzwerk.</German>
651+
</Key>
636652
</Package>
637653
</Project>

addons/sys_intercom/vic3/__PREP__.sqf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ PREP_MODULE(vic3,vic3ffcsOnMonitorKnobPress);
66
PREP_MODULE(vic3,vic3ffcsOnVolumeKnobPress);
77
PREP_MODULE(vic3,vic3ffcsOnWorkKnobPress);
88
PREP_MODULE(vic3,vic3ffcsRender);
9+
PREP_MODULE(vic3,vic3ffcsSetWork);

addons/sys_intercom/vic3/fnc_vic3ffcsOnWorkKnobPress.sqf

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,8 @@ if (_key == 0) then {
2727
private _vehicle = vehicle acre_player;
2828
private _workPos = [_vehicle, acre_player, GVAR(activeIntercom), INTERCOM_STATIONSTATUS_WORKKNOB] call FUNC(getStationConfiguration);
2929
private _newWorkPos = ((_workPos + _currentDirection) max 0) min VIC3FFCS_WORK_KNOB_POSITIONS;
30+
private _success = [GVAR(activeIntercom), _newWorkPos] call FUNC(vic3ffcsSetWork);
3031

31-
if (_newWorkPos == _workPos) exitWith {};
32+
if (!_success) exitWith {};
3233

33-
private _wiredRacks = [_vehicle, acre_player, GVAR(activeIntercom), INTERCOM_STATIONSTATUS_WIREDRACKS] call FUNC(getStationConfiguration);
34-
private _monitorPos = [_vehicle, acre_player, GVAR(activeIntercom), INTERCOM_STATIONSTATUS_MONITORKNOB] call FUNC(getStationConfiguration);
35-
36-
// Set the previous rack to no monitor unless it is selected in the monitor knob
37-
if (_workPos != 0) then {
38-
private _selectedRack = _wiredRacks select (_workPos - 1);
39-
40-
private _rackId = _selectedRack select 0;
41-
if (_rackId != "" && {_selectedRack select 2}) then {
42-
if (_workPos != _monitorPos) then {
43-
private _radioId = [_rackId] call EFUNC(sys_rack,getMountedRadio);
44-
45-
if (_monitorPos != VIC3FFCS_MONITOR_KNOB_POSITIONS) then {
46-
_selectedRack set [1, RACK_NO_MONITOR];
47-
if (_radioId != "") then {
48-
[_vehicle, acre_player, _radioId] call EFUNC(sys_rack,stopUsingMountedRadio);
49-
};
50-
} else {
51-
_selectedRack set [1, RACK_RX_ONLY];
52-
};
53-
} else {
54-
_selectedRack set [1, RACK_RX_ONLY];
55-
};
56-
};
57-
};
58-
59-
if (_newWorkPos != 0) then {
60-
private _selectedRack = _wiredRacks select (_newWorkPos - 1); // RackID, Functionality, Has Access
61-
private _rackId = _selectedRack select 0;
62-
if ((_rackId != "") && {_selectedRack select 2}) then {
63-
private _radioId = [_rackId] call EFUNC(sys_rack,getMountedRadio);
64-
_selectedRack set [1, RACK_RX_AND_TX];
65-
66-
if ((_newWorkPos != _monitorPos) && {_radioId != ""}) then {
67-
[_vehicle, acre_player, _radioId] call EFUNC(sys_rack,startUsingMountedRadio);
68-
};
69-
};
70-
} else {
71-
private _selectedRack = _wiredRacks select (_workPos - 1);
72-
private _rackId = _selectedRack select 0;
73-
if ((_rackId != "") && {_selectedRack select 2} && {_workPos != _monitorPos} && {_monitorPos != VIC3FFCS_MONITOR_KNOB_POSITIONS} ) then {
74-
private _radioId = [_rackId] call EFUNC(sys_rack,getMountedRadio);
75-
76-
_selectedRack set [1, RACK_NO_MONITOR];
77-
if (_radioId != "") then {
78-
[_vehicle, acre_player, _radioId] call EFUNC(sys_rack,stopUsingMountedRadio);
79-
};
80-
};
81-
};
82-
83-
[_vehicle, acre_player, GVAR(activeIntercom), INTERCOM_STATIONSTATUS_WORKKNOB, _newWorkPos] call FUNC(setStationConfiguration);
8434
[MAIN_DISPLAY, _vehicle] call FUNC(vic3ffcsRender);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include "..\script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Sets the Work knob in the FFCS.
5+
*
6+
* Arguments:
7+
* 0: Intercom network <NUMBER>
8+
* 1: Work knob position <NUMBER>
9+
*
10+
* Return Value:
11+
* Success <BOOL>
12+
*
13+
* Example:
14+
* [0, 1] call acre_sys_intercom_fnc_vic3ffcsSetWork
15+
*
16+
* Public: No
17+
*/
18+
19+
params ["_intercomNetwork", "_newWorkPos"];
20+
21+
if (_newWorkPos < 0 || _newWorkPos > VIC3FFCS_WORK_KNOB_POSITIONS) exitWith {false};
22+
23+
private _vehicle = vehicle acre_player;
24+
private _workPos = [_vehicle, acre_player, _intercomNetwork, INTERCOM_STATIONSTATUS_WORKKNOB] call FUNC(getStationConfiguration);
25+
26+
if (_newWorkPos isEqualTo _workPos) exitWith {false};
27+
28+
private _wiredRacks = [_vehicle, acre_player, _intercomNetwork, INTERCOM_STATIONSTATUS_WIREDRACKS] call FUNC(getStationConfiguration);
29+
private _monitorPos = [_vehicle, acre_player, _intercomNetwork, INTERCOM_STATIONSTATUS_MONITORKNOB] call FUNC(getStationConfiguration);
30+
31+
// Set the previous rack to no monitor unless it is selected in the monitor knob
32+
if (_workPos isNotEqualTo 0) then {
33+
private _selectedRack = _wiredRacks select (_workPos - 1);
34+
35+
private _rackId = _selectedRack select 0;
36+
if (_rackId isNotEqualTo "" && {_selectedRack select 2}) then {
37+
if (_workPos isNotEqualTo _monitorPos) then {
38+
private _radioId = [_rackId] call EFUNC(sys_rack,getMountedRadio);
39+
40+
if (_monitorPos isNotEqualTo VIC3FFCS_MONITOR_KNOB_POSITIONS) then {
41+
_selectedRack set [1, RACK_NO_MONITOR];
42+
if (_radioId isNotEqualTo "") then {
43+
[_vehicle, acre_player, _radioId] call EFUNC(sys_rack,stopUsingMountedRadio);
44+
};
45+
} else {
46+
_selectedRack set [1, RACK_RX_ONLY];
47+
};
48+
} else {
49+
_selectedRack set [1, RACK_RX_ONLY];
50+
};
51+
};
52+
};
53+
54+
if (_newWorkPos isNotEqualTo 0) then {
55+
private _selectedRack = _wiredRacks select (_newWorkPos - 1); // RackID, Functionality, Has Access
56+
private _rackId = _selectedRack select 0;
57+
if ((_rackId isNotEqualTo "") && {_selectedRack select 2}) then {
58+
private _radioId = [_rackId] call EFUNC(sys_rack,getMountedRadio);
59+
_selectedRack set [1, RACK_RX_AND_TX];
60+
61+
if ((_newWorkPos isNotEqualTo _monitorPos) && {_radioId isNotEqualTo ""}) then {
62+
[_vehicle, acre_player, _radioId] call EFUNC(sys_rack,startUsingMountedRadio);
63+
};
64+
};
65+
} else {
66+
private _selectedRack = _wiredRacks select (_workPos - 1);
67+
private _rackId = _selectedRack select 0;
68+
if ((_rackId isNotEqualTo "") && {_selectedRack select 2} && {_workPos isNotEqualTo _monitorPos} && {_monitorPos isNotEqualTo VIC3FFCS_MONITOR_KNOB_POSITIONS} ) then {
69+
private _radioId = [_rackId] call EFUNC(sys_rack,getMountedRadio);
70+
71+
_selectedRack set [1, RACK_NO_MONITOR];
72+
if (_radioId isNotEqualTo "") then {
73+
[_vehicle, acre_player, _radioId] call EFUNC(sys_rack,stopUsingMountedRadio);
74+
};
75+
};
76+
};
77+
78+
[_vehicle, acre_player, _intercomNetwork, INTERCOM_STATIONSTATUS_WORKKNOB, _newWorkPos] call FUNC(setStationConfiguration);
79+
80+
true

0 commit comments

Comments
 (0)