Skip to content

Commit

Permalink
Add filtering by result (win, loss, unfinished)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vermintide-Analytics committed Mar 19, 2023
1 parent d49598c commit 514ff8c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Vermintide Analyzer/Controls/FilterDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
AllValues="{Binding GameVersionValues}"
SelectionChanged="MultiSelectComboBox_SelectionChanged" />
</StackPanel>
<StackPanel Grid.Column="1">
<Label Content="Result" />
<local:MultiSelectComboBox x:Name="ResultDropdown"
ItemSource="{Binding RoundResultValues}"
Selected="{Binding RoundResultStrings}"
InitiallySelected="{Binding RoundResultValues}"
AllValues="{Binding RoundResultValues}"
SelectionChanged="MultiSelectComboBox_SelectionChanged" />
</StackPanel>
</Grid>
<Rectangle Margin="0,5" Height="2" Fill="{StaticResource ThemeMidtone}" />
<Grid Width="400" HorizontalAlignment="Left">
Expand Down
12 changes: 11 additions & 1 deletion Vermintide Analyzer/Controls/FilterDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public GameFilter Filter

public IEnumerable<string> SavedFilters => GameRepository.Instance.GameFilters.Keys.OrderBy(str => str);

public List<string> RoundResultStrings { get; set; } = new List<string>();
public List<string> CareerStrings { get; set; } = new List<string>();
public List<string> DifficultyStrings { get; set; } = new List<string>();
public List<string> MissionStrings { get; set; } = new List<string>();
Expand All @@ -56,6 +57,7 @@ public GameFilter Filter
public string MinutesString { get; set; } = "";

public List<string> GameVersionValues => GameRepository.Instance.GameVersions.ToList();
public List<string> RoundResultValues => GameFilter.FilterOptions(typeof(ROUND_RESULT)).ToList();
public List<string> CareerFilterValues => GameFilter.FilterOptions(typeof(CAREER)).ToList();
public List<string> DifficultyFilterValues => GameFilter.FilterOptions(typeof(DIFFICULTY)).ToList();
public List<string> MissionFilterValues => GameFilter.FilterOptions(typeof(MISSION)).ToList();
Expand Down Expand Up @@ -102,6 +104,7 @@ public void ResetFilter()
EmpoweredDropdown.SelectedItem = "Either";

GameVersionDropdown.ResetSelection();
ResultDropdown.ResetSelection();
DaysTextBox.Text = "";
MinutesTextBox.Text = "";
CareerDropdown.ResetSelection();
Expand All @@ -113,6 +116,7 @@ public void ResetFilter()
private void RefreshBindingLists()
{
GameVersionDropdown.SyncSelection(Filter.GameVersion.ToList());
ResultDropdown.SyncSelection(Filter.Result.Select(c => c.ForDisplay()).ToList());
CareerDropdown.SyncSelection(Filter.Career.Select(c => c.ForDisplay()).ToList());
DifficultyDropdown.SyncSelection(Filter.Difficulty.Select(d => d.ForDisplay()).ToList());
MissionDropdown.SyncSelection(Filter.Mission.Select(m => m.ForDisplay()).ToList());
Expand All @@ -124,6 +128,7 @@ public void RefreshDisplay()
RefreshBindingLists();

GameVersionDropdown.GetBindingExpression(MultiSelectComboBox.SelectedProperty).UpdateTarget();
ResultDropdown.GetBindingExpression(MultiSelectComboBox.SelectedProperty).UpdateTarget();
OlderYoungerComboBox.GetBindingExpression(ComboBox.SelectedItemProperty).UpdateTarget();
LongerShorterComboBox.GetBindingExpression(ComboBox.SelectedItemProperty).UpdateTarget();
DaysString = Filter.Days.HasValue ? Filter.Days.ToString() : "";
Expand All @@ -142,7 +147,12 @@ public void RefreshDisplay()

private void MultiSelectComboBox_SelectionChanged(MultiSelectComboBox source, List<string> newSelection)
{
if (source == CareerDropdown)
if(source == ResultDropdown)
{
Filter.Result.Clear();
Filter.Result.AddRange(RoundResultStrings.Select(str => str.FromDisplay<ROUND_RESULT>()));
}
else if (source == CareerDropdown)
{
Filter.Career.Clear();
Filter.Career.AddRange(CareerStrings.Select(str => str.FromDisplay<CAREER>()));
Expand Down
27 changes: 27 additions & 0 deletions Vermintide Analyzer/GameData/GameFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ public List<string> GameVersion
}
}

private List<ROUND_RESULT> mResult = new List<ROUND_RESULT>();
public List<ROUND_RESULT> Result
{
get => mResult;
set
{
mResult = value;
OnFilterChange?.Invoke(nameof(Result));
}
}

private List<DIFFICULTY> mDifficulty = new List<DIFFICULTY>();
public List<DIFFICULTY> Difficulty
{
Expand Down Expand Up @@ -136,6 +147,7 @@ public uint? Minutes

public bool IsMatch(GameHeader gh) =>
MatchGameVersion(gh) &&
MatchGameResult(gh) &&
MatchGameLength(gh) &&
MatchWithinDays(gh) &&
MatchDifficulty(gh) &&
Expand All @@ -146,6 +158,7 @@ public bool IsMatch(GameHeader gh) =>
MatchMission(gh);

private bool MatchGameVersion(GameHeader gh) => GameVersion.Contains(gh.GameVersion);
private bool MatchGameResult(GameHeader gh) => Result.Contains(gh.Result);
private bool MatchWithinDays(GameHeader gh)
{
if (!Days.HasValue || Days.Value == 0) return true;
Expand Down Expand Up @@ -189,6 +202,11 @@ public override string ToString()
{
output.Add(version);
}
var result = RoundResultToString();
if(result != null)
{
output.Add(result);
}
var diff = DifficultyToString();
if (diff != null)
{
Expand Down Expand Up @@ -246,6 +264,9 @@ public void UpdateFromString(string input)
GameVersion.Clear();
GameVersion.AddRange(ReadGameVersion(input));

Result.Clear();
Result.AddRange(ReadRoundResult(input));

(Longer, Minutes) = ReadMinutesLong(input) ?? (true, null);

(Older, Days) = ReadWithinDays(input) ?? (true, null);
Expand Down Expand Up @@ -274,6 +295,9 @@ private string GameVersionToString()

return $"Game Version in ({GetFilterSetString(GameVersion)})";
}

private string RoundResultToString() => EnumListToString(nameof(Result), Result);

private string MinutesLongToString()
{
if (!Minutes.HasValue) return null;
Expand Down Expand Up @@ -335,6 +359,9 @@ private static List<string> ReadGameVersion(string filterString)
}
return result;
}

private static List<ROUND_RESULT> ReadRoundResult(string filterString) => ReadEnumList<ROUND_RESULT>(filterString, nameof(Result));

private static (bool longer, uint? minutes)? ReadMinutesLong(string filterString)
{
var match = Regex.Match(filterString, $@"((?:Longer)|(?:Shorter)) than (\d+) Minutes");
Expand Down
4 changes: 2 additions & 2 deletions Vermintide Analyzer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.11.0")]
[assembly: AssemblyFileVersion("1.1.11.0")]
[assembly: AssemblyVersion("1.1.13.0")]
[assembly: AssemblyFileVersion("1.1.13.0")]

0 comments on commit 514ff8c

Please sign in to comment.