Skip to content

Commit f67bfb6

Browse files
committed
Add exclude directory option
1 parent 38d3a96 commit f67bfb6

5 files changed

Lines changed: 72 additions & 5 deletions

File tree

Unity2Debug.Common/Automation/CopyGameAutomator.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Diagnostics;
1+
using ICSharpCode.Decompiler.IL;
2+
using ICSharpCode.Decompiler.Semantics;
3+
using System.Diagnostics;
24
using Unity2Debug.Common.Logging;
35
using Unity2Debug.Common.SettingsService;
46
using Unity2Debug.Common.Utility;
@@ -48,6 +50,9 @@ await Task.Run(() =>
4850

4951
CancellationToken.ThrowIfCancellationRequested();
5052

53+
if (DebugSettings.ExcludeDirectories.Contains(currentInputPath) || DebugSettings.ExcludeDirectories.Any(excludePath => GetParentDirectories(currentInputPath).Contains(excludePath)))
54+
continue;
55+
5156
if (!Directory.Exists(currentOutputPath))
5257
{
5358
if (DebugSettings.UseSymlinks)
@@ -77,6 +82,9 @@ await Task.Run(() =>
7782

7883
FileMatcher fileMatcher = new(DebugSettings.GetFullSymlinkFileFilters());
7984

85+
if (DebugSettings.UseSymlinks)
86+
DebugSettings.ExcludeDirectories.AddRange(symlinkPaths);
87+
8088
foreach (string currentInputFile in Directory.GetFiles(baseInputPath, "*.*", SearchOption.AllDirectories))
8189
{
8290
try
@@ -86,7 +94,7 @@ await Task.Run(() =>
8694
//if (DecompileSettings.AssemblyPaths.Contains(currentInputFile))
8795
// continue;
8896

89-
if (DebugSettings.UseSymlinks && symlinkPaths.Any(symlinkPath => GetParentDirectories(currentInputFile).Contains(symlinkPath)))
97+
if (DebugSettings.ExcludeDirectories.Any(excludePath => GetParentDirectories(currentInputFile).Contains(excludePath)))
9098
continue;
9199

92100
var currentOutputFile = currentInputFile.Replace(baseInputPath, DebugSettings.DebugOutputPath);

Unity2Debug.Common/SettingsService/DebugSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class DebugSettings : SettingsBase<DebugSettings, DebugSettingsValidator>
1414
public string UnityVersion { get; set; }
1515
public bool UseSymlinks { get; set; }
1616
public List<string> Symlinks { get; set; }
17+
public List<string> ExcludeDirectories { get; set; }
1718
public bool CreateDebugCopy { get; set; }
1819

1920
[JsonIgnore]
@@ -31,6 +32,7 @@ public DebugSettings()
3132
UnityVersion = string.Empty;
3233
UseSymlinks = false;
3334
Symlinks = [];
35+
ExcludeDirectories = [];
3436
}
3537

3638
public List<string> GetFullSymlinkDirectories()

Unity2Debug/Pages/DebugCopySetup.xaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
ItemsSource="{Binding Profiles.CurrentProfile.DebugSettings.SymLinks}"
8383
SelectedItem="{Binding SelectedSymLink, UpdateSourceTrigger=PropertyChanged}"
8484
IsEnabled="{Binding Profiles.CurrentProfile.DebugSettings.UseSymlinks}"
85-
Height="200"/>
85+
Height="150"/>
8686
<StackPanel>
8787
<Button
8888
Content="Add"
@@ -96,6 +96,25 @@
9696
Command="{Binding RemoveSymlinkCommand}"/>
9797
</StackPanel>
9898
</WrapPanel>
99+
<WrapPanel>
100+
<Label
101+
Content="Exclude Paths:"
102+
VerticalAlignment="Top"/>
103+
<ListBox
104+
ItemsSource="{Binding Profiles.CurrentProfile.DebugSettings.ExcludeDirectories}"
105+
SelectedItem="{Binding SelectedExclude, UpdateSourceTrigger=PropertyChanged}"
106+
Height="150"/>
107+
<StackPanel>
108+
<Button
109+
Content="Add"
110+
VerticalAlignment="Top"
111+
Command="{Binding SelectExcludePathCommand}"/>
112+
<Button
113+
Content="Remove"
114+
VerticalAlignment="Top"
115+
Command="{Binding RemoveExcludePathCommand}"/>
116+
</StackPanel>
117+
</WrapPanel>
99118
<WrapPanel>
100119
<Grid>
101120
<Label
@@ -109,7 +128,7 @@
109128
</Grid>
110129
<RichTextBox
111130
x:Name="RichTextBoxLogger"
112-
Height="230"/>
131+
Height="100"/>
113132
<Button
114133
Content="Next"
115134
IsEnabled="{Binding Profiles.CurrentProfile.DebugSettings.IsValid}"

Unity2Debug/Pages/ViewModel/DebugCopySetupVM.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public partial class DebugCopySetupVM : ViewModelBase<DebugCopySetupVM, DebugSet
1616
[ObservableProperty]
1717
private string? _selectedSymLink;
1818

19+
[ObservableProperty]
20+
private string? _selectedExclude;
21+
1922
public DebugCopySetupVM(RichTextBoxLogger logger, IDialogService dialogService, ObservableProfiles profiles) : base(logger, dialogService, profiles)
2023
{
2124
}
@@ -40,6 +43,25 @@ private void SelectDebugOutputPath()
4043
Profiles.CurrentProfile.DebugSettings.DebugOutputPath = path;
4144
}
4245

46+
[RelayCommand]
47+
private void SelectExcludePath()
48+
{
49+
if (Profiles.CurrentProfile == null) return;
50+
51+
var path = _dialogService.OpenFolder();
52+
if (path != null && !Profiles.CurrentProfile.DebugSettings.ExcludeDirectories.Contains(path))
53+
Profiles.CurrentProfile.DebugSettings.ExcludeDirectories.Add(path);
54+
}
55+
56+
[RelayCommand]
57+
private void RemoveExcludePath()
58+
{
59+
if (Profiles.CurrentProfile == null || SelectedExclude == null) return;
60+
61+
if (Profiles.CurrentProfile.DebugSettings.ExcludeDirectories.Contains(SelectedExclude))
62+
Profiles.CurrentProfile.DebugSettings.ExcludeDirectories.Remove(SelectedExclude);
63+
}
64+
4365
[RelayCommand]
4466
private void SelectUnityInstallPath()
4567
{

Unity2Debug/Settings/ObservableDebugSettings.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public partial class ObservableDebugSettings : ObservableSettingsBase<DebugSetti
5252
[NotifyPropertyChangedFor(nameof(IsValid))]
5353
private ObservableCollection<string> _symLinks = [];
5454

55+
[ObservableProperty]
56+
[NotifyPropertyChangedFor(nameof(IsValid))]
57+
private ObservableCollection<string> _excludeDirectories = [];
58+
5559
public ObservableDebugSettings() : this(new())
5660
{
5761
}
@@ -81,6 +85,7 @@ public ObservableDebugSettings(DebugSettings debugSettings)
8185
this.IsDecompileOnly = !debugSettings.CreateDebugCopy;
8286
this.UseSymlinks = debugSettings.UseSymlinks;
8387
this.SymLinks = [.. debugSettings.Symlinks];
88+
this.ExcludeDirectories = [.. debugSettings.ExcludeDirectories];
8489

8590
this.UnityVersions.CollectionChanged += (s, e) =>
8691
{
@@ -91,6 +96,16 @@ public ObservableDebugSettings(DebugSettings debugSettings)
9196
{
9297
base.OnPropertyChanged(nameof(IsValid));
9398
};
99+
100+
this.ExcludeDirectories.CollectionChanged += (s, e) =>
101+
{
102+
base.OnPropertyChanged(nameof(IsValid));
103+
};
104+
}
105+
106+
private void ExcludeDirectories_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
107+
{
108+
throw new NotImplementedException();
94109
}
95110

96111
public override DebugSettings ToNonObservableSettings()
@@ -104,7 +119,8 @@ public override DebugSettings ToNonObservableSettings()
104119
DebugOutputPath = this.DebugOutputPath,
105120
CreateDebugCopy = this.CreateDebugCopy,
106121
UseSymlinks = this.UseSymlinks,
107-
Symlinks = [.. this.SymLinks]
122+
Symlinks = [.. this.SymLinks],
123+
ExcludeDirectories = [.. this.ExcludeDirectories]
108124
};
109125
}
110126
}

0 commit comments

Comments
 (0)