Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fail to read settings from settings file #1134

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/disposable/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ELSTRING(common,WeaponsCategory),
true, // default value
1 // isGlobal
] call EFUNC(settings,init);
] call CBA_fnc_addSetting;

[
QGVAR(dropUsedLauncher),
Expand All @@ -22,4 +22,4 @@
2
],
0 // isGlobal
] call EFUNC(settings,init);
] call CBA_fnc_addSetting;
2 changes: 1 addition & 1 deletion addons/optics/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
private _unit = call CBA_fnc_currentUnit;
[_unit, true] call FUNC(restartCamera);
}
] call EFUNC(settings,init);
] call CBA_fnc_addSetting;
47 changes: 25 additions & 22 deletions addons/settings/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

ADDON = false;

#include "XEH_PREP.sqf"
// Don't prep functions if already prepped by CBA_fnc_addSetting to avoid log spam.
if (isNil QFUNC(init)) then {
#include "XEH_PREP.sqf"
};

//#define DEBUG_MODE_FULL
#ifdef DEBUG_MODE_FULL
Expand All @@ -14,27 +17,27 @@ ADDON = false;
toString _value
};

["Test_Setting_0", "CHECKBOX", ["-test checkbox-", "-tooltip-"], "My Category", true] call cba_settings_fnc_init;
["Test_Setting_1", "EDITBOX", ["-test editbox-", "-tooltip-"], "My Category", ["null", false, _fnc_sanitizeValue]] call cba_settings_fnc_init;
["Test_Setting_2", "LIST", ["-test list-", "-tooltip-"], "My Category", [[1, 0], [["enabled", "tooltip 1"], ["disabled", "tooltip 2"]], 1]] call cba_settings_fnc_init;
["Test_Setting_3", "SLIDER", ["-test slider-", "-tooltip-"], "My Category", [0, 10, 5, 0]] call cba_settings_fnc_init;
["Test_Setting_4", "COLOR", ["-test color-", "-tooltip-"], "My Category", [1, 1 ,0], false, {diag_log text format ["Color Setting Changed: %1", _this];}] call cba_settings_fnc_init;
["Test_Setting_5", "COLOR", ["-test alpha-", "-tooltip-"], "My Category", [1, 0, 0, 0.5], false] call cba_settings_fnc_init;
["Test_Setting_6", "TIME", ["-test time-", "-tooltip-"], "My Category", [0, 3600, 60], false] call cba_settings_fnc_init;
["Test_Padding", "LIST", "Padding test", "My Category", [[0,1,2,3,4,5,6,7,8,9,10], []]] call cba_settings_fnc_init;

["Test_1", "EDITBOX", "setting 1", "Test Category", "null", nil, {systemChat str [1, _this]}] call cba_settings_fnc_init;
["Test_2", "EDITBOX", "setting 2", ["Test Category", "Evens"], "null", nil, {systemChat str [2, _this]}] call cba_settings_fnc_init;
["Test_3", "EDITBOX", "setting 3", "Test Category", "null", nil, {systemChat str [3, _this]}] call cba_settings_fnc_init;
["Test_4", "EDITBOX", "setting 4", ["Test Category", "Evens"], "null", nil, {systemChat str [4, _this]}] call cba_settings_fnc_init;
["Test_5", "EDITBOX", "setting 5", "Test Category", "null", 1, {systemChat str [5, _this]}] call cba_settings_fnc_init;
["Test_6", "EDITBOX", "setting 6", ["Test Category", "Evens"], "null", 2, {systemChat str [6, _this]}] call cba_settings_fnc_init;
["Test_7", "EDITBOX", "setting 7", ["Test Category", "Seven"], "null", 2, {systemChat str [7, _this]}] call cba_settings_fnc_init;

["Test_A", "EDITBOX", "setting 1", "Test Category 1", "a", nil, {systemChat str [1, _this]}] call cba_settings_fnc_init;
["Test_B", "EDITBOX", "setting 2", "Test Category 1", "b", nil, {systemChat str [2, _this]}] call cba_settings_fnc_init;
["Test_C", "EDITBOX", "setting 3", "Test Category 3", "c", nil, {systemChat str [3, _this]}] call cba_settings_fnc_init;
["Test_D", "EDITBOX", "setting 4", "Test Category 3", "d", nil, {systemChat str [4, _this]}] call cba_settings_fnc_init;
["Test_Setting_0", "CHECKBOX", ["-test checkbox-", "-tooltip-"], "My Category", true] call CBA_fnc_addSetting;
["Test_Setting_1", "EDITBOX", ["-test editbox-", "-tooltip-"], "My Category", ["null", false, _fnc_sanitizeValue]] call CBA_fnc_addSetting;
["Test_Setting_2", "LIST", ["-test list-", "-tooltip-"], "My Category", [[1, 0], [["enabled", "tooltip 1"], ["disabled", "tooltip 2"]], 1]] call CBA_fnc_addSetting;
["Test_Setting_3", "SLIDER", ["-test slider-", "-tooltip-"], "My Category", [0, 10, 5, 0]] call CBA_fnc_addSetting;
["Test_Setting_4", "COLOR", ["-test color-", "-tooltip-"], "My Category", [1, 1 ,0], false, {diag_log text format ["Color Setting Changed: %1", _this];}] call CBA_fnc_addSetting;
["Test_Setting_5", "COLOR", ["-test alpha-", "-tooltip-"], "My Category", [1, 0, 0, 0.5], false] call CBA_fnc_addSetting;
["Test_Setting_6", "TIME", ["-test time-", "-tooltip-"], "My Category", [0, 3600, 60], false] call CBA_fnc_addSetting;
["Test_Padding", "LIST", "Padding test", "My Category", [[0,1,2,3,4,5,6,7,8,9,10], []]] call CBA_fnc_addSetting;

["Test_1", "EDITBOX", "setting 1", "Test Category", "null", nil, {systemChat str [1, _this]}] call CBA_fnc_addSetting;
["Test_2", "EDITBOX", "setting 2", ["Test Category", "Evens"], "null", nil, {systemChat str [2, _this]}] call CBA_fnc_addSetting;
["Test_3", "EDITBOX", "setting 3", "Test Category", "null", nil, {systemChat str [3, _this]}] call CBA_fnc_addSetting;
["Test_4", "EDITBOX", "setting 4", ["Test Category", "Evens"], "null", nil, {systemChat str [4, _this]}] call CBA_fnc_addSetting;
["Test_5", "EDITBOX", "setting 5", "Test Category", "null", 1, {systemChat str [5, _this]}] call CBA_fnc_addSetting;
["Test_6", "EDITBOX", "setting 6", ["Test Category", "Evens"], "null", 2, {systemChat str [6, _this]}] call CBA_fnc_addSetting;
["Test_7", "EDITBOX", "setting 7", ["Test Category", "Seven"], "null", 2, {systemChat str [7, _this]}] call CBA_fnc_addSetting;

["Test_A", "EDITBOX", "setting 1", "Test Category 1", "a", nil, {systemChat str [1, _this]}] call CBA_fnc_addSetting;
["Test_B", "EDITBOX", "setting 2", "Test Category 1", "b", nil, {systemChat str [2, _this]}] call CBA_fnc_addSetting;
["Test_C", "EDITBOX", "setting 3", "Test Category 3", "c", nil, {systemChat str [3, _this]}] call CBA_fnc_addSetting;
["Test_D", "EDITBOX", "setting 4", "Test Category 3", "d", nil, {systemChat str [4, _this]}] call CBA_fnc_addSetting;
#endif

// --- init settings namespaces
Expand Down
7 changes: 6 additions & 1 deletion addons/settings/fnc_addSetting.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ Author:
commy2
---------------------------------------------------------------------------- */

call (uiNamespace getVariable QFUNC(init)) == 0
// Prep functions if not yet prepped to avoid race condition.
if (isNil QFUNC(init)) then {
commy2 marked this conversation as resolved.
Show resolved Hide resolved
#include "XEH_PREP.sqf"
};

call FUNC(init) == 0
8 changes: 8 additions & 0 deletions addons/settings/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@ if (isNil QGVAR(default)) then {

private _userconfig = preprocessFile call (uiNamespace getVariable QGVAR(userconfig));

INFO("Reading settings from settings file.");

{
_x params ["_setting", "_value", "_priority"];

#ifdef DEBUG_MODE_FULL
INFO_3("Setting %1 with value %2 and priority %3 set in userconfig.",_setting,_value,_priority);
#endif

GVAR(userconfig) setVariable [_setting, [_value, _priority]];

if (isServer) then {
GVAR(serverConfig) setVariable [_setting, true, true];
};
} forEach ([_userconfig, false] call FUNC(parse));

INFO("Finished reading settings from settings file.");

// --- read mission settings file
GVAR(missionConfig) = [] call CBA_fnc_createNamespace;

Expand Down