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
|
|
|
|
|
2016-12-06 17:56:20 +08:00
|
|
|
|
using System;
|
2017-01-30 12:12:30 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using System.Linq;
|
2020-11-03 18:53:35 +08:00
|
|
|
|
using System.Threading;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2017-04-24 19:11:36 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2016-11-24 12:48:48 +08:00
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2016-12-16 11:25:28 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-12-15 02:55:15 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-12-31 04:12:47 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2020-03-13 13:28:11 +08:00
|
|
|
|
using osu.Framework.Logging;
|
2021-02-25 20:51:32 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2021-07-31 15:46:02 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2018-05-07 10:59:17 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2019-04-08 17:32:05 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-05-07 10:59:17 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2021-04-19 22:53:44 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-23 04:51:42 +08:00
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2019-10-15 07:27:59 +08:00
|
|
|
|
public class BeatmapInfoWedge : VisibilityContainer
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2021-08-13 21:29:22 +08:00
|
|
|
|
public const float BORDER_THICKNESS = 2.5f;
|
2019-09-25 07:06:33 +08:00
|
|
|
|
private const float shear_width = 36.75f;
|
|
|
|
|
|
2021-08-17 09:29:15 +08:00
|
|
|
|
private const float transition_duration = 250;
|
|
|
|
|
|
2020-01-23 19:03:52 +08:00
|
|
|
|
private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / SongSelect.WEDGE_HEIGHT, 0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 21:01:53 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
|
|
|
|
|
2021-05-06 01:14:57 +08:00
|
|
|
|
protected Container DisplayedContent { get; private set; }
|
2021-05-06 01:14:04 +08:00
|
|
|
|
|
2021-05-06 01:14:57 +08:00
|
|
|
|
protected WedgeInfoText Info { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-26 16:31:35 +08:00
|
|
|
|
public BeatmapInfoWedge()
|
|
|
|
|
{
|
|
|
|
|
Shear = wedged_container_shear;
|
|
|
|
|
Masking = true;
|
|
|
|
|
BorderColour = new Color4(221, 255, 255, 255);
|
2021-08-13 21:29:22 +08:00
|
|
|
|
BorderThickness = BORDER_THICKNESS;
|
2017-12-26 19:18:47 +08:00
|
|
|
|
Alpha = 0;
|
2017-06-12 11:48:47 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2016-11-26 16:31:35 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Colour = new Color4(130, 204, 255, 150),
|
|
|
|
|
Radius = 20,
|
|
|
|
|
Roundness = 15,
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 21:09:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-05-07 10:59:17 +08:00
|
|
|
|
{
|
2021-02-25 21:09:41 +08:00
|
|
|
|
ruleset.BindValueChanged(_ => updateDisplay());
|
2018-05-07 10:59:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-19 18:19:46 +08:00
|
|
|
|
private const double animation_duration = 800;
|
|
|
|
|
|
2017-03-14 16:29:20 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2021-08-19 18:19:46 +08:00
|
|
|
|
this.MoveToX(0, animation_duration, Easing.OutQuint);
|
|
|
|
|
this.RotateTo(0, animation_duration, Easing.OutQuint);
|
2021-08-17 09:29:15 +08:00
|
|
|
|
this.FadeIn(transition_duration);
|
2017-03-14 16:29:20 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-14 16:29:20 +08:00
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2021-08-19 18:19:46 +08:00
|
|
|
|
this.MoveToX(-100, animation_duration, Easing.In);
|
|
|
|
|
this.RotateTo(10, animation_duration, Easing.In);
|
2021-08-17 09:29:15 +08:00
|
|
|
|
this.FadeOut(transition_duration * 2, Easing.In);
|
2017-03-14 16:29:20 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-05-07 10:59:17 +08:00
|
|
|
|
private WorkingBeatmap beatmap;
|
|
|
|
|
|
2018-06-01 17:03:16 +08:00
|
|
|
|
public WorkingBeatmap Beatmap
|
2018-05-07 10:59:17 +08:00
|
|
|
|
{
|
2018-06-01 17:03:16 +08:00
|
|
|
|
get => beatmap;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (beatmap == value) return;
|
|
|
|
|
|
|
|
|
|
beatmap = value;
|
2020-10-22 00:57:48 +08:00
|
|
|
|
|
2018-06-01 17:03:16 +08:00
|
|
|
|
updateDisplay();
|
|
|
|
|
}
|
2018-05-07 10:59:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 01:14:04 +08:00
|
|
|
|
public override bool IsPresent => base.IsPresent || DisplayedContent == null; // Visibility is updated in the LoadComponentAsync callback
|
2018-09-25 13:39:10 +08:00
|
|
|
|
|
2021-05-06 00:50:49 +08:00
|
|
|
|
private Container loadingInfo;
|
2018-05-07 10:59:17 +08:00
|
|
|
|
|
2018-06-01 17:03:16 +08:00
|
|
|
|
private void updateDisplay()
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2020-11-04 09:21:42 +08:00
|
|
|
|
Scheduler.AddOnce(perform);
|
2018-05-13 11:55:54 +08:00
|
|
|
|
|
2020-11-04 09:21:42 +08:00
|
|
|
|
void perform()
|
2018-05-13 11:55:54 +08:00
|
|
|
|
{
|
2020-11-04 09:21:42 +08:00
|
|
|
|
void removeOldInfo()
|
|
|
|
|
{
|
|
|
|
|
State.Value = beatmap == null ? Visibility.Hidden : Visibility.Visible;
|
|
|
|
|
|
2021-08-17 09:29:15 +08:00
|
|
|
|
DisplayedContent?.FadeOut(transition_duration);
|
2021-05-06 01:14:04 +08:00
|
|
|
|
DisplayedContent?.Expire();
|
|
|
|
|
DisplayedContent = null;
|
2020-11-04 09:21:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (beatmap == null)
|
|
|
|
|
{
|
|
|
|
|
removeOldInfo();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 00:50:49 +08:00
|
|
|
|
LoadComponentAsync(loadingInfo = new Container
|
2020-11-04 09:21:42 +08:00
|
|
|
|
{
|
2021-05-06 00:50:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-11-04 09:21:42 +08:00
|
|
|
|
Shear = -Shear,
|
2021-05-06 01:14:04 +08:00
|
|
|
|
Depth = DisplayedContent?.Depth + 1 ?? 0,
|
2021-05-06 00:50:49 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new BeatmapInfoWedgeBackground(beatmap),
|
2021-08-24 12:53:49 +08:00
|
|
|
|
Info = new WedgeInfoText(beatmap, ruleset.Value),
|
2021-05-06 00:50:49 +08:00
|
|
|
|
}
|
2020-11-04 09:21:42 +08:00
|
|
|
|
}, loaded =>
|
|
|
|
|
{
|
|
|
|
|
// ensure we are the most recent loaded wedge.
|
|
|
|
|
if (loaded != loadingInfo) return;
|
|
|
|
|
|
|
|
|
|
removeOldInfo();
|
2021-05-06 01:14:04 +08:00
|
|
|
|
Add(DisplayedContent = loaded);
|
2020-11-04 09:21:42 +08:00
|
|
|
|
});
|
2018-05-13 11:55:54 +08:00
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-04-20 05:41:51 +08:00
|
|
|
|
public class WedgeInfoText : Container
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
2017-12-22 19:33:52 +08:00
|
|
|
|
public OsuSpriteText VersionLabel { get; private set; }
|
|
|
|
|
public OsuSpriteText TitleLabel { get; private set; }
|
|
|
|
|
public OsuSpriteText ArtistLabel { get; private set; }
|
|
|
|
|
public FillFlowContainer MapperContainer { get; private set; }
|
2018-06-01 17:03:16 +08:00
|
|
|
|
|
2021-08-19 12:18:02 +08:00
|
|
|
|
private Container difficultyColourBar;
|
2021-08-17 09:29:15 +08:00
|
|
|
|
private StarRatingDisplay starRatingDisplay;
|
|
|
|
|
|
2018-09-19 13:07:46 +08:00
|
|
|
|
private ILocalisedBindableString titleBinding;
|
|
|
|
|
private ILocalisedBindableString artistBinding;
|
2021-02-25 22:36:02 +08:00
|
|
|
|
private FillFlowContainer infoLabelContainer;
|
2021-02-25 20:51:32 +08:00
|
|
|
|
private Container bpmLabelContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-12-10 12:53:48 +08:00
|
|
|
|
private readonly WorkingBeatmap working;
|
2018-05-11 13:10:53 +08:00
|
|
|
|
private readonly RulesetInfo ruleset;
|
2021-08-24 12:53:49 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
2018-05-07 10:59:17 +08:00
|
|
|
|
|
2022-03-10 16:54:31 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapDifficultyCache difficultyCache { get; set; }
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2021-02-25 20:51:32 +08:00
|
|
|
|
private ModSettingChangeTracker settingChangeTracker;
|
|
|
|
|
|
2021-12-10 12:53:48 +08:00
|
|
|
|
public WedgeInfoText(WorkingBeatmap working, RulesetInfo userRuleset)
|
2017-11-21 10:49:21 +08:00
|
|
|
|
{
|
2021-12-10 12:53:48 +08:00
|
|
|
|
this.working = working;
|
|
|
|
|
ruleset = userRuleset ?? working.BeatmapInfo.Ruleset;
|
2017-11-21 10:49:21 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-17 09:29:15 +08:00
|
|
|
|
private CancellationTokenSource cancellationSource;
|
|
|
|
|
private IBindable<StarDifficulty?> starDifficulty;
|
|
|
|
|
|
2018-05-11 13:13:52 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-03-10 16:54:31 +08:00
|
|
|
|
private void load(LocalisationManager localisation)
|
2017-01-30 12:12:30 +08:00
|
|
|
|
{
|
2021-12-10 12:53:48 +08:00
|
|
|
|
var beatmapInfo = working.BeatmapInfo;
|
2021-11-22 15:10:13 +08:00
|
|
|
|
var metadata = beatmapInfo.Metadata;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-11-01 22:39:22 +08:00
|
|
|
|
titleBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.TitleUnicode, metadata.Title));
|
|
|
|
|
artistBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.ArtistUnicode, metadata.Artist));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-19 18:19:46 +08:00
|
|
|
|
const float top_height = 0.7f;
|
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2021-08-19 12:18:02 +08:00
|
|
|
|
difficultyColourBar = new Container
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2021-08-19 12:18:02 +08:00
|
|
|
|
Width = 20f,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-19 18:19:46 +08:00
|
|
|
|
Width = top_height,
|
2021-08-19 12:18:02 +08:00
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
Alpha = 0.5f,
|
2021-08-19 18:19:46 +08:00
|
|
|
|
X = top_height,
|
|
|
|
|
Width = 1 - top_height,
|
2021-08-19 12:18:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
2018-09-13 16:18:20 +08:00
|
|
|
|
Name = "Topleft-aligned metadata",
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2019-09-25 07:28:40 +08:00
|
|
|
|
Padding = new MarginPadding { Top = 10, Left = 25, Right = shear_width * 2.5f },
|
2019-09-25 07:06:33 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-04-02 14:56:12 +08:00
|
|
|
|
{
|
2017-12-22 19:33:52 +08:00
|
|
|
|
VersionLabel = new OsuSpriteText
|
2017-04-24 19:11:36 +08:00
|
|
|
|
{
|
2021-11-11 16:19:53 +08:00
|
|
|
|
Text = beatmapInfo.DifficultyName,
|
2019-02-20 15:52:36 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 24, italics: true),
|
2019-09-25 07:06:33 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Truncate = true,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
2018-09-13 16:18:20 +08:00
|
|
|
|
{
|
|
|
|
|
Name = "Topright-aligned metadata",
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2019-09-25 07:28:40 +08:00
|
|
|
|
Padding = new MarginPadding { Top = 14, Right = shear_width / 2 },
|
2018-09-13 16:18:20 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2020-09-01 01:31:47 +08:00
|
|
|
|
Shear = wedged_container_shear,
|
2021-08-19 13:30:27 +08:00
|
|
|
|
Spacing = new Vector2(0f, 5f),
|
2021-08-17 09:29:15 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-09-13 16:18:20 +08:00
|
|
|
|
{
|
2021-08-19 12:18:02 +08:00
|
|
|
|
starRatingDisplay = new StarRatingDisplay(default, animated: true)
|
2020-08-31 14:03:41 +08:00
|
|
|
|
{
|
2021-08-17 09:29:15 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Shear = -wedged_container_shear,
|
|
|
|
|
Alpha = 0f,
|
|
|
|
|
},
|
2022-03-10 16:54:31 +08:00
|
|
|
|
new BeatmapSetOnlineStatusPill
|
2018-09-13 16:18:20 +08:00
|
|
|
|
{
|
2021-10-26 02:20:40 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2020-09-01 01:23:19 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2020-09-01 01:31:47 +08:00
|
|
|
|
Shear = -wedged_container_shear,
|
2018-09-20 11:35:07 +08:00
|
|
|
|
TextSize = 11,
|
|
|
|
|
TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 },
|
2018-09-13 16:18:20 +08:00
|
|
|
|
Status = beatmapInfo.Status,
|
2022-03-10 16:54:31 +08:00
|
|
|
|
Alpha = string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? 0 : 1
|
2018-09-13 16:18:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
2017-12-26 18:34:26 +08:00
|
|
|
|
Name = "Centre-aligned metadata",
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
2019-09-25 07:28:40 +08:00
|
|
|
|
Y = -7,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2019-09-25 07:28:40 +08:00
|
|
|
|
Padding = new MarginPadding { Left = 25, Right = shear_width },
|
2019-09-25 07:06:33 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-04-24 19:11:36 +08:00
|
|
|
|
{
|
2017-12-22 19:33:52 +08:00
|
|
|
|
TitleLabel = new OsuSpriteText
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2022-03-30 16:59:45 +08:00
|
|
|
|
Current = { BindTarget = titleBinding },
|
2019-02-20 15:52:36 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 28, italics: true),
|
2019-09-25 07:06:33 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Truncate = true,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
},
|
2017-12-22 19:33:52 +08:00
|
|
|
|
ArtistLabel = new OsuSpriteText
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
2022-03-30 16:59:45 +08:00
|
|
|
|
Current = { BindTarget = artistBinding },
|
2019-02-20 15:52:36 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 17, italics: true),
|
2019-09-25 07:06:33 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Truncate = true,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
},
|
2017-12-22 19:33:52 +08:00
|
|
|
|
MapperContainer = new FillFlowContainer
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 10 },
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2021-04-20 01:24:46 +08:00
|
|
|
|
Child = getMapper(metadata),
|
2017-04-28 20:16:37 +08:00
|
|
|
|
},
|
2021-02-25 22:36:02 +08:00
|
|
|
|
infoLabelContainer = new FillFlowContainer
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 20 },
|
|
|
|
|
Spacing = new Vector2(20, 0),
|
2017-04-28 20:16:37 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-12-22 17:18:25 +08:00
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}
|
2017-12-22 17:18:25 +08:00
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
};
|
2018-09-19 13:57:32 +08:00
|
|
|
|
|
2022-03-10 16:54:31 +08:00
|
|
|
|
addInfoLabels();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2021-08-19 12:18:02 +08:00
|
|
|
|
starRatingDisplay.DisplayedStars.BindValueChanged(s =>
|
|
|
|
|
{
|
|
|
|
|
difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue);
|
|
|
|
|
}, true);
|
|
|
|
|
|
2022-03-10 16:54:31 +08:00
|
|
|
|
starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token);
|
2021-08-17 09:29:15 +08:00
|
|
|
|
starDifficulty.BindValueChanged(s =>
|
|
|
|
|
{
|
|
|
|
|
starRatingDisplay.Current.Value = s.NewValue ?? default;
|
2022-03-10 18:59:05 +08:00
|
|
|
|
|
|
|
|
|
// Don't roll the counter on initial display (but still allow it to roll on applying mods etc.)
|
|
|
|
|
if (!starRatingDisplay.IsPresent)
|
|
|
|
|
starRatingDisplay.FinishTransforms(true);
|
|
|
|
|
|
|
|
|
|
starRatingDisplay.FadeIn(transition_duration);
|
2021-08-17 09:29:15 +08:00
|
|
|
|
});
|
|
|
|
|
|
2021-12-09 17:50:53 +08:00
|
|
|
|
mods.BindValueChanged(m =>
|
|
|
|
|
{
|
|
|
|
|
settingChangeTracker?.Dispose();
|
|
|
|
|
|
|
|
|
|
refreshBPMLabel();
|
|
|
|
|
|
|
|
|
|
settingChangeTracker = new ModSettingChangeTracker(m.NewValue);
|
|
|
|
|
settingChangeTracker.SettingChanged += _ => refreshBPMLabel();
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 22:36:02 +08:00
|
|
|
|
private void addInfoLabels()
|
2017-12-22 03:23:10 +08:00
|
|
|
|
{
|
2021-12-10 12:53:48 +08:00
|
|
|
|
if (working.Beatmap?.HitObjects?.Any() != true)
|
2021-02-25 22:36:02 +08:00
|
|
|
|
return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 22:36:02 +08:00
|
|
|
|
infoLabelContainer.Children = new Drawable[]
|
2017-12-22 03:23:10 +08:00
|
|
|
|
{
|
2021-02-25 22:36:02 +08:00
|
|
|
|
new InfoLabel(new BeatmapStatistic
|
2017-12-22 17:18:25 +08:00
|
|
|
|
{
|
|
|
|
|
Name = "Length",
|
2020-09-04 14:01:32 +08:00
|
|
|
|
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length),
|
2021-12-10 12:53:48 +08:00
|
|
|
|
Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(),
|
2021-02-25 22:36:02 +08:00
|
|
|
|
}),
|
|
|
|
|
bpmLabelContainer = new Container
|
2017-12-22 17:18:25 +08:00
|
|
|
|
{
|
2021-02-25 22:36:02 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
2018-05-07 10:59:17 +08:00
|
|
|
|
{
|
2021-02-25 22:36:02 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Spacing = new Vector2(20, 0),
|
|
|
|
|
Children = getRulesetInfoLabels()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 20:51:32 +08:00
|
|
|
|
private InfoLabel[] getRulesetInfoLabels()
|
2017-12-22 03:23:10 +08:00
|
|
|
|
{
|
2021-02-25 20:51:32 +08:00
|
|
|
|
try
|
2017-12-22 03:23:10 +08:00
|
|
|
|
{
|
2021-02-25 20:51:32 +08:00
|
|
|
|
IBeatmap playableBeatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-05-07 10:59:17 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
2021-02-25 20:51:32 +08:00
|
|
|
|
// Try to get the beatmap with the user's ruleset
|
2021-12-10 12:53:48 +08:00
|
|
|
|
playableBeatmap = working.GetPlayableBeatmap(ruleset, Array.Empty<Mod>());
|
2018-05-07 10:59:17 +08:00
|
|
|
|
}
|
2021-02-25 20:51:32 +08:00
|
|
|
|
catch (BeatmapInvalidForRulesetException)
|
2018-05-07 10:59:17 +08:00
|
|
|
|
{
|
2021-02-25 20:51:32 +08:00
|
|
|
|
// Can't be converted to the user's ruleset, so use the beatmap's own ruleset
|
2021-12-10 12:53:48 +08:00
|
|
|
|
playableBeatmap = working.GetPlayableBeatmap(working.BeatmapInfo.Ruleset, Array.Empty<Mod>());
|
2018-05-07 10:59:17 +08:00
|
|
|
|
}
|
2021-02-25 20:51:32 +08:00
|
|
|
|
|
|
|
|
|
return playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)).ToArray();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error(e, "Could not load beatmap successfully!");
|
2017-12-22 03:23:10 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 20:51:32 +08:00
|
|
|
|
return Array.Empty<InfoLabel>();
|
2017-12-22 17:18:25 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 22:36:02 +08:00
|
|
|
|
private void refreshBPMLabel()
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
2021-12-10 12:53:48 +08:00
|
|
|
|
var beatmap = working.Beatmap;
|
|
|
|
|
|
|
|
|
|
if (beatmap == null || bpmLabelContainer == null)
|
2021-02-25 20:51:32 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2021-02-25 16:00:42 +08:00
|
|
|
|
// this doesn't consider mods which apply variable rates, yet.
|
|
|
|
|
double rate = 1;
|
2021-08-24 12:53:49 +08:00
|
|
|
|
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
|
2021-02-25 16:00:42 +08:00
|
|
|
|
rate = mod.ApplyToRate(0, rate);
|
|
|
|
|
|
2022-05-20 22:47:45 +08:00
|
|
|
|
int bpmMax = (int)Math.Round(Math.Round(beatmap.ControlPointInfo.BPMMaximum) * rate);
|
|
|
|
|
int bpmMin = (int)Math.Round(Math.Round(beatmap.ControlPointInfo.BPMMinimum) * rate);
|
|
|
|
|
int mostCommonBPM = (int)Math.Round(Math.Round(60000 / beatmap.GetMostCommonBeatLength()) * rate);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-05-20 22:43:40 +08:00
|
|
|
|
string labelText = bpmMin == bpmMax
|
|
|
|
|
? $"{bpmMin}"
|
|
|
|
|
: $"{bpmMin}-{bpmMax} (mostly {mostCommonBPM})";
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 20:51:32 +08:00
|
|
|
|
bpmLabelContainer.Child = new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "BPM",
|
|
|
|
|
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Bpm),
|
|
|
|
|
Content = labelText
|
|
|
|
|
});
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-04-20 01:24:46 +08:00
|
|
|
|
private Drawable getMapper(BeatmapMetadata metadata)
|
2017-12-22 17:18:25 +08:00
|
|
|
|
{
|
2021-11-04 17:22:21 +08:00
|
|
|
|
if (string.IsNullOrEmpty(metadata.Author.Username))
|
2021-04-20 01:24:46 +08:00
|
|
|
|
return Empty();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-04-19 22:53:44 +08:00
|
|
|
|
return new LinkFlowContainer(s =>
|
2017-12-22 17:18:25 +08:00
|
|
|
|
{
|
2021-04-19 22:53:44 +08:00
|
|
|
|
s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15);
|
|
|
|
|
}).With(d =>
|
|
|
|
|
{
|
|
|
|
|
d.AutoSizeAxes = Axes.Both;
|
|
|
|
|
d.AddText("mapped by ");
|
|
|
|
|
d.AddUserLink(metadata.Author);
|
|
|
|
|
});
|
2017-12-22 17:18:25 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-25 20:51:32 +08:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
settingChangeTracker?.Dispose();
|
2021-08-17 09:29:15 +08:00
|
|
|
|
cancellationSource?.Cancel();
|
2021-02-25 20:51:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-15 02:55:15 +08:00
|
|
|
|
public class InfoLabel : Container, IHasTooltip
|
2016-12-17 22:53:26 +08:00
|
|
|
|
{
|
2021-06-26 01:10:04 +08:00
|
|
|
|
public LocalisableString TooltipText { get; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-23 01:01:26 +08:00
|
|
|
|
internal BeatmapStatistic Statistic { get; }
|
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
public InfoLabel(BeatmapStatistic statistic)
|
2017-01-29 13:47:42 +08:00
|
|
|
|
{
|
2021-08-23 01:01:26 +08:00
|
|
|
|
Statistic = statistic;
|
2017-12-15 02:55:15 +08:00
|
|
|
|
TooltipText = statistic.Name;
|
2017-04-28 20:16:37 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-12-15 12:01:06 +08:00
|
|
|
|
new Container
|
2017-11-21 10:49:21 +08:00
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-12-15 12:01:06 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Size = new Vector2(20),
|
2017-12-15 12:01:06 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"441288"),
|
2019-04-02 18:55:24 +08:00
|
|
|
|
Icon = FontAwesome.Solid.Square,
|
2017-12-15 12:01:06 +08:00
|
|
|
|
Rotation = 45,
|
|
|
|
|
},
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"f7dd55"),
|
2020-09-03 16:51:54 +08:00
|
|
|
|
Icon = FontAwesome.Regular.Circle,
|
2020-09-04 11:55:28 +08:00
|
|
|
|
Size = new Vector2(0.8f)
|
2017-12-15 12:01:06 +08:00
|
|
|
|
},
|
2020-09-03 16:51:54 +08:00
|
|
|
|
statistic.CreateIcon().With(i =>
|
|
|
|
|
{
|
|
|
|
|
i.Anchor = Anchor.Centre;
|
|
|
|
|
i.Origin = Anchor.Centre;
|
|
|
|
|
i.RelativeSizeAxes = Axes.Both;
|
|
|
|
|
i.Colour = Color4Extensions.FromHex(@"f7dd55");
|
2020-09-04 12:05:39 +08:00
|
|
|
|
i.Size = new Vector2(0.64f);
|
2020-09-03 16:51:54 +08:00
|
|
|
|
}),
|
2017-12-15 12:01:06 +08:00
|
|
|
|
}
|
2017-11-21 10:49:21 +08:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-12-15 12:01:06 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Colour = new Color4(255, 221, 85, 255),
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17),
|
2017-12-15 12:01:06 +08:00
|
|
|
|
Margin = new MarginPadding { Left = 30 },
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Text = statistic.Content,
|
2017-12-15 02:55:15 +08:00
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-04-24 19:11:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-23 04:51:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|