Skip to content

Commit

Permalink
AddedVQ3/CPM Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
netquick committed Aug 19, 2024
1 parent d7e01d3 commit e55d4df
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
2 changes: 0 additions & 2 deletions DeFRaG_Helper/ToDo.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
- Search -> v1.>0
- Language -> v1.>0
- Edit maps -> v1.>0
- Config editor -> v1.>0
- Records -> v1.>0

- clear filters
- auto record
- personal best (playername)

Expand Down
35 changes: 32 additions & 3 deletions DeFRaG_Helper/ViewModels/MapViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class MapViewModel : INotifyPropertyChanged
public event EventHandler MapsBatchLoaded;
public ObservableCollection<Map> Maps { get; set; }
private static readonly object _lock = new object();

private bool _showVQ3;
private bool _showCPM;
public List<Map> FilteredMaps { get; private set; }

private bool dataLoaded = false;
Expand Down Expand Up @@ -52,6 +53,8 @@ private void ClearFilters(object parameter)
ShowFavorites = false;
ShowInstalled = false;
ShowDownloaded = false;
ShowVQ3 = false;
ShowCPM = false;
SelectedTags.Clear();
TagBarViewModel.Instance.ClearSelectedTags();

Expand Down Expand Up @@ -185,7 +188,11 @@ await Task.Run(() =>
map.Weapons.Contains(tag) ||
map.Items.Contains(tag) ||
map.Functions.Contains(tag) ||
map.Tags.Contains(tag)))
map.Tags.Contains(tag))) &&
(!ShowVQ3 && !ShowCPM || // If neither VQ3 nor CPM is selected, include all maps
(ShowVQ3 && (map.Physics == 1 || map.Physics == 3)) || // Include VQ3 maps
(ShowCPM && (map.Physics == 2 || map.Physics == 3)) // Include CPM maps
)
).OrderByDescending(map => map.Releasedate).ToList();
}

Expand Down Expand Up @@ -218,6 +225,9 @@ await Task.Run(() =>






public void LoadDisplayedMapsSubset(List<Map> sourceMaps, int startIndex, int count)
{
for (int i = startIndex; i < Math.Min(startIndex + count, sourceMaps.Count); i++)
Expand All @@ -236,7 +246,26 @@ public void LoadDisplayedMapsSubset(List<Map> sourceMaps, int startIndex, int co




public bool ShowVQ3
{
get => _showVQ3;
set
{
_showVQ3 = value;
OnPropertyChanged(nameof(ShowVQ3));
ApplyFilters();
}
}
public bool ShowCPM
{
get => _showCPM;
set
{
_showCPM = value;
OnPropertyChanged(nameof(ShowCPM));
ApplyFilters();
}
}



Expand Down
16 changes: 10 additions & 6 deletions DeFRaG_Helper/Views/Maps.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox Name="chkFavorite" Content="Favorites" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Grid.Column="0" IsChecked="{Binding ShowFavorites, Mode=TwoWay}" />
<CheckBox Name="chkInstalled" Content="Installed" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="1" IsChecked="{Binding ShowInstalled, Mode=TwoWay}" />
<CheckBox Name="chkDownloaded" Content="Downloaded" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="2" IsChecked="{Binding ShowDownloaded, Mode=TwoWay}" />
<TextBox Name="searchBar" Grid.Column="3" VerticalAlignment="Center" FontSize="20" Margin="10,0,10,0" Width="340" Height="34" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<Button Name="btnClear" Padding="10, 0" Height="32" Grid.Column="4" Content="Clear filter" Command="{Binding ClearFiltersCommand}"/>
<Label Name="lblCount" Grid.Column="5" Content="{Binding FilteredMapsCount}" Foreground="White" VerticalAlignment="Center" FontSize="20" Margin="0, 0, 20, 0" Width="100" HorizontalAlignment="Right" HorizontalContentAlignment="Right"/>
<CheckBox Name="chkFavorite" Content="Favorites" FontSize="10" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Grid.Column="0" IsChecked="{Binding ShowFavorites, Mode=TwoWay}" />
<CheckBox Name="chkInstalled" Content="Installed" FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="1" IsChecked="{Binding ShowInstalled, Mode=TwoWay}" />
<CheckBox Name="chkDownloaded" Content="Downloaded" FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="2" IsChecked="{Binding ShowDownloaded, Mode=TwoWay}" />
<CheckBox Name="chkVQ3" Content="VQ3" FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="3" IsChecked="{Binding ShowVQ3, Mode=TwoWay}"/>
<CheckBox Name="chkCPM" Content="CPM" FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,10,0" Grid.Column="4" IsChecked="{Binding ShowCPM, Mode=TwoWay}"/>
<TextBox Name="searchBar" Grid.Column="5" VerticalAlignment="Center" FontSize="20" Margin="10,0,10,0" Width="280" Height="34" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<Button Name="btnClear" Padding="10, 0" Height="32" Grid.Column="6" Content="Clear filter" Command="{Binding ClearFiltersCommand}"/>
<Label Name="lblCount" Grid.Column="7" Content="{Binding FilteredMapsCount}" Foreground="White" VerticalAlignment="Center" FontSize="20" Margin="0, 0, 20, 0" Width="100" HorizontalAlignment="Right" HorizontalContentAlignment="Right"/>
</Grid>
</Border>

Expand Down

0 comments on commit e55d4df

Please sign in to comment.