Add param for settings that require restart (#6512)

This commit is contained in:
PabstMirror 2018-11-02 12:58:57 -05:00 committed by GitHub
parent 50d9fa4230
commit 0104030666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 46 additions and 22 deletions

View File

@ -4,7 +4,9 @@
[LSTRING(Enabled), LSTRING(Enabled_Description)], [LSTRING(Enabled), LSTRING(Enabled_Description)],
LSTRING(DisplayName), LSTRING(DisplayName),
true, true,
true true,
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_Settings_fnc_init; ] call CBA_Settings_fnc_init;
[ [

View File

@ -43,6 +43,7 @@ private _settings = configProperties [configFile >> "ACE_Settings", "(isClass _x
private _category = getText (_config >> "category"); private _category = getText (_config >> "category");
private _cbaIsGlobal = (!_isClientSettable) || _isForced; private _cbaIsGlobal = (!_isClientSettable) || _isForced;
private _warnIfChangedMidMission = _cbaIsGlobal && {(getNumber (_config >> "canBeChanged")) == 0};
if (_isForced) then {GVAR(cbaSettings_forcedSettings) pushBack (toLower _varName);}; if (_isForced) then {GVAR(cbaSettings_forcedSettings) pushBack (toLower _varName);};
// Basic handling of setting types CBA doesn't support: // Basic handling of setting types CBA doesn't support:
@ -117,10 +118,11 @@ private _settings = configProperties [configFile >> "ACE_Settings", "(isClass _x
_output pushBack format [" %1, // %2", _cbaValueInfo, _cbaValueInfoHint]; _output pushBack format [" %1, // %2", _cbaValueInfo, _cbaValueInfoHint];
_output pushBack format [" %1, // isGlobal", _cbaIsGlobal]; _output pushBack format [" %1, // isGlobal", _cbaIsGlobal];
if ((_varName select [0, 4]) == "ACE_") then { if ((_varName select [0, 4]) == "ACE_") then {
_output pushBack format [" {[QGVAR(%1), _this] call EFUNC(common,cbaSettings_settingChanged)}", _gvarName]; _output pushBack format [" {[QGVAR(%1), _this] call EFUNC(common,cbaSettings_settingChanged)},", _gvarName];
} else { } else {
_output pushBack format [" {[""%1"", _this] call ace_common_fnc_cbaSettings_settingChanged}", _varName]; _output pushBack format [" {[""%1"", _this] call ace_common_fnc_cbaSettings_settingChanged},", _varName];
}; };
_output pushBack format [" %1 // Needs mission restart", _warnIfChangedMidMission];
_output pushBack "] call CBA_settings_fnc_init;"; _output pushBack "] call CBA_settings_fnc_init;";
} forEach _settings; } forEach _settings;

View File

@ -32,6 +32,7 @@ private _isForced = (getNumber (_config >> "force")) > 0;
private _category = getText (_config >> "category"); private _category = getText (_config >> "category");
private _cbaIsGlobal = (!_isClientSettable) || _isForced; private _cbaIsGlobal = (!_isClientSettable) || _isForced;
private _warnIfChangedMidMission = _cbaIsGlobal && {(getNumber (_config >> "canBeChanged")) == 0};
if (_isForced) then {GVAR(cbaSettings_forcedSettings) pushBack (toLower _varName);}; if (_isForced) then {GVAR(cbaSettings_forcedSettings) pushBack (toLower _varName);};
// Basic handling of setting types CBA doesn't support: // Basic handling of setting types CBA doesn't support:
@ -97,7 +98,7 @@ private _code = compile format ['["%1", _this] call FUNC(cbaSettings_settingChan
TRACE_2("setting",_cbaSettingType,_cbaValueInfo); TRACE_2("setting",_cbaSettingType,_cbaValueInfo);
TRACE_4("",_isForced,_cbaIsGlobal,_category,_cbaValueInfo); TRACE_4("",_isForced,_cbaIsGlobal,_category,_cbaValueInfo);
private _return = [_varName, _cbaSettingType, [_localizedName, _localizedDescription], _category, _cbaValueInfo, _cbaIsGlobal, _code] call CBA_settings_fnc_init; private _return = [_varName, _cbaSettingType, [_localizedName, _localizedDescription], _category, _cbaValueInfo, _cbaIsGlobal, _code, _warnIfChangedMidMission] call CBA_settings_fnc_init;
TRACE_1("returned",_return); TRACE_1("returned",_return);
if ((isNil "_return") || {_return != 0}) then {ERROR_1("Setting [%1] - CBA Error",_varName);}; if ((isNil "_return") || {_return != 0}) then {ERROR_1("Setting [%1] - CBA Error",_varName);};
_return _return

View File

@ -23,10 +23,9 @@ TRACE_2("",_settingName,_newValue);
["ace_settingChanged", [_settingName, _newValue]] call CBA_fnc_localEvent; ["ace_settingChanged", [_settingName, _newValue]] call CBA_fnc_localEvent;
if (_canBeChanged) exitWith {}; if (!((toLower _settingName) in CBA_settings_needRestart)) exitWith {};
if (_canBeChanged) exitWith {WARNING_1("update cba setting [%1] to use correct Need Restart param",_settingName);};
if (!GVAR(settingsInitFinished)) exitWith {}; // Ignore changed event before CBA_settingsInitialized if (!GVAR(settingsInitFinished)) exitWith {}; // Ignore changed event before CBA_settingsInitialized
if (CBA_settings_default getVariable [_settingName, []] param [7, 0] == 0) exitWith {}; // Ignore if not a global setting
if ((getNumber (configFile >> "ACE_settings" >> _settingName >> "canBeChanged")) == 1) exitWith {}; // Ignore if flagged as ok to change
WARNING_1("Global setting [%1] changed mid-mission",_settingName); WARNING_1("Setting [%1] changed mid-mission",_settingName);
[QGVAR(displayTextStructured), [format ["Global setting %1 changed mid-mission. Mission restart may be required to prevent issues", _settingName], 4]] call CBA_fnc_localEvent; [QGVAR(displayTextStructured), [format ["Setting %1 changed mid-mission. Mission restart may be required to prevent issues", _settingName], 4]] call CBA_fnc_localEvent;

View File

@ -4,7 +4,9 @@
[localize LSTRING(MapIllumination_DisplayName), localize LSTRING(MapIllumination_Description)], [localize LSTRING(MapIllumination_DisplayName), localize LSTRING(MapIllumination_Description)],
format["ACE %1", localize LSTRING(Module_DisplayName)], format["ACE %1", localize LSTRING(Module_DisplayName)],
true, true,
true true,
{[QGVAR(mapIllumination), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
@ -13,7 +15,9 @@
[localize LSTRING(MapGlow_DisplayName), localize LSTRING(MapGlow_Description)], [localize LSTRING(MapGlow_DisplayName), localize LSTRING(MapGlow_Description)],
format["ACE %1", localize LSTRING(Module_DisplayName)], format["ACE %1", localize LSTRING(Module_DisplayName)],
true, true,
true true,
{[QGVAR(mapGlow), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
@ -49,7 +53,9 @@
[localize LSTRING(DefaultChannel_DisplayName), localize LSTRING(DefaultChannel_Description)], [localize LSTRING(DefaultChannel_DisplayName), localize LSTRING(DefaultChannel_Description)],
format["ACE %1", localize LSTRING(Module_DisplayName)], format["ACE %1", localize LSTRING(Module_DisplayName)],
[[-1, 0, 1, 2, 3, 4, 5], [ELSTRING(common,Disabled), "STR_channel_global", "STR_channel_side", "STR_channel_command", "STR_channel_group", "STR_channel_vehicle", "STR_channel_direct"], 0], [[-1, 0, 1, 2, 3, 4, 5], [ELSTRING(common,Disabled), "STR_channel_global", "STR_channel_side", "STR_channel_command", "STR_channel_group", "STR_channel_vehicle", "STR_channel_direct"], 0],
true true,
{[QGVAR(DefaultChannel), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
// Blue Force Tracking // Blue Force Tracking
@ -59,7 +65,9 @@
[localize LSTRING(BFT_Enabled_DisplayName), localize LSTRING(BFT_Enabled_Description)], [localize LSTRING(BFT_Enabled_DisplayName), localize LSTRING(BFT_Enabled_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)], [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
false, false,
true true,
{[QGVAR(BFT_Enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
@ -68,7 +76,9 @@
[localize LSTRING(BFT_Interval_DisplayName), localize LSTRING(BFT_Interval_Description)], [localize LSTRING(BFT_Interval_DisplayName), localize LSTRING(BFT_Interval_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)], [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
[0, 30, 1, 1], [0, 30, 1, 1],
true true,
{[QGVAR(BFT_Interval), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
@ -77,7 +87,9 @@
[localize LSTRING(BFT_ShowPlayerNames_DisplayName), localize LSTRING(BFT_ShowPlayerNames_Description)], [localize LSTRING(BFT_ShowPlayerNames_DisplayName), localize LSTRING(BFT_ShowPlayerNames_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)], [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
false, false,
true true,
{[QGVAR(BFT_ShowPlayerNames), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
@ -86,5 +98,7 @@
[localize LSTRING(BFT_HideAiGroups_DisplayName), localize LSTRING(BFT_HideAiGroups_Description)], [localize LSTRING(BFT_HideAiGroups_DisplayName), localize LSTRING(BFT_HideAiGroups_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)], [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
false, false,
true true,
{[QGVAR(BFT_HideAiGroups), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;

View File

@ -6,7 +6,8 @@
localize LSTRING(Category), localize LSTRING(Category),
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)] [0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal true, // isGlobal
{[QGVAR(effectScaling), _this] call EFUNC(common,cbaSettings_settingChanged)} {[QGVAR(effectScaling), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
QGVAR(fogScaling), "SLIDER", QGVAR(fogScaling), "SLIDER",
@ -14,7 +15,8 @@
localize LSTRING(Category), localize LSTRING(Category),
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)] [0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal true, // isGlobal
{[QGVAR(fogScaling), _this] call EFUNC(common,cbaSettings_settingChanged)} {[QGVAR(fogScaling), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [

View File

@ -35,4 +35,5 @@ if (hasInterface) then {
} else { } else {
[ACE_player, "isPlayer"] call EFUNC(common,unmuteUnit); [ACE_player, "isPlayer"] call EFUNC(common,unmuteUnit);
}; };
}] call CBA_settings_fnc_init; }, true // Needs mission restart
] call CBA_settings_fnc_init;

View File

@ -78,7 +78,8 @@
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"], [localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
true, // default value true, // default value
true, // isGlobal true, // isGlobal
{[QGVAR(addSpareParts), _this] call EFUNC(common,cbaSettings_settingChanged)} {[QGVAR(addSpareParts), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [

View File

@ -15,7 +15,8 @@
LSTRING(DisplayName), LSTRING(DisplayName),
false, // default value false, // default value
true, // isGlobal true, // isGlobal
{[QGVAR(lockVehicleInventory), _this] call EFUNC(common,cbaSettings_settingChanged)} {[QGVAR(lockVehicleInventory), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
@ -24,5 +25,6 @@
LSTRING(DisplayName), LSTRING(DisplayName),
[[-1,0,1,2],["str_cfg_envsounds_default", LSTRING(VehicleStartingLockState_AsIs), LSTRING(VehicleStartingLockState_Locked), LSTRING(VehicleStartingLockState_Unlocked)], 0], // [values, titles, defaultIndex] [[-1,0,1,2],["str_cfg_envsounds_default", LSTRING(VehicleStartingLockState_AsIs), LSTRING(VehicleStartingLockState_Locked), LSTRING(VehicleStartingLockState_Unlocked)], 0], // [values, titles, defaultIndex]
true, // isGlobal true, // isGlobal
{[QGVAR(vehicleStartingLockState), _this] call EFUNC(common,cbaSettings_settingChanged)} {[QGVAR(vehicleStartingLockState), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;