2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-11 13:48:48 +08:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Allocation;
|
2020-03-11 09:18:41 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2021-08-29 20:00:28 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2017-09-11 13:48:48 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-02-22 16:14:00 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-09-11 13:48:48 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2021-07-31 15:46:02 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2017-09-11 13:48:48 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-10-29 16:58:46 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-08-08 16:25:51 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-25 17:26:27 +08:00
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
2017-09-11 13:48:48 +08:00
|
|
|
|
{
|
|
|
|
|
public class BasicStats : Container
|
|
|
|
|
{
|
2017-09-14 05:25:23 +08:00
|
|
|
|
private readonly Statistic length, bpm, circleCount, sliderCount;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
private APIBeatmapSet beatmapSet;
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
public APIBeatmapSet BeatmapSet
|
2017-09-14 05:25:23 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => beatmapSet;
|
2017-09-14 05:25:23 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmapSet) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2017-09-14 05:25:23 +08:00
|
|
|
|
beatmapSet = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
updateDisplay();
|
2017-09-14 05:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
private IBeatmapInfo beatmapInfo;
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
public IBeatmapInfo BeatmapInfo
|
2017-09-11 13:48:48 +08:00
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
|
get => beatmapInfo;
|
2017-09-11 13:48:48 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
|
if (value == beatmapInfo) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2021-10-02 11:44:22 +08:00
|
|
|
|
beatmapInfo = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
updateDisplay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDisplay()
|
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
bpm.Value = BeatmapSet?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-";
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2021-10-02 11:44:22 +08:00
|
|
|
|
if (beatmapInfo == null)
|
2018-04-18 15:04:02 +08:00
|
|
|
|
{
|
|
|
|
|
length.Value = string.Empty;
|
|
|
|
|
circleCount.Value = string.Empty;
|
|
|
|
|
sliderCount.Value = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-10-02 11:44:22 +08:00
|
|
|
|
length.TooltipText = BeatmapsetsStrings.ShowStatsTotalLength(TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration());
|
|
|
|
|
length.Value = TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration();
|
2021-08-08 16:25:51 +08:00
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
var onlineInfo = beatmapInfo as IBeatmapOnlineInfo;
|
|
|
|
|
|
|
|
|
|
circleCount.Value = (onlineInfo?.CircleCount ?? 0).ToLocalisableString(@"N0");
|
|
|
|
|
sliderCount.Value = (onlineInfo?.SliderCount ?? 0).ToLocalisableString(@"N0");
|
2017-09-11 13:48:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-14 05:25:23 +08:00
|
|
|
|
public BasicStats()
|
2017-09-11 13:48:48 +08:00
|
|
|
|
{
|
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2021-08-20 15:47:23 +08:00
|
|
|
|
length = new Statistic(BeatmapStatisticsIconType.Length)
|
|
|
|
|
{
|
|
|
|
|
Width = 0.25f,
|
|
|
|
|
TooltipText = default,
|
|
|
|
|
},
|
|
|
|
|
bpm = new Statistic(BeatmapStatisticsIconType.Bpm)
|
|
|
|
|
{
|
|
|
|
|
Width = 0.25f,
|
|
|
|
|
TooltipText = BeatmapsetsStrings.ShowStatsBpm
|
|
|
|
|
},
|
|
|
|
|
circleCount = new Statistic(BeatmapStatisticsIconType.Circles)
|
|
|
|
|
{
|
|
|
|
|
Width = 0.25f,
|
|
|
|
|
TooltipText = BeatmapsetsStrings.ShowStatsCountCircles
|
|
|
|
|
},
|
|
|
|
|
sliderCount = new Statistic(BeatmapStatisticsIconType.Sliders)
|
|
|
|
|
{
|
|
|
|
|
Width = 0.25f,
|
|
|
|
|
TooltipText = BeatmapsetsStrings.ShowStatsCountSliders
|
|
|
|
|
},
|
2017-09-11 13:48:48 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
updateDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 13:48:48 +08:00
|
|
|
|
private class Statistic : Container, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
private readonly OsuSpriteText value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-08 16:25:51 +08:00
|
|
|
|
public LocalisableString TooltipText { get; set; }
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2021-02-22 16:14:00 +08:00
|
|
|
|
public LocalisableString Value
|
2017-09-11 13:48:48 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => value.Text;
|
|
|
|
|
set => this.value.Text = value;
|
2017-09-11 13:48:48 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-20 15:47:23 +08:00
|
|
|
|
public Statistic(BeatmapStatisticsIconType icon)
|
2017-09-11 13:48:48 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2020-02-17 04:43:33 +08:00
|
|
|
|
Height = 24f;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-11 13:48:48 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2020-02-17 04:43:33 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2017-09-11 13:48:48 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-04-02 18:55:24 +08:00
|
|
|
|
Icon = FontAwesome.Solid.Square,
|
2020-02-17 04:43:33 +08:00
|
|
|
|
Size = new Vector2(12),
|
2017-09-11 13:48:48 +08:00
|
|
|
|
Rotation = 45,
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"441288"),
|
2017-09-11 13:48:48 +08:00
|
|
|
|
},
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.Centre,
|
2021-08-16 05:40:31 +08:00
|
|
|
|
Icon = FontAwesome.Regular.Circle,
|
|
|
|
|
Size = new Vector2(10),
|
|
|
|
|
Rotation = 0,
|
|
|
|
|
Colour = Color4Extensions.FromHex(@"f7dd55"),
|
|
|
|
|
},
|
|
|
|
|
new BeatmapStatisticIcon(icon)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(10),
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"f7dd55"),
|
2017-09-11 13:48:48 +08:00
|
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
|
},
|
|
|
|
|
value = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Margin = new MarginPadding { Left = 10 },
|
2020-02-17 04:43:33 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
2017-09-11 13:48:48 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-11 13:48:48 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colour)
|
|
|
|
|
{
|
|
|
|
|
value.Colour = colour.Yellow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|