2023-08-29 04:16:33 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2023-09-03 07:09:01 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2023-08-29 04:16:33 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
2023-09-03 07:09:01 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-09-03 07:09:01 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2023-09-03 07:09:01 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2023-09-03 07:09:01 +08:00
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
|
{
|
|
|
|
|
public partial class ModMapInfoContainer : Container
|
|
|
|
|
{
|
2023-09-03 07:09:01 +08:00
|
|
|
|
private Container content;
|
|
|
|
|
private Container innerContent;
|
|
|
|
|
|
|
|
|
|
private Box background;
|
|
|
|
|
private Box innerBackground;
|
|
|
|
|
|
|
|
|
|
private StarRatingDisplay starRatingDisplay;
|
|
|
|
|
private BPMDisplay bpmDisplay;
|
|
|
|
|
|
|
|
|
|
private VerticalAttributeDisplay circleSizeDisplay;
|
|
|
|
|
private VerticalAttributeDisplay drainRateDisplay;
|
|
|
|
|
private VerticalAttributeDisplay approachRateDisplay;
|
|
|
|
|
private VerticalAttributeDisplay overallDifficultyDisplay;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
2023-09-03 07:09:01 +08:00
|
|
|
|
private OverlayColourProvider colourProvider { get; set; }
|
2023-08-29 04:16:33 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
2023-09-03 07:09:01 +08:00
|
|
|
|
private Bindable<BeatmapShortInfo> adjustedInfo { get; set; }
|
2023-08-29 04:16:33 +08:00
|
|
|
|
|
2023-09-03 07:09:01 +08:00
|
|
|
|
public ModMapInfoContainer()
|
|
|
|
|
{
|
|
|
|
|
// values as ModSelectOverlay footer buttons
|
|
|
|
|
const float shear = ShearedOverlayContainer.SHEAR;
|
|
|
|
|
const float corner_radius = 7;
|
|
|
|
|
const float border_thickness = 2;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
|
2023-09-03 07:09:01 +08:00
|
|
|
|
InternalChild = content = new InputBlockingContainer
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 50, // as ModSelectOverlay footer buttons
|
|
|
|
|
Shear = new Vector2(shear, 0),
|
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
|
BorderThickness = border_thickness,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer // divide inner and outer content
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
innerContent = new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
BorderThickness = border_thickness,
|
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
innerBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer // actual inner content
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Margin = new MarginPadding { Horizontal = 15 },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container // wrap to reserve space for StarRatingDisplay
|
|
|
|
|
{
|
|
|
|
|
Width = 70, // can be up to 70px on extra high SR
|
|
|
|
|
Child = starRatingDisplay = new StarRatingDisplay(default, animated: true)
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Shear = new Vector2(-shear, 0),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container // wrap to reserve space for BPM
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Width = 70,
|
|
|
|
|
Child = bpmDisplay = new BPMDisplay
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Shear = new Vector2(-shear, 0),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer<VerticalAttributeDisplay> // outer content
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
circleSizeDisplay = new VerticalAttributeDisplay("CS"),
|
|
|
|
|
drainRateDisplay = new VerticalAttributeDisplay("HP"),
|
|
|
|
|
approachRateDisplay = new VerticalAttributeDisplay("AR"),
|
|
|
|
|
overallDifficultyDisplay = new VerticalAttributeDisplay("OD"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-08-29 04:16:33 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2023-09-03 07:09:01 +08:00
|
|
|
|
adjustedInfo.BindValueChanged(e => { UpdateValues(); }, true);
|
2023-08-29 04:16:33 +08:00
|
|
|
|
|
2023-09-03 07:09:01 +08:00
|
|
|
|
background.Colour = colourProvider.Background4;
|
|
|
|
|
innerBackground.Colour = colourProvider.Background3;
|
|
|
|
|
Color4 glow_colour = colourProvider.Background1;
|
2023-08-29 04:16:33 +08:00
|
|
|
|
|
2023-09-03 07:09:01 +08:00
|
|
|
|
content.BorderColour = ColourInfo.GradientVertical(background.Colour, glow_colour);
|
|
|
|
|
innerContent.BorderColour = ColourInfo.GradientVertical(innerBackground.Colour, glow_colour);
|
2023-08-29 04:16:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 07:09:01 +08:00
|
|
|
|
public void UpdateValues()
|
2023-08-29 04:16:33 +08:00
|
|
|
|
{
|
2023-09-03 07:09:01 +08:00
|
|
|
|
if (adjustedInfo.Value == null) return;
|
|
|
|
|
|
|
|
|
|
starRatingDisplay.Current.Value = adjustedInfo.Value.StarDifficulty;
|
|
|
|
|
bpmDisplay.Current.Value = adjustedInfo.Value.BPM;
|
|
|
|
|
|
|
|
|
|
circleSizeDisplay.Current.Value = adjustedInfo.Value.CircleSize;
|
|
|
|
|
drainRateDisplay.Current.Value = adjustedInfo.Value.DrainRate;
|
|
|
|
|
approachRateDisplay.Current.Value = adjustedInfo.Value.ApproachRate;
|
|
|
|
|
overallDifficultyDisplay.Current.Value = adjustedInfo.Value.OverallDifficulty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private partial class BPMDisplay : RollingCounter<double>
|
|
|
|
|
{
|
|
|
|
|
protected override double RollingDuration => 500;
|
|
|
|
|
|
|
|
|
|
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString("0 BPM");
|
|
|
|
|
|
|
|
|
|
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.Default.With(size: 20, weight: FontWeight.SemiBold)
|
|
|
|
|
};
|
2023-08-29 04:16:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|