From b056cac10a1259044e65e67ab059f108b66c23bb Mon Sep 17 00:00:00 2001
From: ansel <79257300125@ya.ru>
Date: Sat, 10 Sep 2022 08:21:38 +0300
Subject: [PATCH] Remove generic and add default implementation for
 `CalculateEffect`

---
 .../Overlays/Mods/DifficultyMultiplierDisplay.cs   |  3 +--
 osu.Game/Overlays/Mods/ModSelectOverlay.cs         |  4 ++--
 osu.Game/Overlays/Mods/ModsEffectDisplay.cs        | 14 ++++++++++----
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/osu.Game/Overlays/Mods/DifficultyMultiplierDisplay.cs b/osu.Game/Overlays/Mods/DifficultyMultiplierDisplay.cs
index 843310249e..5530947d3d 100644
--- a/osu.Game/Overlays/Mods/DifficultyMultiplierDisplay.cs
+++ b/osu.Game/Overlays/Mods/DifficultyMultiplierDisplay.cs
@@ -16,10 +16,9 @@ using osu.Game.Localisation;
 
 namespace osu.Game.Overlays.Mods
 {
-    public sealed class DifficultyMultiplierDisplay : ModsEffectDisplay<double>
+    public sealed class DifficultyMultiplierDisplay : ModsEffectDisplay
     {
         protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
-        protected override ModEffect CalculateEffect(double value) => CalculateForSign(value.CompareTo(1d));
 
         private readonly MultiplierCounter multiplierCounter;
 
diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs
index 80f18eafeb..ccc075b190 100644
--- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs
+++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs
@@ -153,7 +153,7 @@ namespace osu.Game.Overlays.Mods
                     {
                         Padding = new MarginPadding
                         {
-                            Top = (ShowTotalMultiplier ? ModsEffectDisplay<int>.HEIGHT : 0) + PADDING,
+                            Top = (ShowTotalMultiplier ? ModsEffectDisplay.HEIGHT : 0) + PADDING,
                             Bottom = PADDING
                         },
                         RelativeSizeAxes = Axes.Both,
@@ -191,7 +191,7 @@ namespace osu.Game.Overlays.Mods
                     Anchor = Anchor.TopRight,
                     Origin = Anchor.TopRight,
                     AutoSizeAxes = Axes.X,
-                    Height = ModsEffectDisplay<int>.HEIGHT,
+                    Height = ModsEffectDisplay.HEIGHT,
                     Margin = new MarginPadding { Horizontal = 100 },
                     Child = multiplierDisplay = new DifficultyMultiplierDisplay
                     {
diff --git a/osu.Game/Overlays/Mods/ModsEffectDisplay.cs b/osu.Game/Overlays/Mods/ModsEffectDisplay.cs
index 2ff6bf043b..4e630439ee 100644
--- a/osu.Game/Overlays/Mods/ModsEffectDisplay.cs
+++ b/osu.Game/Overlays/Mods/ModsEffectDisplay.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Mods
     /// <summary>
     /// Base class for displays of mods effects.
     /// </summary>
-    public abstract class ModsEffectDisplay<TValue> : Container, IHasCurrentValue<TValue>
+    public abstract class ModsEffectDisplay : Container, IHasCurrentValue<double>
     {
         public const float HEIGHT = 42;
         private const float transition_duration = 200;
@@ -28,13 +28,13 @@ namespace osu.Game.Overlays.Mods
         private readonly Box labelBackground;
         private readonly Container content;
 
-        public Bindable<TValue> Current
+        public Bindable<double> Current
         {
             get => current.Current;
             set => current.Current = value;
         }
 
-        private readonly BindableWithCurrent<TValue> current = new BindableWithCurrent<TValue>();
+        private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>();
 
         [Resolved]
         private OsuColour colours { get; set; } = null!;
@@ -52,7 +52,13 @@ namespace osu.Game.Overlays.Mods
         /// </summary>
         /// <param name="value">Value to calculate for. Will arrive from <see cref="Current"/> bindable once it changes.</param>
         /// <returns>Effect of the value.</returns>
-        protected abstract ModEffect CalculateEffect(TValue value);
+        /// <remarks>
+        /// Default implementation compares the value with <see cref="Current"/>.<see cref="Bindable{T}.Default"/>, bigger value counts as difficulty increase.
+        /// </remarks>
+        protected virtual ModEffect CalculateEffect(double value)
+        {
+            return CalculateForSign(value.CompareTo(Current.Default));
+        }
 
         protected virtual float ValueAreaWidth => 56;