Fix several missing features found during Septimus recompilation

This commit is contained in:
Timothy Baldridge 2022-07-26 21:56:30 -06:00
parent e0702d9f17
commit 8472fa8d73
7 changed files with 79 additions and 8 deletions

View File

@ -79,6 +79,7 @@ namespace Wabbajack
[Reactive] public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>(); [Reactive] public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
[Reactive] public RelativePath[] NoMatchInclude { get; set; } = Array.Empty<RelativePath>(); [Reactive] public RelativePath[] NoMatchInclude { get; set; } = Array.Empty<RelativePath>();
[Reactive] public RelativePath[] Include { get; set; } = Array.Empty<RelativePath>();
[Reactive] public string[] OtherProfiles { get; set; } = Array.Empty<string>(); [Reactive] public string[] OtherProfiles { get; set; } = Array.Empty<string>();
@ -215,6 +216,7 @@ namespace Wabbajack
OtherProfiles = settings.AdditionalProfiles; OtherProfiles = settings.AdditionalProfiles;
AlwaysEnabled = settings.AlwaysEnabled; AlwaysEnabled = settings.AlwaysEnabled;
NoMatchInclude = settings.NoMatchInclude; NoMatchInclude = settings.NoMatchInclude;
Include = settings.Include;
} }
@ -314,6 +316,7 @@ namespace Wabbajack
AlwaysEnabled = AlwaysEnabled, AlwaysEnabled = AlwaysEnabled,
AdditionalProfiles = OtherProfiles, AdditionalProfiles = OtherProfiles,
NoMatchInclude = NoMatchInclude, NoMatchInclude = NoMatchInclude,
Include = Include
}; };
} }
@ -349,6 +352,16 @@ namespace Wabbajack
NoMatchInclude = NoMatchInclude.Where(p => p != path).ToArray(); NoMatchInclude = NoMatchInclude.Where(p => p != path).ToArray();
} }
public void AddInclude(RelativePath path)
{
Include = (Include ?? Array.Empty<RelativePath>()).Append(path).Distinct().ToArray();
}
public void RemoveInclude(RelativePath path)
{
Include = Include.Where(p => p != path).ToArray();
}
#endregion #endregion
} }
} }

View File

@ -158,6 +158,20 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<StackPanel Orientation="Horizontal">
<Button Name="AddInclude">
<icon:Material Kind="Plus"></icon:Material>
</Button>
<Label>Include</Label>
</StackPanel>
<ListBox x:Name="Include">
<ListBox.ItemTemplate>
<DataTemplate>
<controls1:RemovableItemView ViewModel="{Binding}" ></controls1:RemovableItemView>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Button Name="AddOtherProfile"> <Button Name="AddOtherProfile">
<icon:Material Kind="Plus"></icon:Material> <icon:Material Kind="Plus"></icon:Material>

View File

@ -179,6 +179,14 @@ namespace Wabbajack
AddNoMatchInclude.Command = ReactiveCommand.CreateFromTask(async () => await AddNoMatchIncludeCommand()); AddNoMatchInclude.Command = ReactiveCommand.CreateFromTask(async () => await AddNoMatchIncludeCommand());
ViewModel.WhenAnyValue(vm => vm.Include)
.WhereNotNull()
.Select(itms => itms.Select(itm => new RemovableItemViewModel(itm.ToString(), () => ViewModel.RemoveInclude(itm))).ToArray())
.BindToStrict(this, view => view.Include.ItemsSource)
.DisposeWith(disposables);
AddInclude.Command = ReactiveCommand.CreateFromTask(async () => await AddIncludeCommand());
}); });
@ -262,7 +270,7 @@ namespace Wabbajack
{ {
var dlg = new CommonOpenFileDialog var dlg = new CommonOpenFileDialog
{ {
Title = "Please select a profile folder", Title = "Please select a folder",
IsFolderPicker = true, IsFolderPicker = true,
InitialDirectory = ViewModel!.Source.ToString(), InitialDirectory = ViewModel!.Source.ToString(),
AddToMostRecentlyUsedList = false, AddToMostRecentlyUsedList = false,
@ -283,5 +291,31 @@ namespace Wabbajack
ViewModel.AddNoMatchInclude(selectedPath.RelativeTo(ViewModel!.Source)); ViewModel.AddNoMatchInclude(selectedPath.RelativeTo(ViewModel!.Source));
} }
public async Task AddIncludeCommand()
{
var dlg = new CommonOpenFileDialog
{
Title = "Please select a",
IsFolderPicker = true,
InitialDirectory = ViewModel!.Source.ToString(),
AddToMostRecentlyUsedList = false,
AllowNonFileSystemItems = false,
DefaultDirectory = ViewModel!.Source.ToString(),
EnsureFileExists = true,
EnsurePathExists = true,
EnsureReadOnly = false,
EnsureValidNames = true,
Multiselect = false,
ShowPlacesList = true,
};
if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return;
var selectedPath = dlg.FileNames.First().ToAbsolutePath();
if (!selectedPath.InFolder(ViewModel.Source)) return;
ViewModel.AddInclude(selectedPath.RelativeTo(ViewModel!.Source));
}
} }
} }

View File

@ -77,7 +77,7 @@ public class DeconstructBSAs : ACompilationStep
var stack = defaultInclude ? _microstackWithInclude(source.File) : _microstack(source.File); var stack = defaultInclude ? _microstackWithInclude(source.File) : _microstack(source.File);
var id = Guid.NewGuid().ToString(); var id = Guid.NewGuid().ToString().ToRelativePath();
Func<Task>? _cleanup = null; Func<Task>? _cleanup = null;
@ -88,14 +88,14 @@ public class DeconstructBSAs : ACompilationStep
var matches = await sourceFiles.PMapAll(_compiler.CompilerLimiter, var matches = await sourceFiles.PMapAll(_compiler.CompilerLimiter,
e => _mo2Compiler.RunStack(stack, e => _mo2Compiler.RunStack(stack,
new RawSourceFile(e, Consts.BSACreationDir.Combine((RelativePath) id, (RelativePath) e.Name)))) new RawSourceFile(e, Consts.BSACreationDir.Combine(id, (RelativePath) e.Name))))
.ToList(); .ToList();
foreach (var match in matches) foreach (var match in matches)
{ {
if (match is IgnoredDirectly) if (match is IgnoredDirectly ignored)
throw new CompilerException($"File required for BSA {source.Path} creation doesn't exist: {match.To}"); throw new CompilerException($"File required for BSA {source.Path} creation doesn't exist: {match.To} reason {ignored.Reason}");
_mo2Compiler.ExtraFiles.Add(match); _mo2Compiler.ExtraFiles.Add(match);
} }

View File

@ -272,8 +272,6 @@ public class MO2Compiler : ACompiler
new IncludeModIniData(this), new IncludeModIniData(this),
new DirectMatch(this), new DirectMatch(this),
new IncludeTaggedFiles(this, Settings.Include), new IncludeTaggedFiles(this, Settings.Include),
// TODO: rework tagged files
// new IncludeTaggedFolders(this, Consts.WABBAJACK_INCLUDE),
new IgnoreExtension(this, Ext.Pyc), new IgnoreExtension(this, Ext.Pyc),
new IgnoreExtension(this, Ext.Log), new IgnoreExtension(this, Ext.Log),
new PatchStockGameFiles(this, _wjClient), new PatchStockGameFiles(this, _wjClient),

View File

@ -15,6 +15,18 @@ public static class ArrayExtensions
return true; return true;
} }
public static bool AreEqualIgnoreCase(string[] a, int startA, string[] b, int startB, int length)
{
if (startA + length > (a?.Length ?? 0)) return false;
if (startB + length > (b?.Length ?? 0)) return false;
for (var i = 0; i < length; i++)
if (!a[startA + i]!.Equals(b[startB + i], StringComparison.InvariantCultureIgnoreCase))
return false;
return true;
}
public static int Compare<T>(T[] a, T[] b) public static int Compare<T>(T[] a, T[] b)
where T : IComparable<T> where T : IComparable<T>
{ {

View File

@ -70,7 +70,7 @@ public struct RelativePath : IPath, IEquatable<RelativePath>, IComparable<Relati
public bool InFolder(RelativePath parent) public bool InFolder(RelativePath parent)
{ {
return ArrayExtensions.AreEqual(parent.Parts, 0, Parts, 0, parent.Parts.Length); return ArrayExtensions.AreEqualIgnoreCase(parent.Parts, 0, Parts, 0, parent.Parts.Length);
} }
public override string ToString() public override string ToString()