From fbf348d9d8a30f5ca6fc5e54b37e7cf5c611fd8b Mon Sep 17 00:00:00 2001 From: gerard-sog <149936164+gerard-sog@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:30:38 +0100 Subject: [PATCH] Add 'acre_api_fnc_getRadioOnOffState' to accessible method (#1339) --- addons/api/CfgFunctions.hpp | 2 + addons/api/fnc_getRadioOnOffState.sqf | 26 +++ addons/sys_radio/XEH_PREP.hpp | 2 + addons/sys_radio/fnc_getRadioOnOffState.sqf | 22 ++ docs/_includes/custom/functions-list-api.html | 202 ++++++++++-------- 5 files changed, 166 insertions(+), 88 deletions(-) create mode 100644 addons/api/fnc_getRadioOnOffState.sqf create mode 100644 addons/sys_radio/fnc_getRadioOnOffState.sqf diff --git a/addons/api/CfgFunctions.hpp b/addons/api/CfgFunctions.hpp index 5eb452c5d..0161d1255 100644 --- a/addons/api/CfgFunctions.hpp +++ b/addons/api/CfgFunctions.hpp @@ -50,6 +50,8 @@ class CfgFunctions { PATHTO_FNC(setRadioVolume); PATHTO_FNC(getRadioVolume); + PATHTO_FNC(getRadioOnOffState); + PATHTO_FNC(setCurrentRadioChannelNumber); PATHTO_FNC(getCurrentRadioChannelNumber); diff --git a/addons/api/fnc_getRadioOnOffState.sqf b/addons/api/fnc_getRadioOnOffState.sqf new file mode 100644 index 000000000..247796002 --- /dev/null +++ b/addons/api/fnc_getRadioOnOffState.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: Gerard + * Gets the status (ON/OFF) for the given radio. + * + * Arguments: + * 0: Radio ID + * + * Return Value: + * TRUE if radio is ON, False if the radio is OFF + * + * Example: + * ["ACRE_PR77_ID_1"] call acre_api_fnc_getRadioOnOffState + * + * Public: Yes + */ + +params ["_radioId"]; + +if (isNil "_radioId") exitWith { -1 }; + +if (!([_radioId] call EFUNC(sys_data,isRadioInitialized))) exitWith { -1 }; + +private _radioOnOffStatus = [_radioId] call EFUNC(sys_radio,getRadioOnOffState); + +_radioOnOffStatus diff --git a/addons/sys_radio/XEH_PREP.hpp b/addons/sys_radio/XEH_PREP.hpp index 5ee762dd5..5b6d7da5d 100644 --- a/addons/sys_radio/XEH_PREP.hpp +++ b/addons/sys_radio/XEH_PREP.hpp @@ -11,6 +11,8 @@ PREP(onReturnRadioId); PREP(getRadioVolume); PREP(setRadioVolume); +PREP(getRadioOnOffState); + PREP(isUniqueRadio); PREP(isBaseClassRadio); diff --git a/addons/sys_radio/fnc_getRadioOnOffState.sqf b/addons/sys_radio/fnc_getRadioOnOffState.sqf new file mode 100644 index 000000000..2c2cc74d1 --- /dev/null +++ b/addons/sys_radio/fnc_getRadioOnOffState.sqf @@ -0,0 +1,22 @@ +#include "script_component.hpp" +/* + * Author: Gerard + * Returns the status (ON/OFF) for the given radio. + * + * Arguments: + * 0: Unique Radio ID + * + * Return Value: + * TRUE if radio is ON, False if the radio is OFF + * + * Example: + * ["ACRE_PR77_ID_1"] call acre_sys_radio_fnc_getRadioOnOffState + * + * Public: No + */ + +params ["_radio"]; + +private _onOffState = [_radio, "getOnOffState"] call EFUNC(sys_data,dataEvent); + +_onOffState diff --git a/docs/_includes/custom/functions-list-api.html b/docs/_includes/custom/functions-list-api.html index fa9ef2fd7..5d419d871 100644 --- a/docs/_includes/custom/functions-list-api.html +++ b/docs/_includes/custom/functions-list-api.html @@ -39,8 +39,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | -1 | Audio Source | STRING | +0 | Radio ID | STRING | +1 | Audio Source | STRING | __Return Value__ @@ -70,8 +70,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Babel - true to set up a unique babel language for each side. | BOOLEAN | -1 | Radio - true to set up different frequencies for each side by using different presets. | BOOLEAN | +0 | Babel - true to set up a unique babel language for each side. | BOOLEAN | +1 | Radio - true to set up different frequencies for each side by using different presets. | BOOLEAN | __Return Value__ @@ -95,8 +95,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Language ID (used internally for identifying the language or specifying languages via other API methods) | STRING | -1 | Language display name | STRING | +0 | Language ID (used internally for identifying the language or specifying languages via other API methods) | STRING | +1 | Language display name | STRING | __Return Value__ @@ -147,11 +147,11 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio Base class | STRING | -1 | Preset name | STRING | -2 | Channel number | NUMBER | -3 | Field name | STRING | -4 | value | ANY | +0 | Radio Base class | STRING | +1 | Preset name | STRING | +2 | Channel number | NUMBER | +3 | Field name | STRING | +4 | value | ANY | __Return Value__ @@ -177,7 +177,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Curve scale | NUMBER | +0 | Curve scale | NUMBER | __Return Value__ @@ -201,7 +201,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Vehicle | OBJECT | +0 | Vehicle | OBJECT | __Return Value__ @@ -227,7 +227,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -None | Language IDs | ARRAY | +None | Language IDs | ARRAY | __Return Value__ @@ -304,8 +304,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | -1 | Speaker | BOOL | +0 | Radio ID | STRING | +1 | Speaker | BOOL | __Return Value__ @@ -332,8 +332,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | -1 | Channel number | NUMBER | +0 | Radio ID | STRING | +1 | Channel number | NUMBER | __Return Value__ @@ -361,10 +361,10 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base type | STRING | -1 | Preset name | STRING | -2 | Channel number | NUMBER | -3 | Preset data | HASH | +0 | Radio base type | STRING | +1 | Preset name | STRING | +2 | Channel number | NUMBER | +3 | Preset data | HASH | __Return Value__ @@ -390,7 +390,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Unit | OBJECT | +0 | Unit | OBJECT | __Return Value__ @@ -464,8 +464,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Unit or array of item classnames | OBJECT, ARRAY | -1 | Radio base type | STRING | +0 | Unit or array of item classnames | OBJECT, ARRAY | +1 | Radio base type | STRING | __Return Value__ @@ -491,7 +491,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -517,7 +517,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Delay in seconds between 0 and 1. | NUMBER | +0 | Delay in seconds between 0 and 1. | NUMBER | __Return Value__ @@ -543,7 +543,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base type | STRING | +0 | Radio base type | STRING | __Return Value__ @@ -593,7 +593,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Unit | OBJECT | +0 | Unit | OBJECT | __Return Value__ @@ -622,7 +622,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | "ACRE_CURVE_MODEL_ORIGINAL", "ACRE_CURVE_MODEL_SELECTABLE_A" or "ACRE_CURVE_MODEL_SELECTABLE_B" | STRING | +0 | "ACRE_CURVE_MODEL_ORIGINAL", "ACRE_CURVE_MODEL_SELECTABLE_A" or "ACRE_CURVE_MODEL_SELECTABLE_B" | STRING | __Return Value__ @@ -646,7 +646,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Array of radio IDs | ARRAY | +0 | Array of radio IDs | ARRAY | __Return Value__ @@ -675,8 +675,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | -1 | Volume between 0 and 1 | NUMBER | +0 | Radio ID | STRING | +1 | Volume between 0 and 1 | NUMBER | __Return Value__ @@ -702,7 +702,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Channel number | NUMBER | +0 | Channel number | NUMBER | __Return Value__ @@ -753,7 +753,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio type | STRING | +0 | Radio type | STRING | 1 | Optional unit or List of String | ARRAY, OBJECT | [] __Return Value__ @@ -781,7 +781,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | true or false on whether the unit should locally be considered a spectator | BOOLEAN | +0 | true or false on whether the unit should locally be considered a spectator | BOOLEAN | __Return Value__ @@ -807,10 +807,10 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio Base class | STRING | -1 | Preset name | STRING | -2 | Channel number | NUMBER | -3 | Field name | STRING | +0 | Radio Base class | STRING | +1 | Preset name | STRING | +2 | Channel number | NUMBER | +3 | Field name | STRING | __Return Value__ @@ -864,7 +864,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -890,7 +890,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Display ID | NUMBER | +0 | Display ID | NUMBER | __Return Value__ @@ -969,7 +969,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -995,7 +995,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Voice Curve Level | NUMBER | +0 | Voice Curve Level | NUMBER | __Return Value__ @@ -1020,7 +1020,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Display | DISPLAY | +0 | Display | DISPLAY | __Return Value__ @@ -1046,7 +1046,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Language display name | STRING | +0 | Language display name | STRING | __Return Value__ @@ -1096,9 +1096,9 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base type | STRING | -1 | Preset name | STRING | -2 | Preset data | HASH | +0 | Radio base type | STRING | +1 | Preset name | STRING | +2 | Preset data | HASH | __Return Value__ @@ -1124,7 +1124,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Unique rack ID | STRING | +0 | Unique rack ID | STRING | __Return Value__ @@ -1255,7 +1255,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Rack unique ID | STRING | +0 | Rack unique ID | STRING | __Return Value__ @@ -1330,7 +1330,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base type | STRING | +0 | Radio base type | STRING | __Return Value__ @@ -1380,7 +1380,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -1457,9 +1457,9 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -None | Array of sides and languages | ARRAY | -0 | Side | SIDE | -1 | Language display name | STRING | +None | Array of sides and languages | ARRAY | +0 | Side | SIDE | +1 | Language display name | STRING | __Return Value__ @@ -1486,7 +1486,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Vehicle | OBJECT | +0 | Vehicle | OBJECT | __Return Value__ @@ -1512,7 +1512,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Unit | OBJECT | +0 | Unit | OBJECT | __Return Value__ @@ -1538,8 +1538,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base type | STRING | -1 | Preset name | STRING | +0 | Radio base type | STRING | +1 | Preset name | STRING | __Return Value__ @@ -1566,7 +1566,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio type | STRING | +0 | Radio type | STRING | 1 | Optional unit or List of String | ARRAY, OBJECT | [] __Return Value__ @@ -1594,8 +1594,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID/Item classname | STRING | -1 | Radio base type | STRING | +0 | Radio ID/Item classname | STRING | +1 | Radio base type | STRING | __Return Value__ @@ -1648,7 +1648,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- 0 | Vehicle | OBJECT | objNull -1 | Unique rack ID | STRING | +1 | Unique rack ID | STRING | __Return Value__ @@ -1730,7 +1730,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio item name with ID | STRING | +0 | Radio item name with ID | STRING | __Return Value__ @@ -1756,8 +1756,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base class | STRING | -1 | Preset Name | STRING | +0 | Radio base class | STRING | +1 | Preset Name | STRING | __Return Value__ @@ -1783,7 +1783,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Language ID | STRING | +0 | Language ID | STRING | __Return Value__ @@ -1809,7 +1809,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -1835,9 +1835,9 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio base type | STRING | -1 | Preset name to copy | STRING | -2 | Destination preset name | STRING | +0 | Radio base type | STRING | +1 | Preset name to copy | STRING | +2 | Destination preset name | STRING | __Return Value__ @@ -1938,7 +1938,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Item name | STRING | +0 | Item name | STRING | __Return Value__ @@ -1964,7 +1964,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -1994,7 +1994,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Function to use | CODE | +0 | Function to use | CODE | __Return Value__ @@ -2019,7 +2019,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Name | STRING | +0 | Name | STRING | 1 | Group to effect (0-based index) | NUMBER | 0 __Return Value__ @@ -2046,7 +2046,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Unit | OBJECT | +0 | Unit | OBJECT | __Return Value__ @@ -2072,7 +2072,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | +0 | Radio ID | STRING | __Return Value__ @@ -2087,6 +2087,32 @@ ``` +--- + +### acre_api_fnc_getRadioOnOffState +__Description__ + +Gets the status (ON/OFF) for the given radio. + +__Parameters__ + +Index | Description | Datatype(s) | Default Value +--- | --- | --- | --- +0 | Radio ID | STRING | + +__Return Value__ + +Description | Datatype(s) +--- | --- +TRUE if radio is ON, False if the radio is OFF | BOOLEAN + +__Example__ + +```sqf +["ACRE_PR77_ID_1"] call acre_api_fnc_getRadioOnOffState +``` + + --- ### acre_api_fnc_isRadio @@ -2099,7 +2125,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Classname | STRING | +0 | Classname | STRING | __Return Value__ @@ -2152,7 +2178,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Language ID | STRING | +0 | Language ID | STRING | __Return Value__ @@ -2178,8 +2204,8 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Radio ID | STRING | -1 | Spatial “LEFT”, “RIGHT” or “CENTER" | STRING | +0 | Radio ID | STRING | +1 | Spatial “LEFT”, “RIGHT” or “CENTER" | STRING | __Return Value__ @@ -2259,7 +2285,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Volume between 0 and 1 | NUMBER | +0 | Volume between 0 and 1 | NUMBER | __Return Value__ @@ -2288,7 +2314,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- 0 | Vehicle | OBJECT | objNull -1 | Rack configuration | ARRAY | +1 | Rack configuration | ARRAY | 0 | Base classname of the rack (Without ID) | STRING | "" 1 | Rackname - this is diplayed to the user. Ideally short | STRING | "" 2 | Rack short name - displayed in GUI information. Max 4 characters | STRING | "" @@ -2350,9 +2376,9 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Base radio class | STRING | -1 | Preset name | STRING | -2 | Channel number | NUMBER | +0 | Base radio class | STRING | +1 | Preset name | STRING | +2 | Channel number | NUMBER | __Return Value__ @@ -2380,7 +2406,7 @@ Index | Description | Datatype(s) | Default Value --- | --- | --- | --- -0 | Vehicle | OBJECT | +0 | Vehicle | OBJECT | 1 | Condition called with argument "_unit". If a longer function is given, it should be precompiled. | CODE | {} __Return Value__