From 059ce007ac261213f16f6360905b64f59b12e7bf Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 19 Nov 2023 13:52:27 +0100 Subject: [PATCH 01/13] New API Function setupRadios --- addons/api/CfgFunctions.hpp | 1 + addons/api/fnc_setupRadios.sqf | 79 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 addons/api/fnc_setupRadios.sqf diff --git a/addons/api/CfgFunctions.hpp b/addons/api/CfgFunctions.hpp index a202bd0ca..815d36b57 100644 --- a/addons/api/CfgFunctions.hpp +++ b/addons/api/CfgFunctions.hpp @@ -46,6 +46,7 @@ class CfgFunctions { PATHTO_FNC(setRadioChannel); PATHTO_FNC(getRadioChannel); + PATHTO_FNC(setupRadios); PATHTO_FNC(setRadioVolume); PATHTO_FNC(getRadioVolume); diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf new file mode 100644 index 000000000..aa6f310e2 --- /dev/null +++ b/addons/api/fnc_setupRadios.sqf @@ -0,0 +1,79 @@ +#include "script_component.hpp" +/* + * Author: mrschick + * When run locally it will set the currently carried radios to the selected channel numbers. + * + * Arguments: + * 0-N: Radio assignments + * 0: Radio Baseclass + * 1: Radio Channel/Block/Frequency or + * + * Return Value: + * Successful + * + * Example: + * _success = [ ["ACRE_PRC343", [2,3]], ["ACRE_PRC152", 3], ["ACRE_PRC77", [2,4]] ] call acre_api_fnc_setupRadios; + * // Will set PRC343 to Ch2 Blk3, PRC152 to Ch3 and PRC77 to 31.15 MHz + * + * _success = [ ["ACRE_PRC343", 6], ["ACRE_PRC152", 2], ["ACRE_PRC152", 3] ] call acre_api_fnc_setupRadios; + * // Will set PRC343 to Ch6 Blk1, the first PRC152 to Ch2 and the second PRC152 to Ch3 + * + * Public: Yes + */ + +private _assignments = _this; + +if (count(_assignments) isEqualTo 0 || !((_assignments select 0) isEqualType [])) exitWith {}; // Abort if argument is empty or not an array + +private _radios = [] call EFUNC(sys_data,getPlayerRadioList); + +if (_radios isEqualTo []) exitWith {}; // Abort if carrying no radios + +{ // iterate through carried radios + private _radio = _x; + private _radioBaseClass = [_radio] call EFUNC(sys_radio,getRadioBaseClassname); + + // iterate through arguments and set up radio if baseclass matches + for "_i" from 0 to count(_assignments)-1 do { + (_assignments select _i) params ["_radioType", "_channel"]; + private _eventData = []; + + // Skip assignment if its type doesn't match current radio baseclass + if !(_radioType isEqualTo _radioBaseClass) then { continue; }; + + // Turn channel argument into an array of 1 or 2 numbers, 0-index them + if (_channel isEqualType []) then { + { _eventData pushBack (_x - 1) } forEach _channel; + } else { + _eventData = [_channel - 1]; + }; + + // Parse eventData to match the expected input for the respective radio's setCurrentChannel function + switch (_radioType) do { + case "ACRE_PRC343": { + if (count _eventData == 2) then { // set channel and block + _eventData = ((_eventData select 1) * 16) + (_eventData select 0); + } else { // set channel + _eventData = _eventData select 0; + }; + }; + case "ACRE_PRC77": { + if (count _eventData < 2) then { // set only MHz, insert 0 to nullify KHz + _eventData pushBack 0; + }; + }; + // @TODO parsing for SEM52L/SEM70 + default { + _eventData = _eventData select 0; + }; + }; + + [_radio, "setCurrentChannel", _eventData] call EFUNC(sys_data,dataEvent); + + // Delete applied assignment and break out to handle next radio + _assignments deleteAt _i; + break; + }; +} forEach _radios; + +true From f9def942dcaed846717df971a4e57e877781ba4e Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 19 Nov 2023 15:25:49 +0100 Subject: [PATCH 02/13] Rephrase arguments example and rename var accordingly --- addons/api/fnc_setupRadios.sqf | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index aa6f310e2..438cee034 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -4,8 +4,13 @@ * When run locally it will set the currently carried radios to the selected channel numbers. * * Arguments: - * 0-N: Radio assignments - * 0: Radio Baseclass + * [RadioSetting1, RadioSetting2, ...] + * + * RadioSetting: [RadioType, Channel] or + * [RadioType, [Channel, Block]] or + * [RadioType, MHz] or + * [RadioType, [MHz, KHz]] + * 0: Radio Base Class * 1: Radio Channel/Block/Frequency or * * Return Value: @@ -21,9 +26,9 @@ * Public: Yes */ -private _assignments = _this; +private _settings = _this; -if (count(_assignments) isEqualTo 0 || !((_assignments select 0) isEqualType [])) exitWith {}; // Abort if argument is empty or not an array +if (count(_settings) isEqualTo 0 || !((_settings select 0) isEqualType [])) exitWith {}; // Abort if argument is empty or not an array private _radios = [] call EFUNC(sys_data,getPlayerRadioList); @@ -34,11 +39,11 @@ if (_radios isEqualTo []) exitWith {}; // Abort if carrying no radios private _radioBaseClass = [_radio] call EFUNC(sys_radio,getRadioBaseClassname); // iterate through arguments and set up radio if baseclass matches - for "_i" from 0 to count(_assignments)-1 do { - (_assignments select _i) params ["_radioType", "_channel"]; + for "_i" from 0 to count(_settings)-1 do { + (_settings select _i) params ["_radioType", "_channel"]; private _eventData = []; - // Skip assignment if its type doesn't match current radio baseclass + // Skip setting if its type doesn't match current radio baseclass if !(_radioType isEqualTo _radioBaseClass) then { continue; }; // Turn channel argument into an array of 1 or 2 numbers, 0-index them @@ -70,8 +75,8 @@ if (_radios isEqualTo []) exitWith {}; // Abort if carrying no radios [_radio, "setCurrentChannel", _eventData] call EFUNC(sys_data,dataEvent); - // Delete applied assignment and break out to handle next radio - _assignments deleteAt _i; + // Delete applied setting and break out to handle next radio + _settings deleteAt _i; break; }; } forEach _radios; From 01841498f821b609a0f89a59ebdf9c57d80b9aba Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 19 Nov 2023 18:00:25 +0100 Subject: [PATCH 03/13] Add documentation of fnc_setupRadios --- docs/_includes/custom/functions-list-api.html | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/_includes/custom/functions-list-api.html b/docs/_includes/custom/functions-list-api.html index 725621f99..62dd4917c 100644 --- a/docs/_includes/custom/functions-list-api.html +++ b/docs/_includes/custom/functions-list-api.html @@ -348,6 +348,36 @@ ``` +--- + +### acre_api_fnc_setupRadios +__Description__ + +Sets the currently carried radios to the provided channel numbers. + +__Parameters__ + +Index | Description | Datatype(s) | Default Value +--- | --- | --- | --- +0-n | Radio Setting | ARRAY | + +__Return Value__ + +Description | Datatype(s) +--- | --- +Successful | BOOLEAN + +__Example__ + +```sqf +_success = [ ["ACRE_PRC343", [2,3]], ["ACRE_PRC152", 3], ["ACRE_PRC77", [2,4]] ] call acre_api_fnc_setupRadios; +// Will set PRC343 to Ch2 Blk3, PRC152 to Ch3 and PRC77 to 31.15 MHz + +_success = [ ["ACRE_PRC343", 6], ["ACRE_PRC152", 2], ["ACRE_PRC152", 3] ] call acre_api_fnc_setupRadios; +// Will set PRC343 to Ch6 Blk1, the first PRC152 to Ch2 and the second PRC152 to Ch3 +``` + + --- ### acre_api_fnc_setPresetChannelData From 4dc3a6815bb9e5e5a70d678dc604b68fda61c65f Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sat, 25 Nov 2023 11:09:02 +0100 Subject: [PATCH 04/13] Return false on invalid input --- addons/api/fnc_setupRadios.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index 438cee034..7b7b12195 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -28,11 +28,11 @@ private _settings = _this; -if (count(_settings) isEqualTo 0 || !((_settings select 0) isEqualType [])) exitWith {}; // Abort if argument is empty or not an array +if (count(_settings) isEqualTo 0 || !((_settings select 0) isEqualType [])) exitWith { false }; // Abort if argument is empty or not an array private _radios = [] call EFUNC(sys_data,getPlayerRadioList); -if (_radios isEqualTo []) exitWith {}; // Abort if carrying no radios +if (_radios isEqualTo []) exitWith { false }; // Abort if carrying no radios { // iterate through carried radios private _radio = _x; From 6a4c12386bfa45389c0309addb580ed5aba08760 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sat, 25 Nov 2023 17:54:30 +0100 Subject: [PATCH 05/13] Make setup of PRC-77 more user friendly --- addons/api/fnc_setupRadios.sqf | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index 7b7b12195..86fe50cbc 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -17,7 +17,7 @@ * Successful * * Example: - * _success = [ ["ACRE_PRC343", [2,3]], ["ACRE_PRC152", 3], ["ACRE_PRC77", [2,4]] ] call acre_api_fnc_setupRadios; + * _success = [ ["ACRE_PRC343", [2,3]], ["ACRE_PRC152", 3], ["ACRE_PRC77", [31,15]] ] call acre_api_fnc_setupRadios; * // Will set PRC343 to Ch2 Blk3, PRC152 to Ch3 and PRC77 to 31.15 MHz * * _success = [ ["ACRE_PRC343", 6], ["ACRE_PRC152", 2], ["ACRE_PRC152", 3] ] call acre_api_fnc_setupRadios; @@ -46,30 +46,35 @@ if (_radios isEqualTo []) exitWith { false }; // Abort if carrying no radios // Skip setting if its type doesn't match current radio baseclass if !(_radioType isEqualTo _radioBaseClass) then { continue; }; - // Turn channel argument into an array of 1 or 2 numbers, 0-index them + // Turn channel argument into an array of 1 or 2 numbers if (_channel isEqualType []) then { - { _eventData pushBack (_x - 1) } forEach _channel; + { _eventData pushBack (_x) } forEach _channel; } else { - _eventData = [_channel - 1]; + _eventData = [_channel]; }; // Parse eventData to match the expected input for the respective radio's setCurrentChannel function switch (_radioType) do { case "ACRE_PRC343": { if (count _eventData == 2) then { // set channel and block - _eventData = ((_eventData select 1) * 16) + (_eventData select 0); + _eventData = (((_eventData select 1) - 1) * 16) + (_eventData select 0) - 1; } else { // set channel - _eventData = _eventData select 0; + _eventData = (_eventData select 0) - 1; }; }; case "ACRE_PRC77": { if (count _eventData < 2) then { // set only MHz, insert 0 to nullify KHz _eventData pushBack 0; + } else { + if (_eventData select 1 > 0) then { // parse KHz if set by user + _eventData set [1, (floor ((_eventData select 1) / 5) min 19)]; + }; }; + _eventData set [0, (0 max ((_eventData select 0) - 30))]; }; // @TODO parsing for SEM52L/SEM70 default { - _eventData = _eventData select 0; + _eventData = (_eventData select 0) - 1; }; }; From b0231989ab0bf590830a1999fef8839bf7485c8d Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 27 Nov 2023 20:37:28 +0100 Subject: [PATCH 06/13] Support setting SEM52L channels and SEM70 frequencies --- addons/api/fnc_setupRadios.sqf | 14 ++++++++- .../sys_sem70/radio/fnc_setCurrentChannel.sqf | 29 +++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index 86fe50cbc..8e5c2e839 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -22,6 +22,9 @@ * * _success = [ ["ACRE_PRC343", 6], ["ACRE_PRC152", 2], ["ACRE_PRC152", 3] ] call acre_api_fnc_setupRadios; * // Will set PRC343 to Ch6 Blk1, the first PRC152 to Ch2 and the second PRC152 to Ch3 + * + * _success = [ ["ACRE_SEM52SL", 8], ["ACRE_SEM70", [34,075]] ] call acre_api_fnc_setupRadios; + * // Will set SEM52SL to Ch8 and SEM70 to 34.075 MHz * * Public: Yes */ @@ -72,7 +75,16 @@ if (_radios isEqualTo []) exitWith { false }; // Abort if carrying no radios }; _eventData set [0, (0 max ((_eventData select 0) - 30))]; }; - // @TODO parsing for SEM52L/SEM70 + case "ACRE_SEM70": { + if (count _eventData < 2) then { // set only MHz, insert 0 to nullify KHz + _eventData pushBack 0; + } else { + if (_eventData select 1 > 0) then { // parse KHz if set by user + _eventData set [1, (round ((_eventData select 1) / 25) min 39)]; + }; + }; + _eventData set [0, (0 max ((_eventData select 0) - 30))]; + }; default { _eventData = (_eventData select 0) - 1; }; diff --git a/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf b/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf index c2c60dfaa..7c27fd134 100644 --- a/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf +++ b/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf @@ -44,18 +44,29 @@ private _manualChannel = HASH_GET(_radioData, "manualChannelSelection"); TRACE_1("ManualChannel",_manualChannel); if (_manualChannel isEqualTo 1) then { - private _currentMHzFrequency = HASH_GET(_radioData, "MHzKnobPosition"); - _currentMHzFrequency = _currentMHzFrequency + 30; - private _currentkHzFrequency = HASH_GET(_radioData, "kHzKnobPosition"); - _currentkHzFrequency = _currentkHzFrequency * 25 / 1000; - private _newFreq = _currentMHzFrequency + _currentkHzFrequency; - private _channels = HASH_GET(_radioData, "channels"); private _channel = HASHLIST_SELECT(_channels, GVAR(manualChannel)); - HASH_SET(_channel, "frequencyTX", _newFreq); - HASH_SET(_channel, "frequencyRX", _newFreq); - TRACE_3("",_currentMHzFrequency,_currentkHzFrequency,_newFreq); + if (_eventData isEqualType []) then { // if event data comes from a setChannel-type API in the [MHzKnobPos,KHzKnobPos] format + private _newFreq = ((_eventData select 0) + 30) + ((_eventData select 1) * 25 / 1000); + + HASH_SET(_channel, "frequencyTX", _newFreq); + HASH_SET(_channel, "frequencyRX", _newFreq); + TRACE_1("",_newFreq); + + HASH_SET(_radioData, "MHzKnobPosition", (_eventData select 0)); + HASH_SET(_radioData, "kHzKnobPosition", (_eventData select 1)); + } else { + private _currentMHzFrequency = HASH_GET(_radioData, "MHzKnobPosition"); + _currentMHzFrequency = _currentMHzFrequency + 30; + private _currentkHzFrequency = HASH_GET(_radioData, "kHzKnobPosition"); + _currentkHzFrequency = _currentkHzFrequency * 25 / 1000; + private _newFreq = _currentMHzFrequency + _currentkHzFrequency; + + HASH_SET(_channel, "frequencyTX", _newFreq); + HASH_SET(_channel, "frequencyRX", _newFreq); + TRACE_3("",_currentMHzFrequency,_currentkHzFrequency,_newFreq); + }; [_radioID,"setChannelData", [GVAR(manualChannel), _channel]] call EFUNC(sys_data,dataEvent); From d0de00f58465e29cd657c05ffe9a4df7a5e16c98 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 27 Nov 2023 23:47:02 +0100 Subject: [PATCH 07/13] Update Documentation --- docs/_includes/custom/functions-list-api.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/_includes/custom/functions-list-api.html b/docs/_includes/custom/functions-list-api.html index 62dd4917c..b084cc80b 100644 --- a/docs/_includes/custom/functions-list-api.html +++ b/docs/_includes/custom/functions-list-api.html @@ -353,7 +353,7 @@ ### acre_api_fnc_setupRadios __Description__ -Sets the currently carried radios to the provided channel numbers. +Takes an array of "Radio Settings" and matches those to the currently carried radios, setting each type of radio to the selected channel/block or frequency. __Parameters__ @@ -361,6 +361,13 @@ --- | --- | --- | --- 0-n | Radio Setting | ARRAY | +__Radio Setting Parameters__ + +Index | Description | Datatype(s) | Default Value +--- | --- | --- | --- +0 | Radio Baseclass the setting applies to | STRING | +1 | Single Channel number, [Channel,Block] or [MHz,KHz] arrays | NUMBER OR ARRAY | + __Return Value__ Description | Datatype(s) @@ -370,11 +377,14 @@ __Example__ ```sqf -_success = [ ["ACRE_PRC343", [2,3]], ["ACRE_PRC152", 3], ["ACRE_PRC77", [2,4]] ] call acre_api_fnc_setupRadios; +_success = [ ["ACRE_PRC343", [2,3]], ["ACRE_PRC152", 3], ["ACRE_PRC77", [31,15]] ] call acre_api_fnc_setupRadios; // Will set PRC343 to Ch2 Blk3, PRC152 to Ch3 and PRC77 to 31.15 MHz _success = [ ["ACRE_PRC343", 6], ["ACRE_PRC152", 2], ["ACRE_PRC152", 3] ] call acre_api_fnc_setupRadios; // Will set PRC343 to Ch6 Blk1, the first PRC152 to Ch2 and the second PRC152 to Ch3 + +_success = [ ["ACRE_SEM52SL", 8], ["ACRE_SEM70", [34,075]] ] call acre_api_fnc_setupRadios; +// Will set SEM52SL to Ch8 and SEM70 to 34.075 MHz ``` From dbf4865beb5a88eb58793ddc53c22ae79c86fd6a Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:33:02 +0200 Subject: [PATCH 08/13] Remove spaces from Macros --- .../sys_sem70/radio/fnc_setCurrentChannel.sqf | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf b/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf index 7c27fd134..59ed3aa8b 100644 --- a/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf +++ b/addons/sys_sem70/radio/fnc_setCurrentChannel.sqf @@ -40,31 +40,31 @@ params ["_radioId", "", "_eventData", "_radioData"]; TRACE_2("setCurrentChannel",_radioID,_eventData); -private _manualChannel = HASH_GET(_radioData, "manualChannelSelection"); +private _manualChannel = HASH_GET(_radioData,"manualChannelSelection"); TRACE_1("ManualChannel",_manualChannel); if (_manualChannel isEqualTo 1) then { - private _channels = HASH_GET(_radioData, "channels"); - private _channel = HASHLIST_SELECT(_channels, GVAR(manualChannel)); + private _channels = HASH_GET(_radioData,"channels"); + private _channel = HASHLIST_SELECT(_channels,GVAR(manualChannel)); if (_eventData isEqualType []) then { // if event data comes from a setChannel-type API in the [MHzKnobPos,KHzKnobPos] format private _newFreq = ((_eventData select 0) + 30) + ((_eventData select 1) * 25 / 1000); - HASH_SET(_channel, "frequencyTX", _newFreq); - HASH_SET(_channel, "frequencyRX", _newFreq); + HASH_SET(_channel,"frequencyTX",_newFreq); + HASH_SET(_channel,"frequencyRX",_newFreq); TRACE_1("",_newFreq); - HASH_SET(_radioData, "MHzKnobPosition", (_eventData select 0)); - HASH_SET(_radioData, "kHzKnobPosition", (_eventData select 1)); + HASH_SET(_radioData,"MHzKnobPosition",(_eventData select 0)); + HASH_SET(_radioData,"kHzKnobPosition",(_eventData select 1)); } else { - private _currentMHzFrequency = HASH_GET(_radioData, "MHzKnobPosition"); + private _currentMHzFrequency = HASH_GET(_radioData,"MHzKnobPosition"); _currentMHzFrequency = _currentMHzFrequency + 30; - private _currentkHzFrequency = HASH_GET(_radioData, "kHzKnobPosition"); + private _currentkHzFrequency = HASH_GET(_radioData,"kHzKnobPosition"); _currentkHzFrequency = _currentkHzFrequency * 25 / 1000; private _newFreq = _currentMHzFrequency + _currentkHzFrequency; - HASH_SET(_channel, "frequencyTX", _newFreq); - HASH_SET(_channel, "frequencyRX", _newFreq); + HASH_SET(_channel,"frequencyTX",_newFreq); + HASH_SET(_channel,"frequencyRX",_newFreq); TRACE_3("",_currentMHzFrequency,_currentkHzFrequency,_newFreq); }; From 9328f54c13fdd38ce16cfc2d0ceb1a91d87499b6 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:07:57 +0200 Subject: [PATCH 09/13] Refactor exit conditions --- addons/api/fnc_setupRadios.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index 8e5c2e839..15e02c51a 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -31,11 +31,13 @@ private _settings = _this; -if (count(_settings) isEqualTo 0 || !((_settings select 0) isEqualType [])) exitWith { false }; // Abort if argument is empty or not an array +// Abort if argument is empty or not an array +if ((_settings isEqualTo []) || {!((_settings select 0) isEqualType [])}) exitWith { false }; private _radios = [] call EFUNC(sys_data,getPlayerRadioList); -if (_radios isEqualTo []) exitWith { false }; // Abort if carrying no radios +// Abort if carrying no radios +if (_radios isEqualTo []) exitWith { false }; { // iterate through carried radios private _radio = _x; From 052475d237f8f99c53cf1d1b73db91597dfb186d Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:08:41 +0200 Subject: [PATCH 10/13] Case insensitive check for radio baseclass --- addons/api/fnc_setupRadios.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index 15e02c51a..d8d0bbe32 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -49,7 +49,7 @@ if (_radios isEqualTo []) exitWith { false }; private _eventData = []; // Skip setting if its type doesn't match current radio baseclass - if !(_radioType isEqualTo _radioBaseClass) then { continue; }; + if (_radioType != _radioBaseClass) then { continue }; // Turn channel argument into an array of 1 or 2 numbers if (_channel isEqualType []) then { From 962075c75faa85a66c6f4976c22bdd6ff5f27e65 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:50:42 +0200 Subject: [PATCH 11/13] LOG Outputs for API function --- addons/api/fnc_setupRadios.sqf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/api/fnc_setupRadios.sqf b/addons/api/fnc_setupRadios.sqf index d8d0bbe32..63d2de38e 100644 --- a/addons/api/fnc_setupRadios.sqf +++ b/addons/api/fnc_setupRadios.sqf @@ -32,12 +32,18 @@ private _settings = _this; // Abort if argument is empty or not an array -if ((_settings isEqualTo []) || {!((_settings select 0) isEqualType [])}) exitWith { false }; +if ((_settings isEqualTo []) || {!((_settings select 0) isEqualType [])}) exitWith { + WARNING_1("Attempted to import radio setup %1, aborting because it's empty or of the wrong format",_settings); + false +}; private _radios = [] call EFUNC(sys_data,getPlayerRadioList); // Abort if carrying no radios -if (_radios isEqualTo []) exitWith { false }; +if (_radios isEqualTo []) exitWith { + WARNING_1("Attempted to import radio setup %1, aborting due to no radios carried",_settings); + false +}; { // iterate through carried radios private _radio = _x; @@ -94,6 +100,8 @@ if (_radios isEqualTo []) exitWith { false }; [_radio, "setCurrentChannel", _eventData] call EFUNC(sys_data,dataEvent); + INFO_2("Applied radio setup %1 onto carried radio %2",_settings select _i,_radio); + // Delete applied setting and break out to handle next radio _settings deleteAt _i; break; From 6403233586892b9246a433380c849bd86d7189f6 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 13 Aug 2024 17:07:26 +0200 Subject: [PATCH 12/13] EDEN Attribute to set Radio Channels through API --- addons/sys_core/CfgEden.hpp | 21 +++++++++++++++++++++ addons/sys_core/config.cpp | 1 + addons/sys_core/stringtable.xml | 5 +++++ addons/sys_radio/Cfg3DEN.hpp | 20 ++++++++++++++++++++ addons/sys_radio/XEH_postInit.sqf | 12 ++++++++++++ addons/sys_radio/config.cpp | 1 + addons/sys_radio/stringtable.xml | 10 ++++++++++ 7 files changed, 70 insertions(+) create mode 100644 addons/sys_core/CfgEden.hpp create mode 100644 addons/sys_radio/Cfg3DEN.hpp diff --git a/addons/sys_core/CfgEden.hpp b/addons/sys_core/CfgEden.hpp new file mode 100644 index 000000000..241498238 --- /dev/null +++ b/addons/sys_core/CfgEden.hpp @@ -0,0 +1,21 @@ +class Cfg3DEN { + class Object { + class AttributeCategories { + class acre_attributes { + displayName = CSTRING(Options); + collapsed = 1; + class Attributes {}; + }; + }; + }; + + class Group { + class AttributeCategories { + class acre_attributes { + displayName = CSTRING(Options); + collapsed = 1; + class Attributes {}; + }; + }; + }; +}; diff --git a/addons/sys_core/config.cpp b/addons/sys_core/config.cpp index ece4e535f..0c9d2fc72 100644 --- a/addons/sys_core/config.cpp +++ b/addons/sys_core/config.cpp @@ -12,6 +12,7 @@ class CfgPatches { VERSION_CONFIG; }; }; +#include "CfgEden.hpp" #include "CfgEventHandlers.hpp" #include "CfgSounds.hpp" diff --git a/addons/sys_core/stringtable.xml b/addons/sys_core/stringtable.xml index 0370ef6f3..60258b2bc 100644 --- a/addons/sys_core/stringtable.xml +++ b/addons/sys_core/stringtable.xml @@ -1,6 +1,11 @@ + + ACRE Options + ACRE-Optionen + Opzioni ACRE + ACRE2 UI ACRE2 Nutzeroberfläche diff --git a/addons/sys_radio/Cfg3DEN.hpp b/addons/sys_radio/Cfg3DEN.hpp new file mode 100644 index 000000000..a5a463146 --- /dev/null +++ b/addons/sys_radio/Cfg3DEN.hpp @@ -0,0 +1,20 @@ +class Cfg3DEN { + class Object { + class AttributeCategories { + class acre_attributes { + class Attributes { + class GVAR(edenSetup) { + property = QGVAR(edenSetup); + condition = "objectBrain"; + control = "Edit"; + typeName = "STRING"; + displayName = CSTRING(3den_RadioSetup_DisplayName); + tooltip = CSTRING(3den_RadioSetup_Description); + defaultValue = "[[""ACRE_PRC343"",[1,1]],[""ACRE_PRC152"",1],[""ACRE_PRC117F"",1]]"; + expression = QUOTE(_this setVariable [ARR_3(QQGVAR(setup),_value,true)]); + }; + }; + }; + }; + }; +}; diff --git a/addons/sys_radio/XEH_postInit.sqf b/addons/sys_radio/XEH_postInit.sqf index 456989095..2f8663dd4 100644 --- a/addons/sys_radio/XEH_postInit.sqf +++ b/addons/sys_radio/XEH_postInit.sqf @@ -28,3 +28,15 @@ if (!hasInterface) exitWith {}; // main inventory thread [] call FUNC(monitorRadios); // OK + +// Set up radios with EDEN-defined object attribute +private _setup = parseSimpleArray (acre_player getVariable [QGVAR(setup), []]); +if (_setup isNotEqualTo []) then { + [{ + [] call EFUNC(api,isInitialized) + }, { + params ["_setup"]; + _setup call EFUNC(api,setupRadios); + INFO("Applying EDEN-Defined Radio Setup attribute to carried radios"); + }, [_setup]] call CBA_fnc_waitUntilAndExecute; +}; diff --git a/addons/sys_radio/config.cpp b/addons/sys_radio/config.cpp index 3eb801435..93306c541 100644 --- a/addons/sys_radio/config.cpp +++ b/addons/sys_radio/config.cpp @@ -16,5 +16,6 @@ class CfgPatches { PRELOAD_ADDONS; +#include "Cfg3DEN.hpp" #include "CfgVehicles.hpp" #include "CfgEventHandlers.hpp" diff --git a/addons/sys_radio/stringtable.xml b/addons/sys_radio/stringtable.xml index d89d95ffe..ebf579a96 100644 --- a/addons/sys_radio/stringtable.xml +++ b/addons/sys_radio/stringtable.xml @@ -223,5 +223,15 @@ Rimuovere la maniglia ハンドルを外す + + Radio Channel Setup + Funkgeräte Kanalwahl + Canali radio preimpostati + + + Array of Arrays (comma separated) to set up radio channels of the given unit.\nIt's possible to set up multiple radios of the same type.\nSingular Examples:\n["ACRE_PRC343",1] -> Channel 1, Block 1\n["ACRE_PRC343",[2,3]] -> Channel 2, Block 3\n["ACRE_PRC148",5] -> Channel 5 (same for PRC-148/152/117F, BF-888S and SEM52SL)\n["ACRE_PRC77",[31,15]] -> 31.15 MHz\n["ACRE_SEM70",[34,075]] -> 34.075 MHz\n["ACRE_BF888S",4],["ACRE_BF888S",5] -> Set first BF-888S to Ch 4, second to Ch 5 + Array von Arrays (komma-geteilt) um Funkgerätkanäle einer bestimmten Einheit einzustellen.\nEs ist möglich mehrere Funkgeräte der gleichen Modells einzustellen.\nEinzelne Beispiele:\n["ACRE_PRC343",1] -> Channel 1, Block 1\n["ACRE_PRC343",[2,3]] -> Channel 2, Block 3\n["ACRE_PRC148",5] -> Channel 5 (same for PRC-148/152/117F, BF-888S and SEM52SL)\n["ACRE_PRC77",[31,15]] -> 31.15 MHz\n["ACRE_SEM70",[34,075]] -> 34.075 MHz\n["ACRE_BF888S",4],["ACRE_BF888S",5] -> Set first BF-888S to Ch 4, second to Ch 5 + Array di Array (separati da virgola) per impostare i canali radio di una determinata unità.\nÈ possibile impostare molteplici radio dello stesso tipo.\nEsempi:\n["ACRE_PRC343",1] -> Canale 1, Blocco 1\n["ACRE_PRC343",[2,3]] -> Canale 2, Blocco 3\n["ACRE_PRC148",5] -> Canale 5 (stesso formato per PRC-148/152/117F, BF-888S e SEM52SL)\n["ACRE_PRC77",[31,15]] -> 31.15 MHz\n["ACRE_SEM70",[34,075]] -> 34.075 MHz\n["ACRE_BF888S",4],["ACRE_BF888S",5] -> Imposta la prima BF-888S su Ch 4, la seconda su Ch 5 + From 11387973e9c73c40aaecbbf08669ecf02657c4ce Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:54:18 +0200 Subject: [PATCH 13/13] Fix unparsable default value --- addons/sys_radio/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sys_radio/XEH_postInit.sqf b/addons/sys_radio/XEH_postInit.sqf index 2f8663dd4..dc88eaa46 100644 --- a/addons/sys_radio/XEH_postInit.sqf +++ b/addons/sys_radio/XEH_postInit.sqf @@ -30,7 +30,7 @@ if (!hasInterface) exitWith {}; [] call FUNC(monitorRadios); // OK // Set up radios with EDEN-defined object attribute -private _setup = parseSimpleArray (acre_player getVariable [QGVAR(setup), []]); +private _setup = parseSimpleArray (acre_player getVariable [QGVAR(setup), "[]"]); if (_setup isNotEqualTo []) then { [{ [] call EFUNC(api,isInitialized)