Skip to content

Commit

Permalink
Config updater asset matching optionally limited to same file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Piranha91 committed Apr 1, 2024
1 parent d35b54a commit efffc0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions SynthEBD/GUI_Aux/ViewModels/VM_ConfigPathRemapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public VM_ConfigPathRemapper(VM_AssetPack parentAssetPack, Window_ConfigPathRema
private Progress<int> _hashingProgress { get; }
private List<string> _currentFileExtensions { get; set; } = new(); // files extensions used in the original config file (so as to ignore xml files, preview images, etc from the updated mod archive)
public ObservableCollection<RemappedSubgroup> SubgroupsRemappedByHash { get; set; } = new();
public bool LimitHashMatchingByFileName { get; set; } = true;
private List<string> _filesMatchedByHash_Existing { get; set; } = new();
private List<string> _filesMatchedByHash_New { get; set; } = new(); // paths in the new mod that got matched by hash to files in the previous version
private List<string> _unmatchedPaths_Current { get; set; } = new(); // paths in the current config file that do not have a hash match in the new mod
Expand Down Expand Up @@ -370,6 +371,12 @@ private void RemapPathsByHash()
{
var currentHash = _currentPathHashes[pathEntry.Source];
var matchingEntries = _newPathHashes.Where(x => x.Value.Equals(currentHash)).ToList();

if (LimitHashMatchingByFileName)
{
matchingEntries = matchingEntries.Where(x => Path.GetFileName(x.Key).Equals(Path.GetFileName(pathEntry.Source), StringComparison.OrdinalIgnoreCase)).ToList();
}

if (matchingEntries.Any())
{
var newSource = ChooseBestHashMatch(matchingEntries.Select(x => x.Key).ToList(), pathEntry.Source);
Expand Down
4 changes: 3 additions & 1 deletion SynthEBD/GUI_Aux/Views/Window_ConfigPathRemapper.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
<WrapPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
<TextBlock Text="If multiple matching textures exist, choose the one with the " Foreground="White" VerticalAlignment="Center"/>
<ComboBox SelectedItem="{Binding HashMatchMode}" ItemsSource="{Binding Source={local:EnumBindingSource {x:Type local:PathMatchModeHash}}}" MaxWidth="250" Margin="5 0 5 0"/>
<TextBlock Text="path" Foreground="White" VerticalAlignment="Center"/>
<TextBlock Text="path." Foreground="White" VerticalAlignment="Center"/>
<TextBlock Text="Match same file names only" VerticalAlignment="Center" Margin="150 0 5 0" Foreground="White"/>
<CheckBox IsChecked="{Binding LimitHashMatchingByFileName}"/>
</WrapPanel>

<Button Content="Remap Paths" Command="{Binding RemapPaths}" Foreground="MediumPurple" Grid.Row="2" Grid.Column="0" Visibility="{Binding ShowRemapButton, Converter={StaticResource BoolToVis}}"/>
Expand Down

0 comments on commit efffc0e

Please sign in to comment.