-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathXEH_preInit.sqf
93 lines (71 loc) · 3.93 KB
/
XEH_preInit.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "script_component.hpp"
ADDON = false;
#include "XEH_PREP.sqf"
#ifdef DEBUG_MODE_FULL
private _fnc_sanitizeValue = {
params ["_value"];
_value = toArray _value;
_value = _value - toArray "0123456789"; // remove all numbers
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", "disabled"], 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_1", "EDITBOX", "setting 1", "Test Category", "null", nil, {systemChat str [1, _this]}] call cba_settings_fnc_init;
["Test_2", "EDITBOX", "setting 2", "Test Category", "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", "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", "null", 2, {systemChat str [6, _this]}] call cba_settings_fnc_init;
#endif
// --- init settings namespaces
#include "initSettings.sqf"
// --- event to refresh missionNamespace value if setting has changed and call public event as well as execute setting script
[QGVAR(refreshSetting), {
params ["_setting"];
private _value = _setting call FUNC(get);
missionNamespace setVariable [_setting, _value];
if (isNil QGVAR(ready)) exitWith {};
private _script = (GVAR(default) getVariable [_setting, []]) param [8, {}];
[_value, _script, _setting] call {
private ["_setting", "_value", "_script"]; // prevent these variables from being overwritten
private _thisSetting = _this select 2;
(_this select 0) call (_this select 1);
};
["CBA_SettingChanged", [_setting, _value]] call CBA_fnc_localEvent;
}] call CBA_fnc_addEventHandler;
// --- event to refresh all settings at once - saves bandwith
[QGVAR(refreshAllSettings), {
{
[QGVAR(refreshSetting), _x] call CBA_fnc_localEvent;
} forEach GVAR(allSettings);
}] call CBA_fnc_addEventHandler;
// refresh all settings when loading a save game
addMissionEventHandler ["Loaded", {
QGVAR(refreshAllSettings) call CBA_fnc_localEvent;
}];
#ifdef DEBUG_MODE_FULL
["CBA_SettingChanged", {
params ["_setting", "_value"];
private _message = format ["%1 = %2", _setting, _value];
systemChat _message;
//LOG(_message);
}] call CBA_fnc_addEventHandler;
#endif
// --- event to modify settings on a dedicated server as admin
if (isServer) then {
[QGVAR(setSettingServer), {
params ["_setting", "_value", ["_priority", 0], ["_store", false]];
[_setting, _value, _priority, "server", _store] call FUNC(set);
}] call CBA_fnc_addEventHandler;
};
// --- event to modify mission settings
[QGVAR(setSettingMission), {
params ["_setting", "_value", ["_priority", 0], ["_store", false]];
[_setting, _value, _priority, "mission", _store] call FUNC(set);
}] call CBA_fnc_addEventHandler;
[[localize LSTRING(menu_button)], QGVAR(MainMenuHelper)] call CBA_fnc_addPauseMenuOption;
ADDON = true;