Skip to content

Commit 141a109

Browse files
authoredNov 12, 2018
Intercom improvements (IDI-Systems#585)
* Accent implementation. Volume of racks controlled by intercom * Fixes * First testing * Fixes * Fixes * Include before Header * Cpp * Intercom PTT and Intercom Broadcast PTT keys. Cpp cleanup * Improved handling of new PTT * TabsToSpaces * Minor improvements and formatting * Add accent documentation * IntercomSpeaking type * Fixed IntercomPTT * Documentation and code formatting * Remove merge files * Working Intercom PTT * Fix accent * Brackets * Finished accent feature * Requested changes * Tabs! * Factor wording * oops * Fix merge conflicts * German translation Co-Authored-By: TheMagnetar <[email protected]> * German Translation Co-Authored-By: TheMagnetar <[email protected]> * Suggested changes + spanish translations
1 parent 91ffae4 commit 141a109

36 files changed

+870
-521
lines changed
 

‎addons/api/fnc_getRadioVolume.sqf

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* 0: Radio ID <STRING>
88
*
99
* Return Value:
10-
* Volume value between 0 and 1 <NUMBER>
10+
* Volume value between 0 and 1, -1 if error <NUMBER>
1111
*
1212
* Example:
1313
* ["ACRE_PRC148_ID_1"] call acre_api_fnc_getRadioVolume
@@ -17,4 +17,8 @@
1717

1818
params ["_radioId"];
1919

20+
if (isNil "_radioId") exitWith { -1 };
21+
22+
if (!([_radioId] call EFUNC(sys_data,isRadioInitialized))) exitWith { -1 };
23+
2024
[_radioId] call EFUNC(sys_radio,getRadioVolume);

‎addons/api/fnc_isSpeaking.sqf

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ params [
2020
];
2121

2222

23-
if (_unit in EGVAR(sys_core,speakers)) exitWith {
24-
true
25-
};
26-
false
23+
_unit in EGVAR(sys_core,speakers)

‎addons/sys_core/fnc_processRadioSpeaker.sqf

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ if !(_okRadios isEqualTo []) then {
7272

7373

7474
private _radioVolume = [_receivingRadioid, "getVolume"] call EFUNC(sys_data,dataEvent);
75+
_radioVolume = [_x, _radioVolume] call EFUNC(sys_intercom,modifyRadioVolume);
7576
_radioVolume = _radioVolume * GVAR(globalVolume);
7677
// acre_player sideChat format["rv: %1", _radioVolume];
7778
private _isLoudspeaker = [_receivingRadioid, "isExternalAudio"] call EFUNC(sys_data,dataEvent);

‎addons/sys_intercom/XEH_PREP.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ PREP(intercomListVolumeActions);
1414
PREP(intercomPFH);
1515
PREP(isIntercomAvailable);
1616
PREP(isInIntercom);
17+
PREP(modifyRadioVolume);
1718
PREP(noApiFunction);
1819
PREP(seatSwitched);
20+
PREP(handleAccent);
1921
PREP(handleBroadcasting);
2022
PREP(handleLimitedConnection);
2123
PREP(handleIntercomActivation);
2224
PREP(setStationConfiguration);
2325
PREP(setStationUnit);
26+
PREP(updateIntercomUse);
2427

2528
// Infantry Phone
2629
PREP(checkInfantryPhoneAvailability);

‎addons/sys_intercom/XEH_postInit.sqf

+4-19
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,20 @@ if (!isClass (configFile >> "CfgPatches" >> "ace_interact_menu")) exitWith {};
1010

1111
if (!hasInterface) exitWith {};
1212

13-
// CBA Keybindings
14-
//["ACRE2", "IntercomPTTKey", [(localize LSTRING(intercomPttKey)), (localize LSTRING(intercomPttKey_description))], { [PTT_ACTION] call FUNC(handlePttKeyPress) }, { [PTT_ACTION] call FUNC(handlePttKeyPressUp) }, [52, [true, false, false]]] call cba_fnc_addKeybind;
15-
//["ACRE2", "IntercomBroadcastKey", [(localize LSTRING(intercomBroadcastKey)), (localize LSTRING(intercomBroadcastKey_description))], { [BROADCAST_ACTION] call FUNC(handlePttKeyPress) }, { [BROADCAST_ACTION] call FUNC(handlePttKeyPressUp) }, [52, [false, true, false]]] call cba_fnc_addKeybind;
1613
[
1714
"ACRE2",
1815
"IntercomPTTKey",
1916
[(localize LSTRING(intercomPttKey)), (localize LSTRING(intercomPttKey_description))],
20-
"",
21-
{
22-
if(!GVAR(intercomPttKey)) then {
23-
[PTT_ACTION] call FUNC(handlePttKeyPress);
24-
} else {
25-
[PTT_ACTION] call FUNC(handlePttKeyPressUp);
26-
};
27-
}
17+
{[ACTION_INTERCOM_PTT] call FUNC(handlePttKeyPress)},
18+
{[ACTION_INTERCOM_PTT] call FUNC(handlePttKeyPressUp)}
2819
] call cba_fnc_addKeybind;
2920

3021
[
3122
"ACRE2",
3223
"IntercomBroadcastKey",
3324
[(localize LSTRING(intercomBroadcastKey)), (localize LSTRING(intercomBroadcastKey_description))],
34-
"",
35-
{
36-
if(!GVAR(broadcastKey)) then {
37-
[BROADCAST_ACTION] call FUNC(handlePttKeyPress);
38-
} else {
39-
[BROADCAST_ACTION] call FUNC(handlePttKeyPressUp);
40-
};
41-
}
25+
{[ACTION_BROADCAST] call FUNC(handlePttKeyPress)},
26+
{[ACTION_BROADCAST] call FUNC(handlePttKeyPressUp)}
4227
] call cba_fnc_addKeybind;
4328

4429
["ACRE2", "PreviousIntercom", (localize LSTRING(previousIntercom)), "", { [-1, true] call FUNC(switchIntercomFast) }, [51, [true, false, false]]] call cba_fnc_addKeybind;

‎addons/sys_intercom/XEH_preInit.sqf

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if (hasInterface) then {
1515
// Todo: Change to key down/up
1616
GVAR(broadcastKey) = false;
1717
GVAR(intercomPttKey) = false;
18+
GVAR(intercomUse) = [];
1819
};
1920

2021
ADDON = true;

‎addons/sys_intercom/fnc_configIntercom.sqf

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private _intercomMasterStation = [];
2626
private _numLimitedPositions = [];
2727
private _intercomConnectByDefault = [];
2828
private _broadcasting = [];
29+
private _accent = [];
2930

3031
{
3132
private _name = toLower (configName _x);
@@ -110,10 +111,12 @@ private _broadcasting = [];
110111
_intercomConnectByDefault pushBack _connectedByDefault;
111112
_intercomMasterStation pushBack _masterStationPositions;
112113
_broadcasting pushBack [false, objNull];
114+
_accent pushBack false;
113115
} forEach _intercoms;
114116

115117
[_vehicle, _intercomPositions, _intercomExceptions, _intercomLimitedPositions, _intercomConnectByDefault, _intercomMasterStation] call FUNC(configIntercomStations);
116118

117119
_vehicle setVariable [QGVAR(intercomNames), _intercomNames];
118120
_vehicle setVariable [QGVAR(numLimitedPositions), _numLimitedPositions];
119121
_vehicle setVariable [QGVAR(broadcasting), _broadcasting];
122+
_vehicle setVariable [QGVAR(accent), _accent];

‎addons/sys_intercom/fnc_enterVehicle.sqf

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ if (_unit != _vehicle) then {
4343

4444
// Reset variables
4545
_unit setVariable [QGVAR(intercomVehicle), objNull];
46-
_unit setVariable [QGVAR(intercomPTT), false, true];
4746
_unit setVariable [QGVAR(role), ""];
4847
ACRE_PLAYER_INTERCOM = [];
4948
};
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Handles setting up accent in the master station.
5+
*
6+
* Arguments:
7+
* 0: Vehicle with intercom <OBJECT>
8+
* 2: Intercom network <NUMBER>
9+
* 3: Accent active <BOOL>
10+
*
11+
* Return Value:
12+
* None
13+
*
14+
* Example:
15+
* [(vehicle acre_player), "intercom1", true] call acre_sys_intercom_fnc_handleAccent
16+
*
17+
* Public: No
18+
*/
19+
20+
params ["_vehicle", "_intercomNetwork", "_accentActive"];
21+
22+
private _accentConfig = _vehicle getVariable [QGVAR(accent), []];
23+
private _changes = false;
24+
25+
{
26+
if (_intercomNetwork == _forEachIndex || {_intercomNetwork == ALL_INTERCOMS}) then {
27+
_accentConfig set [_forEachIndex, _accentActive];
28+
_changes = true;
29+
};
30+
} forEach (_vehicle getVariable [QGVAR(intercomNames), []]);
31+
32+
// Only broadcast if changes have been made
33+
if (_changes) then {
34+
_vehicle setVariable [QGVAR(accent), _accentConfig, true];
35+
};

‎addons/sys_intercom/fnc_handleBroadcasting.sqf

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
params ["_vehicle", "_unit", "_intercomNetwork", "_isBroadcasting"];
2222

2323
private _broadcastConfig = _vehicle getVariable [QGVAR(broadcasting), []];
24+
GVAR(broadcastKey) = _isBroadcasting;
25+
2426
private _changes = false;
2527
{
2628
private _canBroadcast = [_vehicle, _unit, _forEachIndex, INTERCOM_STATIONSTATUS_MASTERSTATION] call FUNC(getStationConfiguration);
@@ -34,8 +36,16 @@ private _changes = false;
3436
};
3537
} forEach (_vehicle getVariable [QGVAR(intercomNames), []]);
3638

37-
// Only broadcast if changes have been made
39+
// Only broadcast if changes have been made.
40+
// TODO: Remove synchronisation once intercom system has been converted to components and unique IDs.
41+
// It will help in reduce the bandwith, since information will be exchanged through the TS plugin.
3842
if (_changes) then {
3943
[_vehicle, _unit] call FUNC(updateVehicleInfoText);
4044
_vehicle setVariable [QGVAR(broadcasting), _broadcastConfig, true];
45+
46+
if (_isBroadcasting) then {
47+
["startIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
48+
} else {
49+
["stopIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
50+
};
4151
};

‎addons/sys_intercom/fnc_handleIntercomActivation.sqf

+9
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@
1818

1919
params ["_unit", "_voiceActivation"];
2020

21+
// TODO: Remove synchronisation once intercom system has been converted to components and unique IDs.
22+
// It will help in reduce the bandwith, since information will be exchanged through the TS plugin.
2123
_unit setVariable [QGVAR(intercomPTT), _voiceActivation, true];
24+
GVAR(intercomPttKey) = _voiceActivation;
25+
26+
if (_voiceActivation) then {
27+
["startIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
28+
} else {
29+
["stopIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
30+
};

‎addons/sys_intercom/fnc_handlePttKeyPress.sqf

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ private _vehicle = vehicle acre_player;
2424
if (_vehicle == acre_player) exitWith { true };
2525

2626
switch (_action) do {
27-
case 0 : { GVAR(intercomPttKey) = true; [acre_player, true] call FUNC(handleIntercomActivation); };
28-
case 1 : { GVAR(broadcastKey) = true; [_vehicle, acre_player, ALL_INTERCOMS, true] call FUNC(handleBroadcasting); };
27+
case ACTION_INTERCOM_PTT: {[acre_player, true] call FUNC(handleIntercomActivation); };
28+
case ACTION_BROADCAST: {[_vehicle, acre_player, ALL_INTERCOMS, true] call FUNC(handleBroadcasting); };
2929
};
3030

3131
[_vehicle, acre_player] call FUNC(updateVehicleInfoText);

‎addons/sys_intercom/fnc_handlePttKeyPressUp.sqf

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ private _vehicle = vehicle acre_player;
2424
if (_vehicle == acre_player) exitWith { true };
2525

2626
switch (_action) do {
27-
case 0 : { GVAR(intercomPttKey) = false; [acre_player, false] call FUNC(handleIntercomActivation); };
28-
case 1 : { GVAR(broadcastKey) = false; [_vehicle, acre_player, ALL_INTERCOMS, false] call FUNC(handleBroadcasting); };
27+
case ACTION_INTERCOM_PTT: {[acre_player, false] call FUNC(handleIntercomActivation);};
28+
case ACTION_BROADCAST: {[_vehicle, acre_player, ALL_INTERCOMS, false] call FUNC(handleBroadcasting);};
2929
};
3030

3131
[_vehicle, acre_player] call FUNC(updateVehicleInfoText);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Handles multi push-to-talk keybind press (to be ran within PFH).
5+
*
6+
* Arguments:
7+
* 0: Arguments array <ARRAY>
8+
* 0: Broadcasting radio unique ID <STRING>
9+
* 1: Multi-PTT-Key pressed <BOOL>
10+
* 1: PerFrameHandler ID <NUMBER> (unused)
11+
*
12+
* Return Value:
13+
* Handled <BOOL>
14+
*
15+
* Example:
16+
* [] call acre_sys_core_fnc_handleMultiPttKeyPressUpPFH
17+
*
18+
* Public: No
19+
*/
20+
21+
params ["_args", ""];
22+
_args params ["_broadcastRadio", "_keyPressed"];
23+
24+
if (_keyPressed) then {
25+
[GVAR(delayReleasePTT_Handle)] call CBA_fnc_removePerFrameHandler;
26+
GVAR(delayReleasePTT_Handle) = nil;
27+
28+
if (GVAR(pttKeyDown)) then {
29+
[_broadcastRadio, "handlePTTUp"] call EFUNC(sys_data,transEvent);
30+
["stopIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
31+
GVAR(pttKeyDown) = false;
32+
};
33+
} else {
34+
_args set [1, true];
35+
_this set [0, _args];
36+
};

‎addons/sys_intercom/fnc_intercomListChildrenActions.sqf

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ if ([_target, acre_player, _intercomNetwork, INTERCOM_STATIONSTATUS_HASINTERCOMA
9494
_action = [QGVAR(acre_startBroadcast), localize LSTRING(startBroadcast), "", {[_target, _player, _this select 2, true] call FUNC(handleBroadcasting)}, {true}, {}, _intercomNetwork] call ace_interact_menu_fnc_createAction;
9595
};
9696
_actions pushBack [_action, [], _target];
97+
98+
private _accentActive = (_target getVariable [QGVAR(accent), [false]]) select _intercomNetwork;
99+
if (_accentActive) then {
100+
_action = [QGVAR(deactivateAccent), localize LSTRING(deactivateAccent), "", {[_target, _this select 2, false] call FUNC(handleAccent)}, {true}, {}, _intercomNetwork] call ace_interact_menu_fnc_createAction;
101+
} else {
102+
_action = [QGVAR(activateAccent), localize LSTRING(activateAccent), "", {[_target, _this select 2, true] call FUNC(handleAccent)}, {true}, {}, _intercomNetwork] call ace_interact_menu_fnc_createAction;
103+
};
104+
_actions pushBack [_action, [], _target];
97105
};
98106

99107
_action = [

‎addons/sys_intercom/fnc_intercomPFH.sqf

+2
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ for "_i" from 0 to ((count _intercoms) - 1) do {
8989

9090
ACRE_PLAYER_INTERCOM set [_i, _intercomUnits];
9191
};
92+
93+
[_vehicle, ACRE_PLAYER_INTERCOM, _intercoms] call FUNC(updateIntercomUse);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Gets the local radio volume affected by intercom.
5+
*
6+
* Arguments:
7+
* 0: Radio ID <STRING>
8+
* 1: Volume <NUMBER>
9+
* 2: Vehicle <OBJECT> (default: objNull)
10+
* 3: Rack ID <STRING> (default: "")
11+
*
12+
* Return Value:
13+
* Radio volume affected by intercom <NUMBER>
14+
*
15+
* Example:
16+
* ["acre_prc152_id_1", 0.8] call acre_sys_intercom_fnc_modifyRadioVolume
17+
*
18+
* Public: No
19+
*/
20+
21+
params ["_radioId", "_volume", ["_vehicle", objNull], ["_rackId", ""]];
22+
23+
if (!(_radioId in ACRE_ACCESSIBLE_RACK_RADIOS) && {!(_radioId in ACRE_HEARABLE_RACK_RADIOS)}) exitWith {_volume};
24+
25+
if (_rackId isEqualTo "") then {
26+
_rackId = [_radioId] call EFUNC(sys_rack,getRackFromRadio);
27+
};
28+
29+
if (_rackId == "") exitWith {_volume};
30+
31+
if (isNull _vehicle) then {
32+
_vehicle = [_rackId] call EFUNC(sys_rack,getVehicleFromRack);
33+
};
34+
35+
private _accentConfig = _vehicle getVariable [QGVAR(accent), [false]];
36+
private _connectedIntercoms = [_rackId] call EFUNC(sys_rack,getWiredIntercoms);
37+
if (_connectedIntercoms isEqualTo []) exitWith {_volume};
38+
39+
private _modifiedVolume = 0;
40+
{
41+
_x params ["_intercomName", "_intercomInUse"];
42+
private _connected = ([_vehicle, acre_player, _forEachIndex, INTERCOM_STATIONSTATUS_CONNECTION] call FUNC(getStationConfiguration)) > 0;
43+
if ((_intercomName in _connectedIntercoms) && {_connected}) then {
44+
private _intercomVolume = [_vehicle, acre_player, _forEachIndex, INTERCOM_STATIONSTATUS_VOLUME] call FUNC(getStationConfiguration);
45+
private _tempVolume = _intercomVolume;
46+
if (_intercomInUse && {_accentConfig select _forEachIndex}) then {
47+
_tempVolume = _intercomVolume * INTERCOM_ACCENT_VOLUME_FACTOR; // Reduce volume by 20% if intercom is active and there is an incomming radio transmission
48+
if (_tempVolume < MINIMUM_INTERCOM_ACCENT_VOLUME) then {
49+
_tempVolume = MINIMUM_INTERCOM_ACCENT_VOLUME;
50+
};
51+
};
52+
53+
// Always return the highest intercome outcome
54+
if (_tempVolume > _modifiedVolume) then {
55+
_modifiedVolume = _tempVolume;
56+
};
57+
};
58+
} forEach GVAR(intercomUse);
59+
60+
if (_modifiedVolume > 0) exitWith {_modifiedVolume};
61+
62+
_volume

‎addons/sys_intercom/fnc_seatSwitched.sqf

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ params ["_vehicle", "_unit"];
2121
private _intercomNames = _vehicle getVariable [QGVAR(intercomNames), []];
2222
private _oldSeat = _unit getVariable [QGVAR(role), ""];
2323

24+
// If unit is transmitting through intercom, stop the transmittion during the seat switch
25+
if (GVAR(intercomPTT)) then {
26+
[ACTION_INTERCOM_PTT] call FUNC(handlePttKeyPressUp);
27+
};
28+
29+
// Same for broadcast messages
30+
if (GVAR(broadcastKey)) then {
31+
[ACTION_BROADCAST] call FUNC(handlePttKeyPressUp);
32+
};
33+
2434
{
2535
if (_oldSeat != "") then {
2636
private _connectionStatus = [_vehicle, _unit, _forEachIndex, INTERCOM_STATIONSTATUS_CONNECTION, _oldSeat] call FUNC(getStationConfiguration);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: ACRE2Team
4+
* Checks if intercoms are in use. Used by intercom accent.
5+
*
6+
* Arguments:
7+
* 0: Vehicle <OBJECT>
8+
* 1: Units connected to intercom <ARRAY>
9+
* 2: Intercom identifiers <ARRAY>
10+
*
11+
* Return Value:
12+
* None
13+
*
14+
* Example:
15+
* [cursorTarget] call acre_sys_intercom_fnc_updateIntercomUse
16+
*
17+
* Public: No
18+
*/
19+
20+
params ["_vehicle", "_intercoms", "_intercomNames"];
21+
22+
private _intercomNames = _vehicle getVariable [QGVAR(intercomNames), []];
23+
24+
{
25+
private _name = (_intercomNames select _forEachIndex) select 0;
26+
private _inUse = (_x findIf {_x in EGVAR(sys_core,speakers)}) != -1;
27+
GVAR(intercomUse) set [_forEachIndex, [_name, _inUse]];
28+
} forEach _intercoms;

0 commit comments

Comments
 (0)
Please sign in to comment.