mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
added filter for games
This commit is contained in:
parent
bba92fd5a2
commit
17ca59d9d5
@ -34,10 +34,15 @@ namespace Wabbajack
|
||||
|
||||
[Reactive]
|
||||
public bool OnlyInstalled { get; set; }
|
||||
|
||||
|
||||
[Reactive]
|
||||
public bool ShowNSFW { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string GameType { get; set; }
|
||||
|
||||
public List<string> GameTypeEntries { get { return GetGameTypeEntries(); } }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<bool> _Loaded;
|
||||
public bool Loaded => _Loaded.Value;
|
||||
|
||||
@ -47,6 +52,7 @@ namespace Wabbajack
|
||||
: base(mainWindowVM)
|
||||
{
|
||||
MWVM = mainWindowVM;
|
||||
GameType = "All";
|
||||
|
||||
ClearFiltersCommand = ReactiveCommand.Create(
|
||||
() =>
|
||||
@ -54,6 +60,7 @@ namespace Wabbajack
|
||||
OnlyInstalled = false;
|
||||
ShowNSFW = false;
|
||||
Search = string.Empty;
|
||||
GameType = "All";
|
||||
});
|
||||
|
||||
var random = new Random();
|
||||
@ -116,6 +123,25 @@ namespace Wabbajack
|
||||
if (!vm.Metadata.NSFW) return true;
|
||||
return vm.Metadata.NSFW && showNSFW;
|
||||
}))
|
||||
// Filter by Game
|
||||
.Filter(this.WhenAny(x => x.GameType)
|
||||
.Debounce(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler)
|
||||
.Select<string, Func<ModListMetadataVM, bool>>(GameType => (vm) =>
|
||||
{
|
||||
if (Enum.TryParse(GameType, out Game gameFilter))
|
||||
{
|
||||
return gameFilter == vm.Metadata.Game;
|
||||
}
|
||||
else if (GameType == "All")
|
||||
return true;
|
||||
return false;
|
||||
}))
|
||||
.Filter(this.WhenAny(x => x.ShowNSFW)
|
||||
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
|
||||
{
|
||||
if (!vm.Metadata.NSFW) return true;
|
||||
return vm.Metadata.NSFW && showNSFW;
|
||||
}))
|
||||
// Put broken lists at bottom
|
||||
.Sort(Comparer<ModListMetadataVM>.Create((a, b) => a.IsBroken.CompareTo(b.IsBroken)))
|
||||
.Bind(ModLists)
|
||||
@ -138,5 +164,12 @@ namespace Wabbajack
|
||||
{
|
||||
Error = null;
|
||||
}
|
||||
|
||||
private List<string> GetGameTypeEntries()
|
||||
{
|
||||
List<string> gameEntries = new List<string> { "All" };
|
||||
gameEntries.AddRange(Enum.GetNames(typeof(Game)));
|
||||
return gameEntries;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
xmlns:rxui="http://reactiveui.net"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
d:DesignWidth="900"
|
||||
x:TypeArguments="local:ModListGalleryVM"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
@ -97,6 +97,18 @@
|
||||
Margin="5,5,5,10"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Label
|
||||
Margin="0,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Game" />
|
||||
<ComboBox
|
||||
Margin="0,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource ForegroundBrush}"
|
||||
ItemsSource="{Binding Path=GameTypeEntries}"
|
||||
SelectedItem="{Binding GameType, Mode=TwoWay}"
|
||||
ToolTip="Select a game"
|
||||
Width="130" />
|
||||
<TextBlock
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
@ -104,17 +116,17 @@
|
||||
Text="Search" />
|
||||
<TextBox
|
||||
x:Name="SearchBox"
|
||||
Width="160"
|
||||
Width="95"
|
||||
VerticalContentAlignment="Center" />
|
||||
<CheckBox
|
||||
x:Name="ShowNSFW"
|
||||
Margin="20,0,10,0"
|
||||
Margin="10,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Show NSFW"
|
||||
Foreground="{StaticResource ForegroundBrush}"/>
|
||||
<CheckBox
|
||||
x:Name="OnlyInstalledCheckbox"
|
||||
Margin="20,0,10,0"
|
||||
Margin="10,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Only Installed"
|
||||
Foreground="{StaticResource ForegroundBrush}" />
|
||||
@ -139,4 +151,4 @@
|
||||
<iconPacks:PackIconMaterial Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Kind="ArrowLeft" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</rxui:ReactiveUserControl>
|
||||
</rxui:ReactiveUserControl>
|
Loading…
Reference in New Issue
Block a user