From 440d57fb48ec4fc029452ceda9f54aad381fd32a Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sat, 4 Nov 2023 17:47:02 +0200 Subject: [PATCH] Basic rate-adjust tooltip --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index fd9ce8f5d9..fc0ef989e6 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; using osu.Game.Beatmaps; @@ -23,6 +24,7 @@ using osuTK.Graphics; using System.Threading; using osu.Framework.Input.Events; using osu.Game.Configuration; +using osu.Game.Rulesets.Difficulty; namespace osu.Game.Overlays.Mods { @@ -30,7 +32,7 @@ namespace osu.Game.Overlays.Mods /// On the mod select overlay, this provides a local updating view of BPM, star rating and other /// difficulty attributes so the user can have a better insight into what mods are changing. /// - public partial class BeatmapAttributesDisplay : CompositeDrawable + public partial class BeatmapAttributesDisplay : CompositeDrawable, IHasTooltip { private Container content = null!; private Container innerContent = null!; @@ -71,6 +73,10 @@ namespace osu.Game.Overlays.Mods private CancellationTokenSource? cancellationSource; private IBindable starDifficulty = null!; + private BeatmapDifficulty? baseDifficultyAttributes = null; + + private bool haveRateChangedValues = false; + [BackgroundDependencyLoader] private void load() { @@ -256,9 +262,13 @@ namespace osu.Game.Overlays.Mods foreach (var mod in mods.Value.OfType()) mod.ApplyToDifficulty(moddedDifficulty); + baseDifficultyAttributes = moddedDifficulty; + Ruleset ruleset = gameRuleset.Value.CreateInstance(); var rateAdjustedDifficulty = ruleset.GetRateAdjustedDifficulty(moddedDifficulty, rate); + haveRateChangedValues = !haveEqualDifficulties(rateAdjustedDifficulty, moddedDifficulty); + approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(moddedDifficulty.ApproachRate, rateAdjustedDifficulty.ApproachRate); overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(moddedDifficulty.OverallDifficulty, rateAdjustedDifficulty.OverallDifficulty); @@ -268,6 +278,19 @@ namespace osu.Game.Overlays.Mods overallDifficultyDisplay.Current.Value = rateAdjustedDifficulty.OverallDifficulty; }); + private bool haveEqualDifficulties(BeatmapDifficulty? a, BeatmapDifficulty? b) + { + if (a == null && b == null) return true; + if (a == null || b == null) return false; + + if (a.ApproachRate != b.ApproachRate) return false; + if (a.OverallDifficulty != b.OverallDifficulty) return false; + if (a.DrainRate != b.DrainRate) return false; + if (a.CircleSize != b.CircleSize) return false; + + return true; + } + private void updateCollapsedState() { outerContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint); @@ -285,5 +308,17 @@ namespace osu.Game.Overlays.Mods UseFullGlyphHeight = false, }; } + + public LocalisableString TooltipText + { + get + { + if (haveRateChangedValues) + { + return "Some of the values are Rate-Adjusted."; + } + return ""; + } + } } }