2018-09-17 19:19:29 +00:00
|
|
|
#define DEBUG_MODE_FULL
|
|
|
|
#include "script_component.hpp"
|
2015-11-07 02:46:06 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Read settins from paramsArray that have a ACE_setting = 1.
|
|
|
|
* Happens before modules but after all other configs (for force priority)
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [] call ace_common_fnc_readSettingsFromParamsArray
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
//paramsArray is a normal variable not a command
|
2015-11-30 16:27:09 +00:00
|
|
|
private _paramsArray = missionnamespace getVariable ["paramsArray", []];
|
2015-11-07 02:46:06 +00:00
|
|
|
|
|
|
|
TRACE_1("Reading missionConfigFile params",_paramsArray);
|
|
|
|
|
|
|
|
{
|
2015-11-17 20:02:20 +00:00
|
|
|
private _config = (missionConfigFile >> "params") select _forEachIndex;
|
2015-11-07 02:46:06 +00:00
|
|
|
if ((getNumber (_config >> "ACE_setting")) > 0) then {
|
2015-11-17 20:02:20 +00:00
|
|
|
private _settingName = configName _config;
|
|
|
|
private _settingValue = _x;
|
|
|
|
private _title = getText (_config >> "title");
|
2015-11-07 02:46:06 +00:00
|
|
|
|
2015-11-08 17:22:41 +00:00
|
|
|
TRACE_3("ace_setting",_title,_settingName,_settingValue);
|
2015-11-07 02:46:06 +00:00
|
|
|
|
|
|
|
// Check if the variable is already defined
|
|
|
|
if (isNil _settingName) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
ERROR_1("readSettingsFromParamsArray - param [%1] is not an ace_setting", _settingName);
|
2015-11-07 02:46:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The setting is not forced, so update the value
|
|
|
|
// Read entry and cast it to the correct type from the existing variable
|
2018-01-07 01:46:47 +00:00
|
|
|
(cba_settings_default getVariable [_settingName, []]) params ["", "", ["_settingType", ""]];
|
2015-11-17 20:02:20 +00:00
|
|
|
private _validValue = false;
|
2015-11-07 02:53:05 +00:00
|
|
|
switch (true) do {
|
2018-01-07 01:46:47 +00:00
|
|
|
case (_settingType == "LIST");
|
|
|
|
case (_settingType == "SCALAR"): {
|
|
|
|
_validValue = [_settingName, _settingValue] call CBA_settings_fnc_check;
|
2015-11-07 02:46:06 +00:00
|
|
|
};
|
2018-01-07 01:46:47 +00:00
|
|
|
case (_settingType == "CHECKBOX"): {
|
|
|
|
_settingValue = _settingValue > 0;
|
|
|
|
_validValue = [_settingName, _settingValue] call CBA_settings_fnc_check;
|
|
|
|
};
|
|
|
|
// Will not Handle ARRAY,COLOR,STRING??? (bool/scalar covers most important settings)
|
2015-11-07 02:46:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!_validValue) exitWith {
|
2018-01-07 01:46:47 +00:00
|
|
|
WARNING_3("readSettingsFromParamsArray - param [%1] type not valid [%2] - expected type [%3]", _settingName,_settingValue,_settingType);
|
2015-11-07 02:46:06 +00:00
|
|
|
};
|
|
|
|
|
2017-11-11 19:21:55 +00:00
|
|
|
if ([_settingName, "mission"] call CBA_settings_fnc_isForced) then {
|
|
|
|
WARNING_1("Setting [%1] - Already Forced",_settingName);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set the setting as a mission setting and force it
|
2018-01-07 01:46:47 +00:00
|
|
|
private _return = ["CBA_settings_setSettingMission", [_settingName, _settingValue, true]] call CBA_fnc_localEvent;
|
|
|
|
TRACE_3("setSettingMission from paramsArray",_settingName,_settingValue,_return);
|
2015-11-07 02:46:06 +00:00
|
|
|
};
|
2015-11-30 16:23:48 +00:00
|
|
|
} forEach _paramsArray;
|