mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Remove generic and add default implementation for CalculateEffect
This commit is contained in:
parent
545e0bbcef
commit
b056cac10a
@ -16,10 +16,9 @@ using osu.Game.Localisation;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public sealed class DifficultyMultiplierDisplay : ModsEffectDisplay<double>
|
public sealed class DifficultyMultiplierDisplay : ModsEffectDisplay
|
||||||
{
|
{
|
||||||
protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
|
protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
|
||||||
protected override ModEffect CalculateEffect(double value) => CalculateForSign(value.CompareTo(1d));
|
|
||||||
|
|
||||||
private readonly MultiplierCounter multiplierCounter;
|
private readonly MultiplierCounter multiplierCounter;
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Top = (ShowTotalMultiplier ? ModsEffectDisplay<int>.HEIGHT : 0) + PADDING,
|
Top = (ShowTotalMultiplier ? ModsEffectDisplay.HEIGHT : 0) + PADDING,
|
||||||
Bottom = PADDING
|
Bottom = PADDING
|
||||||
},
|
},
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -191,7 +191,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
Height = ModsEffectDisplay<int>.HEIGHT,
|
Height = ModsEffectDisplay.HEIGHT,
|
||||||
Margin = new MarginPadding { Horizontal = 100 },
|
Margin = new MarginPadding { Horizontal = 100 },
|
||||||
Child = multiplierDisplay = new DifficultyMultiplierDisplay
|
Child = multiplierDisplay = new DifficultyMultiplierDisplay
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base class for displays of mods effects.
|
/// Base class for displays of mods effects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ModsEffectDisplay<TValue> : Container, IHasCurrentValue<TValue>
|
public abstract class ModsEffectDisplay : Container, IHasCurrentValue<double>
|
||||||
{
|
{
|
||||||
public const float HEIGHT = 42;
|
public const float HEIGHT = 42;
|
||||||
private const float transition_duration = 200;
|
private const float transition_duration = 200;
|
||||||
@ -28,13 +28,13 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private readonly Box labelBackground;
|
private readonly Box labelBackground;
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
public Bindable<TValue> Current
|
public Bindable<double> Current
|
||||||
{
|
{
|
||||||
get => current.Current;
|
get => current.Current;
|
||||||
set => current.Current = value;
|
set => current.Current = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly BindableWithCurrent<TValue> current = new BindableWithCurrent<TValue>();
|
private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; } = null!;
|
private OsuColour colours { get; set; } = null!;
|
||||||
@ -52,7 +52,13 @@ namespace osu.Game.Overlays.Mods
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">Value to calculate for. Will arrive from <see cref="Current"/> bindable once it changes.</param>
|
/// <param name="value">Value to calculate for. Will arrive from <see cref="Current"/> bindable once it changes.</param>
|
||||||
/// <returns>Effect of the value.</returns>
|
/// <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;
|
protected virtual float ValueAreaWidth => 56;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user