2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
2015-01-15 17:41:22 +00:00
|
|
|
* Set all keys from the 'ACE_Default_Keys' base class that are missing in the current user profile.
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 1: Overwrite existing key binds? (Bool)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None.
|
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
private ["_overwrite", "_saveProfile", "_config", "_count", "_index", "_configFile", "_name", "_key", "_shft", "_ctrl", "_alt", "_keyCode", "_state"];
|
|
|
|
|
|
|
|
_overwrite = _this select 0;
|
|
|
|
|
|
|
|
_saveProfile = false;
|
|
|
|
|
2015-01-13 16:42:56 +00:00
|
|
|
_config = configFile >> "ACE_Default_Keys";
|
2015-01-11 16:42:31 +00:00
|
|
|
_count = count _config;
|
|
|
|
|
|
|
|
for "_index" from 0 to (_count - 1) do {
|
|
|
|
_configFile = _config select _index;
|
2015-01-12 04:02:33 +00:00
|
|
|
_name = format ["ACE_Key_%1", configName _configFile];
|
2015-01-11 16:42:31 +00:00
|
|
|
_key = profileNamespace getVariable _name;
|
|
|
|
|
|
|
|
if (isNil "_key" || {_overwrite}) then {
|
|
|
|
_key = getNumber (_configFile >> "Key");
|
|
|
|
_shft = getNumber (_configFile >> "Shift") == 1;
|
|
|
|
_ctrl = getNumber (_configFile >> "Control") == 1;
|
|
|
|
_alt = getNumber (_configFile >> "Alt") == 1;
|
|
|
|
|
2015-01-11 18:20:14 +00:00
|
|
|
_keyCode = [_key, _shft, _ctrl, _alt] call FUNC(convertKeyCode);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
profileNamespace setVariable [_name, _keyCode];
|
|
|
|
_saveProfile = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-01-13 16:42:56 +00:00
|
|
|
_config = configFile >> "ACE_Options";
|
2015-01-11 16:42:31 +00:00
|
|
|
_count = count _config;
|
|
|
|
|
|
|
|
for "_index" from 0 to (_count - 1) do {
|
|
|
|
_configFile = _config select _index;
|
2015-01-12 04:02:33 +00:00
|
|
|
_name = format ["ACE_%1", configName _configFile];
|
2015-01-11 16:42:31 +00:00
|
|
|
_state = profileNamespace getVariable _name;
|
|
|
|
|
|
|
|
if (isNil "_state" || {_overwrite}) then {
|
|
|
|
_state = getNumber (_configFile >> "default") == 1;
|
|
|
|
|
|
|
|
profileNamespace setVariable [_name, _state];
|
|
|
|
_saveProfile = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_overwrite) then {
|
|
|
|
saveProfileNamespace;
|
2015-01-12 04:02:33 +00:00
|
|
|
diag_log text "[ACE]: Profile settings overwritten.";
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
|
|
|
if (_saveProfile) then {
|
|
|
|
saveProfileNamespace;
|
2015-01-12 04:02:33 +00:00
|
|
|
diag_log text "[ACE]: Encountered missing variable in profile namespace. Profile saved.";
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
2015-01-12 04:02:33 +00:00
|
|
|
diag_log text "[ACE]: No missing variables encountered in profile namespace.";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|