Skip to content

Commit

Permalink
small update to dps window
Browse files Browse the repository at this point in the history
  • Loading branch information
smasherprog committed Dec 20, 2022
1 parent 2591938 commit 9f6e1dd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
40 changes: 25 additions & 15 deletions src/DPSMeter.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,43 @@
</Border>
<Grid Grid.Row="1" Background="LightGray">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="190" />
<ColumnDefinition Width="210" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Left" Grid.Column="0" FontWeight="Bold" Text="Source" ToolTip="The NPC/PC who is Dealing the damage" />
<TextBlock HorizontalAlignment="Left" Grid.Column="1" FontWeight="Bold" Text="DPS" ToolTip="Average DPS over the last 12 second window" />
<TextBlock HorizontalAlignment="Left" Grid.Column="2" FontWeight="Bold" Text="Biggest" ToolTip="Biggest single hit!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="3" FontWeight="Bold" Text="12s Dmg" ToolTip="Highest 12 second period of Damage dealt. This is good for gauging how many are required in a CH chain!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="4" FontWeight="Bold" Text="Dmg" ToolTip="Total Damage done!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="1" FontWeight="Bold" Text="12s DPS" ToolTip="Average DPS over the last 12 second window" />
<TextBlock HorizontalAlignment="Left" Grid.Column="2" FontWeight="Bold" Text="12s Dmg" ToolTip="Highest 12 second period of Damage dealt. This is good for gauging how many are required in a CH chain!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="3" FontWeight="Bold" Text="Biggest" ToolTip="Biggest single hit!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="4" FontWeight="Bold" Text="% of DMG" ToolTip="Percent of Total Damage!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="5" FontWeight="Bold" Text="DPS" ToolTip="Total DPS!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="6" FontWeight="Bold" Text="DMG" ToolTip="Total Damage done!" />
</Grid>
<ListView Name="DpsList" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" Grid.Row="2" Background="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="190" />
<ColumnDefinition Width="210" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<ProgressBar Grid.Column="0" Grid.ColumnSpan="5" Value="{Binding PercentOfTotalDamage}" Maximum="100" Foreground="{Binding ProgressBarColor}" />
<TextBlock HorizontalAlignment="Stretch" Margin="10,0,0,0" Grid.Column="0" FontWeight="Bold" Text="{Binding SourceName}" ToolTip="The NPC/PC who is Dealing the damage" />
<ProgressBar Grid.Column="0" Grid.ColumnSpan="7" Value="{Binding PercentOfTotalDamage}" Maximum="100" Foreground="{Binding ProgressBarColor}" />
<TextBlock HorizontalAlignment="Stretch" Margin="10,0,0,0" Grid.Column="0" FontWeight="Bold" Text="{Binding SourceName_and_Info}" ToolTip="The NPC/PC who is Dealing the damage" />
<TextBlock HorizontalAlignment="Left" Grid.Column="1" FontWeight="Bold" Text="{Binding DPS}" ToolTip="Average DPS over the last 12 second window" />
<TextBlock HorizontalAlignment="Left" Grid.Column="2" FontWeight="Bold" Text="{Binding HighestHit}" ToolTip="Biggest single hit!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="3" FontWeight="Bold" Text="{Binding TotalTwelveSecondDamage}" ToolTip="Highest 12 second period of Damage dealt. This is good for gauging how many are required in a CH chain!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="4" FontWeight="Bold" Text="{Binding TotalDamage}" ToolTip="Total Damage done!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="2" FontWeight="Bold" Text="{Binding TotalTwelveSecondDamage}" ToolTip="Highest 12 second period of Damage dealt. This is good for gauging how many are required in a CH chain!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="3" FontWeight="Bold" Text="{Binding HighestHit}" ToolTip="Biggest single hit!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="4" FontWeight="Bold" Text="{Binding PercentOfTotalDamage}" ToolTip="Percent of Total Damage!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="5" FontWeight="Bold" Text="{Binding TotalDPS}" ToolTip="Total DPS!" />
<TextBlock HorizontalAlignment="Left" Grid.Column="6" FontWeight="Bold" Text="{Binding TotalDamage}" ToolTip="Total Damage done!" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
Expand All @@ -86,14 +94,16 @@
<Expander.Header>
<Grid HorizontalAlignment="{Binding Path=HorizontalAlignment, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContentPresenter}}, Mode=OneWayToSource}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="190" />
<ColumnDefinition Width="210" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="45" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Grid.ColumnSpan="5" Text="{Binding Name}" FontWeight="Bold" FontSize="{DynamicResource GlobalFontSize}" />
<TextBlock HorizontalAlignment="Left" Grid.Column="4" FontWeight="Bold" Text="{Binding Items[0].TargetTotalDamage}" />
<TextBlock HorizontalAlignment="Left" Grid.Column="6" FontWeight="Bold" Text="{Binding Items[0].TargetTotalDamage}" />
</Grid>
</Expander.Header>
<ItemsPresenter />
Expand Down
5 changes: 3 additions & 2 deletions src/ViewModels/DPSWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ public void TargetDied(string target)

public void TryAdd(DPSParseMatch entitiy)
{
if (entitiy == null)
//when charmed pet and nps have the same name, everything is messed up
if (entitiy == null || entitiy.SourceName == entitiy.TargetName)
{
return;
}

appDispatcher.DispatchUI(() =>
{
var item = EntityList.FirstOrDefault(a => a.SourceName == entitiy.SourceName && a.TargetName == entitiy.TargetName);
var item = EntityList.FirstOrDefault(a => a.SourceName == entitiy.SourceName && a.TargetName == entitiy.TargetName && !a.DeathTime.HasValue);
if (item == null)
{
item = new EntittyDPS
Expand Down
12 changes: 11 additions & 1 deletion src/ViewModels/EntittyDPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public string SourceName
}
}

public string SourceName_and_Info
{
get => _SourceName + $" {TotalSeconds} sec";
}

private string _TargetName = string.Empty;

public string TargetName
Expand Down Expand Up @@ -61,6 +66,7 @@ public void UpdateDps()

TrailingDamage = Damage.Where(a => a.TimeStamp >= DateTime.Now.AddSeconds(-12)).Sum(a => a.Damage);
TotalDamage = Damage.Sum(a => a.Damage);

if (Damage.Any())
{
var timestampstep = Damage.FirstOrDefault().TimeStamp;
Expand All @@ -85,8 +91,11 @@ public void UpdateDps()
OnPropertyChanged(nameof(TotalTwelveSecondDamage));
OnPropertyChanged(nameof(TotalDamage));
OnPropertyChanged(nameof(DPS));
OnPropertyChanged(nameof(TotalDPS));
OnPropertyChanged(nameof(SourceName_and_Info));
}


public int TotalSeconds => DeathTime.HasValue ? (int)(DeathTime.Value - _StartTime).TotalSeconds : (int)(DateTime.Now - _StartTime).TotalSeconds;
public DateTime? LastDamageDone => Damage.LastOrDefault()?.TimeStamp;
public void AddDamage(DamagePerTime damage)
Expand Down Expand Up @@ -164,7 +173,8 @@ private static System.Windows.Media.Color GetColorFromRedYellowGreenGradient(dou
public int PercentOfTotalDamage { get; set; }
public SolidColorBrush BackGroundColor { get; set; }
public SolidColorBrush ProgressBarColor { get; set; } = new SolidColorBrush(GetColorFromRedYellowGreenGradient(0));
public int DPS => (TrailingDamage > 0 && TotalSeconds > 0) ? (int)(TrailingDamage / (double)12) : 0;
public int TotalDPS => (TotalDamage > 0 && TotalSeconds > 0) ? (int)(TotalDamage / (double)TotalSeconds) : 0;
public int DPS => (TrailingDamage > 0) ? (int)(TrailingDamage / (double)12) : 0;
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
Expand Down

0 comments on commit 9f6e1dd

Please sign in to comment.