|
|
@ -323,68 +323,83 @@ public function UpdateFeatureArray( |
|
|
|
out array<Packages.FeatureConfigPair> featuresToEnable) |
|
|
|
out array<Packages.FeatureConfigPair> featuresToEnable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local int i; |
|
|
|
local int i; |
|
|
|
local Text newConfigName; |
|
|
|
local HashTable includedFeaturesMap; |
|
|
|
|
|
|
|
local Text nextKey, nextConfig; |
|
|
|
local string nextFeatureClassName; |
|
|
|
local string nextFeatureClassName; |
|
|
|
|
|
|
|
local CollectionIterator iter; |
|
|
|
|
|
|
|
local Packages.FeatureConfigPair newPair; |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < featuresToEnable.length; i += 1) |
|
|
|
// Exclude features we're told to exclude |
|
|
|
|
|
|
|
while (i < featuresToEnable.length) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nextFeatureClassName = string(featuresToEnable[i].featureClass); |
|
|
|
nextFeatureClassName = string(featuresToEnable[i].featureClass); |
|
|
|
// `excludeFeature` |
|
|
|
if (IsFeatureExcluded(nextFeatureClassName)) |
|
|
|
if (FeatureExcluded(nextFeatureClassName)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
_.memory.Free(featuresToEnable[i].configName); |
|
|
|
_.memory.Free(featuresToEnable[i].configName); |
|
|
|
featuresToEnable[i].configName = none; |
|
|
|
featuresToEnable.Remove(i, 1); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
i += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
// `includeFeatureAs` |
|
|
|
} |
|
|
|
newConfigName = TryReplacingFeatureConfig(nextFeatureClassName); |
|
|
|
// Rewrite auto-enabled configs if different config was specified |
|
|
|
if (newConfigName != none) |
|
|
|
includedFeaturesMap = BuildIncludedFeaturesMap(); |
|
|
|
|
|
|
|
for (i = 0; i < featuresToEnable.length; i += 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nextKey = |
|
|
|
|
|
|
|
_.text.FromString(Locs(string(featuresToEnable[i].featureClass))); |
|
|
|
|
|
|
|
nextConfig = Text(includedFeaturesMap.TakeItem(nextKey)); |
|
|
|
|
|
|
|
if (nextConfig != none) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_.memory.Free(featuresToEnable[i].configName); |
|
|
|
_.memory.Free(featuresToEnable[i].configName); |
|
|
|
featuresToEnable[i].configName = newConfigName; |
|
|
|
featuresToEnable[i].configName = nextConfig; |
|
|
|
} |
|
|
|
} |
|
|
|
// `includeFeature` |
|
|
|
nextKey.FreeSelf(); |
|
|
|
if ( featuresToEnable[i].configName == none |
|
|
|
|
|
|
|
&& FeatureInIncludedArray(nextFeatureClassName)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
featuresToEnable[i].configName = P("default").Copy(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Add features that are included, but weren't auto-enabled in |
|
|
|
|
|
|
|
// the first place |
|
|
|
|
|
|
|
for (iter = includedFeaturesMap.Iterate(); !iter.HasFinished(); iter.Next()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nextKey = Text(iter.GetKey()); |
|
|
|
|
|
|
|
newPair.featureClass = class<Feature>(_.memory.LoadClass(nextKey)); |
|
|
|
|
|
|
|
newPair.configName = Text(iter.Get()); |
|
|
|
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
|
|
|
|
featuresToEnable[featuresToEnable.length] = newPair; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
includedFeaturesMap.FreeSelf(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function bool FeatureExcluded(string featureClassName) |
|
|
|
private function HashTable BuildIncludedFeaturesMap() |
|
|
|
{ |
|
|
|
{ |
|
|
|
local int i; |
|
|
|
local int i; |
|
|
|
|
|
|
|
local Text nextKey; |
|
|
|
|
|
|
|
local HashTable result; |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < excludeFeature.length; i += 1) |
|
|
|
result = _.collections.EmptyHashTable(); |
|
|
|
|
|
|
|
// First fill `HashTable` with non-specified conmfigs from `includeFeature` |
|
|
|
|
|
|
|
for (i = 0; i < includeFeature.length; i += 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (excludeFeature[i] ~= featureClassName) { |
|
|
|
nextKey = _.text.FromString(Locs(includeFeature[i])); |
|
|
|
return true; |
|
|
|
result.SetItem(nextKey, none); |
|
|
|
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Then add/rewrite configs from `includeFeatureAs` |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function Text TryReplacingFeatureConfig(string featureClassName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local int i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < includeFeatureAs.length; i += 1) |
|
|
|
for (i = 0; i < includeFeatureAs.length; i += 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (includeFeatureAs[i].feature ~= featureClassName) { |
|
|
|
nextKey = _.text.FromString(Locs(includeFeatureAs[i].feature)); |
|
|
|
return _.text.FromString(includeFeatureAs[i].config); |
|
|
|
result.SetString(nextKey, Locs(includeFeatureAs[i].config)); |
|
|
|
|
|
|
|
nextKey.FreeSelf(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return none; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function bool FeatureInIncludedArray(string featureClassName) |
|
|
|
private function bool IsFeatureExcluded(string featureClassName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local int i; |
|
|
|
local int i; |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < includeFeature.length; i += 1) |
|
|
|
for (i = 0; i < excludeFeature.length; i += 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (includeFeature[i] ~= featureClassName) { |
|
|
|
if (excludeFeature[i] ~= featureClassName) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|