diff --git a/Compression.BSA/Compression.BSA.csproj b/Compression.BSA/Compression.BSA.csproj index 50859329..e9e33b40 100644 --- a/Compression.BSA/Compression.BSA.csproj +++ b/Compression.BSA/Compression.BSA.csproj @@ -10,7 +10,7 @@ - + diff --git a/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs b/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs index 4d0141a3..665be40d 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs @@ -1,58 +1,65 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Alphaleonis.Win32.Filesystem; -using Newtonsoft.Json; -using Wabbajack.Common; - -namespace Wabbajack.Lib.CompilationSteps -{ - public class IncludeThisProfile : ACompilationStep - { - private readonly IEnumerable _correctProfiles; - private MO2Compiler _mo2Compiler; - - public IncludeThisProfile(ACompiler compiler) : base(compiler) - { - _mo2Compiler = (MO2Compiler) compiler; - _correctProfiles = _mo2Compiler.SelectedProfiles.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList(); - } - - public override async ValueTask Run(RawSourceFile source) - { - if (!_correctProfiles.Any(p => source.AbsolutePath.InFolder(p))) - return null; - - var data = source.Path.FileName == Consts.ModListTxt - ? await ReadAndCleanModlist(source.AbsolutePath) - : await source.AbsolutePath.ReadAllBytesAsync(); - - var e = source.EvolveTo(); - e.SourceDataID = await _compiler.IncludeFile(data); - return e; - - } - - public override IState GetState() - { - return new State(); - } - - private static async Task ReadAndCleanModlist(AbsolutePath absolutePath) - { - var lines = await absolutePath.ReadAllLinesAsync(); - lines = lines.Where(line => !(line.StartsWith("-") && !line.EndsWith("_separator"))).ToArray(); - return Encoding.UTF8.GetBytes(string.Join("\r\n", lines)); - } - - [JsonObject("IncludeThisProfile")] - public class State : IState - { - public ICompilationStep CreateStep(ACompiler compiler) - { - return new IncludeThisProfile(compiler); - } - } - } -} +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Alphaleonis.Win32.Filesystem; +using Newtonsoft.Json; +using Wabbajack.Common; + +namespace Wabbajack.Lib.CompilationSteps +{ + public class IncludeThisProfile : ACompilationStep + { + private readonly IEnumerable _correctProfiles; + private MO2Compiler _mo2Compiler; + + public IncludeThisProfile(ACompiler compiler) : base(compiler) + { + _mo2Compiler = (MO2Compiler) compiler; + _correctProfiles = _mo2Compiler.SelectedProfiles.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList(); + } + + public override async ValueTask Run(RawSourceFile source) + { + if (!_correctProfiles.Any(p => source.AbsolutePath.InFolder(p))) + return null; + + var data = source.Path.FileName == Consts.ModListTxt + ? await ReadAndCleanModlist(source.AbsolutePath) + : await source.AbsolutePath.ReadAllBytesAsync(); + + var e = source.EvolveTo(); + e.SourceDataID = await _compiler.IncludeFile(data); + return e; + + } + + public override IState GetState() + { + return new State(); + } + + private async Task ReadAndCleanModlist(AbsolutePath absolutePath) + { + var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IgnoreDisabledMods.IsAlwaysEnabled(f.Value)) + .Select(f => f.Key) + .Distinct(); + var lines = (await absolutePath.ReadAllLinesAsync()).Where(l => + { + return l.StartsWith("+") + || alwaysEnabled.Any(x => x.Equals(l.Substring(1))) + || l.EndsWith("_separator"); + }).ToArray(); + return Encoding.UTF8.GetBytes(string.Join("\r\n", lines)); + } + + [JsonObject("IncludeThisProfile")] + public class State : IState + { + public ICompilationStep CreateStep(ACompiler compiler) + { + return new IncludeThisProfile(compiler); + } + } + } +} diff --git a/Wabbajack.Lib/Wabbajack.Lib.csproj b/Wabbajack.Lib/Wabbajack.Lib.csproj index 146bee3e..fe247e11 100644 --- a/Wabbajack.Lib/Wabbajack.Lib.csproj +++ b/Wabbajack.Lib/Wabbajack.Lib.csproj @@ -44,7 +44,7 @@ 0.25.0 - 1.7.0 + 1.7.1 4.7.0 @@ -65,7 +65,7 @@ 1.0.0 - 5.0.3 + 5.0.4 diff --git a/Wabbajack.Server/Wabbajack.Server.csproj b/Wabbajack.Server/Wabbajack.Server.csproj index 34a8fbe9..b68c97f0 100644 --- a/Wabbajack.Server/Wabbajack.Server.csproj +++ b/Wabbajack.Server/Wabbajack.Server.csproj @@ -18,7 +18,7 @@ - + diff --git a/Wabbajack.VirtualFileSystem/Wabbajack.VirtualFileSystem.csproj b/Wabbajack.VirtualFileSystem/Wabbajack.VirtualFileSystem.csproj index 1a2fe92d..238a9673 100644 --- a/Wabbajack.VirtualFileSystem/Wabbajack.VirtualFileSystem.csproj +++ b/Wabbajack.VirtualFileSystem/Wabbajack.VirtualFileSystem.csproj @@ -13,7 +13,7 @@ - + diff --git a/Wabbajack/Settings.cs b/Wabbajack/Settings.cs index 091f7f12..4987666f 100644 --- a/Wabbajack/Settings.cs +++ b/Wabbajack/Settings.cs @@ -21,6 +21,7 @@ namespace Wabbajack public double Height { get; set; } public double Width { get; set; } public InstallerSettings Installer { get; set; } = new InstallerSettings(); + public FiltersSettings Filters { get; set; } = new FiltersSettings(); public CompilerSettings Compiler { get; set; } = new CompilerSettings(); public PerformanceSettings Performance { get; set; } = new PerformanceSettings(); @@ -93,6 +94,18 @@ namespace Wabbajack public AbsolutePath OutputLocation { get; set; } public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings(); } + + [JsonName("FiltersSettings")] + [JsonObject(MemberSerialization.OptOut)] + public class FiltersSettings : ViewModel + { + public bool ShowNSFW { get; set; } + public bool OnlyInstalled { get; set; } + public string Game { get; set; } + public string Search { get; set; } + private bool _isPersistent = true; + public bool IsPersistent { get => _isPersistent; set => RaiseAndSetIfChanged(ref _isPersistent, value); } + } [JsonName("PerformanceSettings")] [JsonObject(MemberSerialization.OptOut)] diff --git a/Wabbajack/View Models/Gallery/ModListGalleryVM.cs b/Wabbajack/View Models/Gallery/ModListGalleryVM.cs index b153aea6..7d914fa8 100644 --- a/Wabbajack/View Models/Gallery/ModListGalleryVM.cs +++ b/Wabbajack/View Models/Gallery/ModListGalleryVM.cs @@ -26,8 +26,6 @@ namespace Wabbajack private const string ALL_GAME_TYPE = "All"; - public ICommand OnlyInstalledCheckedCommand { get; } - [Reactive] public IErrorResponse Error { get; set; } @@ -46,6 +44,9 @@ namespace Wabbajack public List GameTypeEntries { get { return GetGameTypeEntries(); } } private readonly ObservableAsPropertyHelper _Loaded; + + private FiltersSettings settings => MWVM.Settings.Filters; + public bool Loaded => _Loaded.Value; public ICommand ClearFiltersCommand { get; } @@ -54,7 +55,22 @@ namespace Wabbajack : base(mainWindowVM) { MWVM = mainWindowVM; - GameType = ALL_GAME_TYPE; + + // load persistent filter settings + if (settings.IsPersistent) + { + GameType = !string.IsNullOrEmpty(settings.Game) ? settings.Game : ALL_GAME_TYPE; + ShowNSFW = settings.ShowNSFW; + OnlyInstalled = settings.OnlyInstalled; + Search = settings.Search; + } + else + GameType = ALL_GAME_TYPE; + + // subscribe to save signal + MWVM.Settings.SaveSignal + .Subscribe(_ => UpdateFiltersSettings()) + .DisposeWith(this.CompositeDisposable); ClearFiltersCommand = ReactiveCommand.Create( () => @@ -65,6 +81,15 @@ namespace Wabbajack GameType = ALL_GAME_TYPE; }); + + this.WhenAny(x => x.OnlyInstalled) + .Subscribe(val => + { + if(val) + GameType = ALL_GAME_TYPE; + }) + .DisposeWith(CompositeDisposable); + var random = new Random(); var sourceList = Observable.Return(Unit.Default) .ObserveOn(RxApp.TaskpoolScheduler) @@ -98,11 +123,6 @@ namespace Wabbajack .Select(c => c > 0) .ToProperty(this, nameof(Loaded)); - OnlyInstalledCheckedCommand = ReactiveCommand.Create(() => - { - GameType = ALL_GAME_TYPE; - }); - // Convert to VM and bind to resulting list sourceList .ObserveOnGuiThread() @@ -137,7 +157,11 @@ namespace Wabbajack { if (GameType == ALL_GAME_TYPE) return true; - return GameType == EnumExtensions.GetDescription(vm.Metadata.Game).ToString(); + if (string.IsNullOrEmpty(GameType)) + return false; + + return GameType == vm.Metadata.Game.GetDescription().ToString(); + })) .Filter(this.WhenAny(x => x.ShowNSFW) .Select>(showNSFW => vm => @@ -171,11 +195,16 @@ namespace Wabbajack private List GetGameTypeEntries() { List gameEntries = new List { ALL_GAME_TYPE }; - foreach (var gameType in EnumExtensions.GetAllItems() ) - { - gameEntries.Add(EnumExtensions.GetDescription(gameType)); - } + gameEntries.AddRange(EnumExtensions.GetAllItems().Select(gameType => gameType.GetDescription())); return gameEntries; } + + private void UpdateFiltersSettings() + { + settings.Game = GameType; + settings.Search = Search; + settings.ShowNSFW = ShowNSFW; + settings.OnlyInstalled = OnlyInstalled; + } } } diff --git a/Wabbajack/View Models/Settings/SettingsVM.cs b/Wabbajack/View Models/Settings/SettingsVM.cs index 4175f7f2..b2b19344 100644 --- a/Wabbajack/View Models/Settings/SettingsVM.cs +++ b/Wabbajack/View Models/Settings/SettingsVM.cs @@ -13,7 +13,7 @@ namespace Wabbajack public MainWindowVM MWVM { get; } public LoginManagerVM Login { get; } public PerformanceSettings Performance { get; } - + public FiltersSettings Filters { get; } public AuthorFilesVM AuthorFile { get; } public SettingsVM(MainWindowVM mainWindowVM) @@ -23,6 +23,7 @@ namespace Wabbajack Login = new LoginManagerVM(this); Performance = mainWindowVM.Settings.Performance; AuthorFile = new AuthorFilesVM(this); + Filters = mainWindowVM.Settings.Filters; } } diff --git a/Wabbajack/Views/ModListGalleryView.xaml b/Wabbajack/Views/ModListGalleryView.xaml index af20b13d..75f252a6 100644 --- a/Wabbajack/Views/ModListGalleryView.xaml +++ b/Wabbajack/Views/ModListGalleryView.xaml @@ -108,6 +108,7 @@ ItemsSource="{Binding Path=GameTypeEntries}" SelectedItem="{Binding GameType, Mode=TwoWay}" ToolTip="Select a game" + IsEnabled="{Binding OnlyInstalled, Converter={StaticResource InverseBooleanConverter}}" Width="130" />