Replaced custom mapping implementation with ACE Hash

This commit is contained in:
Michael Braun 2015-08-24 22:45:59 +02:00
parent 2b0ef7bc6d
commit 93acdbcb4d
4 changed files with 13 additions and 37 deletions

View File

@ -51,18 +51,11 @@ class ACE_Settings {
typeName = "ARRAY";
value[] = {};
};
class GVAR(GroupColorConfigurationsGroups) {
displayName = CSTRING(GroupColorConfigurationsGroups_displayName);
description = CSTRING(GroupColorConfigurationsGroups_description);
class GVAR(GroupColorConfigurationMapping) {
displayName = CSTRING(GroupColorConfigurationMapping_displayName);
description = CSTRING(GroupColorConfigurationMapping_description);
category = CSTRING(mapGestures_category);
typeName = "ARRAY";
value[] = {};
};
class GVAR(GroupColorConfigurationsGroupIndex) {
displayName = CSTRING(GroupColorConfigurationsGroupIndex_displayName);
description = CSTRING(GroupColorConfigurationsGroupIndex_description);
category = CSTRING(mapGestures_category);
typeName = "ARRAY";
value[] = {};
value[] = {{}, {}};
};
};

View File

@ -44,9 +44,8 @@ params ["_mapHandle"];
_grpName = groupID _group;
// If color settings for the group exist, then use those, otherwise fall back to the default colors
_color = if (_grpName in GVAR(GroupColorConfigurationsGroups)) then {
_grpNameIndex = GVAR(GroupColorConfigurationsGroups) find _grpName;
(GVAR(GroupColorConfigurations) select (GVAR(GroupColorConfigurationsGroupIndex) select _grpNameIndex)) select (_x != leader _group)
_color = if (HASH_HASKEY(GVAR(GroupColorConfigurationMapping),_grpName)) then {
(GVAR(GroupColorConfigurations) select (HASH_GET(GVAR(GroupColorConfigurationMapping),_grpName))) select (_x != leader _group)
} else {
if (_x == leader _group) then {GVAR(defaultLeadColor)} else {GVAR(defaultColor)};
};

View File

@ -29,25 +29,15 @@ if (!([_color] call FUNC(isValidColorArray))) exitWith {ERROR("color is not a va
// If we already have color configurations from another source, use those, otherwise use default.
_configurations = if (isNil QGVAR(GroupColorConfigurations)) then { [] } else { +GVAR(GroupColorConfigurations) };
_configurationGroups = if (isNil QGVAR(GroupColorConfigurationsGroups)) then { [] } else { +GVAR(GroupColorConfigurationsGroups) };
_configurationGroupsIndex = if (isNil QGVAR(GroupColorConfigurationsGroupIndex)) then { [] } else { +GVAR(GroupColorConfigurationsGroupIndex) };
_configurationGroupMappings = if(isNil QGVAR(GroupColorConfigurationMapping)) then { HASH_CREATE } else { +GVAR(GroupColorConfigurationMapping) };
// Save custom color configuration and keep the index of the entry.
_configurationIndex = _configurations pushBack [_leadColor, _color];
// Add all synchronized groups and reference custom configuration for them
_completedGroups = [];
{
private "_group";
_group = groupID (group _x);
if (!(_group in _completedGroups)) then {
_index = if (_group in _configurationGroups) then {_configurationGroups find _group} else {_configurationGroups pushBack _group};
_configurationGroupsIndex set [_index, _configurationIndex];
_completedGroups pushBack _group;
};
nil
HASH_SET(_configurationGroupMappings,groupID (group _x),_configurationIndex);
} count _units;
[QGVAR(GroupColorConfigurations), _configurations, false, true] call EFUNC(common,setSetting);
[QGVAR(GroupColorConfigurationsGroups), _configurationGroups, false, true] call EFUNC(common,setSetting);
[QGVAR(GroupColorConfigurationsGroupIndex), _configurationGroupsIndex, false, true] call EFUNC(common,setSetting);
[QGVAR(GroupColorConfigurationMapping), _configurationGroupMappings, false, true] call EFUNC(common,setSetting);

View File

@ -76,17 +76,11 @@
<Key ID="STR_ACE_map_gestures_GroupColorConfigurations_description">
<English>Group color configuration containing arrays of color pairs ([leadColor, color]).</English>
</Key>
<Key ID="STR_ACE_map_gestures_GroupColorConfigurationsGroups_description">
<English>Group color group name index, containing names of groups with configurations attached to them.</English>
<Key ID="STR_ACE_map_gestures_GroupColorConfigurationMapping_description">
<English>Hash of Group ID mapped to the Group color configuration index.</English>
</Key>
<Key ID="STR_ACE_map_gestures_GroupColorConfigurationsGroups_displayName">
<English>Group color group name index</English>
</Key>
<Key ID="STR_ACE_map_gestures_GroupColorConfigurationsGroupIndex_displayName">
<English>Group color group name mapping index</English>
</Key>
<Key ID="STR_ACE_map_gestures_GroupColorConfigurationsGroupIndex_description">
<English>Group color group name mapping index, mapping the GroupColorConfigurationsGroups to the GroupColorConfigurations.</English>
<Key ID="STR_ACE_map_gestures_GroupColorConfigurationMapping_displayName">
<English>GroupID Color configuration mapping</English>
</Key>
<Key ID="STR_ACE_map_gestures_enabled_description">
<English>Enables the Map Gestures.</English>