diff --git a/addons/api/CfgFunctions.hpp b/addons/api/CfgFunctions.hpp index 79c7485e6..2a0ced90f 100644 --- a/addons/api/CfgFunctions.hpp +++ b/addons/api/CfgFunctions.hpp @@ -39,6 +39,7 @@ class CfgFunctions { }; class Radios { + DEFINE_FUNCTION(getAllRadios); DEFINE_FUNCTION(getCurrentRadio); DEFINE_FUNCTION(setCurrentRadio); DEFINE_FUNCTION(getCurrentRadioList); @@ -96,7 +97,6 @@ class CfgFunctions { class AcreModules { class GVAR(mission_setup) { class basicMissionSetup { file = PATHTOF(modules\basicMissionSetup.sqf); }; - class disableSignalLoss { file = PATHTOF(modules\disableSignalLoss.sqf); }; class difficultySettings { file = PATHTOF(modules\difficultySettings.sqf); }; class nameChannels { file = PATHTOF(modules\nameChannels.sqf); }; }; diff --git a/addons/api/CfgModules.hpp b/addons/api/CfgModules.hpp index dccb9a21d..7f07f2521 100644 --- a/addons/api/CfgModules.hpp +++ b/addons/api/CfgModules.hpp @@ -9,9 +9,9 @@ class CfgVehicles { class Logic; class Module_F: Logic { class ArgumentsBaseUnits { class Units; }; class ModuleDescription { class AnyBrain; }; }; - + class GVAR(basicMissionSetup) : Module_F { - scope = 2; + scope = 1; displayName = "Basic Mission Setup"; author = "ACRE Team"; category = QGVAR(mission_setup); @@ -28,14 +28,14 @@ class CfgVehicles class Arguments { class RadioSetup { displayName = "Channels Per Side"; - description = "Set to true to have each side have different ACRE radio frequencies"; - typeName = "BOOL"; + description = "Set to true to have each side have different ACRE radio frequencies"; + typeName = "BOOL"; class values { }; }; class BabelSetup { displayName = "Babel Language Per Side"; - description = "Select whether each side has its own language, and whether they also share a common tongue."; - typeName = "NUMBER"; + description = "Select whether each side has its own language, and whether they also share a common tongue."; + typeName = "NUMBER"; class values { class AllDifferent {name = "Per-Side"; value = 1; }; class SharingDifferent {name = "Per-Side /w Common"; value = 2; default = 2; }; @@ -69,9 +69,9 @@ class CfgVehicles sync[] = {}; }; }; - + class GVAR(DifficultySettings) : Module_F { - scope = 2; + scope = 1; displayName = "Difficulty Settings"; category = QGVAR(mission_setup); @@ -87,29 +87,29 @@ class CfgVehicles class Arguments { class SignalLoss { displayName = "Signal Loss"; - description = "Set to false to disable signal and terrain loss values"; - typeName = "BOOL"; + description = "Set to false to disable signal and terrain loss values"; + typeName = "BOOL"; defaultValue = true; class values { }; }; class FullDuplex { displayName = "Full-Duplex Transmissions"; - description = "Set to true to enable full-duplex, or multiple people transmitting"; - typeName = "BOOL"; + description = "Set to true to enable full-duplex, or multiple people transmitting"; + typeName = "BOOL"; defaultValue = false; class values { }; }; class Interference { displayName = "Signal Interference"; - description = "Set to false to disable the interference from multiple transmitters"; - typeName = "BOOL"; + description = "Set to false to disable the interference from multiple transmitters"; + typeName = "BOOL"; defaultValue = true; class values { }; }; class IgnoreAntennaDirection { displayName = "Ignore Antenna Direction"; - description = "Set to true to disable loss due to antenna directional radiation patterns."; - typeName = "BOOL"; + description = "Set to true to disable loss due to antenna directional radiation patterns."; + typeName = "BOOL"; defaultValue = false; class values { }; }; @@ -120,7 +120,7 @@ class CfgVehicles sync[] = {}; }; }; - + class GVAR(nameChannels) : Module_F { scope = 2; displayName = "Name Channels"; @@ -137,11 +137,11 @@ class CfgVehicles // Module arguments class Arguments { - + class SideSelect { displayName = "Side"; - description = "Select the side to name channels for"; - typeName = "NUMBER"; + description = "Select the side to name channels for"; + typeName = "NUMBER"; class values { class All {name = "All"; value = 1; default = 1;}; @@ -151,7 +151,7 @@ class CfgVehicles class Civ {name = "Civilian"; value = 5;}; }; }; - + class Channel_1 { displayName = "Channel 1"; description = "Name of Channel 1"; @@ -209,4 +209,4 @@ class CfgVehicles sync[] = {}; }; }; -}; \ No newline at end of file +}; diff --git a/addons/api/XEH_pre_init.sqf b/addons/api/XEH_pre_init.sqf index 233bcdba6..f02a57d8d 100644 --- a/addons/api/XEH_pre_init.sqf +++ b/addons/api/XEH_pre_init.sqf @@ -5,15 +5,17 @@ ADDON = false; DGVAR(selectableCurveScale) = 1.0; DVAR(ACRE_IS_SPECTATOR) = false; +// Private helper functions +PREP(setupDefaultRadios); +PREP(setupFrequenciesAndBabel); + // Field name mapping for unifying radio field names PREP(mapChannelFieldName); - // DEPRICATED ///// PREP(setDefaultChannels); // DEPRICATING PREP(getDefaultChannels); // DEPRICATING -// module loading variables -GVAR(basicMissionSetup) = false; +#include "initSettings.sqf" ADDON = true; diff --git a/addons/api/fnc_getAllRadios.sqf b/addons/api/fnc_getAllRadios.sqf new file mode 100644 index 000000000..096716e10 --- /dev/null +++ b/addons/api/fnc_getAllRadios.sqf @@ -0,0 +1,39 @@ +/* + * Author: ACRE2Team + * Returns all radios defined in CfgAcreRadios. + * + * Arguments: + * None + * + * Return Value: + * 1: Radio Class Names + * 2: Radio Display Names + * + * Example: + * [] call acre_api_fnc_getAllRadios; + * + * Public: Yes + */ +#include "script_component.hpp" + +// Return cached if already ran +if (!isNil QGVAR(allRadios)) exitWith { + GVAR(allRadios) +}; + +// Compile and cache for later calls +private _classes = []; +private _names = []; +{ + private _isAcre = getNumber (_x >> "isAcre"); // All radio classes have that + private _name = getText (_x >> "name"); // Only non-base classes have that + + // Has name and isAcre, assume valid radio class + if (_isAcre == 1 && {_name != ""}) then { + _classes pushBack (configName _x); + _names pushBack _name; + }; +} forEach ("true" configClasses (configFile >> "CfgAcreComponents")); + +GVAR(allRadios) = [_classes, _names]; +GVAR(allRadios) diff --git a/addons/api/fnc_setupDefaultRadios.sqf b/addons/api/fnc_setupDefaultRadios.sqf new file mode 100644 index 000000000..52f3dee40 --- /dev/null +++ b/addons/api/fnc_setupDefaultRadios.sqf @@ -0,0 +1,82 @@ +/* + * Author: ACRE2Team + * Sets up side frequencies and babel settings from settings menu. Can be ran only once per mission. + * + * Arguments: + * 1: Radio Order + * 0: Radio Class Name + * + * Return Value: + * None + * + * Example: + * [0, "ACRE_PRC343"] call acre_api_fnc_setupDefaultRadios; + * + * Public: No + */ +#include "script_component.hpp" + +// Exit on dedicated server or headless client +if (!hasInterface) exitWith {}; + +// Run once after all 4 defaults have been initialized +if (!isNil QGVAR(hasSetupDefaultRadios) && {GVAR(hasSetupDefaultRadios)}) exitWith {}; + +params ["_order", "_radioClass"]; + +// Wait for all 4 defaults to be initialized +if (isNil QGVAR(defaultRadios)) then { + GVAR(defaultRadios) = []; +}; +GVAR(defaultRadios) set [_order, _radioClass]; +if (count (GVAR(defaultRadios) select {_x isEqualType ""}) < 4) exitWith {}; + +// Apply default radios +private _addRadios = { + // Don't regive radios if already given + if (acre_player getVariable [QGVAR(hasGivenDefaultRadios), false]) exitWith {}; + acre_player setVariable [QGVAR(hasGivenDefaultRadios), true, true]; + + private _cleanRadioList = []; + if !("ACRE_PRC343" in _this) then { + [acre_player, "ItemRadio"] call EFUNC(lib,removeGear); + [acre_player, "ACRE_PRC343"] call EFUNC(lib,removeGear); + _cleanRadioList = _this; + } else { + private _countDefaultRadios = 0; + { + if (_x == "ACRE_PRC343") then { + _countDefaultRadios = _countDefaultRadios + 1; + if (_countDefaultRadios > 1) then { + _cleanRadioList pushBack _x; + }; + } else { + _cleanRadioList pushBack _x; + }; + } forEach _this; + }; + + TRACE_1("Adding Radios",_cleanRadioList); + + if (!((["ACRE_PRC77", "ACRE_PRC117F"] arrayIntersect _cleanRadioList) isEqualTo []) && {backpack acre_player == ""}) then { + acre_player addBackpack "B_AssaultPack_khk"; + }; + + { + if (_x != "") then { + acre_player addItem _x; + }; + } forEach _cleanRadioList; +}; + +if (isNull acre_player) then { + GVAR(defaultRadios) spawn { + waitUntil {!isNull acre_player}; + _this call _addRadios; + }; +} else { + GVAR(defaultRadios) call _addRadios; +}; + + +GVAR(hasSetupDefaultRadios) = true; diff --git a/addons/api/fnc_setupFrequenciesAndBabel.sqf b/addons/api/fnc_setupFrequenciesAndBabel.sqf new file mode 100644 index 000000000..82614747f --- /dev/null +++ b/addons/api/fnc_setupFrequenciesAndBabel.sqf @@ -0,0 +1,49 @@ +/* + * Author: ACRE2Team + * Sets up side frequencies and babel settings from settings menu. Can be ran only once per mission. + * + * Arguments: + * 0: Unique Side Frequencies + * 1: Babel + * + * Return Value: + * None + * + * Example: + * [false, 0] call acre_api_fnc_setupFrequenciesAndBabel; + * + * Public: No + */ +#include "script_component.hpp" + +// Run once +if (!isNil QGVAR(hasSetupFrequenciesAndBabel) && {GVAR(hasSetupFrequenciesAndBabel)}) exitWith {}; + +params ["_uniqueFrequencies", "_babel"]; + +// Unique frequencies are handled in FUNC(setupMission), no need to handle it here + +// No babel +if (_babel == 0) exitWith { + [false, _uniqueFrequencies] call FUNC(setupMission); +}; + +// One language per side babel +if (_babel == 1) exitWith { + [true, _uniqueFrequencies] call FUNC(setupMission); +}; + +// One language per side + common babel (Zeus gets ALL Languages, including "Common") +// Handle the babel setup via an array, so the bool is set to false +if (_babel == 2) exitWith { + [false, _uniqueFrequencies] call FUNC(setupMission); + [ + [east, "Opfor", "Common"], + [west, "Blufor", "Common"], + [independent, "Indepedent", "Common"], + [civilian, "Civilian", "Common"], + [sideLogic, "Opfor", "Blufor", "Indepedent", "Civilian", "Common"] + ] call FUNC(babelSetupMission); +}; + +GVAR(hasSetupFrequenciesAndBabel) = true; diff --git a/addons/api/initSettings.sqf b/addons/api/initSettings.sqf new file mode 100644 index 000000000..cdd24d65e --- /dev/null +++ b/addons/api/initSettings.sqf @@ -0,0 +1,138 @@ +// Plugin Settings (local) +[ + QGVAR(postmixGlobalVolume), + "SLIDER", + "Post-Mix Global Volume", + "ACRE2", + [0, 3, 1, 2], + false, + {["globalVolume", _this] call FUNC(setPluginSetting)} +] call CBA_Settings_fnc_init; + +[ + QGVAR(premixGlobalVolume), + "SLIDER", + "Pre-Mix Global Volume", + "ACRE2", + [0, 3, 1, 2], + false, + {["premixGlobalVolume", _this] call FUNC(setPluginSetting)} +] call CBA_Settings_fnc_init; + +[ + QGVAR(unmuteClients), + "CHECKBOX", + "Unmute Clients", + "ACRE2", + true, + false, + {["disableUnmuteClients", _this] call FUNC(setPluginSetting)} +] call CBA_Settings_fnc_init; + + +// Difficulty settings (global) +[ + QGVAR(signalLoss), + "CHECKBOX", + ["Signal Loss", "Enables signal and terrain loss."], + "ACRE2", + true, + true, + {if (!_this) then {[0.0] call FUNC(setLossModelScale)}} +] call CBA_Settings_fnc_init; + +[ + QGVAR(fullDuplex), + "CHECKBOX", + ["Full-Duplex Transmissions", "Allows multiple people to transmit simultaneously."], + "ACRE2", + false, + true, + {if (_this) then {[true] call acre_api_fnc_setFullDuplex}} +] call CBA_Settings_fnc_init; + +[ + QGVAR(interference), + "CHECKBOX", + ["Signal Interference", "Enables interference from multiple transmitters."], + "ACRE2", + true, + true, + {if (!_this) then {[false] call acre_api_fnc_setInterference}} +] call CBA_Settings_fnc_init; + +[ + QGVAR(ignoreAntennaDirection), + "CHECKBOX", + ["Ignore Antenna Direction", "Enables loss due to antenna directional radiation patterns."], + "ACRE2", + false, + true, + {if (_this) then {[true] call acre_api_fnc_ignoreAntennaDirection}} +] call CBA_Settings_fnc_init; + + +// Basic Mission settings (global) +[ + QGVAR(sideFrequenciesAndBabel), + "LIST", + ["Side Frequencies / Babel", "Sets unique side radio frequencies and babel language settings."], + "ACRE2", + [[ + [false, 0], [false, 1], [false, 2], + [true, 0], [true, 1], [true, 2] + ], [ + "Common Freq. / No Babel", "Common Freq. / Per-Side Babel", "Common Freq. / Per-Side + Common Babel", + "Unique Freq. / No Babel", "Unique Freq. / Per-Side Babel", "Unique Freq. / Per-Side + Common Babel" + ], 0], + true, + {_this call FUNC(setupFrequenciesAndBabel)} +] call CBA_Settings_fnc_init; + + +// Default radio settings (global) +private _allRadios = call FUNC(getAllRadios); +private _allRadiosClasses = [""]; +_allRadiosClasses append (_allRadios select 0); +private _allRadiosNames = ["None"]; +_allRadiosNames append (_allRadios select 1); + +[ + QGVAR(defaultRadio1), + "LIST", + ["Default Radio 1", "Default first radio for to give to player."], + "ACRE2", + [_allRadiosClasses, _allRadiosNames, _allRadiosClasses find "ACRE_PRC343"], + true, + {[0, _this] call FUNC(setupDefaultRadios)} +] call CBA_Settings_fnc_init; + +[ + QGVAR(defaultRadio2), + "LIST", + ["Default Radio 2", "Default second radio for to give to player."], + "ACRE2", + [_allRadiosClasses, _allRadiosNames, 0], + true, + {[1, _this] call FUNC(setupDefaultRadios)} +] call CBA_Settings_fnc_init; + +[ + QGVAR(defaultRadio3), + "LIST", + ["Default Radio 3", "Default third radio for to give to player."], + "ACRE2", + [_allRadiosClasses, _allRadiosNames, 0], + true, + {[2, _this] call FUNC(setupDefaultRadios)} +] call CBA_Settings_fnc_init; + +[ + QGVAR(defaultRadio4), + "LIST", + ["Default Radio 4", "Default fourth radio for to give to player."], + "ACRE2", + [_allRadiosClasses, _allRadiosNames, 0], + true, + {[3, _this] call FUNC(setupDefaultRadios)} +] call CBA_Settings_fnc_init; diff --git a/addons/api/modules/basicMissionSetup.sqf b/addons/api/modules/basicMissionSetup.sqf index c01aeb53d..72bdf20a3 100644 --- a/addons/api/modules/basicMissionSetup.sqf +++ b/addons/api/modules/basicMissionSetup.sqf @@ -18,110 +18,15 @@ params ["_logic", "_units", "_activated"]; -// Run once -if(!isNil QUOTE(GVAR(basicMissionSetup))) then { - if(GVAR(basicMissionSetup)) exitWith {}; -}; +if (!_activated) exitWith {}; -TRACE_1("enter", _this); +ACRE_DEPRECATED("Basic Mission Setup module","2.4.0","CBA Settings"); -_setupRadios = _logic getVariable["RadioSetup", false]; -_setupBabel = _logic getVariable["BabelSetup", 0]; +// Frequencies and Babel +[_logic getVariable ["RadioSetup", false], _logic getVariable ["BabelSetup", 0]] call FUNC(setupFrequenciesAndBabel); -_defaultRadios = []; -_defaultRadios set[0, ( _logic getVariable["DefaultRadio", ""] ) ]; -_defaultRadios set[1, ( _logic getVariable["DefaultRadio_Two", ""] ) ]; -_defaultRadios set[2, ( _logic getVariable["DefaultRadio_Three", ""] ) ]; -_defaultRadios set[3, ( _logic getVariable["DefaultRadio_Four", ""] ) ]; - -//_setupRadios is handles in the acre_api_fnc_setupMission. No need to handle it here -switch (_setupBabel) do { - //We don't want the babel system - case 0: { - [false, _setupRadios] call acre_api_fnc_setupMission; - }; - //We want the babel system to be set to one language per side - case 1: { - [true, _setupRadios] call acre_api_fnc_setupMission; - }; - //We need to handle the babel setup via an array, so the bool is set to false - //Zeus gets ALL Languages, including "Common" - case 2: { - [false, _setupRadios] call acre_api_fnc_setupMission; - [ - [east, "Opfor", "Common"], - [west, "Blufor", "Common"], - [independent, "Indepedent", "Common"], - [civilian, "Civilian", "Common"], - [sideLogic, "Opfor", "Blufor", "Indepedent", "Civilian", "Common"] - ] call acre_api_fnc_babelSetupMission; - }; - //This shouldn't be reached. If so, we throw an error. - default { - [false, _setupRadios] call acre_api_fnc_setupMission; - hint "The Babel System is not set correctly. Please double check the settings in the module you placed." - }; -}; - -FUNC(_addRadios) = { - private _unit = acre_player; - // Don't regive radios if already given - if (_unit getVariable [QGVAR(basicMissionSetup),false]) exitWith {}; - _unit setVariable [QGVAR(basicMissionSetup),true,true]; - - private _cleanRadioList = []; - - if(!("ACRE_PRC343" in _this) ) then { - [_unit, "ItemRadio"] call EFUNC(lib,removeGear); - [_unit, "ACRE_PRC343"] call EFUNC(lib,removeGear); - - _cleanRadioList = _this; - } else { - private _countDefaultRadios = 0; - - { - if(_x == "ACRE_PRC343") then { - _countDefaultRadios = _countDefaultRadios + 1; - if(_countDefaultRadios > 1) then { - _cleanRadioList pushBack _x; - }; - } else { - _cleanRadioList pushBack _x; - }; - } forEach _this; - - }; - - TRACE_1("Adding Radios", _cleanRadioList); - - if( ("ACRE_PRC77" in _cleanRadioList) || ("ACRE_PRC117F" in _cleanRadioList) ) then { - if( (backpack _unit) == "") then { - _unit addBackpack "B_AssaultPack_khk"; - }; - }; - { - private _radioType = _x; - TRACE_1("", _radioType); - - if(!isNil "_radioType") then { - if(_radioType != "") then { - _unit addItem _radioType; - }; - }; - } forEach _cleanRadioList; -}; - -if(hasInterface) then { - if(isNull acre_player) then { - _defaultRadios spawn { - waituntil { !isNull acre_player }; - _this call FUNC(_addRadios); - }; - } else { - _defaultRadios call FUNC(_addRadios); - }; -}; - -GVAR(basicMissionSetup) = true; - -true \ No newline at end of file +// Default radios +[0, _logic getVariable ["DefaultRadio", ""]] call FUNC(setupDefaultRadios); +[1, _logic getVariable ["DefaultRadio_Two", ""]] call FUNC(setupDefaultRadios); +[2, _logic getVariable ["DefaultRadio_Three", ""]] call FUNC(setupDefaultRadios); +[3, _logic getVariable ["DefaultRadio_Four", ""]] call FUNC(setupDefaultRadios); diff --git a/addons/api/modules/difficultySettings.sqf b/addons/api/modules/difficultySettings.sqf index 482fb436a..f2802c9db 100644 --- a/addons/api/modules/difficultySettings.sqf +++ b/addons/api/modules/difficultySettings.sqf @@ -20,6 +20,8 @@ params ["_logic", "_units", "_activated"]; if (!_activated) exitWith {}; +ACRE_DEPRECATED("Difficulty Settings module","2.4.0","CBA Settings"); + TRACE_1("enter", _this); _signalLoss = _logic getVariable["SignalLoss", true]; @@ -38,4 +40,4 @@ if(!_interference) then { }; if(_ignoreAntennaDirection) then { [true] call acre_api_fnc_ignoreAntennaDirection; -}; \ No newline at end of file +}; diff --git a/addons/api/modules/disableSignalLoss.sqf b/addons/api/modules/disableSignalLoss.sqf deleted file mode 100644 index fcc381e79..000000000 --- a/addons/api/modules/disableSignalLoss.sqf +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Author: ACRE2Team - * SHORT DESCRIPTION - * - * Arguments: - * 0: ARGUMENT ONE - * 1: ARGUMENT TWO - * - * Return Value: - * RETURN VALUE - * - * Example: - * [ARGUMENTS] call acre_COMPONENT_fnc_FUNCTIONNAME - * - * Public: No - */ -#include "script_component.hpp" - -[0.0] call acre_api_fnc_setLossModelScale; \ No newline at end of file diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index dad9ea617..082cee91f 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -276,3 +276,5 @@ PERFORMANCE COUNTERS SECTION #define END_COUNTER(x) /* disabled */ #define DUMP_COUNTERS /* disabled */ #endif + +#define ACRE_DEPRECATED(arg1,arg2,arg3) diag_log text format ["[ACRE] (%1) WARNING: %2 is deprecated. Support will be dropped in version %3. Replaced by: %4", QUOTE(COMPONENT), arg1, arg2, arg3] diff --git a/addons/sys_core/XEH_pre_init.sqf b/addons/sys_core/XEH_pre_init.sqf index c1f58a7dc..3ab750c95 100644 --- a/addons/sys_core/XEH_pre_init.sqf +++ b/addons/sys_core/XEH_pre_init.sqf @@ -33,6 +33,7 @@ PREP(processDirectSpeaker); PREP(processRadioSpeaker); PREP(remoteStartSpeaking); PREP(remoteStopSpeaking); +PREP(setPluginSetting); PREP(setSpeakingLanguage); PREP(setSpokenLanguages); PREP(showBroadCastHint); @@ -101,8 +102,6 @@ DVAR(ACRE_PTT_RELEASE_DELAY) = 0.2; DVAR(ACRE_ASSIGNED_PTT_RADIOS) = []; GVAR(delayReleasePTT_Handle) = nil; -// DVAR(ACRE_USE_DEBUG_EXTENSIONS) = true; - DVAR(ACRE_ACTIVE_PTTKEY) = -2; DVAR(ACRE_BROADCASTING_RADIOID) = ""; diff --git a/addons/sys_core/fnc_setPluginSetting.sqf b/addons/sys_core/fnc_setPluginSetting.sqf new file mode 100644 index 000000000..4b53b950c --- /dev/null +++ b/addons/sys_core/fnc_setPluginSetting.sqf @@ -0,0 +1,49 @@ +/* + * Author: ACRE2Team + * Handles setting TeamSpeak plugin settings. Waits for pipe to open and then applies them. + * + * Arguments: + * 0: Setting Name + * 1: Setting Value + * + * Return Value: + * None + * + * Example: + * ["globalVolume", "1.5"] call acre_sys_core_fnc_setPluginSetting + * + * Public: No + */ +#include "script_component.hpp" + +params ["_name", "_value"]; + +// Plugin initialized, apply setting directly +if (EGVAR(sys_io,serverStarted)) exitWith { + ["setSetting", [_name, _value]] call EFUNC(sys_rpc,callRemoteProcedure); +}; + +// Already waiting for plugin initialization, add setting to delayed settings array +if !(GVAR(delayedPluginSettings) isEqualTo []) exitWith { + // Filter settings already set in case of prolonged wait where user can modify it multiple times + GVAR(delayedPluginSettings) = GVAR(delayedPluginSettings) select {_x select 0 != _name}; + GVAR(delayedPluginSettings) pushBack _this; +}; + +// Start PFH for waiting for plugin initialization +GVAR(delayedPluginSettings) = [_this]; +[{ + if (EGVAR(sys_io,serverStarted)) exitWith { + // Save settings to local variable in case settings are changed while delayed ones are being applied + private _delayedSettings = GVAR(delayedPluginSettings); + GVAR(delayedPluginSettings) = []; + + [_this select 1] call CBA_fnc_removePerFrameHandler; + + // Set settings in plugin + { + _x params ["_name", "_value"]; + ["setSetting", [_name, _value]] call EFUNC(sys_rpc,callRemoteProcedure); + } forEach _delayedSettings; + }; +}, 1, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/sys_core/script_component.hpp b/addons/sys_core/script_component.hpp index 5846881bf..9606d3a70 100644 --- a/addons/sys_core/script_component.hpp +++ b/addons/sys_core/script_component.hpp @@ -13,4 +13,4 @@ #define EOL_CHAR toString[10] -//#define USE_DEBUG_EXTENSIONS 1 +//#define USE_DEBUG_EXTENSIONS diff --git a/extensions/src/ACRE2Arma/acre/acre_dllmain.cpp b/extensions/src/ACRE2Arma/acre/acre_dllmain.cpp index 3521728b5..aeaaff789 100644 --- a/extensions/src/ACRE2Arma/acre/acre_dllmain.cpp +++ b/extensions/src/ACRE2Arma/acre/acre_dllmain.cpp @@ -21,7 +21,7 @@ BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%datetime-{%level}- %msg"); #endif el::Loggers::setDefaultConfigurations(conf, true); - + LOG(INFO) << "ACRE Loaded"; break; @@ -35,4 +35,4 @@ BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, return bSuccess; -} \ No newline at end of file +} diff --git a/extensions/src/ACRE2Arma/dynload/CMakeLists.txt b/extensions/src/ACRE2Arma/dynload/CMakeLists.txt index 6604b5d83..686172524 100644 --- a/extensions/src/ACRE2Arma/dynload/CMakeLists.txt +++ b/extensions/src/ACRE2Arma/dynload/CMakeLists.txt @@ -14,4 +14,4 @@ set_target_properties(${ACRE_EXTENSION_NAME}_static PROPERTIES FOLDER ACRE2Arma) if(CMAKE_COMPILER_IS_GNUCXX) set_target_properties(${ACRE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1) set_target_properties(${ACRE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1) -endif() \ No newline at end of file +endif() diff --git a/extensions/src/ACRE2Arma/dynload/dynloader.hpp b/extensions/src/ACRE2Arma/dynload/dynloader.hpp index 821ffeb87..8106022bc 100644 --- a/extensions/src/ACRE2Arma/dynload/dynloader.hpp +++ b/extensions/src/ACRE2Arma/dynload/dynloader.hpp @@ -38,7 +38,7 @@ namespace acre { LOG(INFO) << "Load requested [" << args_.as_string(0) << "]"; if (_modules.find(args_.as_string(0)) != _modules.end()) { - LOG(ERROR) << "Module already loaded [" << args_.as_string(0) << "]"; + LOG(INFO) << "Module already loaded [" << args_.as_string(0) << "]"; return true; } @@ -153,7 +153,7 @@ namespace acre { return false; } - + bool register_functions() { dispatch::get().add("list", std::bind(&acre::dynloader::list, this, std::placeholders::_1, std::placeholders::_2)); dispatch::get().add("load", std::bind(&acre::dynloader::load, this, std::placeholders::_1, std::placeholders::_2)); diff --git a/extensions/src/ACRE2Core/AcreSettings.cpp b/extensions/src/ACRE2Core/AcreSettings.cpp index 7edd32579..9d6f41e39 100644 --- a/extensions/src/ACRE2Core/AcreSettings.cpp +++ b/extensions/src/ACRE2Core/AcreSettings.cpp @@ -16,7 +16,7 @@ ACRE_RESULT CAcreSettings::save(std::string filename) { iniFile << "globalVolume = " << this->m_GlobalVolume << ";\n"; iniFile << "premixGlobalVolume = " << this->m_PremixGlobalVolume << ";\n"; iniFile << "disableUnmuteClients = " << (this->m_DisableUnmuteClients ? "true" : "false") << ";\n"; - + //LOG("Config Save: %f,%f", m_GlobalVolume, m_PremixGlobalVolume); iniFile.flush(); iniFile.close(); @@ -32,6 +32,8 @@ ACRE_RESULT CAcreSettings::load(std::string filename) { LOG("Failed to load ACRE ini file. Using defaults..."); this->save(filename); return ACRE_ERROR; + } else { + LOG("Successfully loaded ACRE ini file (any failures above can be ignored)."); } this->m_HasShownWelcome = config.GetBoolean("acre2", "hasShownWelcome", true); diff --git a/extensions/src/ACRE2Core/Engine.cpp b/extensions/src/ACRE2Core/Engine.cpp index d4df10aef..0613e96ac 100644 --- a/extensions/src/ACRE2Core/Engine.cpp +++ b/extensions/src/ACRE2Core/Engine.cpp @@ -21,16 +21,17 @@ #include "ping.h" #include "updateSelf.h" #include "setSelectableVoiceCurve.h" +#include "setSetting.h" ACRE_RESULT CEngine::initialize(IClient *client, IServer *externalServer, std::string fromPipeName, std::string toPipeName) { - + if(!g_Log) { - g_Log = (Log *)new Log("acre2.log"); + g_Log = (Log *)new Log("acre2.log"); LOG("* Logging engine initialized."); } - LOG("Configuration Path: {%s}", client->getConfigFilePath().c_str()); - CAcreSettings::getInstance()->load(client->getConfigFilePath() + "acre2.ini"); + LOG("Configuration Path: {%s\\acre2.ini}", client->getConfigFilePath().c_str()); + CAcreSettings::getInstance()->load(client->getConfigFilePath() + "\\acre2.ini"); this->setClient(client); this->setExternalServer(externalServer); @@ -63,16 +64,17 @@ ACRE_RESULT CEngine::initialize(IClient *client, IServer *externalServer, std::s this->getRpcEngine()->addProcedure(new ping()); this->getRpcEngine()->addProcedure(new updateSelf()); this->getRpcEngine()->addProcedure(new setSelectableVoiceCurve()); + this->getRpcEngine()->addProcedure(new setSetting()); // Initialize the client, because it never was derp this->getClient()->initialize(); - + return ACRE_OK; } ACRE_RESULT CEngine::initialize(IClient *client, IServer *externalServer, std::string fromPipeName, std::string toPipeName, std::string loggingPath) { - - g_Log = (Log *)new Log(const_cast(loggingPath.c_str())); + + g_Log = (Log *)new Log(const_cast(loggingPath.c_str())); LOG("* Logging engine initialized."); return initialize(client, externalServer, fromPipeName, toPipeName); @@ -121,10 +123,10 @@ ACRE_RESULT CEngine::stop() { if(this->getExternalServer()) { this->getExternalServer()->shutdown(); - } + } CAcreSettings::getInstance()->save(); - + this->setState(ACRE_STATE_STOPPED); LOG("Engine Shutdown Complete"); return ACRE_OK; @@ -144,7 +146,7 @@ ACRE_RESULT CEngine::localStartSpeaking(ACRE_SPEAKING_TYPE speakingType, std::st this->getSelf()->clearSoundChannels(); CEngine::getInstance()->getExternalServer()->sendMessage( - CTextMessage::formatNewMessage("ext_remoteStartSpeaking", + CTextMessage::formatNewMessage("ext_remoteStartSpeaking", "%d,%d,%s,%d,%s,%f,", this->getSelf()->getId(), this->getSelf()->getCurrentLanguageId(), @@ -152,17 +154,17 @@ ACRE_RESULT CEngine::localStartSpeaking(ACRE_SPEAKING_TYPE speakingType, std::st this->getSelf()->getSpeakingType(), this->getSelf()->getCurrentRadioId().c_str(), this->getSelf()->getSelectableCurveScale() - ) + ) ); // Send the local start speaking event to ourselves, so we can play squawk, etc in game. - CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("localStartSpeaking", + CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("localStartSpeaking", "%d,%d,%d,%s,", this->getSelf()->getId(), this->getSelf()->getCurrentLanguageId(), this->getSelf()->getSpeakingType(), this->getSelf()->getCurrentRadioId().c_str() - ) + ) ); this->getSelf()->setSpeaking(TRUE); @@ -173,22 +175,22 @@ ACRE_RESULT CEngine::localStartSpeaking(ACRE_SPEAKING_TYPE speakingType, std::st ACRE_RESULT CEngine::localStopSpeaking( void ) { this->getSelf()->setSpeaking(FALSE); CEngine::getInstance()->getExternalServer()->sendMessage( - CTextMessage::formatNewMessage("ext_remoteStopSpeaking", + CTextMessage::formatNewMessage("ext_remoteStopSpeaking", "%d,%s,", this->getSelf()->getId(), this->getSelf()->getNetId().c_str() - ) + ) ); - CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("localStopSpeaking", + CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("localStopSpeaking", "%d,%d,%s,", this->getSelf()->getId(), this->getSelf()->getSpeakingType(), this->getSelf()->getCurrentRadioId().c_str() - ) + ) ); - + return ACRE_OK; } @@ -207,16 +209,16 @@ ACRE_RESULT CEngine::remoteStartSpeaking(ACRE_ID remoteId, int languageId, std:: remotePlayer->setCurrentRadioId(radioId); remotePlayer->setNetId(netId); - - CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("remoteStartSpeaking", + + CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("remoteStartSpeaking", "%d,%d,%s,%d,%s,", remoteId, languageId, netId.c_str(), speakingType, radioId.c_str() - ) + ) ); return ACRE_OK; @@ -228,13 +230,13 @@ ACRE_RESULT CEngine::remoteStopSpeaking(ACRE_ID remoteId) { if(it != this->speakingList.end()) { CPlayer *remotePlayer = (CPlayer *)it->second; - CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("remoteStopSpeaking", + CEngine::getInstance()->getGameServer()->sendMessage( CTextMessage::formatNewMessage("remoteStopSpeaking", "%d,%s,%d,%s,", remotePlayer->getId(), remotePlayer->getNetId().c_str(), remotePlayer->getSpeakingType(), remotePlayer->getCurrentRadioId().c_str() - ) + ) ); this->speakingList.erase(it); diff --git a/extensions/src/ACRE2Core/setSetting.h b/extensions/src/ACRE2Core/setSetting.h new file mode 100644 index 000000000..abf52f772 --- /dev/null +++ b/extensions/src/ACRE2Core/setSetting.h @@ -0,0 +1,40 @@ +#pragma once + +#include "IRpcFunction.h" +#include "Log.h" +#include "AcreSettings.h" + +RPC_FUNCTION(setSetting) { + std::string name; + float value = 1.0f; + + name = std::string((char *)vMessage->getParameter(0)); + value = vMessage->getParameterAsFloat(1); + value = round(value * 100) / 100; + + if (name == "globalVolume") { + if (CAcreSettings::getInstance()->getGlobalVolume() != value) { + CAcreSettings::getInstance()->setGlobalVolume(value); + } + } + else if (name == "premixGlobalVolume") { + if (CAcreSettings::getInstance()->getPremixGlobalVolume() != value) { + CAcreSettings::getInstance()->setPremixGlobalVolume(value); + } + } + else if (name == "disableUnmuteClients") { + if (CAcreSettings::getInstance()->getDisableUnmuteClients() != (value != 1)) { + CAcreSettings::getInstance()->setDisableUnmuteClients(value != 1); + } + } + else { + LOG("Setting [%s] failed to change to [%f]", name.c_str(), value); + return ACRE_ERROR; + } + + LOG("Setting [%s] set to [%f]", name.c_str(), value); + CAcreSettings::getInstance()->save(); + return ACRE_OK; +} +DECLARE_MEMBER(char *, Name); +};