mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Replaced custom mapping implementation with ACE Hash
This commit is contained in:
parent
2b0ef7bc6d
commit
93acdbcb4d
@ -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[] = {{}, {}};
|
||||
};
|
||||
};
|
||||
|
@ -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)};
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user