diff --git a/Wabbajack.App/Screens/CompilerConfigurationView.axaml b/Wabbajack.App/Screens/CompilerConfigurationView.axaml index 470eb86a..8c6de53c 100644 --- a/Wabbajack.App/Screens/CompilerConfigurationView.axaml +++ b/Wabbajack.App/Screens/CompilerConfigurationView.axaml @@ -8,7 +8,7 @@ x:Class="Wabbajack.App.Screens.CompilerConfigurationView"> Compiler Configuration - @@ -29,9 +29,28 @@ - - + + + + + + + + + + + + + + + + + + + @@ -48,6 +67,8 @@ + + diff --git a/Wabbajack.App/Screens/CompilerConfigurationView.axaml.cs b/Wabbajack.App/Screens/CompilerConfigurationView.axaml.cs index 191ee1a5..64cc85dd 100644 --- a/Wabbajack.App/Screens/CompilerConfigurationView.axaml.cs +++ b/Wabbajack.App/Screens/CompilerConfigurationView.axaml.cs @@ -20,6 +20,7 @@ public partial class CompilerConfigurationView : ScreenBase AddAlwaysEnabled_Command().FireAndForget()); + AddOtherProfile.Command = ReactiveCommand.Create(() => AddOtherProfile_Command().FireAndForget()); this.WhenActivated(disposables => { @@ -54,8 +55,27 @@ public partial class CompilerConfigurationView : ScreenBase { ViewModel?.RemoveAlwaysExcluded(itm); }) })) .DisposeWith(disposables); + + this.OneWayBind(ViewModel, vm => vm.OtherProfiles, view => view.OtherProfilesList.Items, + d => d!.Select(itm => new RemovableItemViewModel + { + Text = itm.ToString(), + DeleteCommand = ReactiveCommand.Create(() => { ViewModel?.RemoveOtherProfile(itm); }) + })) + .DisposeWith(disposables); }); } + + private async Task AddOtherProfile_Command() + { + var dialog = new OpenFolderDialog + { + Title = "Select a profile folder" + }; + var result = await dialog.ShowAsync(App.MainWindow); + if (!string.IsNullOrWhiteSpace(result)) + ViewModel!.AddOtherProfile(result.ToAbsolutePath()); + } private async Task AddAlwaysEnabled_Command() { diff --git a/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs b/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs index b60850f6..e4ffb383 100644 --- a/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs +++ b/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs @@ -71,6 +71,9 @@ public class CompilerConfigurationViewModel : ViewModelBase [Reactive] public IEnumerable AlwaysEnabled { get; set; } = Array.Empty(); + [Reactive] + public string[] OtherProfiles { get; set; } = Array.Empty(); + public AbsolutePath SettingsOutputLocation => Source.Combine(Title) .WithExtension(IsMO2Compilation ? Ext.MO2CompilerSettings : Ext.CompilerSettings); @@ -109,10 +112,24 @@ public class CompilerConfigurationViewModel : ViewModelBase Profile = SelectedProfile, UseGamePaths = true, OutputFile = OutputFolder.Combine(SelectedProfile).WithExtension(Ext.Wabbajack), - AlwaysEnabled = AlwaysEnabled.ToArray() + AlwaysEnabled = AlwaysEnabled.ToArray(), + OtherProfiles = OtherProfiles.ToArray() }; } + public bool AddOtherProfile(AbsolutePath path) + { + if (!path.InFolder(Source.Combine(Consts.MO2Profiles))) return false; + var relative = path.RelativeTo(Source.Combine(Consts.MO2Profiles)).ToString(); + OtherProfiles = OtherProfiles.Append(relative).Distinct().ToArray(); + return true; + } + + public void RemoveOtherProfile(string profile) + { + OtherProfiles = OtherProfiles.Where(p => p != profile).ToArray(); + } + public bool AddAlwaysExcluded(AbsolutePath path) { if (!path.InFolder(Source)) return false; @@ -150,6 +167,8 @@ public class CompilerConfigurationViewModel : ViewModelBase IsMO2Compilation = true; + + AlwaysEnabled = Array.Empty(); // Find Always Enabled mods foreach (var modFolder in mo2Folder.Combine("mods").EnumerateDirectories()) { @@ -158,12 +177,17 @@ public class CompilerConfigurationViewModel : ViewModelBase var data = iniFile.LoadIniFile(); var generalModData = data["General"]; - AlwaysEnabled = Array.Empty(); if ((generalModData["notes"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false) || (generalModData["comments"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false)) AlwaysEnabled = AlwaysEnabled.Append(modFolder.RelativeTo(mo2Folder)).ToArray(); } + var otherProfilesFile = settingsFile.Parent.Combine("otherprofiles.txt"); + if (otherProfilesFile.FileExists()) + { + OtherProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray(); + } + if (mo2Folder.Depth > 1) OutputFolder = mo2Folder.Parent; @@ -173,6 +197,8 @@ public class CompilerConfigurationViewModel : ViewModelBase } } + + private async Task SaveSettingsFile() { await using var st = SettingsOutputLocation.Open(FileMode.Create, FileAccess.Write, FileShare.None); @@ -189,6 +215,7 @@ public class CompilerConfigurationViewModel : ViewModelBase { var mo2 = await LoadSettingsFile(path); AlwaysEnabled = mo2.AlwaysEnabled; + OtherProfiles = mo2.OtherProfiles; SelectedProfile = mo2.Profile; s = mo2; } diff --git a/Wabbajack.Compiler/MO2CompilerSettings.cs b/Wabbajack.Compiler/MO2CompilerSettings.cs index 2a3bed7c..ce3ac65d 100644 --- a/Wabbajack.Compiler/MO2CompilerSettings.cs +++ b/Wabbajack.Compiler/MO2CompilerSettings.cs @@ -7,4 +7,5 @@ public class MO2CompilerSettings : CompilerSettings { public string Profile { get; set; } = ""; public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty(); + public string[] OtherProfiles { get; set; } } \ No newline at end of file