mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Added persistent filters on exit and more
* Added persistent filters on exit * settings to disable the persistent filters * fixed a bug related to game comboBox and OnlyInstalled ( the comboBox is now disabled if OnlyInstalled is checked)
This commit is contained in:
parent
33c1de3ad3
commit
961fb39f9a
@ -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)]
|
||||
|
@ -24,6 +24,8 @@ namespace Wabbajack
|
||||
|
||||
public ObservableCollectionExtended<ModListMetadataVM> ModLists { get; } = new ObservableCollectionExtended<ModListMetadataVM>();
|
||||
|
||||
private FiltersSettings settings;
|
||||
|
||||
private int missingHashFallbackCounter;
|
||||
|
||||
private const string ALL_GAME_TYPE = "All";
|
||||
@ -44,6 +46,9 @@ namespace Wabbajack
|
||||
|
||||
[Reactive]
|
||||
public string GameType { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool GameTypeEnabled { get; set; }
|
||||
|
||||
public List<string> GameTypeEntries { get { return GetGameTypeEntries(); } }
|
||||
|
||||
@ -56,8 +61,22 @@ namespace Wabbajack
|
||||
: base(mainWindowVM)
|
||||
{
|
||||
MWVM = mainWindowVM;
|
||||
GameType = ALL_GAME_TYPE;
|
||||
GameTypeEnabled = true;
|
||||
|
||||
// load persistent filter settings
|
||||
settings = MWVM.Settings.Filters;
|
||||
if (settings.isPersistent)
|
||||
{
|
||||
GameType = !string.IsNullOrEmpty(settings.Game) ? settings.Game : ALL_GAME_TYPE;
|
||||
ShowNSFW = settings.showNSFW;
|
||||
OnlyInstalled = settings.OnlyInstalled;
|
||||
if (OnlyInstalled)
|
||||
GameTypeEnabled = false;
|
||||
Search = settings.Search;
|
||||
}
|
||||
else
|
||||
GameType = ALL_GAME_TYPE;
|
||||
|
||||
ClearFiltersCommand = ReactiveCommand.Create(
|
||||
() =>
|
||||
{
|
||||
@ -65,6 +84,8 @@ namespace Wabbajack
|
||||
ShowNSFW = false;
|
||||
Search = string.Empty;
|
||||
GameType = ALL_GAME_TYPE;
|
||||
GameTypeEnabled = true;
|
||||
UpdateFiltersSettings();
|
||||
});
|
||||
|
||||
var random = new Random();
|
||||
@ -102,7 +123,13 @@ namespace Wabbajack
|
||||
|
||||
OnlyInstalledCheckedCommand = ReactiveCommand.Create(() =>
|
||||
{
|
||||
GameType = ALL_GAME_TYPE;
|
||||
if (OnlyInstalled)
|
||||
{
|
||||
GameType = ALL_GAME_TYPE;
|
||||
GameTypeEnabled = false;
|
||||
}
|
||||
else
|
||||
GameTypeEnabled = true;
|
||||
});
|
||||
|
||||
// Convert to VM and bind to resulting list
|
||||
@ -114,6 +141,7 @@ namespace Wabbajack
|
||||
.Filter(this.WhenAny(x => x.OnlyInstalled)
|
||||
.Select<bool, Func<ModListMetadataVM, bool>>(onlyInstalled => (vm) =>
|
||||
{
|
||||
UpdateFiltersSettings();
|
||||
if (!onlyInstalled) return true;
|
||||
if (!GameRegistry.Games.TryGetValue(vm.Metadata.Game, out var gameMeta)) return false;
|
||||
return gameMeta.IsInstalled;
|
||||
@ -124,11 +152,13 @@ namespace Wabbajack
|
||||
.Select<string, Func<ModListMetadataVM, bool>>(search => (vm) =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(search)) return true;
|
||||
UpdateFiltersSettings();
|
||||
return vm.Metadata.Title.ContainsCaseInsensitive(search);
|
||||
}))
|
||||
.Filter(this.WhenAny(x => x.ShowNSFW)
|
||||
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
|
||||
{
|
||||
UpdateFiltersSettings();
|
||||
if (!vm.Metadata.NSFW) return true;
|
||||
return vm.Metadata.NSFW && showNSFW;
|
||||
}))
|
||||
@ -139,11 +169,17 @@ namespace Wabbajack
|
||||
{
|
||||
if (GameType == ALL_GAME_TYPE)
|
||||
return true;
|
||||
return GameType == EnumExtensions.GetDescription<Game>(vm.Metadata.Game).ToString();
|
||||
if (string.IsNullOrEmpty(GameType))
|
||||
return false;
|
||||
|
||||
UpdateFiltersSettings();
|
||||
return GameType == vm.Metadata.Game.GetDescription<Game>().ToString();
|
||||
|
||||
}))
|
||||
.Filter(this.WhenAny(x => x.ShowNSFW)
|
||||
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
|
||||
{
|
||||
UpdateFiltersSettings();
|
||||
if (!vm.Metadata.NSFW) return true;
|
||||
return vm.Metadata.NSFW && showNSFW;
|
||||
}))
|
||||
@ -173,11 +209,20 @@ namespace Wabbajack
|
||||
private List<string> GetGameTypeEntries()
|
||||
{
|
||||
List<string> gameEntries = new List<string> { ALL_GAME_TYPE };
|
||||
foreach (var gameType in EnumExtensions.GetAllItems<Game>() )
|
||||
{
|
||||
gameEntries.Add(EnumExtensions.GetDescription<Game>(gameType));
|
||||
}
|
||||
gameEntries.AddRange(EnumExtensions.GetAllItems<Game>().Select(gameType => gameType.GetDescription<Game>()));
|
||||
return gameEntries;
|
||||
}
|
||||
|
||||
private void UpdateFiltersSettings()
|
||||
{
|
||||
if (!settings.isPersistent)
|
||||
return;
|
||||
if (!string.IsNullOrEmpty(GameType))
|
||||
settings.Game = GameType;
|
||||
if (Search != null)
|
||||
settings.Search = Search;
|
||||
settings.showNSFW = ShowNSFW;
|
||||
settings.OnlyInstalled = OnlyInstalled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -108,6 +108,7 @@
|
||||
ItemsSource="{Binding Path=GameTypeEntries}"
|
||||
SelectedItem="{Binding GameType, Mode=TwoWay}"
|
||||
ToolTip="Select a game"
|
||||
IsEnabled="{Binding GameTypeEnabled}"
|
||||
Width="130" />
|
||||
<TextBlock
|
||||
Margin="0,0,5,0"
|
||||
|
65
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml
Normal file
65
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml
Normal file
@ -0,0 +1,65 @@
|
||||
<rxui:ReactiveUserControl
|
||||
x:Class="Wabbajack.ModlistGallerySettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:rxui="http://reactiveui.net"
|
||||
xmlns:xwpf="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:TypeArguments="local:FiltersSettings"
|
||||
mc:Ignorable="d">
|
||||
<Border
|
||||
x:Name="PerformanceView"
|
||||
MinWidth="280"
|
||||
Margin="5"
|
||||
Background="{StaticResource BackgroundBrush}"
|
||||
BorderBrush="{StaticResource ButtonNormalBorder}"
|
||||
BorderThickness="1">
|
||||
<Grid Margin="15,10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="25" />
|
||||
<RowDefinition Height="25" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Text="Modlist Gallery" />
|
||||
<Grid
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3">
|
||||
<Grid.Resources>
|
||||
<Style BasedOn="{StaticResource MainButtonStyle}" TargetType="Button">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
|
||||
<Setter Property="Background" Value="{StaticResource SecondaryBackgroundBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{StaticResource DarkSecondaryBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<CheckBox Name="FilterPersistCheckBox" Content="Filters are saved on exit" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top">
|
||||
<CheckBox.LayoutTransform>
|
||||
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
|
||||
</CheckBox.LayoutTransform>
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</rxui:ReactiveUserControl>
|
39
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs
Normal file
39
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ModlistGallerySettingsView.xaml
|
||||
/// </summary>
|
||||
public partial class ModlistGallerySettingsView : ReactiveUserControl<FiltersSettings>
|
||||
{
|
||||
public ModlistGallerySettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.WhenActivated(disposable =>
|
||||
{
|
||||
// Bind Values
|
||||
this.Bind(this.ViewModel, x => x.isPersistent, x => x.FilterPersistCheckBox.IsChecked)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@
|
||||
<WrapPanel>
|
||||
<local:LoginSettingsView x:Name="LoginView" />
|
||||
<local:PerformanceSettingsView x:Name="PerformanceView" />
|
||||
<local:ModlistGallerySettingsView x:Name="ModlistGalleryView" />
|
||||
<local:AuthorFilesView x:Name="AuthorFilesView"></local:AuthorFilesView>
|
||||
</WrapPanel>
|
||||
</ScrollViewer>
|
||||
|
@ -34,6 +34,8 @@ namespace Wabbajack
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBindStrict(this.ViewModel, x => x.Performance, x => x.PerformanceView.ViewModel)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBindStrict(this.ViewModel, x => x.Filters, x => x.ModlistGalleryView.ViewModel)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user