2015-08-08 06:26:15 +00:00
|
|
|
/*
|
2015-08-10 06:45:43 +00:00
|
|
|
* Author: Dslyecxi, MikeMatrix
|
2015-08-08 06:26:15 +00:00
|
|
|
* Initializes Settings for the groups modules and transcodes settings to a useable format.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Logic <LOGIC>
|
|
|
|
* 1: Units <ARRAY>
|
|
|
|
* 2: Activated <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [module, [player], true] call ace_map_gestures_fnc_moduleGroupSettings
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-24 21:26:03 +00:00
|
|
|
private ["_color", "_configurationGroupMappings", "_configurationIndex", "_configurations", "_leadColor"];
|
|
|
|
|
2015-08-08 06:26:15 +00:00
|
|
|
params ["_logic", "_units", "_activated"];
|
|
|
|
|
2015-08-24 15:03:47 +00:00
|
|
|
if (!_activated || !isServer) exitWith {};
|
2015-08-08 06:26:15 +00:00
|
|
|
|
2015-08-24 15:03:47 +00:00
|
|
|
// Transcode string setting into usable array. Example: "1,1,1,1" -> [1, 1, 1, 1]
|
2015-08-08 06:26:15 +00:00
|
|
|
_leadColor = call compile ("[" + (_logic getVariable ["leadColor", ""]) + "]");
|
2015-08-10 17:04:49 +00:00
|
|
|
if (!([_leadColor] call FUNC(isValidColorArray))) exitWith {ERROR("leadColor is not a valid color array.")};
|
2015-08-08 06:26:15 +00:00
|
|
|
_color = call compile ("[" + (_logic getVariable ["color", ""]) + "]");
|
2015-08-10 17:04:49 +00:00
|
|
|
if (!([_color] call FUNC(isValidColorArray))) exitWith {ERROR("color is not a valid color array.")};
|
2015-08-08 06:26:15 +00:00
|
|
|
|
2015-08-24 15:03:47 +00:00
|
|
|
// If we already have color configurations from another source, use those, otherwise use default.
|
2015-08-10 17:04:49 +00:00
|
|
|
_configurations = if (isNil QGVAR(GroupColorConfigurations)) then { [] } else { +GVAR(GroupColorConfigurations) };
|
2015-08-24 20:45:59 +00:00
|
|
|
_configurationGroupMappings = if(isNil QGVAR(GroupColorConfigurationMapping)) then { HASH_CREATE } else { +GVAR(GroupColorConfigurationMapping) };
|
2015-08-08 06:26:15 +00:00
|
|
|
|
2015-08-24 15:03:47 +00:00
|
|
|
// Save custom color configuration and keep the index of the entry.
|
2015-08-10 17:04:49 +00:00
|
|
|
_configurationIndex = _configurations pushBack [_leadColor, _color];
|
2015-08-24 15:03:47 +00:00
|
|
|
|
|
|
|
// Add all synchronized groups and reference custom configuration for them
|
2015-08-08 06:26:15 +00:00
|
|
|
{
|
2015-08-24 20:45:59 +00:00
|
|
|
HASH_SET(_configurationGroupMappings,groupID (group _x),_configurationIndex);
|
2015-08-08 06:26:15 +00:00
|
|
|
} count _units;
|
|
|
|
|
2015-08-24 20:03:47 +00:00
|
|
|
[QGVAR(GroupColorConfigurations), _configurations, false, true] call EFUNC(common,setSetting);
|
2015-08-24 20:45:59 +00:00
|
|
|
[QGVAR(GroupColorConfigurationMapping), _configurationGroupMappings, false, true] call EFUNC(common,setSetting);
|