From e277b05afff3cd810054470dc9d20b04b88fd0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 30 Jan 2015 18:56:45 -0300 Subject: [PATCH 01/22] ace_settings: first draft --- addons/common/CfgEventHandlers.hpp | 1 - addons/common/XEH_preInit.sqf | 8 +- addons/common/config.cpp | 10 ++- .../functions/fnc_loadSettingsOnServer.sqf | 74 ++++++++++++++++++ addons/common/functions/fnc_setSetting.sqf | 40 ++++++++++ .../functions/fnc_setSettingFromConfig.sqf | 76 +++++++++++++++++++ addons/common/scripts/readParameters.sqf | 55 -------------- addons/nametags/config.cpp | 42 +++++++--- 8 files changed, 235 insertions(+), 71 deletions(-) create mode 100644 addons/common/functions/fnc_loadSettingsOnServer.sqf create mode 100644 addons/common/functions/fnc_setSetting.sqf create mode 100644 addons/common/functions/fnc_setSettingFromConfig.sqf delete mode 100644 addons/common/scripts/readParameters.sqf diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp index 7ea3b1e1f9..b9c5d7e4ce 100644 --- a/addons/common/CfgEventHandlers.hpp +++ b/addons/common/CfgEventHandlers.hpp @@ -2,7 +2,6 @@ class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); - serverInit = QUOTE(call COMPILE_FILE(scripts\readParameters)); disableModuload = true; }; }; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 1bd305fa02..6cd1c4ce61 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -85,6 +85,7 @@ PREP(isInBuilding); PREP(isPlayer); PREP(isTurnedOut); PREP(letterToCode); +PREP(loadSettingsOnServer); PREP(map); PREP(moduleCheckPBOs); PREP(moduleLSDVehicles); @@ -115,6 +116,8 @@ PREP(setName); PREP(setParameter); PREP(setPitchBankYaw); PREP(setVariableJIP); +PREP(setSetting); +PREP(setSettingFromConfig); PREP(stringToColoredText); PREP(subString); PREP(toBin); @@ -163,6 +166,10 @@ PREP(hashListSet); PREP(hashListPush); +// Load settings +if (isServer) {} + call FUNC(loadSettingsOnServer); +}; ACE_player = player; @@ -183,7 +190,6 @@ if (hasInterface) then { }, 0, []] call cba_fnc_addPerFrameHandler; }; - PREP(stringCompare); PREP(string_removeWhiteSpace); PREP(isHC); diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 2be05e6b57..0189facd47 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -57,10 +57,16 @@ class ACE_canInteractConditions { }; }; -class ACE_Options { +class ACE_Settings { + class GVAR(forceAllSettings) { + value = 0; + typeName = "BOOL"; + }; class GVAR(enableNumberHotkeys) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Common_EnableNumberHotkeys"; - default = 1; }; }; diff --git a/addons/common/functions/fnc_loadSettingsOnServer.sqf b/addons/common/functions/fnc_loadSettingsOnServer.sqf new file mode 100644 index 0000000000..000d8f69cc --- /dev/null +++ b/addons/common/functions/fnc_loadSettingsOnServer.sqf @@ -0,0 +1,74 @@ +/* + * Author: CAA-Picard + * Load the parameters on the server. + * Config < Server UserConfig < Mission Config + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +GVAR(settingsList) = []; + +// Load settings from main config +_countOptions = count (configFile >> "ACE_Settings"); +for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = (configFile >> "ACE_Settings") select _index; + + _name = configName _optionEntry; + _valueEntry = _optionEntry >> "value"; + _typeEntry = _optionEntry >> "typeName"; + + [_name, _valueEntry, _typeEntry] call FUNC(setSettingFromConfig); +}; +// Check if all settings should be forced +if (GVAR(forceAllSettings)) then { + { + if !(missionNamespace getVariable format ["%1_forced", _x]) then { + missionNamespace setVariable format ["%1_forced", _x, true]; + publicVariable format ["%1_forced", _name]; + }; + } forEach GVAR(settingsList); +}; + + +// Load settings from server userconfig +DFUNC(common,serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp"; +if !(isNil QFUNC(common,serverUserConfig)) then { + [] call FUNC(serverUserConfig); +}; +// Check if all settings should be forced +if (GVAR(forceAllSettings)) then { + { + if !(missionNamespace getVariable format ["%1_forced", _x]) then { + missionNamespace setVariable format ["%1_forced", _x, true]; + publicVariable format ["%1_forced", _name]; + }; + } forEach GVAR(settingsList); +}; + + +// Load settings from mission config +_countOptions = count (missionConfigFile >> "ACE_Settings"); +for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = (missionConfigFile >> "ACE_Settings") select _index; + + _name = configName _optionEntry; + _valueEntry = _optionEntry >> "value"; + + [_name, _valueEntry] call FUNC(setSettingFromConfig); +}; +// Check if all settings should be forced +if (GVAR(forceAllSettings)) then { + { + if !(missionNamespace getVariable format ["%1_forced", _x]) then { + missionNamespace setVariable format ["%1_forced", _x, true]; + publicVariable format ["%1_forced", _name]; + }; + } forEach GVAR(settingsList); +}; \ No newline at end of file diff --git a/addons/common/functions/fnc_setSetting.sqf b/addons/common/functions/fnc_setSetting.sqf new file mode 100644 index 0000000000..5a570d618a --- /dev/null +++ b/addons/common/functions/fnc_setSetting.sqf @@ -0,0 +1,40 @@ +/* + * Author: CAA-Picard + * Set a setting if it was not previosuly forced. Force if neccesary. + * + * Arguments: + * 0: Setting name (String) + * 1: Value (Any) + * 2: Force it? (Bool) (Optional) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_2_PVT(_this,_name,_value); + +if !(isServer) exitWith {}; + +private ["force"]; +_force = false; +if (count _this > 2) then { + _force = _this select 2; +}; + +// Check if it's already forced and quit +if (missionNamespace getVariable [format ["%1_forced", _name], false]) exitWith {}; + +// Check if the variable is already defined +if (isNil _name) then { + // Add the variable to a list on the server + GVAR(settingsList) pushBack _name; +}; + +// Update the variable and publish it +missionNamespace setVariable [_name, _value]; +publicVariable _name; +missionNamespace setVariable [format ["%1_forced", _name], _force]; +publicVariable format ["%1_forced", _name]; diff --git a/addons/common/functions/fnc_setSettingFromConfig.sqf b/addons/common/functions/fnc_setSettingFromConfig.sqf new file mode 100644 index 0000000000..8423a16bef --- /dev/null +++ b/addons/common/functions/fnc_setSettingFromConfig.sqf @@ -0,0 +1,76 @@ +/* + * Author: CAA-Picard + * Load a setting from config if it was not previosuly forced. Force if neccesary. + * + * Arguments: + * 0: Setting name (String) + * 1: Config entry (config entry) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_2_PVT(_this,_name,_optionEntry); + +_fnc_getValueWithType = { + EXPLODE_2_PVT(_this,_optionEntry,_typeName); + + _value = getNumber (_optionEntry >> "value"); + if (_typeName == "BOOL") exitWith { + _value = _value > 0; + }; + if (_typeName == "STRING") exitWith { + _value = getText (_optionEntry >> "value"); + }; + if (_typeName == "ARRAY") exitWith { + _value = getArray (_optionEntry >> "value"); + }; + _value +}; + +// Check if the variable is already defined +if (isNil _name) exitWith { + // That setting was not loaded yet + + //diag_log text format ["[ACE]: Mission setting '%1' doesn't exist", _name]; + + _typeEntry = _this select 2; + _typeName = getText _typeEntry; + + _value = [_optionEntry, _typeName] call _fnc_getValueWithType; + + // Init the variable and publish it + missionNamespace setVariable [_name, _value]; + publicVariable _name; + // Set the variable to not forced + missionNamespace setVariable [format ["%1_forced", _name], false]; + publicVariable format ["%1_forced", _name]; + + // Add the variable to a list on the server + GVAR(settingsList) pushBack _name; + +} else { + // The setting already exists. + + // Check if it's already forced and quit + if (missionNamespace getVariable format ["%1_forced", _name]) exitWith {}; + + // The setting is not forced, so update the value + + // Get the type from the existing variable + _typeName = typeName missionNamespace getVariable _name; + _value = [_optionEntry, _typeName] call _fnc_getValueWithType; + + // Update the variable and publish it + missionNamespace setVariable [_name, _value]; + publicVariable _name; + + // Check if it needs forcing + if (getNumber (_optionEntry >> "force") > 0) then { + missionNamespace setVariable [format ["%1_forced", _name], true]; + publicVariable format ["%1_forced", _name]; + }; +}; diff --git a/addons/common/scripts/readParameters.sqf b/addons/common/scripts/readParameters.sqf deleted file mode 100644 index 3b17ea7f1f..0000000000 --- a/addons/common/scripts/readParameters.sqf +++ /dev/null @@ -1,55 +0,0 @@ -// by CAA-Picard -#include "script_component.hpp" - -// Read ACE_Parameters from config and set them on the mission namespace -_config = configFile >> "ACE_Parameters_Numeric"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value] call FUNC(setParameter); -}; - -_config = configFile >> "ACE_Parameters_Boolean"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value > 0] call FUNC(setParameter); -}; - - -// Read ACE_Parameters from mission and set them on the mission namespace, replacing defaults if necesary -_config = missionConfigFile >> "ACE_Parameters"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value] call FUNC(setParameter); -}; - -_config = missionConfigFile >> "ACE_Parameters_Numeric"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value] call FUNC(setParameter); -}; - -_config = missionConfigFile >> "ACE_Parameters_Boolean"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value > 0] call FUNC(setParameter); -}; diff --git a/addons/nametags/config.cpp b/addons/nametags/config.cpp index 1846cd616e..58440192c0 100644 --- a/addons/nametags/config.cpp +++ b/addons/nametags/config.cpp @@ -15,29 +15,47 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -class ACE_Options { +class ACE_Settings { class GVAR(showPlayerNames) { + value = 1; + typeName = "SCALAR"; + isClientSetable = 1; displayName = "$STR_ACE_NameTags_ShowPlayerNames"; values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"}; - default = 1; }; class GVAR(showPlayerRanks) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_NameTags_ShowPlayerRanks"; - default = 1; }; class GVAR(showVehicleCrewInfo) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_CrewInfo_ShowVehicleCrewInfo"; - default = 1; }; -}; -class ACE_Parameters_Numeric { - GVAR(PlayerNamesViewDistance) = 5; - GVAR(PlayerNamesMaxAlpha) = 0.8; - GVAR(CrewInfoVisibility) = 0; -}; -class ACE_Parameters_Boolean { - GVAR(ShowNamesForAI) = 0; + class GVAR(PlayerNamesViewDistance) { + value = 5; + typeName = "SCALAR"; + isClientSetable = 0; + }; + class GVAR(PlayerNamesMaxAlpha) { + value = 0.8; + typeName = "SCALAR"; + isClientSetable = 0; + }; + class GVAR(CrewInfoVisibility) { + value = 0; + typeName = "BOOL"; + isClientSetable = 0; + }; + class GVAR(ShowNamesForAI) { + value = 0; + typeName = "BOOL"; + isClientSetable = 0; + }; }; #include From 981978d043ca65f82c47b0670c499752f71c3d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 30 Jan 2015 19:06:25 -0300 Subject: [PATCH 02/22] ACE_Settings: replace all ACE_Parameters --- addons/explosives/config.cpp | 12 +++++++--- addons/interaction/config.cpp | 7 ++++-- addons/magazinerepack/config.cpp | 12 +++++++--- addons/map/config.cpp | 24 +++++++++++++------ addons/respawn/config.cpp | 12 +++++++--- addons/switchunits/config.cpp | 40 +++++++++++++++++++++++--------- addons/vehiclelock/config.cpp | 7 ++++-- addons/weather/config.cpp | 8 ------- 8 files changed, 83 insertions(+), 39 deletions(-) diff --git a/addons/explosives/config.cpp b/addons/explosives/config.cpp index 8bf463c9f4..e4a079f107 100644 --- a/addons/explosives/config.cpp +++ b/addons/explosives/config.cpp @@ -39,7 +39,13 @@ class CfgMineTriggers { }; }; -class ACE_Parameters_Boolean { - GVAR(RequireSpecialist) = 0; - GVAR(PunishNonSpecialists) = 1; +class ACE_Settings { + class GVAR(RequireSpecialist) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(PunishNonSpecialists) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp index acb41d362f..38933ef506 100644 --- a/addons/interaction/config.cpp +++ b/addons/interaction/config.cpp @@ -33,8 +33,11 @@ class ACE_Options { }; }; -class ACE_Parameters_Boolean { - ACE_Interaction_EnableTeamManagement = 1; +class ACE_Settings { + class GVAR(EnableTeamManagement) { + value = 1; + typeName = "BOOL"; + }; }; class ACE_canInteractConditions { diff --git a/addons/magazinerepack/config.cpp b/addons/magazinerepack/config.cpp index 5f2c6edc7d..91a6f5abf5 100644 --- a/addons/magazinerepack/config.cpp +++ b/addons/magazinerepack/config.cpp @@ -15,7 +15,13 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -class ACE_Parameters_Numeric { - GVAR(TimePerAmmo) = 1.5; - GVAR(TimePerMagazine) = 2.0; +class ACE_Settings { + class GVAR(TimePerAmmo) { + value = 1.5; + typeName = "SCALAR"; + }; + class GVAR(TimePerMagazine) { + value = 2.0; + typeName = "SCALAR"; + }; }; diff --git a/addons/map/config.cpp b/addons/map/config.cpp index c9980458db..36a6f85168 100644 --- a/addons/map/config.cpp +++ b/addons/map/config.cpp @@ -23,13 +23,23 @@ class RscButtonMenuCancel; class RscButtonMenu; class RscEdit; -class ACE_Parameters_Numeric { - GVAR(BFT_Interval) = 1; -}; -class ACE_Parameters_Boolean { - GVAR(EveryoneCanDrawOnBriefing) = 1; - GVAR(BFT_Enabled) = 0; - GVAR(BFT_HideAiGroups) = 0; +class ACE_Settings { + class GVAR(BFT_Interval) { + value = 1.0; + typeName = "SCALAR"; + }; + class GVAR(EveryoneCanDrawOnBriefing) { + value = 1; + typeName = "BOOL"; + }; + class GVAR(BFT_Enabled) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(BFT_HideAiGroups) { + value = 0; + typeName = "BOOL"; + }; }; #include "MapGpsUI.hpp" diff --git a/addons/respawn/config.cpp b/addons/respawn/config.cpp index 0d914df949..19032df4f7 100644 --- a/addons/respawn/config.cpp +++ b/addons/respawn/config.cpp @@ -17,7 +17,13 @@ class CfgPatches { #include "CfgVehicleClasses.hpp" #include "CfgVehicles.hpp" -class ACE_Parameters_Boolean { - GVAR(SavePreDeathGear) = 0; - GVAR(RemoveDeadBodiesDisconnected) = 1; +class ACE_Settings { + class GVAR(SavePreDeathGear) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(RemoveDeadBodiesDisconnected) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/switchunits/config.cpp b/addons/switchunits/config.cpp index b89adb3a7a..09d3e05594 100644 --- a/addons/switchunits/config.cpp +++ b/addons/switchunits/config.cpp @@ -15,15 +15,33 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -class ACE_Parameters_Numeric { - GVAR(SafeZoneRadius) = 100; -}; - -class ACE_Parameters_Boolean { - GVAR(EnableSwitchUnits) = 0; - GVAR(SwitchToWest) = 0; - GVAR(SwitchToEast) = 0; - GVAR(SwitchToIndependent) = 0; - GVAR(SwitchToCivilian) = 0; - GVAR(EnableSafeZone) = 1; +class ACE_Settings { + class GVAR(SafeZoneRadius) { + value = 100; + typeName = "SCALAR"; + }; + class GVAR(EnableSwitchUnits) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToWest) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToEast) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToIndependent) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToCivilian) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(EnableSafeZone) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/vehiclelock/config.cpp b/addons/vehiclelock/config.cpp index 83850a2bef..9031987315 100644 --- a/addons/vehiclelock/config.cpp +++ b/addons/vehiclelock/config.cpp @@ -12,8 +12,11 @@ class CfgPatches { }; }; -class ACE_Parameters_Numeric { - GVAR(DefaultLockpickStrength) = 10; +class ACE_Settings { + class GVAR(DefaultLockpickStrength) { + value = 10; + typeName = "SCALAR"; + }; }; #include "CfgEventHandlers.hpp" diff --git a/addons/weather/config.cpp b/addons/weather/config.cpp index dc3faecf5f..f59267690f 100644 --- a/addons/weather/config.cpp +++ b/addons/weather/config.cpp @@ -14,11 +14,3 @@ class CfgPatches { #include "CfgEventhandlers.hpp" #include "CfgWorlds.hpp" - -/*class ACE_Parameters_Numeric { - GVAR(XXXX) = 100; -}; - -class ACE_Parameters_Boolean { - GVAR(XXXX) = 0; -};*/ From 96b7c0d30c464b8d0a3a571e3362962a3683b7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 30 Jan 2015 19:19:45 -0300 Subject: [PATCH 03/22] ACE_Settings: replace all ACE_Options --- addons/goggles/config.cpp | 22 +++++++------ .../goggles/functions/fnc_externalCamera.sqf | 2 +- addons/hearing/config.cpp | 12 ++++--- addons/hearing/functions/fnc_earRinging.sqf | 2 +- addons/interaction/XEH_clientInit.sqf | 4 +-- addons/interaction/config.cpp | 33 ++++++++++--------- .../interaction/functions/fnc_getActions2.sqf | 2 +- .../functions/fnc_initialiseInteraction.sqf | 2 +- addons/movement/config.cpp | 6 ++-- addons/movement/functions/fnc_getWeight.sqf | 2 +- 10 files changed, 48 insertions(+), 39 deletions(-) diff --git a/addons/goggles/config.cpp b/addons/goggles/config.cpp index f804be003e..eafe07fb27 100644 --- a/addons/goggles/config.cpp +++ b/addons/goggles/config.cpp @@ -3,13 +3,13 @@ #define COLOUR 8.0 class CfgPatches { class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"Garth 'L-H' de Wet"}; - authorUrl = "http://garth.snakebiteink.co.za/"; - VERSION_CONFIG; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Garth 'L-H' de Wet"}; + authorUrl = "http://garth.snakebiteink.co.za/"; + VERSION_CONFIG; }; }; @@ -243,10 +243,12 @@ class SniperCloud { ACE_Goggles_BulletCount = 1; }; -class ACE_Options { +class ACE_Settings { class GVAR(showInThirdPerson) { - displayName = $STR_ACE_Goggles_ShowInThirdPerson; - default = 0; + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Goggles_ShowInThirdPerson;" }; }; diff --git a/addons/goggles/functions/fnc_externalCamera.sqf b/addons/goggles/functions/fnc_externalCamera.sqf index 35b94171a6..91cc3f568c 100644 --- a/addons/goggles/functions/fnc_externalCamera.sqf +++ b/addons/goggles/functions/fnc_externalCamera.sqf @@ -19,5 +19,5 @@ #include "script_component.hpp" -if ((missionNameSpace getVariable [QGVAR(showInThirdPerson), 0]) == 1) exitWith { false }; +if (GVAR(showInThirdPerson)) exitWith { false }; (cameraView == "External") diff --git a/addons/hearing/config.cpp b/addons/hearing/config.cpp index 708146a89b..4499e647f6 100644 --- a/addons/hearing/config.cpp +++ b/addons/hearing/config.cpp @@ -22,9 +22,11 @@ class CfgPatches { #include "CfgAmmo.hpp" -class ACE_Options { - class GVAR(Hearing_DisableEarRinging) { - displayName = "$STR_ACE_Hearing_DisableEarRinging"; - default = 0; - }; +class ACE_Settings { + class GVAR(DisableEarRinging) { + default = 1; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Hearing_DisableEarRinging"; + }; }; \ No newline at end of file diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index 9279b6b954..b578dad979 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -25,7 +25,7 @@ GVAR(newStrength) = GVAR(newStrength) max _strength; if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {}; -if (profileNamespace getVariable [QGVAR(DisableEarRinging), false]) exitWith {}; +if (QGVAR(DisableEarRinging)) exitWith {}; if (_strength > 0.75) exitWith { playSound "ACE_EarRinging_Heavy"; diff --git a/addons/interaction/XEH_clientInit.sqf b/addons/interaction/XEH_clientInit.sqf index bcc3f47def..a4474a5f3e 100644 --- a/addons/interaction/XEH_clientInit.sqf +++ b/addons/interaction/XEH_clientInit.sqf @@ -41,7 +41,7 @@ GVAR(isOpeningDoor) = false; _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific - if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false}; + if !(!isNull (findDisplay 1713999) && {QGVAR(AutoCloseMenu)}) exitWith {false}; // Statement if (GVAR(MenuType) mod 2 == 0) then {call FUNC(onButtonUp)}; @@ -77,7 +77,7 @@ GVAR(isOpeningDoor) = false; _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific - if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false}; + if !(!isNull (findDisplay 1713999) && {QGVAR(AutoCloseMenu)}) exitWith {false}; // Statement if (GVAR(MenuType) mod 2 == 1) then {call FUNC(onButtonUp)}; diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp index 38933ef506..da62019d3a 100644 --- a/addons/interaction/config.cpp +++ b/addons/interaction/config.cpp @@ -18,22 +18,25 @@ class CfgPatches { #include -class ACE_Options { - class Interaction_FlowMenu { - displayName = "$STR_ACE_Interaction_FlowMenu"; - default = 0; - }; - class Interaction_AutoCloseMenu { - displayName = "$STR_ACE_Interaction_AutoCloseMenu"; - default = 0; - }; - class Interaction_AutoCenterCursor { - displayName = "$STR_ACE_Interaction_AutoCenterCursor"; - default = 1; - }; -}; - class ACE_Settings { + class GVAR(FlowMenu) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Interaction_FlowMenu"; + }; + class GVAR(AutoCloseMenu) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Interaction_AutoCloseMenu"; + }; + class GVAR(AutoCenterCursor) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Interaction_AutoCenterCursor"; + }; class GVAR(EnableTeamManagement) { value = 1; typeName = "BOOL"; diff --git a/addons/interaction/functions/fnc_getActions2.sqf b/addons/interaction/functions/fnc_getActions2.sqf index ab64d8d390..0de4f7a534 100644 --- a/addons/interaction/functions/fnc_getActions2.sqf +++ b/addons/interaction/functions/fnc_getActions2.sqf @@ -66,7 +66,7 @@ _cacheIndices = _cache select 2; _statement = getText (_action >> "statement"); _statement = compile _statement; - if (profileNamespace getVariable ["ACE_Interaction_FlowMenu", false]) then { + if (GVAR(FlowMenu)) then { _statement = if (getText (_action >> "statement") == "" && {count _subMenu > 1}) then { compile format [QUOTE( call FUNC(hideMenu);if(%2 == 1)then{['%1'] call FUNC(openSubMenuSelf);}else{['%1'] call FUNC(openSubMenu);}; ), _subMenu select 0, _subMenu select 1]; } else { diff --git a/addons/interaction/functions/fnc_initialiseInteraction.sqf b/addons/interaction/functions/fnc_initialiseInteraction.sqf index 2637d28bf9..4d88eb4ea1 100644 --- a/addons/interaction/functions/fnc_initialiseInteraction.sqf +++ b/addons/interaction/functions/fnc_initialiseInteraction.sqf @@ -67,7 +67,7 @@ if (_this select 2) then { disableSerialization; _dlgInteractionDialog = uiNamespace getVariable QGVAR(Dialog); _ctrlInteractionDialog = _dlgInteractionDialog displayCtrl 3; - if (profileNamespace getVariable [QGVAR(AutoCenterCursor), true]) then {setMousePosition [0.5, 0.5]}; + if (GVAR(AutoCenterCursor)) then {setMousePosition [0.5, 0.5]}; if !(_subMenu) then { _ctrlInteractionDialog ctrlSetText ([_target] call EFUNC(common,getName)); } else { diff --git a/addons/movement/config.cpp b/addons/movement/config.cpp index e8661b748c..51ab97b80a 100644 --- a/addons/movement/config.cpp +++ b/addons/movement/config.cpp @@ -17,9 +17,11 @@ class CfgPatches { //#include "CfgInventoryGlobalVariable.hpp" #include "CfgMoves.hpp" -class ACE_Options { +class ACE_Settings { class GVAR(useImperial) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Movement_UseImperial"; - default = 0; }; }; diff --git a/addons/movement/functions/fnc_getWeight.sqf b/addons/movement/functions/fnc_getWeight.sqf index a52ed3cb12..254b706d56 100644 --- a/addons/movement/functions/fnc_getWeight.sqf +++ b/addons/movement/functions/fnc_getWeight.sqf @@ -7,7 +7,7 @@ _unit = _this select 0; _weight = loadAbs _unit * 0.1; -if (GETGVAR(useImperial, 0) == 1) then { +if (GVAR(useImperial)) then { _weight = format ["%1lb", (round (_weight * 100)) / 100]; } else { _weight = format ["%1kg", (round (_weight * FACTOR_POUND_TO_KILOGRAMM * 100)) / 100]; From 0600a72147c81671d534e2028b2cb72d9ea3288f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Mon, 2 Feb 2015 21:13:31 -0300 Subject: [PATCH 04/22] Fixes --- addons/common/XEH_preInit.sqf | 3 +- .../functions/fnc_loadSettingsOnServer.sqf | 43 ++++++++----------- .../functions/fnc_setSettingFromConfig.sqf | 29 +++++++------ addons/hearing/functions/fnc_earRinging.sqf | 2 +- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 6cd1c4ce61..a7b48d7192 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -165,9 +165,8 @@ PREP(hashListSelect); PREP(hashListSet); PREP(hashListPush); - // Load settings -if (isServer) {} +if (isServer) then { call FUNC(loadSettingsOnServer); }; diff --git a/addons/common/functions/fnc_loadSettingsOnServer.sqf b/addons/common/functions/fnc_loadSettingsOnServer.sqf index 000d8f69cc..e9d87ad742 100644 --- a/addons/common/functions/fnc_loadSettingsOnServer.sqf +++ b/addons/common/functions/fnc_loadSettingsOnServer.sqf @@ -20,11 +20,7 @@ _countOptions = count (configFile >> "ACE_Settings"); for "_index" from 0 to (_countOptions - 1) do { _optionEntry = (configFile >> "ACE_Settings") select _index; - _name = configName _optionEntry; - _valueEntry = _optionEntry >> "value"; - _typeEntry = _optionEntry >> "typeName"; - - [_name, _valueEntry, _typeEntry] call FUNC(setSettingFromConfig); + [_optionEntry] call FUNC(setSettingFromConfig); }; // Check if all settings should be forced if (GVAR(forceAllSettings)) then { @@ -36,32 +32,29 @@ if (GVAR(forceAllSettings)) then { } forEach GVAR(settingsList); }; - -// Load settings from server userconfig -DFUNC(common,serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp"; -if !(isNil QFUNC(common,serverUserConfig)) then { - [] call FUNC(serverUserConfig); +// Load settings from server userconfig only if the ACE_ServerSettings is loaded +if (isClass (configFile >> "CfgPatches" >> "ACE_ServerSettings")) then { + DFUNC(serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp"; + if !(isNil DFUNC(serverUserConfig)) then { + [] call FUNC(serverUserConfig); + }; + // Check if all settings should be forced + if (GVAR(forceAllSettings)) then { + { + if !(missionNamespace getVariable format ["%1_forced", _x]) then { + missionNamespace setVariable format ["%1_forced", _x, true]; + publicVariable format ["%1_forced", _name]; + }; + } forEach GVAR(settingsList); + }; }; -// Check if all settings should be forced -if (GVAR(forceAllSettings)) then { - { - if !(missionNamespace getVariable format ["%1_forced", _x]) then { - missionNamespace setVariable format ["%1_forced", _x, true]; - publicVariable format ["%1_forced", _name]; - }; - } forEach GVAR(settingsList); -}; - // Load settings from mission config _countOptions = count (missionConfigFile >> "ACE_Settings"); for "_index" from 0 to (_countOptions - 1) do { _optionEntry = (missionConfigFile >> "ACE_Settings") select _index; - _name = configName _optionEntry; - _valueEntry = _optionEntry >> "value"; - - [_name, _valueEntry] call FUNC(setSettingFromConfig); + [_optionEntry] call FUNC(setSettingFromConfig); }; // Check if all settings should be forced if (GVAR(forceAllSettings)) then { @@ -71,4 +64,4 @@ if (GVAR(forceAllSettings)) then { publicVariable format ["%1_forced", _name]; }; } forEach GVAR(settingsList); -}; \ No newline at end of file +}; diff --git a/addons/common/functions/fnc_setSettingFromConfig.sqf b/addons/common/functions/fnc_setSettingFromConfig.sqf index 8423a16bef..89967c357c 100644 --- a/addons/common/functions/fnc_setSettingFromConfig.sqf +++ b/addons/common/functions/fnc_setSettingFromConfig.sqf @@ -3,9 +3,8 @@ * Load a setting from config if it was not previosuly forced. Force if neccesary. * * Arguments: - * 0: Setting name (String) - * 1: Config entry (config entry) - * + * 0: Config entry (config entry) + * * Return Value: * None * @@ -13,33 +12,35 @@ */ #include "script_component.hpp" -EXPLODE_2_PVT(_this,_name,_optionEntry); +EXPLODE_1_PVT(_this,_optionEntry); _fnc_getValueWithType = { EXPLODE_2_PVT(_this,_optionEntry,_typeName); _value = getNumber (_optionEntry >> "value"); + diag_log text format ["%1 %2: %3", configName _optionEntry, _typeName, _value]; if (_typeName == "BOOL") exitWith { - _value = _value > 0; + _value > 0 }; if (_typeName == "STRING") exitWith { - _value = getText (_optionEntry >> "value"); + getText (_optionEntry >> "value") }; if (_typeName == "ARRAY") exitWith { - _value = getArray (_optionEntry >> "value"); + getArray (_optionEntry >> "value") }; _value }; +_name = configName _optionEntry; + // Check if the variable is already defined -if (isNil _name) exitWith { +if (isNil _name) then { // That setting was not loaded yet - //diag_log text format ["[ACE]: Mission setting '%1' doesn't exist", _name]; - - _typeEntry = _this select 2; - _typeName = getText _typeEntry; + // Get type from config + _typeName = getText (_optionEntry >> "typeName"); + // Read entry and cast it to the correct type _value = [_optionEntry, _typeName] call _fnc_getValueWithType; // Init the variable and publish it @@ -61,7 +62,9 @@ if (isNil _name) exitWith { // The setting is not forced, so update the value // Get the type from the existing variable - _typeName = typeName missionNamespace getVariable _name; + _typeName = typeName (missionNamespace getVariable _name); + + // Read entry and cast it to the correct type _value = [_optionEntry, _typeName] call _fnc_getValueWithType; // Update the variable and publish it diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index b578dad979..4581a6fdd9 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -25,7 +25,7 @@ GVAR(newStrength) = GVAR(newStrength) max _strength; if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {}; -if (QGVAR(DisableEarRinging)) exitWith {}; +if (GVAR(DisableEarRinging)) exitWith {}; if (_strength > 0.75) exitWith { playSound "ACE_EarRinging_Heavy"; From 37199f2ba29b1697810eb908456c272caab71d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Mon, 2 Feb 2015 21:14:16 -0300 Subject: [PATCH 05/22] Load client setable settings from profile --- addons/common/XEH_postInit.sqf | 3 ++ .../functions/fnc_loadSettingsFromProfile.sqf | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 addons/common/functions/fnc_loadSettingsFromProfile.sqf diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 542c4277cf..df48d076f2 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,6 +1,9 @@ // ACE - Common #include "script_component.hpp" +// Load settings from profile +call FUNC(loadSettingsFromProfile); + // hack to get PFH to work in briefing [QGVAR(onBriefingPFH), "onEachFrame", { if (time > 0) exitWith { diff --git a/addons/common/functions/fnc_loadSettingsFromProfile.sqf b/addons/common/functions/fnc_loadSettingsFromProfile.sqf new file mode 100644 index 0000000000..a77af66309 --- /dev/null +++ b/addons/common/functions/fnc_loadSettingsFromProfile.sqf @@ -0,0 +1,48 @@ +/* + * Author: CAA-Picard + * Load the user setable setting from the user profile. + * Config < Server UserConfig < Mission Config < Client settings + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +_fnc_setSettingFromProfile = { + EXPLODE_1_PVT(_this,_optionEntry); + + _name = configName _optionEntry; + _valueEntry = _optionEntry >> "value"; + _isClientSetable = getNumber (_optionEntry >> "isClientSetable"); + + if (_isClientSetable > 0) then { + if !(missionNamespace getVariable format ["%1_forced", _name, false]) then { + _profileValue = profileNamespace getvariable _name; + if !(isNil _profileValue) then { + if (typeName _profileValue == typeName (missionNamespace getvariable _name)) then { + missionNamespace setvariable [_name, _profileValue]; + }; + }; + }; + }; +}; + +// Iterate through settings from main config +_countOptions = count (configFile >> "ACE_Settings"); +for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = (configFile >> "ACE_Settings") select _index; + [_optionEntry] call _fnc_setSettingFromProfile; + +}; + +// Iterate through settings from mission config +_countOptions = count (missionConfigFile >> "ACE_Settings"); +for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = (missionConfigFile >> "ACE_Settings") select _index; + [_optionEntry] call _fnc_setSettingFromProfile; +}; From 67f78427226895a01fcaa8c1f6e4253a5600308c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 00:43:23 -0300 Subject: [PATCH 06/22] ACE_Settings: store settings data on a list --- addons/common/XEH_preInit.sqf | 1 + .../common/functions/fnc_getSettingData.sqf | 29 ++++++++++++ .../functions/fnc_loadSettingsFromProfile.sqf | 39 ++++++---------- .../functions/fnc_loadSettingsOnServer.sqf | 28 ++++++------ .../functions/fnc_setSettingFromConfig.sqf | 45 ++++++++++++++----- 5 files changed, 92 insertions(+), 50 deletions(-) create mode 100644 addons/common/functions/fnc_getSettingData.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index a7b48d7192..1b724625ab 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -55,6 +55,7 @@ PREP(getMarkerType); PREP(getName); PREP(getNumberFromMissionSQM); PREP(getPitchBankYaw); +PREP(getSettingData); PREP(getStringFromMissionSQM); PREP(getTargetAzimuthAndInclination); PREP(getTargetDistance); diff --git a/addons/common/functions/fnc_getSettingData.sqf b/addons/common/functions/fnc_getSettingData.sqf new file mode 100644 index 0000000000..f8572c5f42 --- /dev/null +++ b/addons/common/functions/fnc_getSettingData.sqf @@ -0,0 +1,29 @@ +/* + * Author: CAA-Picard + * Returns the metadata of a setting if it exists + * + * Arguments: + * 0: Name of the setting (String) + * + * Return Value: + * Setting Data (Array) + * 0: _name + * 1: _typeName + * 2: _isClientSetable + * 3: _localizedName + * 4: _localizedDescription + * 5: _possibleValues + * 6: _isForced + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_1_PVT(_this,_name); + +_value = objNull; +{ + if ((_x select 0) == _name) exitWith {_value = _x}; +} forEach GVAR(settings); + +_value diff --git a/addons/common/functions/fnc_loadSettingsFromProfile.sqf b/addons/common/functions/fnc_loadSettingsFromProfile.sqf index a77af66309..9d077359ce 100644 --- a/addons/common/functions/fnc_loadSettingsFromProfile.sqf +++ b/addons/common/functions/fnc_loadSettingsFromProfile.sqf @@ -1,6 +1,6 @@ /* * Author: CAA-Picard - * Load the user setable setting from the user profile. + * Load the user setable settings from the user profile. * Config < Server UserConfig < Mission Config < Client settings * * Arguments: @@ -13,36 +13,25 @@ */ #include "script_component.hpp" -_fnc_setSettingFromProfile = { - EXPLODE_1_PVT(_this,_optionEntry); +// Iterate through settings +{ + _name = _x select 0; + _isClientSetable = _x select 2; + _isForced = _x select 6; - _name = configName _optionEntry; - _valueEntry = _optionEntry >> "value"; - _isClientSetable = getNumber (_optionEntry >> "isClientSetable"); - - if (_isClientSetable > 0) then { - if !(missionNamespace getVariable format ["%1_forced", _name, false]) then { + // If setting is user setable + if (_isClientSetable) then { + // If setting is not forced + if !(_isForced) then { _profileValue = profileNamespace getvariable _name; + // If the setting is stored on the profile if !(isNil _profileValue) then { + // If the profile variable has the correct type if (typeName _profileValue == typeName (missionNamespace getvariable _name)) then { + // Load the setting from the profile missionNamespace setvariable [_name, _profileValue]; }; }; }; }; -}; - -// Iterate through settings from main config -_countOptions = count (configFile >> "ACE_Settings"); -for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (configFile >> "ACE_Settings") select _index; - [_optionEntry] call _fnc_setSettingFromProfile; - -}; - -// Iterate through settings from mission config -_countOptions = count (missionConfigFile >> "ACE_Settings"); -for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (missionConfigFile >> "ACE_Settings") select _index; - [_optionEntry] call _fnc_setSettingFromProfile; -}; +} forEach GVAR(settings); diff --git a/addons/common/functions/fnc_loadSettingsOnServer.sqf b/addons/common/functions/fnc_loadSettingsOnServer.sqf index e9d87ad742..20a7e1c40f 100644 --- a/addons/common/functions/fnc_loadSettingsOnServer.sqf +++ b/addons/common/functions/fnc_loadSettingsOnServer.sqf @@ -13,7 +13,7 @@ */ #include "script_component.hpp" -GVAR(settingsList) = []; +GVAR(settings) = []; // Load settings from main config _countOptions = count (configFile >> "ACE_Settings"); @@ -25,15 +25,13 @@ for "_index" from 0 to (_countOptions - 1) do { // Check if all settings should be forced if (GVAR(forceAllSettings)) then { { - if !(missionNamespace getVariable format ["%1_forced", _x]) then { - missionNamespace setVariable format ["%1_forced", _x, true]; - publicVariable format ["%1_forced", _name]; - }; - } forEach GVAR(settingsList); + _x set [6, true]; + } forEach GVAR(settings); }; +// @todo // Load settings from server userconfig only if the ACE_ServerSettings is loaded -if (isClass (configFile >> "CfgPatches" >> "ACE_ServerSettings")) then { +/*if (isClass (configFile >> "CfgPatches" >> "ACE_ServerSettings")) then { DFUNC(serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp"; if !(isNil DFUNC(serverUserConfig)) then { [] call FUNC(serverUserConfig); @@ -47,7 +45,7 @@ if (isClass (configFile >> "CfgPatches" >> "ACE_ServerSettings")) then { }; } forEach GVAR(settingsList); }; -}; +};*/ // Load settings from mission config _countOptions = count (missionConfigFile >> "ACE_Settings"); @@ -59,9 +57,13 @@ for "_index" from 0 to (_countOptions - 1) do { // Check if all settings should be forced if (GVAR(forceAllSettings)) then { { - if !(missionNamespace getVariable format ["%1_forced", _x]) then { - missionNamespace setVariable format ["%1_forced", _x, true]; - publicVariable format ["%1_forced", _name]; - }; - } forEach GVAR(settingsList); + _x set [6, true]; + } forEach GVAR(settings); }; + +// Publish all settings data +publicVariable QGVAR(settings); +// Publish all setting values +{ + publicVariable (_x select 0); +} forEach GVAR(settings); diff --git a/addons/common/functions/fnc_setSettingFromConfig.sqf b/addons/common/functions/fnc_setSettingFromConfig.sqf index 89967c357c..a6b46f45c4 100644 --- a/addons/common/functions/fnc_setSettingFromConfig.sqf +++ b/addons/common/functions/fnc_setSettingFromConfig.sqf @@ -28,6 +28,9 @@ _fnc_getValueWithType = { if (_typeName == "ARRAY") exitWith { getArray (_optionEntry >> "value") }; + if (_typeName == "COLOR") exitWith { + getArray (_optionEntry >> "value") + }; _value }; @@ -39,41 +42,59 @@ if (isNil _name) then { // Get type from config _typeName = getText (_optionEntry >> "typeName"); + if (_typeName == "") then { + _typeName = "SCALAR"; + }; // Read entry and cast it to the correct type _value = [_optionEntry, _typeName] call _fnc_getValueWithType; // Init the variable and publish it missionNamespace setVariable [_name, _value]; - publicVariable _name; - // Set the variable to not forced - missionNamespace setVariable [format ["%1_forced", _name], false]; - publicVariable format ["%1_forced", _name]; - // Add the variable to a list on the server - GVAR(settingsList) pushBack _name; + // Add the setting to a list on the server + // Set the variable to not forced + /*_settingData = [ + _name, + _typeName, + _isClientSetable, + _localizedName, + _localizedDescription, + _possibleValues, + _isForced + ];*/ + _settingData = [ + _name, + _typeName, + (getNumber (_optionEntry >> "isClientSetable")) > 0, + getText (_optionEntry >> "displayName"), + getText (_optionEntry >> "description"), + getArray (_optionEntry >> "values"), + getNumber (_optionEntry >> "force") > 0 + ]; + + GVAR(settings) pushBack _settingData; } else { // The setting already exists. // Check if it's already forced and quit - if (missionNamespace getVariable format ["%1_forced", _name]) exitWith {}; + _settingData = [_name] call FUNC(getSettingData); + if (_settingData select 6) exitWith {}; // The setting is not forced, so update the value // Get the type from the existing variable - _typeName = typeName (missionNamespace getVariable _name); + _typeName = _settingData select 1; // Read entry and cast it to the correct type _value = [_optionEntry, _typeName] call _fnc_getValueWithType; // Update the variable and publish it missionNamespace setVariable [_name, _value]; - publicVariable _name; - // Check if it needs forcing + // Force the setting if requested if (getNumber (_optionEntry >> "force") > 0) then { - missionNamespace setVariable [format ["%1_forced", _name], true]; - publicVariable format ["%1_forced", _name]; + _settingData set [6, true]; }; }; From 354b2616779df2a42bfa8f9284c1ac278858f024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 00:43:53 -0300 Subject: [PATCH 07/22] ACE_Settings: added sample setting entry for documentation --- addons/common/config.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 0189facd47..84052cbdfb 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -58,6 +58,32 @@ class ACE_canInteractConditions { }; class ACE_Settings { + /* + *class GVAR(sampleSetting) { + * Value + * value = 1; + * + * Type (SCALAR, BOOL, STRING, ARRAY, COLOR) + * typeName = "SCALAR"; + * + * Force the setting? + * force = 0; + * + * Does it appear on the options menu? + * isClientSetable = 1; + * + * The following settings only apply when isClientSetable == 1 + * Stringtable entry with the setting name + * displayName = "$STR_ACE_Common_SettingName"; + * + * Stringtable entry with the setting description + * description = "$STR_ACE_Common_SettingDescription"; + * + * Stringtable entries that describe the options + * Only applies if typeName == "SCALAR"; + * values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"}; + *}; + */ class GVAR(forceAllSettings) { value = 0; typeName = "BOOL"; From 173169bc3d6b1aba5176c48deee2c15b943daadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 00:44:06 -0300 Subject: [PATCH 08/22] Fix in goggles --- addons/goggles/config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/goggles/config.cpp b/addons/goggles/config.cpp index eafe07fb27..dcc9c6ed0e 100644 --- a/addons/goggles/config.cpp +++ b/addons/goggles/config.cpp @@ -248,7 +248,7 @@ class ACE_Settings { value = 0; typeName = "BOOL"; isClientSetable = 1; - displayName = "$STR_ACE_Goggles_ShowInThirdPerson;" + displayName = "$STR_ACE_Goggles_ShowInThirdPerson"; }; }; From 91cfb40e6f5b25918daa33fb7c76beac8e2f7a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 00:44:34 -0300 Subject: [PATCH 09/22] ACE_Settings: updated optionsmenu to use the the new system --- addons/optionsmenu/CfgEventHandlers.hpp | 6 --- addons/optionsmenu/XEH_postInit.sqf | 4 -- addons/optionsmenu/XEH_preInit.sqf | 5 --- .../functions/fnc_addClientSideColor.sqf | 19 ---------- .../functions/fnc_addClientSideOptions.sqf | 19 ---------- .../functions/fnc_addFromConfig.sqf | 38 ------------------- .../functions/fnc_loadFromProfile.sqf | 36 ------------------ .../functions/fnc_onSettingsMenuOpen.sqf | 21 ++++++++++ .../functions/fnc_saveToProfile.sqf | 37 ------------------ .../fnc_settingsMenuUpdateKeyView.sqf | 22 +++++++---- .../functions/fnc_settingsMenuUpdateList.sqf | 19 +++++++--- .../functions/fnc_updateSetting.sqf | 20 +++++++--- 12 files changed, 64 insertions(+), 182 deletions(-) delete mode 100644 addons/optionsmenu/XEH_postInit.sqf delete mode 100644 addons/optionsmenu/functions/fnc_addClientSideColor.sqf delete mode 100644 addons/optionsmenu/functions/fnc_addClientSideOptions.sqf delete mode 100644 addons/optionsmenu/functions/fnc_addFromConfig.sqf delete mode 100644 addons/optionsmenu/functions/fnc_loadFromProfile.sqf delete mode 100644 addons/optionsmenu/functions/fnc_saveToProfile.sqf diff --git a/addons/optionsmenu/CfgEventHandlers.hpp b/addons/optionsmenu/CfgEventHandlers.hpp index 88bfdf4e6b..b97829836e 100644 --- a/addons/optionsmenu/CfgEventHandlers.hpp +++ b/addons/optionsmenu/CfgEventHandlers.hpp @@ -3,9 +3,3 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - }; -}; diff --git a/addons/optionsmenu/XEH_postInit.sqf b/addons/optionsmenu/XEH_postInit.sqf deleted file mode 100644 index c0b61d87de..0000000000 --- a/addons/optionsmenu/XEH_postInit.sqf +++ /dev/null @@ -1,4 +0,0 @@ -#include "script_component.hpp" - -//Add Settings from configFile -[] call FUNC(addFromConfig); diff --git a/addons/optionsmenu/XEH_preInit.sqf b/addons/optionsmenu/XEH_preInit.sqf index 97df9410e6..83a50bce65 100644 --- a/addons/optionsmenu/XEH_preInit.sqf +++ b/addons/optionsmenu/XEH_preInit.sqf @@ -2,16 +2,11 @@ ADDON = false; -PREP(addClientSideColor); -PREP(addClientSideOptions); -PREP(addFromConfig); -PREP(loadFromProfile); PREP(onListBoxSettingsChanged); PREP(onListBoxShowSelectionChanged); PREP(onSettingsMenuOpen); PREP(onSliderPosChanged); PREP(resetSettings); -PREP(saveToProfile); PREP(settingsMenuUpdateKeyView); PREP(settingsMenuUpdateList); PREP(updateSetting); diff --git a/addons/optionsmenu/functions/fnc_addClientSideColor.sqf b/addons/optionsmenu/functions/fnc_addClientSideColor.sqf deleted file mode 100644 index ca0473cb89..0000000000 --- a/addons/optionsmenu/functions/fnc_addClientSideColor.sqf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * fnc_addClientSideColor.sqf - * @Descr: N/A - * @Author: PabstMirror - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ -#include "script_component.hpp" - -private ["_currentValue"]; -PARAMS_4(_name,_localizedName,_localizedDescription,_defaultValue); - -GVAR(clientSideColors) pushBack [_name, _localizedName, _localizedDescription, [], _defaultValue]; - -//Get the current setting from profile (or default) and set it: -_currentValue = [MENU_TAB_COLORS, _name, _defaultValue] call FUNC(loadFromProfile); -[MENU_TAB_COLORS, _name, _currentValue] call FUNC(updateSetting); diff --git a/addons/optionsmenu/functions/fnc_addClientSideOptions.sqf b/addons/optionsmenu/functions/fnc_addClientSideOptions.sqf deleted file mode 100644 index 4ad9584410..0000000000 --- a/addons/optionsmenu/functions/fnc_addClientSideOptions.sqf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * fnc_addClientSideOptions.sqf - * @Descr: N/A - * @Author: Glowbal - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ -#include "script_component.hpp" - -private ["_currentValue"]; -PARAMS_5(_name,_localizedName,_localizedDescription,_possibleValues,_defaultValue); - -GVAR(clientSideOptions) pushBack [_name, _localizedName, _localizedDescription, _possibleValues, -1, _defaultValue]; - -//Get the current setting from profile (or default) and set it: -_currentValue = [MENU_TAB_OPTIONS, _name, _defaultValue] call FUNC(loadFromProfile); -[MENU_TAB_OPTIONS, _name, _currentValue] call FUNC(updateSetting); diff --git a/addons/optionsmenu/functions/fnc_addFromConfig.sqf b/addons/optionsmenu/functions/fnc_addFromConfig.sqf deleted file mode 100644 index 226b5dee73..0000000000 --- a/addons/optionsmenu/functions/fnc_addFromConfig.sqf +++ /dev/null @@ -1,38 +0,0 @@ -/** -* fnc_addFromConfig.sqf -* @Descr: N/A -* @Author: PabstMirror -* -* @Arguments: [] -* @Return: -* @PublicAPI: false -*/ -#include "script_component.hpp" - -if (isClass (configFile >> "ACE_Options")) then { - _countOptions = count (configFile >> "ACE_Options"); - for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (configFile >> "ACE_Options") select _index; - _name = configName _optionEntry; - _displayName = getText (_optionEntry >> "displayName"); - _description = getText (_optionEntry >> "description"); - _default = getNumber (_optionEntry >> "default"); - _choices = getArray (_optionEntry >> "values"); - if ((count _choices) == 0) then { - _choices = [(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")]; - }; - [_name, _displayName, _description, _choices, _default] call FUNC(addClientSideOptions); - }; -}; - -if (isClass (configFile >> "ACE_Colors")) then { - _countOptions = count (configFile >> "ACE_Colors"); - for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (configFile >> "ACE_Colors") select _index; - _name = configName _optionEntry; - _displayName = getText (_optionEntry >> "displayName"); - _description = getText (_optionEntry >> "description"); - _default = getArray (_optionEntry >> "default"); - [_name, _displayName, _description, _default] call FUNC(addClientSideColor); - }; -}; diff --git a/addons/optionsmenu/functions/fnc_loadFromProfile.sqf b/addons/optionsmenu/functions/fnc_loadFromProfile.sqf deleted file mode 100644 index 21819f1add..0000000000 --- a/addons/optionsmenu/functions/fnc_loadFromProfile.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/** -* fnc_loadFromProfile.sqf -* @Descr: N/A -* @Author: Glowbal -* -* @Arguments: [] -* @Return: -* @PublicAPI: false -*/ -#include "script_component.hpp" - -private ["_typeString", "_settingValue", "_badData"]; -PARAMS_3(_type,_name,_default); - -_typeString = ""; -switch (_type) do { -case (MENU_TAB_OPTIONS): {_typeString = "option";}; -case (MENU_TAB_COLORS): {_typeString = "color";}; -}; - -_settingValue = profileNamespace getvariable [(format ["ace_%1_%2", _typeString, _name]), _default]; - -_badData = isNil "_settingValue"; -if (!_badData) then { - switch (_type) do { - case (MENU_TAB_OPTIONS): {_badData = ((typeName _settingValue) != (typeName 0));}; - case (MENU_TAB_COLORS): {_badData = (((typeName _settingValue) != (typeName [])) || {(count _settingValue) != 4});}; - }; -}; -if (_badData) then { - _settingValue = _default; - systemChat format ["Bad Data in profile [ace_%1_%2] using default", _typeString, _name]; - ERROR("Bad Value in profile"); -}; - -_settingValue diff --git a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf index 11f5a3ef64..d0b104135d 100644 --- a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf @@ -9,5 +9,26 @@ */ #include "script_component.hpp" +// Filter only user setable setting +GVAR(clientSideOptions) = []; +GVAR(clientSideColors) = []; +{ + // If the setting is user setable + if (_x select 2) then { + // Append the current value to the setting metadata + _setting = + _x; + _setting pushBack (missionNamespace getVariable (_x select 0)); + + // Categorize the setting according to types + // @todo: allow the user to modify other types of parameters? + if ((_x select 1) == "SCALAR" || (_x select 1) == "BOOL") then { + GVAR(clientSideOptions) pushBack _setting; + }; + if ((_x select 1) == "COLOR") then { + GVAR(clientSideColors) pushBack _setting; + }; + }; +} forEach EGVAR(common,settings); + //Delay a frame [{ [MENU_TAB_OPTIONS] call FUNC(onListBoxShowSelectionChanged) }, []] call EFUNC(common,execNextFrame); diff --git a/addons/optionsmenu/functions/fnc_saveToProfile.sqf b/addons/optionsmenu/functions/fnc_saveToProfile.sqf deleted file mode 100644 index 30db652186..0000000000 --- a/addons/optionsmenu/functions/fnc_saveToProfile.sqf +++ /dev/null @@ -1,37 +0,0 @@ -/** -* fnc_saveToProfile.sqf -* @Descr: Save the clientside option to the profile. -* @Author: Glowbal -* -* @Arguments: [name STRING (Name of setting)] -* @Return: BOOL True if saved. -* @PublicAPI: false -*/ -#include "script_component.hpp" - -private ["_nameSelected", "_saved"]; -PARAMS_2(_type,_name); - -_saved = false; -switch (_type) do { -case (MENU_TAB_OPTIONS): { - { - _nameSelected = _x select 0; - if (_nameSelected == _name) exitwith { - profileNamespace setvariable [(format ["ace_option_%1", _name]), (_x select 4)]; - _saved = true; - }; - }foreach GVAR(clientSideOptions); - }; -case (MENU_TAB_COLORS): { - { - _nameSelected = _x select 0; - if (_nameSelected == _name) exitwith { - profileNamespace setvariable [(format ["ace_color_%1", _name]), (_x select 3)]; - _saved = true; - }; - }foreach GVAR(clientSideColors); - }; -}; - -_saved diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf index 09242bcb8c..23b9ed9523 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf @@ -33,8 +33,8 @@ if (count _collection > 0) then { _setting = _collection select _settingIndex; _entryName = _setting select 0; - _localizedName = _setting select 1; - _localizedDescription = _setting select 2; + _localizedName = _setting select 3; + _localizedDescription = _setting select 4; if (_localizedName == "") then {_localizedName = _entryName;}; (_settingsMenu displayCtrl 250) ctrlSetText _localizedName; @@ -43,15 +43,23 @@ if (count _collection > 0) then { switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { - _possibleValues = _setting select 3; - _settingsValue = _setting select 4; - lbClear 400; - { lbAdd [400, _x]; } foreach _possibleValues; + _possibleValues = _setting select 5; + _settingsValue = _setting select 7; + // Created disable/enable options for bools + if ((_setting select 1) == "BOOL") then { + lbClear 400; + lbAdd [400, (localize "STR_ACE_OptionsMenu_Disabled")]; + lbAdd [400, (localize "STR_ACE_OptionsMenu_Enabled")]; + _settingsValue = [0, 1] select _settingsValue; + } else { + lbClear 400; + { lbAdd [400, _x]; } foreach _possibleValues; + }; (_settingsMenu displayCtrl 400) lbSetCurSel _settingsValue; }; case (MENU_TAB_COLORS): { - _currentColor = _setting select 3; + _currentColor = _setting select 7; { sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))]; } forEach [410, 411, 412, 413]; diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf index ff825a2141..78b5113203 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf @@ -21,21 +21,30 @@ lbclear _ctrlList; switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { { - _settingsText = ((_x select 3) select (_x select 4)); - _ctrlList lbadd (_x select 1); + _ctrlList lbadd (_x select 3); + + _settingsValue = _x select 7; + + // Created disable/enable options for bools + _settingsText = if ((_x select 1) == "BOOL") then { + [(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")] select _settingsValue; + } else { + (_x select 5) select _settingsValue; + }; + _ctrlList lbadd (_settingsText); }foreach GVAR(clientSideOptions); }; case (MENU_TAB_COLORS): { { - _color = +(_x select 3); + _color = +(_x select 7); { _color set [_forEachIndex, ((round (_x * 100))/100)]; } forEach _color; _settingsColor = str _color; - _ctrlList lbadd (_x select 1); + _ctrlList lbadd (_x select 3); _ctrlList lbadd (_settingsColor); - _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 3)]; + _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 7)]; }foreach GVAR(clientSideColors); }; }; diff --git a/addons/optionsmenu/functions/fnc_updateSetting.sqf b/addons/optionsmenu/functions/fnc_updateSetting.sqf index 403a09cdb2..270d39f540 100644 --- a/addons/optionsmenu/functions/fnc_updateSetting.sqf +++ b/addons/optionsmenu/functions/fnc_updateSetting.sqf @@ -17,25 +17,33 @@ _changed = false; switch (_type) do { case (MENU_TAB_OPTIONS): { { - if (((_x select 0) == _name) && {!((_x select 4) isEqualTo _newValue)}) then { - _changed = true; - _x set [4, _newValue]; + if ((_x select 0) == _name) then { + + if ((_x select 1) == "BOOL") then { + _newValue = [false, true] select _newValue; + }; + + if !((_x select 7) isEqualTo _newValue) then { + _changed = true; + _x set [7, _newValue]; + } ; + }; } foreach GVAR(clientSideOptions); }; case (MENU_TAB_COLORS): { { - if (((_x select 0) == _name) && {!((_x select 3) isEqualTo _newValue)}) then { + if (((_x select 0) == _name) && {!((_x select 7) isEqualTo _newValue)}) then { _changed = true; - _x set [3, _newValue]; + _x set [7, _newValue]; }; } foreach GVAR(clientSideColors); }; }; if (_changed) then { + profileNamespace setvariable [_name, _newValue]; missionNameSpace setVariable [_name, _newValue]; - [_type, _name] call FUNC(saveToProfile); ["SettingChanged", [_name, _newValue]] call EFUNC(common,localEvent); TRACE_2("Variable Updated",_name,_newValue); }; From 857b45453a126f045fc01babeb8c207a51ba3371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 01:03:26 -0300 Subject: [PATCH 10/22] ACE_Settings: fix option to reset user setable settings to default --- addons/common/functions/fnc_getSettingData.sqf | 1 + addons/common/functions/fnc_setSettingFromConfig.sqf | 6 ++++-- addons/optionsmenu/functions/fnc_resetSettings.sqf | 4 ++-- .../functions/fnc_settingsMenuUpdateKeyView.sqf | 4 ++-- .../functions/fnc_settingsMenuUpdateList.sqf | 6 +++--- addons/optionsmenu/functions/fnc_updateSetting.sqf | 10 +++++----- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/addons/common/functions/fnc_getSettingData.sqf b/addons/common/functions/fnc_getSettingData.sqf index f8572c5f42..5b0c1c96ea 100644 --- a/addons/common/functions/fnc_getSettingData.sqf +++ b/addons/common/functions/fnc_getSettingData.sqf @@ -14,6 +14,7 @@ * 4: _localizedDescription * 5: _possibleValues * 6: _isForced + * 7: _defaultValue * * Public: No */ diff --git a/addons/common/functions/fnc_setSettingFromConfig.sqf b/addons/common/functions/fnc_setSettingFromConfig.sqf index a6b46f45c4..f87249786f 100644 --- a/addons/common/functions/fnc_setSettingFromConfig.sqf +++ b/addons/common/functions/fnc_setSettingFromConfig.sqf @@ -61,7 +61,8 @@ if (isNil _name) then { _localizedName, _localizedDescription, _possibleValues, - _isForced + _isForced, + _defaultValue ];*/ _settingData = [ _name, @@ -70,7 +71,8 @@ if (isNil _name) then { getText (_optionEntry >> "displayName"), getText (_optionEntry >> "description"), getArray (_optionEntry >> "values"), - getNumber (_optionEntry >> "force") > 0 + getNumber (_optionEntry >> "force") > 0, + _value ]; GVAR(settings) pushBack _settingData; diff --git a/addons/optionsmenu/functions/fnc_resetSettings.sqf b/addons/optionsmenu/functions/fnc_resetSettings.sqf index bdc5c7662a..dd4b951ef5 100644 --- a/addons/optionsmenu/functions/fnc_resetSettings.sqf +++ b/addons/optionsmenu/functions/fnc_resetSettings.sqf @@ -13,13 +13,13 @@ private ["_name", "_default", "_lastSelected"]; { _name = _x select 0; - _default = _x select 5; + _default = _x select 7; [MENU_TAB_OPTIONS, _name, _default] call FUNC(updateSetting); } forEach GVAR(clientSideOptions); { _name = _x select 0; - _default = _x select 4; + _default = _x select 7; [MENU_TAB_COLORS, _name, _default] call FUNC(updateSetting); } forEach GVAR(clientSideColors); diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf index 23b9ed9523..c271ecd176 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf @@ -44,7 +44,7 @@ if (count _collection > 0) then { switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { _possibleValues = _setting select 5; - _settingsValue = _setting select 7; + _settingsValue = _setting select 8; // Created disable/enable options for bools if ((_setting select 1) == "BOOL") then { @@ -59,7 +59,7 @@ if (count _collection > 0) then { (_settingsMenu displayCtrl 400) lbSetCurSel _settingsValue; }; case (MENU_TAB_COLORS): { - _currentColor = _setting select 7; + _currentColor = _setting select 8; { sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))]; } forEach [410, 411, 412, 413]; diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf index 78b5113203..73a6d3de3b 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf @@ -23,7 +23,7 @@ case (MENU_TAB_OPTIONS): { { _ctrlList lbadd (_x select 3); - _settingsValue = _x select 7; + _settingsValue = _x select 8; // Created disable/enable options for bools _settingsText = if ((_x select 1) == "BOOL") then { @@ -37,14 +37,14 @@ case (MENU_TAB_OPTIONS): { }; case (MENU_TAB_COLORS): { { - _color = +(_x select 7); + _color = +(_x select 8); { _color set [_forEachIndex, ((round (_x * 100))/100)]; } forEach _color; _settingsColor = str _color; _ctrlList lbadd (_x select 3); _ctrlList lbadd (_settingsColor); - _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 7)]; + _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 8)]; }foreach GVAR(clientSideColors); }; }; diff --git a/addons/optionsmenu/functions/fnc_updateSetting.sqf b/addons/optionsmenu/functions/fnc_updateSetting.sqf index 270d39f540..4691ff8e67 100644 --- a/addons/optionsmenu/functions/fnc_updateSetting.sqf +++ b/addons/optionsmenu/functions/fnc_updateSetting.sqf @@ -23,9 +23,9 @@ case (MENU_TAB_OPTIONS): { _newValue = [false, true] select _newValue; }; - if !((_x select 7) isEqualTo _newValue) then { + if !((_x select 8) isEqualTo _newValue) then { _changed = true; - _x set [7, _newValue]; + _x set [8, _newValue]; } ; }; @@ -33,16 +33,16 @@ case (MENU_TAB_OPTIONS): { }; case (MENU_TAB_COLORS): { { - if (((_x select 0) == _name) && {!((_x select 7) isEqualTo _newValue)}) then { + if (((_x select 0) == _name) && {!((_x select 8) isEqualTo _newValue)}) then { _changed = true; - _x set [7, _newValue]; + _x set [8, _newValue]; }; } foreach GVAR(clientSideColors); }; }; if (_changed) then { - profileNamespace setvariable [_name, _newValue]; + profileNamespace setVariable [_name, _newValue]; missionNameSpace setVariable [_name, _newValue]; ["SettingChanged", [_name, _newValue]] call EFUNC(common,localEvent); TRACE_2("Variable Updated",_name,_newValue); From 2c0d2013d47e9716bd02be857190b76519af56d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 01:45:04 -0300 Subject: [PATCH 11/22] ACE_Settings: Added a function to change settings on runtime (e.g. for modules) --- addons/common/XEH_postInit.sqf | 14 ++++++ addons/common/functions/fnc_setSetting.sqf | 46 +++++++++++++------ .../functions/fnc_setSettingFromConfig.sqf | 4 +- .../functions/fnc_updateSetting.sqf | 4 +- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 70826b7f11..5abdfbc597 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -4,6 +4,20 @@ // Load settings from profile call FUNC(loadSettingsFromProfile); +// Listens for global "SettingChanged" events, to update the force status locally +["SettingChanged", { + + PARAMS_2(_name,_value); + if !(count _this > 2) exitWith {}; + + _force = _this select 2; + if (_force) then { + _settingData = [_name] call FUNC(getSettingData); + if (isNull _settingData) exitWith {}; + _settingData set [6,_force]; + }; +}] call FUNC(addEventhandler); + // hack to get PFH to work in briefing [QGVAR(onBriefingPFH), "onEachFrame", { if (time > 0) exitWith { diff --git a/addons/common/functions/fnc_setSetting.sqf b/addons/common/functions/fnc_setSetting.sqf index 5a570d618a..3fd273adca 100644 --- a/addons/common/functions/fnc_setSetting.sqf +++ b/addons/common/functions/fnc_setSetting.sqf @@ -1,11 +1,14 @@ /* * Author: CAA-Picard - * Set a setting if it was not previosuly forced. Force if neccesary. + * Change the value of an existing setting if it was not previously forced. Force if neccesary. + * If executed on clients it has local effect. + * If executed on server it can have global effect if the last parameter is set to true. * * Arguments: * 0: Setting name (String) * 1: Value (Any) * 2: Force it? (Bool) (Optional) + * 3: Broadcast the change to all clients (Bool) (Optional) * * Return Value: * None @@ -16,25 +19,40 @@ EXPLODE_2_PVT(_this,_name,_value); -if !(isServer) exitWith {}; - private ["force"]; _force = false; if (count _this > 2) then { _force = _this select 2; }; -// Check if it's already forced and quit -if (missionNamespace getVariable [format ["%1_forced", _name], false]) exitWith {}; +_settingData = [_name] call FUNC(getSettingData); -// Check if the variable is already defined -if (isNil _name) then { - // Add the variable to a list on the server - GVAR(settingsList) pushBack _name; -}; +// Exit if the setting does not exist +if (isNull _settingData) exitWith {}; -// Update the variable and publish it +// Exit if the setting is already forced +if (_settingData select 6) exitWith {}; + +// Exit if the type is not right +if (typeName _value != typeName (missionNamespace getVariable _name)) exitWith {}; + +// Force it if it was required +_settingData set [6, _force]; + +// Exit if the value didn't change +if (_value isEqualTo (missionNamespace getVariable _name)) exitWith {}; + +// Update the variable +TRACE_2("Variable Updated",_name,_value); missionNamespace setVariable [_name, _value]; -publicVariable _name; -missionNamespace setVariable [format ["%1_forced", _name], _force]; -publicVariable format ["%1_forced", _name]; + +if (isServer && {count _this > 3} && {_this select 3}) then { + // Publicize the new value + publicVariable _name; + + // Raise event globally, this publicizes eventual changes in _force status so clients can update it locally + ["SettingChanged", [_name, _value, _force]] call FUNC(globalEvent); +} else { + // Raise event locally + ["SettingChanged", [_name, _value, _force]] call FUNC(localEvent); +}; diff --git a/addons/common/functions/fnc_setSettingFromConfig.sqf b/addons/common/functions/fnc_setSettingFromConfig.sqf index f87249786f..6054942485 100644 --- a/addons/common/functions/fnc_setSettingFromConfig.sqf +++ b/addons/common/functions/fnc_setSettingFromConfig.sqf @@ -49,7 +49,7 @@ if (isNil _name) then { // Read entry and cast it to the correct type _value = [_optionEntry, _typeName] call _fnc_getValueWithType; - // Init the variable and publish it + // Init the variable missionNamespace setVariable [_name, _value]; // Add the setting to a list on the server @@ -92,7 +92,7 @@ if (isNil _name) then { // Read entry and cast it to the correct type _value = [_optionEntry, _typeName] call _fnc_getValueWithType; - // Update the variable and publish it + // Update the variable missionNamespace setVariable [_name, _value]; // Force the setting if requested diff --git a/addons/optionsmenu/functions/fnc_updateSetting.sqf b/addons/optionsmenu/functions/fnc_updateSetting.sqf index 4691ff8e67..e4a9917f25 100644 --- a/addons/optionsmenu/functions/fnc_updateSetting.sqf +++ b/addons/optionsmenu/functions/fnc_updateSetting.sqf @@ -43,7 +43,5 @@ case (MENU_TAB_COLORS): { if (_changed) then { profileNamespace setVariable [_name, _newValue]; - missionNameSpace setVariable [_name, _newValue]; - ["SettingChanged", [_name, _newValue]] call EFUNC(common,localEvent); - TRACE_2("Variable Updated",_name,_newValue); + [_name, _newValue] call EFUNC(common,setSetting); }; From 658f30b9a2f28b871216754f3bdffe2337b730b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 02:37:13 -0300 Subject: [PATCH 12/22] ACE_Settings: various fixes --- addons/common/XEH_postInit.sqf | 2 +- addons/common/functions/fnc_getSettingData.sqf | 3 ++- addons/common/functions/fnc_setSetting.sqf | 10 ++++++---- .../optionsmenu/functions/fnc_onSettingsMenuOpen.sqf | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 5abdfbc597..a645d48293 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -13,7 +13,7 @@ call FUNC(loadSettingsFromProfile); _force = _this select 2; if (_force) then { _settingData = [_name] call FUNC(getSettingData); - if (isNull _settingData) exitWith {}; + if (count _settingData == 0) exitWith {}; _settingData set [6,_force]; }; }] call FUNC(addEventhandler); diff --git a/addons/common/functions/fnc_getSettingData.sqf b/addons/common/functions/fnc_getSettingData.sqf index 5b0c1c96ea..3dd2582860 100644 --- a/addons/common/functions/fnc_getSettingData.sqf +++ b/addons/common/functions/fnc_getSettingData.sqf @@ -22,7 +22,8 @@ EXPLODE_1_PVT(_this,_name); -_value = objNull; +private ["_value"]; +_value = []; { if ((_x select 0) == _name) exitWith {_value = _x}; } forEach GVAR(settings); diff --git a/addons/common/functions/fnc_setSetting.sqf b/addons/common/functions/fnc_setSetting.sqf index 3fd273adca..8c9e6853a9 100644 --- a/addons/common/functions/fnc_setSetting.sqf +++ b/addons/common/functions/fnc_setSetting.sqf @@ -17,9 +17,11 @@ */ #include "script_component.hpp" -EXPLODE_2_PVT(_this,_name,_value); +private ["_name","_value"]; +_name = _this select 0; +_value = _this select 1; -private ["force"]; +private ["_force"]; _force = false; if (count _this > 2) then { _force = _this select 2; @@ -28,13 +30,13 @@ if (count _this > 2) then { _settingData = [_name] call FUNC(getSettingData); // Exit if the setting does not exist -if (isNull _settingData) exitWith {}; +if (count _settingData == 0) exitWith {}; // Exit if the setting is already forced if (_settingData select 6) exitWith {}; // Exit if the type is not right -if (typeName _value != typeName (missionNamespace getVariable _name)) exitWith {}; +if ((typeName _value) != typeName (missionNamespace getVariable _name)) exitWith {}; // Force it if it was required _settingData set [6, _force]; diff --git a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf index d0b104135d..e3137f8ca9 100644 --- a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf @@ -13,8 +13,8 @@ GVAR(clientSideOptions) = []; GVAR(clientSideColors) = []; { - // If the setting is user setable - if (_x select 2) then { + // If the setting is user setable and not forced + if ((_x select 2) && !(_x select 6)) then { // Append the current value to the setting metadata _setting = + _x; _setting pushBack (missionNamespace getVariable (_x select 0)); From 051ad008060636c8b135df975445ba29b59d1d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 02:37:38 -0300 Subject: [PATCH 13/22] ACE_Settings: added function to add settings at runtime --- addons/common/XEH_preInit.sqf | 1 + addons/common/functions/fnc_addSetting.sqf | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 addons/common/functions/fnc_addSetting.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 1b724625ab..a967c5f222 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -11,6 +11,7 @@ PREP(addCustomEventHandler); PREP(addLineToDebugDraw); PREP(addMapMarkerCreatedEventHandler); PREP(addScrollWheelEventHandler); +PREP(addSetting); PREP(adminKick); PREP(ambientBrightness); PREP(applyForceWalkStatus); diff --git a/addons/common/functions/fnc_addSetting.sqf b/addons/common/functions/fnc_addSetting.sqf new file mode 100644 index 0000000000..866b7fb35b --- /dev/null +++ b/addons/common/functions/fnc_addSetting.sqf @@ -0,0 +1,40 @@ +/* + * Author: CAA-Picard + * Adds a new setting at runtime, with all it's metadata. + * If has only local effects. + * + * Arguments: + * 0: _name (String) + * 1: _typeName (String) + * 2: _isClientSetable (Bool) + * 3: _localizedName (String) + * 4: _localizedDescription (String) + * 5: _possibleValues (Array) + * 6: _isForced (Bool) + * 7: _defaultValue (Any) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_8_PVT(_this,_name,_typeName,_isClientSetable,_localizedName,_localizedDescription,_possibleValues,_isForced,_value); + +_settingData = [_name] call FUNC(getSettingData); + +// Exit if the setting already exists +if (count _settingData > 0) exitWith {}; + +// Update the variable +TRACE_2("Setting added",_name,_value); + +// Init the variable +missionNamespace setVariable [_name, _value]; + +// Add the setting data +GVAR(settings) pushBack _this; + +// Raise event locally +["SettingChanged", [_name, _value]] call FUNC(localEvent); From 66045b8d5198fe0d9eb854bfeab68802c0fa6f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 02:51:41 -0300 Subject: [PATCH 14/22] ACE_Settings: setSettings tab to space, casting --- addons/common/functions/fnc_setSetting.sqf | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/addons/common/functions/fnc_setSetting.sqf b/addons/common/functions/fnc_setSetting.sqf index 8c9e6853a9..ec83cd8c31 100644 --- a/addons/common/functions/fnc_setSetting.sqf +++ b/addons/common/functions/fnc_setSetting.sqf @@ -35,8 +35,18 @@ if (count _settingData == 0) exitWith {}; // Exit if the setting is already forced if (_settingData select 6) exitWith {}; -// Exit if the type is not right -if ((typeName _value) != typeName (missionNamespace getVariable _name)) exitWith {}; +// If the type is not equal, try to cast it +if ((typeName _value) != (_settingData select 1)) then { + _failed = True; + if ((_settingData select 1) == "BOOL" and (typeName _value) == "SCALAR") exitWith { + _value = _value > 0; + _failed = false; + }; + if ((_settingData select 1) == "COLOR" and (typeName _value) == "ARRAY") exitWith { + _failed = false; + }; +}; +if (_failed) exitWith {}; // Force it if it was required _settingData set [6, _force]; @@ -49,12 +59,12 @@ TRACE_2("Variable Updated",_name,_value); missionNamespace setVariable [_name, _value]; if (isServer && {count _this > 3} && {_this select 3}) then { - // Publicize the new value - publicVariable _name; + // Publicize the new value + publicVariable _name; - // Raise event globally, this publicizes eventual changes in _force status so clients can update it locally - ["SettingChanged", [_name, _value, _force]] call FUNC(globalEvent); + // Raise event globally, this publicizes eventual changes in _force status so clients can update it locally + ["SettingChanged", [_name, _value, _force]] call FUNC(globalEvent); } else { - // Raise event locally - ["SettingChanged", [_name, _value, _force]] call FUNC(localEvent); + // Raise event locally + ["SettingChanged", [_name, _value, _force]] call FUNC(localEvent); }; From 92d21af8c602348e397816d292d8daa5311bda5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 02:52:07 -0300 Subject: [PATCH 15/22] ACE_Settings: function for updating settings from modules --- addons/common/XEH_preInit.sqf | 3 +- .../fnc_readBooleanParameterFromModule.sqf | 28 --------------- .../fnc_readNumericParameterFromModule.sqf | 34 ------------------- .../functions/fnc_readSettingFromModule.sqf | 27 +++++++++++++++ 4 files changed, 28 insertions(+), 64 deletions(-) delete mode 100644 addons/common/functions/fnc_readBooleanParameterFromModule.sqf delete mode 100644 addons/common/functions/fnc_readNumericParameterFromModule.sqf create mode 100644 addons/common/functions/fnc_readSettingFromModule.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index a967c5f222..b2f5ef209d 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -100,8 +100,7 @@ PREP(player); PREP(playerSide); PREP(progressBar); PREP(queueAnimation); -PREP(readBooleanParameterFromModule); -PREP(readNumericParameterFromModule); +PREP(readSettingFromModule); PREP(removeActionEventHandler); PREP(removeActionMenuEventHandler); PREP(removeCameraEventHandler); diff --git a/addons/common/functions/fnc_readBooleanParameterFromModule.sqf b/addons/common/functions/fnc_readBooleanParameterFromModule.sqf deleted file mode 100644 index 9ee2faa001..0000000000 --- a/addons/common/functions/fnc_readBooleanParameterFromModule.sqf +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Author: CAA-Picard - * - * Reads a boolean value from a module, sets de ACE_Parameter. Logs if parameters are missing in the module. - * - * Arguments: - * 0: Module (Object) - * 1: ACE_Parameter name (string) - * 2: Module parameter name (string) - * - * Return Value: - * None - */ -#include "script_component.hpp" - - private ["_logic", "_parameterName", "_moduleParameterName"]; - -_logic = _this select 0; -_parameterName = _this select 1; -_moduleParameterName = _this select 2; - -// Check if the parameter is defined in the module -if (isNil {_logic getVariable _moduleParameterName}) exitWith { - diag_log text format["[ACE]: Warning in %1 module: %2 parameter is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleParameterName]; -}; - -// Set the parameter -[_parameterName , if (_logic getVariable _moduleParameterName) then {1} else {0}] call FUNC(setParameter); diff --git a/addons/common/functions/fnc_readNumericParameterFromModule.sqf b/addons/common/functions/fnc_readNumericParameterFromModule.sqf deleted file mode 100644 index a9c35f5b46..0000000000 --- a/addons/common/functions/fnc_readNumericParameterFromModule.sqf +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Author: CAA-Picard - * - * Reads a numeric value from a module, sets de ACE_Parameter. Logs if parameters are missing in the module. - * - * Arguments: - * 0: Module (Object) - * 1: ACE_Parameter name (string) - * 2: Module parameter name (string) - * - * Return Value: - * None - */ -#include "script_component.hpp" - - private ["_logic", "_parameterName", "_moduleParameterName", "_value"]; - -_logic = _this select 0; -_parameterName = _this select 1; -_moduleParameterName = _this select 2; - -// Check if the parameter is defined in the module -if (isNil {_logic getVariable _moduleParameterName}) exitWith { - diag_log text format["[ACE]: Warning in %1 module: %2 parameter is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleParameterName] -}; - -// Check if the value is defined as string for backward compatibility -_value = _logic getVariable _moduleParameterName; -if (typeName _value == "STRING") then { - _value = parseNumber _value; -}; - -// Set the parameter -[_parameterName, _value] call FUNC(setParameter); diff --git a/addons/common/functions/fnc_readSettingFromModule.sqf b/addons/common/functions/fnc_readSettingFromModule.sqf new file mode 100644 index 0000000000..0f3ab447b1 --- /dev/null +++ b/addons/common/functions/fnc_readSettingFromModule.sqf @@ -0,0 +1,27 @@ +/* + * Author: CAA-Picard + * + * Reads a setting value from a module, set it and force it. Logs if the setting is missing from the module. + * Must be called on the server, effect is global. + * + * Arguments: + * 0: Module (Object) + * 1: ACE_Parameter name (string) + * 2: Module parameter name (string) + * + * Return Value: + * None + */ +#include "script_component.hpp" + +if !(isServer) exitWith {}; + +EXPLODE_3_PVT(_this,_logic,_settingName,_moduleVariable); + +// Check if the parameter is defined in the module +if (isNil {_logic getVariable _moduleVariable}) exitWith { + diag_log text format["[ACE]: Warning in %1 module: %2 setting is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleVariable]; +}; + +// Set the setting globally and force it +[_settingName, _logic getVariable _moduleVariable, true, true] call FUNC(setSetting); From 74d0ae95ff45c6ac672390df26448e455348bb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 02:53:02 -0300 Subject: [PATCH 16/22] Change ACE_Settings from modules --- addons/explosives/functions/fnc_module.sqf | 4 ++-- .../functions/fnc_moduleInteraction.sqf | 2 +- .../functions/fnc_blueForceTrackingModule.sqf | 4 ++-- .../functions/fnc_moduleBasicRevive.sqf | 6 ++--- .../nametags/functions/fnc_moduleNameTags.sqf | 6 ++--- addons/respawn/functions/fnc_module.sqf | 12 +++++----- addons/switchunits/functions/fnc_module.sqf | 22 +++++++++---------- .../vehiclelock/functions/fnc_moduleInit.sqf | 2 +- .../functions/fnc_initalizeModule.sqf | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/addons/explosives/functions/fnc_module.sqf b/addons/explosives/functions/fnc_module.sqf index 415b537266..4784b7684e 100644 --- a/addons/explosives/functions/fnc_module.sqf +++ b/addons/explosives/functions/fnc_module.sqf @@ -22,7 +22,7 @@ _activated = _this select 2; if !(_activated) exitWith {}; -[_logic, QGVAR(RequireSpecialist), "RequireSpecialist" ] call EFUNC(Common,readBooleanParameterFromModule); -[_logic, QGVAR(PunishNonSpecialists), "PunishNonSpecialists" ] call EFUNC(Common,readBooleanParameterFromModule); +[_logic, QGVAR(RequireSpecialist), "RequireSpecialist" ] call EFUNC(Common,readSettingFromModule); +[_logic, QGVAR(PunishNonSpecialists), "PunishNonSpecialists" ] call EFUNC(Common,readSettingFromModule); diag_log text "[ACE]: Explosive Module Initialized."; diff --git a/addons/interaction/functions/fnc_moduleInteraction.sqf b/addons/interaction/functions/fnc_moduleInteraction.sqf index 78fd6e2acc..37b7bacba5 100644 --- a/addons/interaction/functions/fnc_moduleInteraction.sqf +++ b/addons/interaction/functions/fnc_moduleInteraction.sqf @@ -16,6 +16,6 @@ _activated = _this select 2; if !(_activated) exitWith {}; -[_logic, QGVAR(EnableTeamManagement), "EnableTeamManagement"] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(EnableTeamManagement), "EnableTeamManagement"] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: Interaction Module Initialized."; diff --git a/addons/map/functions/fnc_blueForceTrackingModule.sqf b/addons/map/functions/fnc_blueForceTrackingModule.sqf index 3951473026..cecfd348d2 100644 --- a/addons/map/functions/fnc_blueForceTrackingModule.sqf +++ b/addons/map/functions/fnc_blueForceTrackingModule.sqf @@ -21,8 +21,8 @@ _activated = _this select 2; if !(_activated) exitWith {}; GVAR(BFT_Enabled) = true; -[_logic, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: Blue Force Tracking Module initialized."; TRACE_2("[ACE]: Blue Force Tracking Module initialized.",GVAR(BFT_Interval), GVAR(BFT_HideAiGroups)); diff --git a/addons/medical/functions/fnc_moduleBasicRevive.sqf b/addons/medical/functions/fnc_moduleBasicRevive.sqf index 6d8bfa2e6c..b02d873313 100644 --- a/addons/medical/functions/fnc_moduleBasicRevive.sqf +++ b/addons/medical/functions/fnc_moduleBasicRevive.sqf @@ -15,9 +15,9 @@ _logic = _this select 0; GVAR(Module) = true; -[_logic, QGVAR(ENABLE_REVIVE_F), "enableFor" ] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(REVIVE_TIMER_MAX_F), "timer" ] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(REVIVE_NUMBER_MAX_F), "amountOf" ] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(ENABLE_REVIVE_F), "enableFor" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(REVIVE_TIMER_MAX_F), "timer" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(REVIVE_NUMBER_MAX_F), "amountOf" ] call EFUNC(common,readSettingFromModule); [ {(((_this select 0) getvariable[QGVAR(ENABLE_REVIVE_SETDEAD_F),0]) > 0)} diff --git a/addons/nametags/functions/fnc_moduleNameTags.sqf b/addons/nametags/functions/fnc_moduleNameTags.sqf index b701a2db8c..83087fc4ff 100644 --- a/addons/nametags/functions/fnc_moduleNameTags.sqf +++ b/addons/nametags/functions/fnc_moduleNameTags.sqf @@ -22,8 +22,8 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(CrewInfoVisibility), "Visibility" ] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(CrewInfoVisibility), "Visibility" ] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: NameTags Module Initialized."; diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 0a996d0acc..5ba52fd40e 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -1,17 +1,17 @@ /* Name: ACE_Respawn_fnc_module - + Author(s): KoffeinFlummi, bux578, CAA-Picard, commy2 - + Description: initializes the respawn module - + Parameters: 0: OBJECT - logic 1: ARRAY - synced units 2: BOOLEAN - activated - + Returns: VOID */ @@ -27,8 +27,8 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readSettingFromModule); if (isServer) then { if (GVAR(RemoveDeadBodiesDisconnected)) then { diff --git a/addons/switchunits/functions/fnc_module.sqf b/addons/switchunits/functions/fnc_module.sqf index c4f5c378c2..9a50e5c435 100644 --- a/addons/switchunits/functions/fnc_module.sqf +++ b/addons/switchunits/functions/fnc_module.sqf @@ -1,17 +1,17 @@ /* Name: ACE_SwitchUnits_fnc_module - + Author(s): bux578 - + Description: Initializes the SwitchUnits module - + Parameters: 0: OBJECT - module logic 1: ARRAY - list of affected units 2: BOOLEAN - isActivated - + Returns: BOOLEAN (Good practice to include one) */ @@ -29,12 +29,12 @@ GVAR(Module) = true; [QGVAR(EnableSwitchUnits), true] call EFUNC(common,setParameter); -[_logic, QGVAR(SwitchToWest), "SwitchToWest"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SwitchToEast), "SwitchToEast"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SwitchToIndependent), "SwitchToIndependent"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SwitchToCivilian), "SwitchToCivilian"] call EFUNC(common,readBooleanParameterFromModule); - -[_logic, QGVAR(EnableSafeZone), "EnableSafeZone"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SafeZoneRadius), "SafeZoneRadius"] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(SwitchToWest), "SwitchToWest"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SwitchToEast), "SwitchToEast"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SwitchToIndependent), "SwitchToIndependent"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SwitchToCivilian), "SwitchToCivilian"] call EFUNC(common,readSettingFromModule); + +[_logic, QGVAR(EnableSafeZone), "EnableSafeZone"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SafeZoneRadius), "SafeZoneRadius"] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: SwitchUnits Module Initialized."; diff --git a/addons/vehiclelock/functions/fnc_moduleInit.sqf b/addons/vehiclelock/functions/fnc_moduleInit.sqf index b0ae230724..a344185ab0 100644 --- a/addons/vehiclelock/functions/fnc_moduleInit.sqf +++ b/addons/vehiclelock/functions/fnc_moduleInit.sqf @@ -29,7 +29,7 @@ _sideKeysAssignment = _logic getVariable["SideKeysAssignment", 0]; _setLockState = _logic getVariable["SetLockState", 0]; if (isServer) then { - [_logic, QGVAR(DefaultLockpickStrength), "LockpickStrength"] call EFUNC(common,readNumericParameterFromModule); + [_logic, QGVAR(DefaultLockpickStrength), "LockpickStrength"] call EFUNC(common,readSettingFromModule); }; //Run at mission start (anyone besides JIPs) diff --git a/addons/winddeflection/functions/fnc_initalizeModule.sqf b/addons/winddeflection/functions/fnc_initalizeModule.sqf index d0b9937a58..8bd2a2f1bc 100644 --- a/addons/winddeflection/functions/fnc_initalizeModule.sqf +++ b/addons/winddeflection/functions/fnc_initalizeModule.sqf @@ -15,5 +15,5 @@ if (!hasInterface) exitwith {}; // No need for this module on HC or dedicated se private ["_logic"]; _logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; if (!isNull _logic) then { - [_logic, QGVAR(EnableForAI), "forAI" ] call EFUNC(common,readBooleanParameterFromModule); + [_logic, QGVAR(EnableForAI), "forAI" ] call EFUNC(common,readSettingFromModule); }; \ No newline at end of file From b119d5246b502746f63ca782b19feab29439c8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 15:46:33 -0300 Subject: [PATCH 17/22] fix in setsettings --- addons/common/functions/fnc_setSetting.sqf | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/common/functions/fnc_setSetting.sqf b/addons/common/functions/fnc_setSetting.sqf index ec83cd8c31..5b6f7945b5 100644 --- a/addons/common/functions/fnc_setSetting.sqf +++ b/addons/common/functions/fnc_setSetting.sqf @@ -36,13 +36,22 @@ if (count _settingData == 0) exitWith {}; if (_settingData select 6) exitWith {}; // If the type is not equal, try to cast it +_failed = false; if ((typeName _value) != (_settingData select 1)) then { - _failed = True; - if ((_settingData select 1) == "BOOL" and (typeName _value) == "SCALAR") exitWith { - _value = _value > 0; - _failed = false; + _failed = true; + diag_log (typeName _value); + if ((_settingData select 1) == "BOOL" and (typeName _value) == "SCALAR") then { + // If value is not 0 or 1 consider it invalid and don't set anything + if (_value == 0) then { + _value = false; + _failed = false; + }; + if (_value == 1) then { + _value = true; + _failed = false; + }; }; - if ((_settingData select 1) == "COLOR" and (typeName _value) == "ARRAY") exitWith { + if ((_settingData select 1) == "COLOR" and (typeName _value) == "ARRAY") then { _failed = false; }; }; From 146e87f02e0db3d8993c41b02f05dc204b418cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 15:47:17 -0300 Subject: [PATCH 18/22] nametags: slightly changed module options to use the new ACE_Settings --- addons/nametags/CfgVehicles.hpp | 50 ++++++++++--------- addons/nametags/config.cpp | 18 +++---- addons/nametags/functions/fnc_canShow.sqf | 15 ++---- .../nametags/functions/fnc_moduleNameTags.sqf | 2 +- addons/nametags/stringtable.xml | 7 +-- 5 files changed, 44 insertions(+), 48 deletions(-) diff --git a/addons/nametags/CfgVehicles.hpp b/addons/nametags/CfgVehicles.hpp index 444622f0ed..e3c4227834 100644 --- a/addons/nametags/CfgVehicles.hpp +++ b/addons/nametags/CfgVehicles.hpp @@ -15,40 +15,44 @@ class CfgVehicles { typeName = "NUMBER"; defaultValue = 5; }; - class ShowNamesForAI { + class showNamesForAI { displayName = "Show name tags for AI?"; - description = "Show the name and rank tags for friendly AI units? Default: No"; - typeName = "BOOL"; - class values { - class Yes { - name = "Yes"; - value = 1; - }; - class No { - default = 1; - name = "No"; - value = 0; - }; - }; - }; - class Visibility { - displayName = "Visibility of crew info"; - description = "Forces visibility of vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; - typeName = "INT"; + description = "Show the name and rank tags for friendly AI units? Default: Do not force"; + typeName = "NUMBER"; class values { class DoNotForce { default = 1; name = "Do Not Force"; + value = -1; + }; + class ForceHide { + name = "Force Hide"; + value = 0; + }; + class ForceShow { + name = "Force show"; + value = 1; + }; + }; + }; + class showVehicleCrewInfo { + displayName = "Show crew info?"; + description = "Show vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; + typeName = "NUMBER"; + class values { + class DoNotForce { + default = 1; + name = "Do Not Force"; + value = -1; + }; + class ForceHide { + name = "Force Hide"; value = 0; }; class ForceShow { name = "Force Show"; value = 1; }; - class ForceHide { - name = "Force Hide"; - value = -1; - }; }; }; }; diff --git a/addons/nametags/config.cpp b/addons/nametags/config.cpp index 58440192c0..aa55dd2aad 100644 --- a/addons/nametags/config.cpp +++ b/addons/nametags/config.cpp @@ -33,7 +33,13 @@ class ACE_Settings { value = 1; typeName = "BOOL"; isClientSetable = 1; - displayName = "$STR_ACE_CrewInfo_ShowVehicleCrewInfo"; + displayName = "$STR_ACE_NameTags_ShowVehicleCrewInfo"; + }; + class GVAR(showNamesForAI) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_NameTags_ShowNamesForAI"; }; class GVAR(PlayerNamesViewDistance) { @@ -46,16 +52,6 @@ class ACE_Settings { typeName = "SCALAR"; isClientSetable = 0; }; - class GVAR(CrewInfoVisibility) { - value = 0; - typeName = "BOOL"; - isClientSetable = 0; - }; - class GVAR(ShowNamesForAI) { - value = 0; - typeName = "BOOL"; - isClientSetable = 0; - }; }; #include diff --git a/addons/nametags/functions/fnc_canShow.sqf b/addons/nametags/functions/fnc_canShow.sqf index 8b61352def..0e187fee0f 100644 --- a/addons/nametags/functions/fnc_canShow.sqf +++ b/addons/nametags/functions/fnc_canShow.sqf @@ -1,12 +1,12 @@ /* Author: aeroson - + Description: Might be called several times a second - - Parameters: + + Parameters: None - + Returns: true if CrewInfo can be shown, false otherwise */ @@ -17,11 +17,6 @@ private["_player"]; _player = ACE_player; -// AGM_NameTags_ShowVehicleCrewInfo: -1 force NO, 0 doesnt care, 1 force YES - vehicle _player != _player && -{ - (GVAR(CrewInfoVisibility) == 1) || - (GVAR(CrewInfoVisibility) != -1 && GVAR(showVehicleCrewInfo)) -} && +{GVAR(ShowCrewInfo)} && {!(vehicle _player isKindOf "ParachuteBase")}; diff --git a/addons/nametags/functions/fnc_moduleNameTags.sqf b/addons/nametags/functions/fnc_moduleNameTags.sqf index 83087fc4ff..24b30e5d6b 100644 --- a/addons/nametags/functions/fnc_moduleNameTags.sqf +++ b/addons/nametags/functions/fnc_moduleNameTags.sqf @@ -24,6 +24,6 @@ GVAR(Module) = true; [_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(CrewInfoVisibility), "Visibility" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(showVehicleCrewInfo), "showVehicleCrewInfo" ] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: NameTags Module Initialized."; diff --git a/addons/nametags/stringtable.xml b/addons/nametags/stringtable.xml index 7d085b9d44..9cd99adaef 100644 --- a/addons/nametags/stringtable.xml +++ b/addons/nametags/stringtable.xml @@ -58,9 +58,7 @@ Játékosok rendfokozatának mutatása (névcímke szükséges) Показать звания игроков (требует имен игроков) - - - + Show vehicle crew info Zeige Fahrzeugbesatzung Mostrar tripulantes @@ -68,5 +66,8 @@ Zobrazit info o posádce vozidla Показать экипаж + + Show name tags for AI units + From 5f44af2341442b8b0aa85574bf2ebf83042d5c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 16:47:23 -0300 Subject: [PATCH 19/22] Missing prep --- addons/common/XEH_preInit.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index b2f5ef209d..90a774ddfe 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -87,6 +87,7 @@ PREP(isInBuilding); PREP(isPlayer); PREP(isTurnedOut); PREP(letterToCode); +PREP(loadSettingsFromProfile); PREP(loadSettingsOnServer); PREP(map); PREP(moduleCheckPBOs); From e57a135750f455638350ea0336505e258d4020fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 16:49:40 -0300 Subject: [PATCH 20/22] Missing prep --- addons/common/XEH_preInit.sqf | 1 + addons/common/functions/fnc_loadSettingsFromProfile.sqf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index b2f5ef209d..90a774ddfe 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -87,6 +87,7 @@ PREP(isInBuilding); PREP(isPlayer); PREP(isTurnedOut); PREP(letterToCode); +PREP(loadSettingsFromProfile); PREP(loadSettingsOnServer); PREP(map); PREP(moduleCheckPBOs); diff --git a/addons/common/functions/fnc_loadSettingsFromProfile.sqf b/addons/common/functions/fnc_loadSettingsFromProfile.sqf index 9d077359ce..1e8e9001aa 100644 --- a/addons/common/functions/fnc_loadSettingsFromProfile.sqf +++ b/addons/common/functions/fnc_loadSettingsFromProfile.sqf @@ -25,7 +25,7 @@ if !(_isForced) then { _profileValue = profileNamespace getvariable _name; // If the setting is stored on the profile - if !(isNil _profileValue) then { + if !(isNil "_profileValue") then { // If the profile variable has the correct type if (typeName _profileValue == typeName (missionNamespace getvariable _name)) then { // Load the setting from the profile From d65a740b7ad85a45d5093981279008499925cb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Tue, 3 Feb 2015 17:47:25 -0300 Subject: [PATCH 21/22] WindDeflection using ace_settings --- addons/winddeflection/CfgEventHandlers.hpp | 6 --- addons/winddeflection/CfgVehicles.h | 43 ++++++++----------- addons/winddeflection/XEH_postInit.sqf | 15 ------- addons/winddeflection/config.cpp | 27 +++++++----- .../functions/fnc_initalizeModule.sqf | 2 +- 5 files changed, 36 insertions(+), 57 deletions(-) delete mode 100644 addons/winddeflection/XEH_postInit.sqf diff --git a/addons/winddeflection/CfgEventHandlers.hpp b/addons/winddeflection/CfgEventHandlers.hpp index 6cf7856ba5..4961d7dbc7 100644 --- a/addons/winddeflection/CfgEventHandlers.hpp +++ b/addons/winddeflection/CfgEventHandlers.hpp @@ -4,12 +4,6 @@ class Extended_PreInit_EventHandlers { }; }; -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE( call compile preprocessFileLineNumbers PATHTOF(XEH_postInit.sqf) ); - }; -}; - class Extended_Fired_Eventhandlers { class CaManBase { fired = QUOTE( call FUNC(handleFired) ); diff --git a/addons/winddeflection/CfgVehicles.h b/addons/winddeflection/CfgVehicles.h index fe0e31bda5..e84727b94e 100644 --- a/addons/winddeflection/CfgVehicles.h +++ b/addons/winddeflection/CfgVehicles.h @@ -1,27 +1,20 @@ class CfgVehicles { - - // TODO Stringtable usage - class Logic; - class Module_F: Logic { - class ArgumentsBaseUnits { - }; - }; - class GVAR(Module): Module_F { - scope = 2; - displayName = "Wind Deflection [ACE]"; - icon = QUOTE(PATHTOF(data\module_icon.paa)); - category = "ACE"; - function = FUNC(enableModule); - functionPriority = 1; - isGlobal = 1; - isTriggerActivated = 0; - class Arguments { - class forAI { - displayName = "Enable for AI"; - description = "Should the module be enabled for AI"; - typeName = "BOOL"; - defaultValue = 0; - }; - }; - }; + class Module_F; + class GVAR(Module): Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Wind Deflection"; + function = FUNC(enableModule); + scope = 2; + isGlobal = 1; + icon = QUOTE(PATHTOF(data\module_icon.paa)); + class Arguments { + class EnableForAI { + displayName = "Enable for AI"; + description = "Should the module be enabled for AI"; + typeName = "BOOL"; + defaultValue = 0; + }; + }; + }; }; diff --git a/addons/winddeflection/XEH_postInit.sqf b/addons/winddeflection/XEH_postInit.sqf deleted file mode 100644 index 9c3a4bc41f..0000000000 --- a/addons/winddeflection/XEH_postInit.sqf +++ /dev/null @@ -1,15 +0,0 @@ -/** - * XEH_postInit.sqf - * @Descr: N/A - * @Author: Glowbal - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ - -#include "script_component.hpp" - -if (isnil QGVAR(EnableForAI)) then { - GVAR(EnableForAI) = false; -}; diff --git a/addons/winddeflection/config.cpp b/addons/winddeflection/config.cpp index 6e1bdbc379..f71ef251cd 100644 --- a/addons/winddeflection/config.cpp +++ b/addons/winddeflection/config.cpp @@ -1,16 +1,16 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ACE_common", "ACE_weather"}; - versionDesc = "ACE Wind Deflection"; - version = VERSION; - author[] = {$STR_ACE_Core_ACETeam, "Glowbal", "Ruthberg"}; - authorUrl = "http://csemod.com"; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ACE_common", "ACE_weather"}; + versionDesc = "ACE Wind Deflection"; + version = VERSION; + author[] = {$STR_ACE_Core_ACETeam, "Glowbal", "Ruthberg"}; + authorUrl = "http://csemod.com"; + }; }; class CfgAddons { @@ -21,4 +21,11 @@ class CfgAddons { }; }; +class ACE_Settings { + class GVAR(EnableForAI) { + value = 0; + typeName = "BOOL"; + isClientSetable = 0; + }; +}; #include "CfgVehicles.h" \ No newline at end of file diff --git a/addons/winddeflection/functions/fnc_initalizeModule.sqf b/addons/winddeflection/functions/fnc_initalizeModule.sqf index 8bd2a2f1bc..2833ecc54c 100644 --- a/addons/winddeflection/functions/fnc_initalizeModule.sqf +++ b/addons/winddeflection/functions/fnc_initalizeModule.sqf @@ -15,5 +15,5 @@ if (!hasInterface) exitwith {}; // No need for this module on HC or dedicated se private ["_logic"]; _logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; if (!isNull _logic) then { - [_logic, QGVAR(EnableForAI), "forAI" ] call EFUNC(common,readSettingFromModule); + [_logic, QGVAR(EnableForAI), "EnableForAI" ] call EFUNC(common,readSettingFromModule); }; \ No newline at end of file From 1b9d0aa6357c246a00a984868c5ef2c0e49abaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Sun, 8 Feb 2015 18:29:49 -0300 Subject: [PATCH 22/22] ACE_Settings: do not load client settings on dedi servers or HC --- addons/common/XEH_postInit.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index a645d48293..0767e42737 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -2,7 +2,9 @@ #include "script_component.hpp" // Load settings from profile -call FUNC(loadSettingsFromProfile); +if (hasInterface) then { + call FUNC(loadSettingsFromProfile); +}; // Listens for global "SettingChanged" events, to update the force status locally ["SettingChanged", {