mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Inherit difficulty multiplier display from ModsEffectDiplay
This commit is contained in:
parent
90334a2b91
commit
039f009562
@ -3,27 +3,24 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
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
|
||||
{
|
||||
@ -33,143 +30,44 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
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;
|
||||
|
||||
[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()
|
||||
{
|
||||
Height = HEIGHT;
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = new InputBlockingContainer
|
||||
Add(new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Masking = true,
|
||||
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
||||
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0),
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(2, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
underlayBackground = new Box
|
||||
multiplierCounter = new MultiplierCounter
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = multiplier_value_area_width + ModSelectPanel.CORNER_RADIUS
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Current = { BindTarget = Current }
|
||||
},
|
||||
new GridContainer
|
||||
new SpriteIcon
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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()
|
||||
{
|
||||
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
|
||||
// due to `Current.Value` having a nonstandard default value of 1.
|
||||
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);
|
||||
}
|
||||
multiplierCounter.SetCountWithoutRolling(current.Value);
|
||||
}
|
||||
|
||||
private class MultiplierCounter : RollingCounter<double>
|
||||
|
@ -153,7 +153,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = (ShowTotalMultiplier ? DifficultyMultiplierDisplay.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 = DifficultyMultiplierDisplay.HEIGHT,
|
||||
Height = ModsEffectDisplay.HEIGHT,
|
||||
Margin = new MarginPadding { Horizontal = 100 },
|
||||
Child = multiplierDisplay = new DifficultyMultiplierDisplay
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user