Skip to content

Commit

Permalink
Add param for settings that require restart (#6512)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored Nov 2, 2018
1 parent 8472276 commit 61f0914
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
4 changes: 3 additions & 1 deletion addons/advanced_fatigue/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
[LSTRING(Enabled), LSTRING(Enabled_Description)],
LSTRING(DisplayName),
true,
true
true,
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_Settings_fnc_init;

[
Expand Down
6 changes: 4 additions & 2 deletions addons/common/functions/fnc_cbaSettings_convertHelper.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ private _settings = configProperties [configFile >> "ACE_Settings", "(isClass _x
private _category = getText (_config >> "category");

private _cbaIsGlobal = (!_isClientSettable) || _isForced;
private _warnIfChangedMidMission = _cbaIsGlobal && {(getNumber (_config >> "canBeChanged")) == 0};
if (_isForced) then {GVAR(cbaSettings_forcedSettings) pushBack (toLower _varName);};

// Basic handling of setting types CBA doesn't support:
Expand Down Expand Up @@ -117,10 +118,11 @@ private _settings = configProperties [configFile >> "ACE_Settings", "(isClass _x
_output pushBack format [" %1, // %2", _cbaValueInfo, _cbaValueInfoHint];
_output pushBack format [" %1, // isGlobal", _cbaIsGlobal];
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 {
_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;";
} forEach _settings;

Expand Down
3 changes: 2 additions & 1 deletion addons/common/functions/fnc_cbaSettings_loadFromConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private _isForced = (getNumber (_config >> "force")) > 0;
private _category = getText (_config >> "category");

private _cbaIsGlobal = (!_isClientSettable) || _isForced;
private _warnIfChangedMidMission = _cbaIsGlobal && {(getNumber (_config >> "canBeChanged")) == 0};
if (_isForced) then {GVAR(cbaSettings_forcedSettings) pushBack (toLower _varName);};

// Basic handling of setting types CBA doesn't support:
Expand Down Expand Up @@ -97,7 +98,7 @@ private _code = compile format ['["%1", _this] call FUNC(cbaSettings_settingChan

TRACE_2("setting",_cbaSettingType,_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);
if ((isNil "_return") || {_return != 0}) then {ERROR_1("Setting [%1] - CBA Error",_varName);};
_return
Expand Down
9 changes: 4 additions & 5 deletions addons/common/functions/fnc_cbaSettings_settingChanged.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ TRACE_2("",_settingName,_newValue);

["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 (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);
[QGVAR(displayTextStructured), [format ["Global setting %1 changed mid-mission. Mission restart may be required to prevent issues", _settingName], 4]] call CBA_fnc_localEvent;
WARNING_1("Setting [%1] changed mid-mission",_settingName);
[QGVAR(displayTextStructured), [format ["Setting %1 changed mid-mission. Mission restart may be required to prevent issues", _settingName], 4]] call CBA_fnc_localEvent;
28 changes: 21 additions & 7 deletions addons/map/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
[localize LSTRING(MapIllumination_DisplayName), localize LSTRING(MapIllumination_Description)],
format["ACE %1", localize LSTRING(Module_DisplayName)],
true,
true
true,
{[QGVAR(mapIllumination), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
Expand All @@ -13,7 +15,9 @@
[localize LSTRING(MapGlow_DisplayName), localize LSTRING(MapGlow_Description)],
format["ACE %1", localize LSTRING(Module_DisplayName)],
true,
true
true,
{[QGVAR(mapGlow), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
Expand Down Expand Up @@ -49,7 +53,9 @@
[localize LSTRING(DefaultChannel_DisplayName), localize LSTRING(DefaultChannel_Description)],
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],
true
true,
{[QGVAR(DefaultChannel), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

// Blue Force Tracking
Expand All @@ -59,7 +65,9 @@
[localize LSTRING(BFT_Enabled_DisplayName), localize LSTRING(BFT_Enabled_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
false,
true
true,
{[QGVAR(BFT_Enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
Expand All @@ -68,7 +76,9 @@
[localize LSTRING(BFT_Interval_DisplayName), localize LSTRING(BFT_Interval_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
[0, 30, 1, 1],
true
true,
{[QGVAR(BFT_Interval), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
Expand All @@ -77,7 +87,9 @@
[localize LSTRING(BFT_ShowPlayerNames_DisplayName), localize LSTRING(BFT_ShowPlayerNames_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
false,
true
true,
{[QGVAR(BFT_ShowPlayerNames), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;

[
Expand All @@ -86,5 +98,7 @@
[localize LSTRING(BFT_HideAiGroups_DisplayName), localize LSTRING(BFT_HideAiGroups_Description)],
[format ["ACE %1", localize LSTRING(Module_DisplayName)], localize LSTRING(BFT_Module_DisplayName)],
false,
true
true,
{[QGVAR(BFT_HideAiGroups), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_settings_fnc_init;
6 changes: 4 additions & 2 deletions addons/nightvision/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
localize LSTRING(Category),
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
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;
[
QGVAR(fogScaling), "SLIDER",
[LSTRING(fogScaling_DisplayName), LSTRING(fogScaling_Description)],
localize LSTRING(Category),
[0,2,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
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;

[
Expand Down
3 changes: 2 additions & 1 deletion addons/noradio/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ if (hasInterface) then {
} else {
[ACE_player, "isPlayer"] call EFUNC(common,unmuteUnit);
};
}] call CBA_settings_fnc_init;
}, true // Needs mission restart
] call CBA_settings_fnc_init;
3 changes: 2 additions & 1 deletion addons/repair/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
true, // default value
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;

[
Expand Down
6 changes: 4 additions & 2 deletions addons/vehiclelock/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
LSTRING(DisplayName),
false, // default value
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;

[
Expand All @@ -24,5 +25,6 @@
LSTRING(DisplayName),
[[-1,0,1,2],["str_cfg_envsounds_default", LSTRING(VehicleStartingLockState_AsIs), LSTRING(VehicleStartingLockState_Locked), LSTRING(VehicleStartingLockState_Unlocked)], 0], // [values, titles, defaultIndex]
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;

0 comments on commit 61f0914

Please sign in to comment.