mirror of
https://github.com/ppy/osu.git
synced 2025-02-27 21:12:56 +08:00
Inherit difficulty multiplier display from ModsEffectDiplay
This commit is contained in:
parent
90334a2b91
commit
039f009562
@ -3,27 +3,24 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public class DifficultyMultiplierDisplay : CompositeDrawable, IHasCurrentValue<double>
|
public sealed class DifficultyMultiplierDisplay : ModsEffectDisplay, IHasCurrentValue<double>
|
||||||
{
|
{
|
||||||
public const float HEIGHT = 42;
|
protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
|
||||||
|
|
||||||
public Bindable<double> Current
|
public Bindable<double> Current
|
||||||
{
|
{
|
||||||
@ -33,143 +30,44 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private readonly BindableNumberWithCurrent<double> current = new BindableNumberWithCurrent<double>(1);
|
private readonly BindableNumberWithCurrent<double> current = new BindableNumberWithCurrent<double>(1);
|
||||||
|
|
||||||
private readonly Box underlayBackground;
|
|
||||||
private readonly Box contentBackground;
|
|
||||||
private readonly FillFlowContainer multiplierFlow;
|
|
||||||
private readonly MultiplierCounter multiplierCounter;
|
private readonly MultiplierCounter multiplierCounter;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OsuColour colours { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
|
||||||
|
|
||||||
private const float multiplier_value_area_width = 56;
|
|
||||||
private const float transition_duration = 200;
|
|
||||||
|
|
||||||
public DifficultyMultiplierDisplay()
|
public DifficultyMultiplierDisplay()
|
||||||
{
|
{
|
||||||
Height = HEIGHT;
|
Add(new FillFlowContainer
|
||||||
AutoSizeAxes = Axes.X;
|
|
||||||
|
|
||||||
InternalChild = new InputBlockingContainer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Both,
|
||||||
AutoSizeAxes = Axes.X,
|
Direction = FillDirection.Horizontal,
|
||||||
Masking = true,
|
Spacing = new Vector2(2, 0),
|
||||||
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
|
||||||
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0),
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
underlayBackground = new Box
|
multiplierCounter = new MultiplierCounter
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreLeft,
|
||||||
RelativeSizeAxes = Axes.Y,
|
Current = { BindTarget = Current }
|
||||||
Width = multiplier_value_area_width + ModSelectPanel.CORNER_RADIUS
|
|
||||||
},
|
},
|
||||||
new GridContainer
|
new SpriteIcon
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
Anchor = Anchor.CentreLeft,
|
||||||
AutoSizeAxes = Axes.X,
|
Origin = Anchor.CentreLeft,
|
||||||
ColumnDimensions = new[]
|
Icon = FontAwesome.Solid.Times,
|
||||||
{
|
Size = new Vector2(7),
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
Margin = new MarginPadding { Top = 1 }
|
||||||
new Dimension(GridSizeMode.Absolute, multiplier_value_area_width)
|
|
||||||
},
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
Masking = true,
|
|
||||||
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
contentBackground = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Margin = new MarginPadding { Horizontal = 18 },
|
|
||||||
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
|
||||||
Text = DifficultyMultiplierDisplayStrings.DifficultyMultiplier,
|
|
||||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
multiplierFlow = new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(2, 0),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
multiplierCounter = new MultiplierCounter
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Current = { BindTarget = Current }
|
|
||||||
},
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Icon = FontAwesome.Solid.Times,
|
|
||||||
Size = new Vector2(7),
|
|
||||||
Margin = new MarginPadding { Top = 1 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
contentBackground.Colour = colourProvider.Background4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
current.BindValueChanged(_ => updateState(), true);
|
current.BindValueChanged(e => SetColours(e.NewValue.CompareTo(current.Default)), true);
|
||||||
|
|
||||||
// required to prevent the counter initially rolling up from 0 to 1
|
// required to prevent the counter initially rolling up from 0 to 1
|
||||||
// due to `Current.Value` having a nonstandard default value of 1.
|
// due to `Current.Value` having a nonstandard default value of 1.
|
||||||
multiplierCounter.SetCountWithoutRolling(Current.Value);
|
multiplierCounter.SetCountWithoutRolling(current.Value);
|
||||||
}
|
|
||||||
|
|
||||||
private void updateState()
|
|
||||||
{
|
|
||||||
if (Current.IsDefault)
|
|
||||||
{
|
|
||||||
underlayBackground.FadeColour(colourProvider.Background3, transition_duration, Easing.OutQuint);
|
|
||||||
multiplierFlow.FadeColour(Colour4.White, transition_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var backgroundColour = Current.Value < 1
|
|
||||||
? colours.ForModType(ModType.DifficultyReduction)
|
|
||||||
: colours.ForModType(ModType.DifficultyIncrease);
|
|
||||||
|
|
||||||
underlayBackground.FadeColour(backgroundColour, transition_duration, Easing.OutQuint);
|
|
||||||
multiplierFlow.FadeColour(colourProvider.Background5, transition_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MultiplierCounter : RollingCounter<double>
|
private class MultiplierCounter : RollingCounter<double>
|
||||||
|
@ -153,7 +153,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Top = (ShowTotalMultiplier ? DifficultyMultiplierDisplay.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 = DifficultyMultiplierDisplay.HEIGHT,
|
Height = ModsEffectDisplay.HEIGHT,
|
||||||
Margin = new MarginPadding { Horizontal = 100 },
|
Margin = new MarginPadding { Horizontal = 100 },
|
||||||
Child = multiplierDisplay = new DifficultyMultiplierDisplay
|
Child = multiplierDisplay = new DifficultyMultiplierDisplay
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user