Skip to content

Commit

Permalink
Added style elements for taken damage area
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Jul 25, 2024
1 parent 1a50fad commit 3616d35
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 25 deletions.
23 changes: 15 additions & 8 deletions src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,48 +351,55 @@ public void SetDamageMeterSnapshotSort()
switch (DamageMeterSnapshotSortSelection.DamageMeterSortType)
{
case DamageMeterSortType.Damage:
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, true);
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Damage);
if (DamageMeterSnapshotSelection != null)
{
DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.DamageInPercent).ToList();
}
return;
case DamageMeterSortType.Dps:
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, true);
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Damage);
if (DamageMeterSnapshotSelection != null)
{
DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.Dps).ToList();
}
return;
case DamageMeterSortType.Name:
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, true);
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Damage);
if (DamageMeterSnapshotSelection != null)
{
DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderBy(x => x.Name).ToList();
}
return;
case DamageMeterSortType.Heal:
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, false);
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Heal);
if (DamageMeterSnapshotSelection != null)
{
DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.HealInPercent).ToList();
}
return;
case DamageMeterSortType.Hps:
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, false);
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Heal);
if (DamageMeterSnapshotSelection != null)
{
DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.Hps).ToList();
}
break;
case DamageMeterSortType.TakenDamage:
SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.TakenDamage);
if (DamageMeterSnapshotSelection != null)
{
DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.TakenDamage).ToList();
}
break;
}
}

private static void SetIsDamageMeterSnapshotShowing(IEnumerable<DamageMeterSnapshotFragment> damageMeter, bool isDamageMeterShowing)
private static void SetIsDamageMeterSnapshotShowing(IEnumerable<DamageMeterSnapshotFragment> damageMeter, DamageMeterStyleFragmentType damageMeterStyleFragmentType)
{
foreach (var fragment in damageMeter ?? new List<DamageMeterSnapshotFragment>())
{
fragment.IsDamageMeterShowing = isDamageMeterShowing;
fragment.DamageMeterStyleFragmentType = damageMeterStyleFragmentType;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public long TakenDamage
set
{
_takenDamage = value;
TakenDamageShortString = _damage.ToShortNumberString();
TakenDamageShortString = _takenDamage.ToShortNumberString();
OnPropertyChanged();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public sealed class DamageMeterSnapshotFragment : BaseViewModel
private double _dps;
private long _heal;
private double _hps;
private long _takenDamage;
private string _takenDamageShortString;
private double _takenDamageInPercent;
private double _takenDamagePercentage;
private DamageMeterStyleFragmentType _damageMeterStyleFragmentType;
private Visibility _spellsContainerVisibility = Visibility.Collapsed;

public DamageMeterSnapshotFragment(DamageMeterFragment damageMeterFragment)
Expand All @@ -31,6 +36,9 @@ public DamageMeterSnapshotFragment(DamageMeterFragment damageMeterFragment)
Hps = damageMeterFragment.Hps;
HealInPercent = damageMeterFragment.HealInPercent;
HealPercentage = damageMeterFragment.HealPercentage;
TakenDamage = damageMeterFragment.TakenDamage;
TakenDamageInPercent = damageMeterFragment.TakenDamageInPercent;
TakenDamagePercentage = damageMeterFragment.TakenDamagePercentage;
CauserMainHandItemUniqueName = damageMeterFragment.CauserMainHand?.UniqueName ?? string.Empty;
OverhealedPercentageOfTotalHealing = damageMeterFragment.OverhealedPercentageOfTotalHealing;
Spells = damageMeterFragment.Spells.Select(x => new SpellsSnapshotFragment()
Expand Down Expand Up @@ -140,6 +148,61 @@ public Visibility SpellsContainerVisibility

#endregion

#region Take Damage

public long TakenDamage
{
get => _takenDamage;
set
{
_takenDamage = value;
TakenDamageShortString = _damage.ToShortNumberString();
OnPropertyChanged();
}
}

public string TakenDamageShortString
{
get => _takenDamageShortString;
private set
{
_takenDamageShortString = value;
OnPropertyChanged();
}
}

public double TakenDamageInPercent
{
get => _takenDamageInPercent;
set
{
_takenDamageInPercent = value;
OnPropertyChanged();
}
}

public double TakenDamagePercentage
{
get => _takenDamagePercentage;
set
{
_takenDamagePercentage = value;
OnPropertyChanged();
}
}

#endregion

public DamageMeterStyleFragmentType DamageMeterStyleFragmentType
{
get => _damageMeterStyleFragmentType;
set
{
_damageMeterStyleFragmentType = value;
OnPropertyChanged();
}
}

private void PerformShowSpells(object value)
{
SpellsContainerVisibility = SpellsContainerVisibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
Expand Down
13 changes: 13 additions & 0 deletions src/StatisticsAnalysisTool/Localization/localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -37248,6 +37248,19 @@
"seg": "Ouvrir la validation d'événement"
}
]
},
{
"tuid": "TAKEN_DAMAGE",
"tuv": [
{
"lang": "de-DE",
"seg": "Erlittener Schaden"
},
{
"lang": "en-US",
"seg": "Damage suffered"
}
]
}
]
}
18 changes: 11 additions & 7 deletions src/StatisticsAnalysisTool/Network/Manager/CombatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CombatController(TrackingController trackingController, MainWindowViewMod
OnDamageUpdate += UpdateDamageMeterUiAsync;

#if DEBUG
RunDamageMeterDebugAsync(0, 0);
RunDamageMeterDebugAsync(10, 10);
#endif
}

Expand Down Expand Up @@ -188,7 +188,7 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra
fragment.Damage = healthChangeObjectValue.Damage;
}

if (healthChangeObjectValue?.Dps != null)
if (healthChangeObjectValue?.Dps is not null)
{
fragment.Dps = healthChangeObjectValue.Dps;
}
Expand All @@ -200,7 +200,7 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra
fragment.Heal = healthChangeObjectValue.Heal;
}

if (healthChangeObjectValue?.Hps != null)
if (healthChangeObjectValue?.Hps is not null)
{
fragment.Hps = healthChangeObjectValue.Hps;
}
Expand All @@ -211,13 +211,12 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra
}

// Taken Damage
if (healthChangeObjectValue?.Damage > 0)
if (healthChangeObjectValue?.TakenDamage > 0)
{
fragment.TakenDamageInPercent = (double) healthChangeObjectValue.TakenDamage / currentTotalTakenDamage * 100;
fragment.TakenDamage = healthChangeObjectValue.TakenDamage;
}


// Spells
await AddOrUpdateSpellFragmentAsync(fragment.Spells, healthChangeObjectValue?.Spells);

Expand All @@ -230,6 +229,9 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra
fragment.TakenDamagePercentage = entities.GetTakenDamagePercentage(healthChangeObjectValue.TakenDamage);
fragment.OverhealedPercentageOfTotalHealing = GetOverhealedPercentageOfHealWithOverhealed(healthChangeObjectValue.Overhealed, healthChangeObjectValue.Heal);
}

Debug.Print($"AddDamageMeterFragmentAsync - Name: {fragment.Name}, Damage: {fragment.Damage}, Heal: {fragment.Heal}, TakenDamage: {fragment.TakenDamage}");

}

public static double GetOverhealedPercentageOfHealWithOverhealed(double overhealed, double heal)
Expand Down Expand Up @@ -268,7 +270,7 @@ private static async Task AddDamageMeterFragmentAsync(ICollection<DamageMeterFra
Overhealed = healthChangeObjectValue.Overhealed,
OverhealedPercentageOfTotalHealing = GetOverhealedPercentageOfHealWithOverhealed(healthChangeObjectValue.Overhealed, healthChangeObjectValue.Heal),

TakenDamage = healthChangeObjectValue.Damage,
TakenDamage = healthChangeObjectValue.TakenDamage,
TakenDamageInPercent = (double) healthChangeObjectValue.TakenDamage / currentTotalTakenDamage * 100,
TakenDamagePercentage = entities.GetDamagePercentage(healthChangeObjectValue.TakenDamage),

Expand All @@ -277,7 +279,7 @@ private static async Task AddDamageMeterFragmentAsync(ICollection<DamageMeterFra

Spells = spells
};

await Application.Current.Dispatcher.InvokeAsync(() =>
{
damageMeter.Add(damageMeterFragment);
Expand Down Expand Up @@ -614,7 +616,9 @@ private async Task AddDamageAsync(PlayerGameObject entity, int runs)
for (var i = 0; i < runs; i++)
{
var damage = Random.Next(-5000, 5000);
var takenDamage = Random.Next(-5000, 5000);
await AddDamage(9999, entity.ObjectId ?? -1, damage, Random.Next(2000, 3000), Random.Next(2000, 3000));
await AddTakenDamage(entity.ObjectId ?? -1, 9999, takenDamage, Random.Next(2000, 3000), Random.Next(2000, 3000));
//Debug.Print($"--- AddDamage - {entity.Name}: {damage}");

await Task.Delay(Random.Next(1, 1000));
Expand Down
1 change: 1 addition & 0 deletions src/StatisticsAnalysisTool/Styles/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
<SolidColorBrush x:Key="SolidColorBrush.Weapon.Knuckles" Color="#914210"/>
<SolidColorBrush x:Key="SolidColorBrush.Weapon.UnknownWeaponType" Color="#555555"/>
<SolidColorBrush x:Key="SolidColorBrush.Weapon.HealBar" Color="#00aa1a"/>
<SolidColorBrush x:Key="SolidColorBrush.Weapon.TakenDamageBar" Color="#a32423"/>

<SolidColorBrush x:Key="Solid.Color.Text.ToOldFirst" Color="{StaticResource Color.Text.ToOldFirst}"/>
<SolidColorBrush x:Key="Solid.Color.Text.ToOldSecond" Color="{StaticResource Color.Text.ToOldSecond}"/>
Expand Down
56 changes: 47 additions & 9 deletions src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
</Grid.InputBindings>
<ProgressBar common:ProgressBarSmoother.SmoothValue="{Binding TakenDamageInPercent}" Minimum="0" Maximum="100"
MinHeight="40" Height="auto" Margin="3,0,2,1" VerticalAlignment="Top" Background="#00FFFFFF" BorderThickness="0"
Style="{StaticResource DamageMeter.ProgressBar.Colors}" />
Foreground="{StaticResource SolidColorBrush.Weapon.TakenDamageBar}" />
<StackPanel Orientation="Horizontal">
<Grid Margin="10,0, 0, 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="{Binding CauserMainHand.Icon}" Style="{StaticResource DamageMeter.Icon}" />
Expand Down Expand Up @@ -288,13 +288,11 @@
<Grid MinHeight="42" Height="auto">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsDamageMeterShowing}" Value="True">
<DataTrigger Binding="{Binding DamageMeterStyleFragmentType}" Value="{x:Static damageMeter:DamageMeterStyleFragmentType.Damage}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsDamageMeterShowing}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
Expand Down Expand Up @@ -337,14 +335,54 @@
</TextBlock>
</StackPanel>
</Grid>
<Grid>
<Grid MinHeight="42" Height="auto">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsDamageMeterShowing}" Value="True">
<Setter Property="Visibility" Value="Collapsed"/>
<DataTrigger Binding="{Binding DamageMeterStyleFragmentType}" Value="{x:Static damageMeter:DamageMeterStyleFragmentType.TakenDamage}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsDamageMeterShowing}" Value="False">
</Style.Triggers>
</Style>
</Grid.Style>
<Grid.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding ShowSpells}" />
</Grid.InputBindings>
<ProgressBar common:ProgressBarSmoother.SmoothValue="{Binding TakenDamageInPercent}" Minimum="0" Maximum="100"
MinHeight="40" Height="auto" Margin="3,0,2,1" VerticalAlignment="Top" Background="#00FFFFFF" BorderThickness="0"
Foreground="{StaticResource SolidColorBrush.Weapon.TakenDamageBar}" />
<StackPanel Orientation="Horizontal">
<Grid Margin="10,0, 0, 0" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="{Binding CauserMainHand.Icon}" Style="{StaticResource DamageMeter.Icon}" />
</Grid>
<Label Foreground="{StaticResource SolidColorBrush.Weapon.Text}" Content="{Binding TakenDamagePercentage}"
ContentStringFormat="{}{0:N2}%" MinWidth="55" Margin="10,5" HorizontalContentAlignment="Right" VerticalAlignment="Top" />
<Label Content="{Binding Name}" MinWidth="125" MaxWidth="125" Margin="10,5, 0, 0" VerticalAlignment="Top" />
<Label Foreground="{StaticResource SolidColorBrush.Weapon.Text}" Content="{Binding TakenDamageShortString}"
MinWidth="100" MaxWidth="100" FontWeight="Bold" Margin="10,5, 5, 0" VerticalAlignment="Top" />
<Label Foreground="{StaticResource SolidColorBrush.Weapon.Text}" Content="" MinWidth="75" MaxWidth="75"
FontWeight="Bold" Margin="10,5, 50, 0" VerticalAlignment="Top" />
<Grid Width="16" Height="16" Margin="0,10" VerticalAlignment="Top" ToolTip="{Binding TranslationCombatTime, FallbackValue='COMBAT_TIME'}">
<fa5:ImageAwesome Icon="Regular_Clock" Foreground="{StaticResource SolidColorBrush.Text.1}" />
</Grid>
<TextBlock Foreground="{StaticResource SolidColorBrush.Weapon.Text}" VerticalAlignment="Top" MinWidth="75" MaxWidth="100" FontWeight="Bold" Margin="10,10,50,0">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:00}:{1:00}:{2:00}">
<Binding Path="CombatTime.Hours" />
<Binding Path="CombatTime.Minutes" />
<Binding Path="CombatTime.Seconds" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</Grid>
<Grid MinHeight="42" Height="auto">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding DamageMeterStyleFragmentType}" Value="{x:Static damageMeter:DamageMeterStyleFragmentType.Heal}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
Expand Down

0 comments on commit 3616d35

Please sign in to comment.