Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
added four new toggleable columns that summarize multiple columns in …
Browse files Browse the repository at this point in the history
…order to improve readability
  • Loading branch information
slimDebug committed Jul 24, 2022
1 parent a112d63 commit dc4f896
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 5 deletions.
14 changes: 13 additions & 1 deletion HuntMmrReader/Enums/PlayerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,21 @@ internal enum PlayerOptions
///<summary>This should be a bool.</summary>
[Description("teamextraction")] TeamExtraction = 2097152,

///<summary>This should be a ulong.</summary>
OverallKilledByMe = 4194304,

///<summary>This should be a ulong.</summary>
OverallKilledByTeammate = 8388608,

///<summary>This should be a ulong.</summary>
OverallKilledMe = 16777216,

///<summary>This should be a ulong.</summary>
OverallKilledTeammate = 33554432,

///<summary>All values combined.</summary>
All = BloodLineName | BountyExtracted | BountyPickedUp | DownedByMe | DownedByTeammate | DownedMe | DownedTeammate |
HadWellspring | HadBounty | IsPartner | IsSoulSurvivor | KilledByMe | KilledByTeammate | KilledMe |
KilledTeammate | Mmr | ProfileId | Proximity | ProximityToMe | ProximityToTeammate | SkillBased |
TeamExtraction
TeamExtraction | OverallKilledByMe | OverallKilledByTeammate | OverallKilledMe | OverallKilledTeammate
}
4 changes: 2 additions & 2 deletions HuntMmrReader/HuntMmrReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<AssemblyVersion>1.3.2.0</AssemblyVersion>
<FileVersion>1.3.2.0</FileVersion>
<AssemblyVersion>1.3.3.0</AssemblyVersion>
<FileVersion>1.3.3.0</FileVersion>
<PackageReadmeFile></PackageReadmeFile>
<RepositoryUrl></RepositoryUrl>
</PropertyGroup>
Expand Down
4 changes: 4 additions & 0 deletions HuntMmrReader/Models/HuntPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public HuntPlayer(ushort id, string? mmr, string? bloodLineName, string? bountyE
public bool ProximityToTeammate { get; }
public bool SkillBased { get; }
public bool TeamExtraction { get; }
public ushort OverallKilledByMe => (ushort) (DownedByMe + KilledByMe);
public ushort OverallKilledByTeammate => (ushort) (KilledByTeammate + DownedByTeammate);
public ushort OverallKilledMe => (ushort) (KilledMe + DownedMe);
public ushort OverallKilledTeammate => (ushort) (KilledTeammate + DownedTeammate);

public override string ToString()
{
Expand Down
86 changes: 85 additions & 1 deletion HuntMmrReader/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
Expand Down Expand Up @@ -126,12 +127,95 @@ private void LoadSettings()
}
catch
{
FilePath = "";
FilePath = string.Empty;
_displayOptions = PlayerOptions.None;
}
}

private void HandleOption(PlayerOptions option)
{
switch (option)
{
case PlayerOptions.None:
case PlayerOptions.All:
DisplayOptions = option;
break;
case PlayerOptions.BloodLineName:
case PlayerOptions.BountyExtracted:
case PlayerOptions.BountyPickedUp:
case PlayerOptions.HadWellspring:
case PlayerOptions.HadBounty:
case PlayerOptions.IsPartner:
case PlayerOptions.IsSoulSurvivor:
case PlayerOptions.Mmr:
case PlayerOptions.ProfileId:
case PlayerOptions.Proximity:
case PlayerOptions.ProximityToMe:
case PlayerOptions.ProximityToTeammate:
case PlayerOptions.SkillBased:
case PlayerOptions.TeamExtraction:
ToggleOption(option);
break;
// OverallKilledByMe option handling
case PlayerOptions.DownedByMe:
case PlayerOptions.KilledByMe:
if (DisplayOptions.HasFlag(PlayerOptions.OverallKilledByMe))
DisplayOptions &= ~PlayerOptions.OverallKilledByMe;
ToggleOption(option);
break;
case PlayerOptions.OverallKilledByMe:
foreach (var opt in new[] {PlayerOptions.DownedByMe, PlayerOptions.KilledByMe})
if (DisplayOptions.HasFlag(opt))
DisplayOptions &= ~opt;
ToggleOption(option);
break;
// OverallKilledByTeammate option handling
case PlayerOptions.DownedByTeammate:
case PlayerOptions.KilledByTeammate:
if (DisplayOptions.HasFlag(PlayerOptions.OverallKilledByTeammate))
DisplayOptions &= ~PlayerOptions.OverallKilledByTeammate;
ToggleOption(option);
break;
case PlayerOptions.OverallKilledByTeammate:
foreach (var opt in new[] {PlayerOptions.DownedByTeammate, PlayerOptions.KilledByTeammate})
if (DisplayOptions.HasFlag(opt))
DisplayOptions &= ~opt;
ToggleOption(option);
break;
// OverallKilledMe option handling
case PlayerOptions.DownedMe:
case PlayerOptions.KilledMe:
if (DisplayOptions.HasFlag(PlayerOptions.OverallKilledMe))
DisplayOptions &= ~PlayerOptions.OverallKilledMe;
ToggleOption(option);
break;
case PlayerOptions.OverallKilledMe:
foreach (var opt in new[] {PlayerOptions.DownedMe, PlayerOptions.KilledMe})
if (DisplayOptions.HasFlag(opt))
DisplayOptions &= ~opt;
ToggleOption(option);
break;
// OverallKilledTeammate option handling
case PlayerOptions.DownedTeammate:
case PlayerOptions.KilledTeammate:
if (DisplayOptions.HasFlag(PlayerOptions.OverallKilledTeammate))
DisplayOptions &= ~PlayerOptions.OverallKilledTeammate;
ToggleOption(option);
break;
case PlayerOptions.OverallKilledTeammate:
foreach (var opt in new[] {PlayerOptions.DownedTeammate, PlayerOptions.KilledTeammate})
if (DisplayOptions.HasFlag(opt))
DisplayOptions &= ~opt;
ToggleOption(option);
break;
default:
AddException(new ArgumentOutOfRangeException(nameof(option), option,
$"{((int) option).ToString(CultureInfo.InvariantCulture)} is not a valid {nameof(option)} value."));
break;
}
}

private void ToggleOption(PlayerOptions option)
{
if (DisplayOptions.HasFlag(option))
DisplayOptions &= ~option;
Expand Down
37 changes: 36 additions & 1 deletion HuntMmrReader/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@
<MenuItem Header="_MMR" x:Name="MmrOption" Command="{Binding SetUnsetDisplayOptionsCommand}"
CommandParameter="{x:Static enums:PlayerOptions.Mmr}" StaysOpenOnClick="True"
IsChecked="{Binding DisplayOptions, Converter={StaticResource PlayerOptionsToBooleanConverter}, ConverterParameter={x:Static enums:PlayerOptions.Mmr}, Mode=OneWay}" />
<MenuItem Header="_Overall Killed By Me" x:Name="OverallKilledByMeOption" FontStyle="Italic"
Command="{Binding SetUnsetDisplayOptionsCommand}"
CommandParameter="{x:Static enums:PlayerOptions.OverallKilledByMe}" StaysOpenOnClick="True"
IsChecked="{Binding DisplayOptions, Converter={StaticResource PlayerOptionsToBooleanConverter}, ConverterParameter={x:Static enums:PlayerOptions.OverallKilledByMe}, Mode=OneWay}" />
<MenuItem Header="_Overall Killed By Teammate" x:Name="OverallKilledByTeammateOption"
FontStyle="Italic"
Command="{Binding SetUnsetDisplayOptionsCommand}"
CommandParameter="{x:Static enums:PlayerOptions.OverallKilledByTeammate}"
StaysOpenOnClick="True"
IsChecked="{Binding DisplayOptions, Converter={StaticResource PlayerOptionsToBooleanConverter}, ConverterParameter={x:Static enums:PlayerOptions.OverallKilledByTeammate}, Mode=OneWay}" />
<MenuItem Header="_Overall Killed Me" x:Name="OverallKilledMeOption" FontStyle="Italic"
Command="{Binding SetUnsetDisplayOptionsCommand}"
CommandParameter="{x:Static enums:PlayerOptions.OverallKilledMe}" StaysOpenOnClick="True"
IsChecked="{Binding DisplayOptions, Converter={StaticResource PlayerOptionsToBooleanConverter}, ConverterParameter={x:Static enums:PlayerOptions.OverallKilledMe}, Mode=OneWay}" />
<MenuItem Header="_Overall Killed Teammate" x:Name="OverallKilledTeammateOption" FontStyle="Italic"
Command="{Binding SetUnsetDisplayOptionsCommand}"
CommandParameter="{x:Static enums:PlayerOptions.OverallKilledTeammate}"
StaysOpenOnClick="True"
IsChecked="{Binding DisplayOptions, Converter={StaticResource PlayerOptionsToBooleanConverter}, ConverterParameter={x:Static enums:PlayerOptions.OverallKilledTeammate}, Mode=OneWay}" />
<MenuItem Header="_Bounty Extracted" x:Name="BountyExtractedOption"
Command="{Binding SetUnsetDisplayOptionsCommand}"
CommandParameter="{x:Static enums:PlayerOptions.BountyExtracted}" StaysOpenOnClick="True"
Expand Down Expand Up @@ -275,7 +294,7 @@
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding BloodLineName}" Width="*"
<DataGridTextColumn Header="Name" Binding="{Binding BloodLineName}" Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference BloodLineNameOption}}" />
<DataGridTemplateColumn Header="MMR" Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference MmrOption}}">
Expand Down Expand Up @@ -346,16 +365,32 @@
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Overall killed by me X times"
Binding="{Binding OverallKilledByMe}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference OverallKilledByMeOption}}" />
<DataGridTextColumn Header="Downed by me X times" Binding="{Binding DownedByMe}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference DownedByMeOption}}" />
<DataGridTextColumn Header="Overall killed by teammate X times"
Binding="{Binding OverallKilledByTeammate}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference OverallKilledByTeammateOption}}" />
<DataGridTextColumn Header="Downed by teammate X times"
Binding="{Binding DownedByTeammate}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference DownedByTeammateOption}}" />
<DataGridTextColumn Header="Overall killed me X times"
Binding="{Binding OverallKilledMe}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference OverallKilledMeOption}}" />
<DataGridTextColumn Header="Downed me X times" Binding="{Binding DownedMe}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference DownedMeOption}}" />
<DataGridTextColumn Header="Overall killed teammate X times"
Binding="{Binding OverallKilledTeammate}"
Width="Auto"
Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Reference OverallKilledTeammateOption}}" />
<DataGridTextColumn Header="Downed teammate X times"
Binding="{Binding DownedTeammate}"
Width="Auto"
Expand Down

0 comments on commit dc4f896

Please sign in to comment.