From 26d493986c318e2a390ecf02af10785f5ee760f1 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 12 Nov 2023 18:05:18 +0200 Subject: [PATCH] Fixed precision and updated AdvancedStats --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 4 +- .../Screens/Select/Details/AdvancedStats.cs | 48 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 5531ed5461..bf39666f83 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -204,8 +204,8 @@ namespace osu.Game.Overlays.Mods if (haveRateChangedValues) { return $"One or more values are being adjusted by mods that change speed." + - $" (AR {originalDifficulty?.ApproachRate ?? 0}→{adjustedDifficulty?.ApproachRate ?? 0}, " + - $"OD {originalDifficulty?.OverallDifficulty ?? 0}→{adjustedDifficulty?.OverallDifficulty ?? 0})"; + $" (AR {originalDifficulty?.ApproachRate ?? 0}→{(adjustedDifficulty?.ApproachRate ?? 0):0.0#}, " + + $"OD {originalDifficulty?.OverallDifficulty ?? 0}→{(adjustedDifficulty?.OverallDifficulty ?? 0):0.0#})"; } return string.Empty; diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index f84422ae65..25c18f7328 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -46,6 +46,7 @@ namespace osu.Game.Screens.Select.Details private readonly StatisticRow starDifficulty; private BeatmapDifficulty originalDifficulty; + private BeatmapDifficulty adjustedDifficulty; private bool haveRateChangedValues; private IBeatmapInfo beatmapInfo; @@ -120,24 +121,25 @@ namespace osu.Game.Screens.Select.Details private void updateStatistics() { IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty; - BeatmapDifficulty adjustedDifficulty = null; if (baseDifficulty != null) { - adjustedDifficulty = new BeatmapDifficulty(baseDifficulty); + originalDifficulty = new BeatmapDifficulty(baseDifficulty); foreach (var mod in mods.Value.OfType()) - mod.ApplyToDifficulty(adjustedDifficulty); + mod.ApplyToDifficulty(originalDifficulty); - originalDifficulty = adjustedDifficulty; + if (gameRuleset != null) + { + Ruleset ruleset = gameRuleset.Value.CreateInstance(); - Ruleset ruleset = gameRuleset.Value.CreateInstance(); - double rate = 1; - foreach (var mod in mods.Value.OfType()) - rate = mod.ApplyToRate(0, rate); - adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate); + double rate = 1; + foreach (var mod in mods.Value.OfType()) + rate = mod.ApplyToRate(0, rate); - haveRateChangedValues = isDifferentArOd(originalDifficulty, adjustedDifficulty); + adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(originalDifficulty, rate); + haveRateChangedValues = hasRateAdjustedProperties(originalDifficulty, adjustedDifficulty); + } } switch (BeatmapInfo?.Ruleset.OnlineID) @@ -202,31 +204,29 @@ namespace osu.Game.Screens.Select.Details starDifficultyCancellationSource?.Cancel(); } - private bool isDifferentArOd(BeatmapDifficulty a, BeatmapDifficulty b) - { - if (a == null && b == null) return false; - if (a == null || b == null) return true; - - if (!Precision.AlmostEquals(a.ApproachRate, b.ApproachRate, 0.01)) return true; - if (!Precision.AlmostEquals(a.OverallDifficulty, b.OverallDifficulty, 0.01)) return true; - - return false; - } - public LocalisableString TooltipText { get { if (haveRateChangedValues) { - return LocalisableString.Format("Values are changed by mods that change speed.\n" + - "Original values: AR = {0}, OD = {1}", originalDifficulty?.ApproachRate ?? 0, originalDifficulty?.OverallDifficulty ?? 0); + return $"One or more values are being adjusted by mods that change speed." + + $" (AR {originalDifficulty?.ApproachRate ?? 0}→{(adjustedDifficulty?.ApproachRate ?? 0):0.0#}, " + + $"OD {originalDifficulty?.OverallDifficulty ?? 0}→{(adjustedDifficulty?.OverallDifficulty ?? 0):0.0#})"; } - return ""; + return string.Empty; } } + private static bool hasRateAdjustedProperties(BeatmapDifficulty a, BeatmapDifficulty b) + { + if (!Precision.AlmostEquals(a.ApproachRate, b.ApproachRate)) return true; + if (!Precision.AlmostEquals(a.OverallDifficulty, b.OverallDifficulty)) return true; + + return false; + } + public partial class StatisticRow : Container, IHasAccentColour { private const float value_width = 25;