From 3616d35e1536a7769c58e26d65102cbbc147009e Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 25 Jul 2024 21:14:35 +0200 Subject: [PATCH] Added style elements for taken damage area --- .../DamageMeter/DamageMeterBindings.cs | 23 ++++--- .../DamageMeter/DamageMeterFragment.cs | 2 +- .../DamageMeterSnapshotFragment.cs | 63 +++++++++++++++++++ .../Localization/localization.json | 13 ++++ .../Network/Manager/CombatController.cs | 18 +++--- src/StatisticsAnalysisTool/Styles/Colors.xaml | 1 + .../Styles/DamageMeterStyles.xaml | 56 ++++++++++++++--- 7 files changed, 151 insertions(+), 25 deletions(-) diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs index 45e4c1b9e..3cf988d3b 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs @@ -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 damageMeter, bool isDamageMeterShowing) + + private static void SetIsDamageMeterSnapshotShowing(IEnumerable damageMeter, DamageMeterStyleFragmentType damageMeterStyleFragmentType) { foreach (var fragment in damageMeter ?? new List()) { - fragment.IsDamageMeterShowing = isDamageMeterShowing; + fragment.DamageMeterStyleFragmentType = damageMeterStyleFragmentType; } } diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs index 9d80b3aa0..f15f5694c 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs @@ -272,7 +272,7 @@ public long TakenDamage set { _takenDamage = value; - TakenDamageShortString = _damage.ToShortNumberString(); + TakenDamageShortString = _takenDamage.ToShortNumberString(); OnPropertyChanged(); } } diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs index 2dc5c883f..4c02f6264 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs @@ -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) @@ -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() @@ -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; diff --git a/src/StatisticsAnalysisTool/Localization/localization.json b/src/StatisticsAnalysisTool/Localization/localization.json index e75a1dbe5..64c08c236 100644 --- a/src/StatisticsAnalysisTool/Localization/localization.json +++ b/src/StatisticsAnalysisTool/Localization/localization.json @@ -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" + } + ] } ] } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs b/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs index b90e299c9..8fba6d9dd 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs @@ -37,7 +37,7 @@ public CombatController(TrackingController trackingController, MainWindowViewMod OnDamageUpdate += UpdateDamageMeterUiAsync; #if DEBUG - RunDamageMeterDebugAsync(0, 0); + RunDamageMeterDebugAsync(10, 10); #endif } @@ -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; } @@ -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; } @@ -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); @@ -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) @@ -268,7 +270,7 @@ private static async Task AddDamageMeterFragmentAsync(ICollection { damageMeter.Add(damageMeterFragment); @@ -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)); diff --git a/src/StatisticsAnalysisTool/Styles/Colors.xaml b/src/StatisticsAnalysisTool/Styles/Colors.xaml index ed9cce9fe..93ccc5e2a 100644 --- a/src/StatisticsAnalysisTool/Styles/Colors.xaml +++ b/src/StatisticsAnalysisTool/Styles/Colors.xaml @@ -316,6 +316,7 @@ + diff --git a/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml b/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml index 85219cee2..2f1424905 100644 --- a/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml +++ b/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml @@ -185,7 +185,7 @@ + Foreground="{StaticResource SolidColorBrush.Weapon.TakenDamageBar}" /> @@ -288,13 +288,11 @@ @@ -337,14 +335,54 @@ - + + + + + + + + + + + + + + +