2020-03-17 15:59:34 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-20 13:46:22 +08:00
|
|
|
using System;
|
2020-03-17 16:25:24 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2022-09-16 07:50:18 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-01-03 16:31:12 +08:00
|
|
|
using osu.Framework.Extensions;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Framework.Graphics;
|
2020-03-17 15:59:34 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-02-22 16:14:13 +08:00
|
|
|
using osu.Framework.Localisation;
|
2020-10-23 13:57:27 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2021-07-17 11:54:11 +08:00
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2022-09-16 07:50:18 +08:00
|
|
|
using osu.Game.Configuration;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-03-18 14:03:01 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-03-17 15:59:34 +08:00
|
|
|
using osu.Game.Scoring;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
using osu.Game.Screens.Ranking.Expanded.Accuracy;
|
|
|
|
using osu.Game.Screens.Ranking.Expanded.Statistics;
|
|
|
|
using osuTK;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Ranking.Expanded
|
|
|
|
{
|
2020-03-17 16:34:16 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The content that appears in the middle section of the <see cref="ScorePanel"/>.
|
|
|
|
/// </summary>
|
2020-03-17 15:59:34 +08:00
|
|
|
public class ExpandedPanelMiddleContent : CompositeDrawable
|
|
|
|
{
|
2020-08-28 21:51:48 +08:00
|
|
|
private const float padding = 10;
|
2020-03-17 16:25:24 +08:00
|
|
|
|
2020-08-28 21:51:48 +08:00
|
|
|
private readonly ScoreInfo score;
|
2020-10-29 15:11:25 +08:00
|
|
|
private readonly bool withFlair;
|
|
|
|
|
2020-03-17 16:25:24 +08:00
|
|
|
private readonly List<StatisticDisplay> statisticDisplays = new List<StatisticDisplay>();
|
2020-04-04 02:30:22 +08:00
|
|
|
|
|
|
|
private FillFlowContainer starAndModDisplay;
|
2020-03-17 16:25:24 +08:00
|
|
|
private RollingCounter<long> scoreCounter;
|
|
|
|
|
2020-08-28 21:51:48 +08:00
|
|
|
[Resolved]
|
|
|
|
private ScoreManager scoreManager { get; set; }
|
2020-05-01 13:13:38 +08:00
|
|
|
|
2020-03-17 16:34:16 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new <see cref="ExpandedPanelMiddleContent"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="score">The score to display.</param>
|
2020-10-29 15:11:25 +08:00
|
|
|
/// <param name="withFlair">Whether to add flair for a new score being set.</param>
|
|
|
|
public ExpandedPanelMiddleContent(ScoreInfo score, bool withFlair = false)
|
2020-03-17 15:59:34 +08:00
|
|
|
{
|
2020-03-17 16:25:24 +08:00
|
|
|
this.score = score;
|
2020-10-29 15:11:25 +08:00
|
|
|
this.withFlair = withFlair;
|
2020-03-17 16:25:24 +08:00
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Masking = true;
|
|
|
|
|
2020-05-01 13:13:38 +08:00
|
|
|
Padding = new MarginPadding(padding);
|
2020-03-17 16:25:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-09-16 12:14:25 +08:00
|
|
|
private void load(BeatmapDifficultyCache beatmapDifficultyCache)
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-10-04 16:35:53 +08:00
|
|
|
var beatmap = score.BeatmapInfo;
|
2020-06-11 13:55:49 +08:00
|
|
|
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
2021-11-04 17:22:21 +08:00
|
|
|
string creator = metadata.Author.Username;
|
2020-03-17 21:54:02 +08:00
|
|
|
|
2020-03-17 16:25:24 +08:00
|
|
|
var topStatistics = new List<StatisticDisplay>
|
|
|
|
{
|
|
|
|
new AccuracyStatistic(score.Accuracy),
|
2022-08-22 20:31:30 +08:00
|
|
|
new ComboStatistic(score.MaxCombo, scoreManager.GetMaximumAchievableCombo(score)),
|
2020-09-26 01:15:40 +08:00
|
|
|
new PerformanceStatistic(score),
|
2020-03-17 16:25:24 +08:00
|
|
|
};
|
|
|
|
|
2020-10-07 15:17:08 +08:00
|
|
|
var bottomStatistics = new List<HitResultStatistic>();
|
2020-09-25 19:22:59 +08:00
|
|
|
|
2020-10-07 14:35:04 +08:00
|
|
|
foreach (var result in score.GetStatisticsForDisplay())
|
|
|
|
bottomStatistics.Add(new HitResultStatistic(result));
|
2020-03-17 16:25:24 +08:00
|
|
|
|
|
|
|
statisticDisplays.AddRange(topStatistics);
|
|
|
|
statisticDisplays.AddRange(bottomStatistics);
|
|
|
|
|
2021-07-20 13:46:22 +08:00
|
|
|
AddInternal(new FillFlowContainer
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(20),
|
|
|
|
Children = new Drawable[]
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new FillFlowContainer
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new OsuSpriteText
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Text = new RomanisableString(metadata.TitleUnicode, metadata.Title),
|
|
|
|
Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold),
|
|
|
|
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
|
|
|
|
Truncate = true,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist),
|
|
|
|
Font = OsuFont.Torus.With(size: 14, weight: FontWeight.SemiBold),
|
|
|
|
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
|
|
|
|
Truncate = true,
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding { Top = 40 },
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 230,
|
|
|
|
Child = new AccuracyCircle(score, withFlair)
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
}
|
|
|
|
},
|
2022-07-22 18:48:29 +08:00
|
|
|
scoreCounter = new TotalScoreCounter(!withFlair)
|
2021-07-20 13:46:22 +08:00
|
|
|
{
|
|
|
|
Margin = new MarginPadding { Top = 0, Bottom = 5 },
|
|
|
|
Current = { Value = 0 },
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
|
|
|
},
|
|
|
|
starAndModDisplay = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(5, 0),
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
2020-10-07 15:30:14 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new OsuSpriteText
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-11-11 16:19:53 +08:00
|
|
|
Text = beatmap.DifficultyName,
|
2021-07-20 13:46:22 +08:00
|
|
|
Font = OsuFont.Torus.With(size: 16, weight: FontWeight.SemiBold),
|
2022-06-07 12:05:03 +08:00
|
|
|
MaxWidth = ScorePanel.EXPANDED_WIDTH - padding * 2,
|
|
|
|
Truncate = true,
|
2021-07-20 13:46:22 +08:00
|
|
|
},
|
|
|
|
new OsuTextFlowContainer(s => s.Font = OsuFont.Torus.With(size: 12))
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
}.With(t =>
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(creator))
|
2020-10-07 15:30:14 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
t.AddText("mapped by ");
|
|
|
|
t.AddText(creator, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
Children = new Drawable[]
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new GridContainer
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Content = new[] { topStatistics.Cast<Drawable>().ToArray() },
|
|
|
|
RowDimensions = new[]
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Content = new[] { bottomStatistics.Where(s => s.Result <= HitResult.Perfect).ToArray() },
|
|
|
|
RowDimensions = new[]
|
2020-10-07 15:17:08 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Content = new[] { bottomStatistics.Where(s => s.Result > HitResult.Perfect).ToArray() },
|
|
|
|
RowDimensions = new[]
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2021-07-20 13:46:22 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-03-17 16:25:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-20 13:46:22 +08:00
|
|
|
});
|
|
|
|
|
2021-07-20 18:05:08 +08:00
|
|
|
if (score.Date != default)
|
2022-09-16 12:14:25 +08:00
|
|
|
AddInternal(new PlayedOnText(score.Date));
|
2020-04-04 02:30:22 +08:00
|
|
|
|
2022-03-20 10:33:35 +08:00
|
|
|
var starDifficulty = beatmapDifficultyCache.GetDifficultyAsync(beatmap, score.Ruleset, score.Mods).GetResultSafely();
|
|
|
|
|
2021-11-20 23:54:58 +08:00
|
|
|
if (starDifficulty != null)
|
|
|
|
{
|
|
|
|
starAndModDisplay.Add(new StarRatingDisplay(starDifficulty.Value)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-04 02:30:22 +08:00
|
|
|
if (score.Mods.Any())
|
|
|
|
{
|
|
|
|
starAndModDisplay.Add(new ModDisplay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
ExpansionMode = ExpansionMode.AlwaysExpanded,
|
|
|
|
Scale = new Vector2(0.5f),
|
|
|
|
Current = { Value = score.Mods }
|
|
|
|
});
|
|
|
|
}
|
2020-03-17 16:25:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
// Score counter value setting must be scheduled so it isn't transferred instantaneously
|
|
|
|
ScheduleAfterChildren(() =>
|
|
|
|
{
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY))
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
|
|
|
scoreCounter.FadeIn();
|
2020-09-09 16:04:02 +08:00
|
|
|
scoreCounter.Current = scoreManager.GetBindableTotalScore(score);
|
2020-03-17 16:25:24 +08:00
|
|
|
|
|
|
|
double delay = 0;
|
|
|
|
|
|
|
|
foreach (var stat in statisticDisplays)
|
|
|
|
{
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(delay))
|
2020-03-17 16:25:24 +08:00
|
|
|
stat.Appear();
|
|
|
|
|
|
|
|
delay += 200;
|
|
|
|
}
|
|
|
|
}
|
2020-10-29 16:04:33 +08:00
|
|
|
|
|
|
|
if (!withFlair)
|
|
|
|
FinishTransforms(true);
|
2020-03-17 16:25:24 +08:00
|
|
|
});
|
2020-03-17 15:59:34 +08:00
|
|
|
}
|
2021-07-20 13:46:22 +08:00
|
|
|
|
|
|
|
public class PlayedOnText : OsuSpriteText
|
|
|
|
{
|
2022-09-16 12:14:25 +08:00
|
|
|
private readonly DateTimeOffset time;
|
|
|
|
private readonly Bindable<bool> prefer24HourTime = new Bindable<bool>();
|
2022-09-16 07:50:18 +08:00
|
|
|
|
2022-09-16 12:14:25 +08:00
|
|
|
public PlayedOnText(DateTimeOffset time)
|
2021-07-20 13:46:22 +08:00
|
|
|
{
|
2022-09-16 12:14:25 +08:00
|
|
|
this.time = time;
|
|
|
|
|
2021-07-20 13:46:22 +08:00
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold);
|
2022-09-16 07:50:18 +08:00
|
|
|
}
|
|
|
|
|
2022-09-16 12:14:25 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuConfigManager configManager)
|
|
|
|
{
|
|
|
|
configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
prefer24HourTime.BindValueChanged(_ => updateDisplay(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateDisplay()
|
2022-09-16 07:50:18 +08:00
|
|
|
{
|
2022-09-16 12:14:25 +08:00
|
|
|
Text = prefer24HourTime.Value ? $"Played on {time.ToLocalTime():d MMMM yyyy HH:mm}" : $"Played on {time.ToLocalTime():d MMMM yyyy h:mm tt}";
|
2021-07-20 13:46:22 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 15:59:34 +08:00
|
|
|
}
|
|
|
|
}
|