2018-04-13 17:19:50 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2018-12-21 15:28:33 +08:00
|
|
|
using osu.Framework.Extensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-21 15:28:33 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2018-12-21 15:28:33 +08:00
|
|
|
using osu.Framework.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-12-21 15:28:33 +08:00
|
|
|
using osu.Game.Online.Leaderboards;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-12-21 15:28:33 +08:00
|
|
|
using osu.Game.Scoring;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Users;
|
2018-12-21 15:28:33 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-21 15:28:33 +08:00
|
|
|
namespace osu.Game.Screens.Ranking.Pages
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-12-21 15:28:33 +08:00
|
|
|
public class ScoreResultsPage : ResultsPage
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-09-10 17:13:44 +08:00
|
|
|
private Container scoreContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
private ScoreCounter scoreCounter;
|
|
|
|
|
2018-12-21 15:28:33 +08:00
|
|
|
public ScoreResultsPage(ScoreInfo score, WorkingBeatmap beatmap)
|
|
|
|
: base(score, beatmap)
|
|
|
|
{
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
private FillFlowContainer<DrawableScoreStatistic> statisticsContainer;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
const float user_header_height = 120;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Top = user_header_height },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.White,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2018-11-30 14:18:52 +08:00
|
|
|
new UserHeader(Score.User)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = user_header_height,
|
|
|
|
},
|
2018-11-30 14:18:52 +08:00
|
|
|
new DrawableRank(Score.Rank)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Size = new Vector2(150, 60),
|
|
|
|
Margin = new MarginPadding(20),
|
|
|
|
},
|
2018-09-10 17:13:44 +08:00
|
|
|
scoreContainer = new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 60,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new SongProgressGraph
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0.5f,
|
|
|
|
Objects = Beatmap.Beatmap.HitObjects,
|
|
|
|
},
|
|
|
|
scoreCounter = new SlowScoreCounter(6)
|
|
|
|
{
|
2018-09-10 17:13:44 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2018-04-13 17:19:50 +08:00
|
|
|
Colour = colours.PinkDarker,
|
|
|
|
Y = 10,
|
|
|
|
TextSize = 56,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Colour = colours.PinkDarker,
|
|
|
|
Shadow = false,
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
TextSize = 16,
|
|
|
|
Text = "total score",
|
|
|
|
Margin = new MarginPadding { Bottom = 15 },
|
|
|
|
},
|
|
|
|
new BeatmapDetails(Beatmap.BeatmapInfo)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding { Bottom = 10 },
|
|
|
|
},
|
2018-11-30 14:18:52 +08:00
|
|
|
new DateTimeDisplay(Score.Date.LocalDateTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Size = new Vector2(0.75f, 1),
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding { Top = 10, Bottom = 10 },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = ColourInfo.GradientHorizontal(
|
|
|
|
colours.GrayC.Opacity(0),
|
|
|
|
colours.GrayC.Opacity(0.9f)),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(0.5f, 1),
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(
|
|
|
|
colours.GrayC.Opacity(0.9f),
|
|
|
|
colours.GrayC.Opacity(0)),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(0.5f, 1),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
statisticsContainer = new FillFlowContainer<DrawableScoreStatistic>
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
LayoutDuration = 200,
|
|
|
|
LayoutEasing = Easing.OutQuint
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-11-30 14:18:52 +08:00
|
|
|
statisticsContainer.ChildrenEnumerable = Score.Statistics.OrderByDescending(p => p.Key).Select(s => new DrawableScoreStatistic(s));
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
Schedule(() =>
|
|
|
|
{
|
2018-11-30 14:18:52 +08:00
|
|
|
scoreCounter.Increment(Score.TotalScore);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
int delay = 0;
|
|
|
|
foreach (var s in statisticsContainer.Children)
|
|
|
|
{
|
|
|
|
s.FadeOut()
|
|
|
|
.Then(delay += 200)
|
|
|
|
.FadeIn(300 + delay, Easing.Out);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-10 17:13:44 +08:00
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
{
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
scoreCounter.Scale = new Vector2(Math.Min(1f, (scoreContainer.DrawWidth - 20) / scoreCounter.DrawWidth));
|
|
|
|
}
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
private class DrawableScoreStatistic : Container
|
|
|
|
{
|
2018-12-05 18:44:01 +08:00
|
|
|
private readonly KeyValuePair<HitResult, int> statistic;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-05 18:44:01 +08:00
|
|
|
public DrawableScoreStatistic(KeyValuePair<HitResult, int> statistic)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
this.statistic = statistic;
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Margin = new MarginPadding { Left = 5, Right = 5 };
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText {
|
|
|
|
Text = statistic.Value.ToString().PadLeft(4, '0'),
|
|
|
|
Colour = colours.Gray7,
|
|
|
|
TextSize = 30,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
new OsuSpriteText {
|
|
|
|
Text = statistic.Key.GetDescription(),
|
|
|
|
Colour = colours.Gray7,
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
Y = 26,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class DateTimeDisplay : Container
|
|
|
|
{
|
2018-04-23 13:56:45 +08:00
|
|
|
private readonly DateTime date;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-04-23 13:56:45 +08:00
|
|
|
public DateTimeDisplay(DateTime date)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-04-23 13:56:45 +08:00
|
|
|
this.date = date;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
Width = 140;
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colours.Gray6,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2018-04-23 13:56:45 +08:00
|
|
|
Text = date.ToShortDateString(),
|
2018-04-13 17:19:50 +08:00
|
|
|
Padding = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
|
|
|
Colour = Color4.White,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Anchor = Anchor.CentreRight,
|
2018-04-23 13:56:45 +08:00
|
|
|
Text = date.ToShortTimeString(),
|
2018-04-13 17:19:50 +08:00
|
|
|
Padding = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
|
|
|
Colour = Color4.White,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class BeatmapDetails : Container
|
|
|
|
{
|
|
|
|
private readonly BeatmapInfo beatmap;
|
|
|
|
|
|
|
|
private readonly OsuSpriteText title;
|
|
|
|
private readonly OsuSpriteText artist;
|
|
|
|
private readonly OsuSpriteText versionMapper;
|
|
|
|
|
|
|
|
public BeatmapDetails(BeatmapInfo beatmap)
|
|
|
|
{
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
title = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Shadow = false,
|
|
|
|
TextSize = 24,
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
|
|
|
},
|
|
|
|
artist = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Shadow = false,
|
|
|
|
TextSize = 20,
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
|
|
|
},
|
|
|
|
versionMapper = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Shadow = false,
|
|
|
|
TextSize = 16,
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-09-19 13:07:46 +08:00
|
|
|
private void load(OsuColour colours)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
title.Colour = artist.Colour = colours.BlueDarker;
|
|
|
|
versionMapper.Colour = colours.Gray8;
|
|
|
|
|
|
|
|
var creator = beatmap.Metadata.Author?.Username;
|
|
|
|
if (!string.IsNullOrEmpty(creator)) {
|
|
|
|
versionMapper.Text = $"mapped by {creator}";
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(beatmap.Version))
|
|
|
|
versionMapper.Text = $"{beatmap.Version} - " + versionMapper.Text;
|
|
|
|
}
|
|
|
|
|
2018-09-19 13:07:46 +08:00
|
|
|
title.Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title));
|
|
|
|
artist.Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist));
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class UserHeader : Container
|
|
|
|
{
|
|
|
|
private readonly User user;
|
|
|
|
private readonly Sprite cover;
|
|
|
|
|
|
|
|
public UserHeader(User user)
|
|
|
|
{
|
|
|
|
this.user = user;
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
cover = new Sprite
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = @"Exo2.0-RegularItalic",
|
|
|
|
Text = user.Username,
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
TextSize = 30,
|
|
|
|
Padding = new MarginPadding { Bottom = 10 },
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-09-09 01:41:47 +08:00
|
|
|
private void load(LargeTextureStore textures)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(user.CoverUrl))
|
2018-08-31 06:04:40 +08:00
|
|
|
cover.Texture = textures.Get(user.CoverUrl);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class SlowScoreCounter : ScoreCounter
|
|
|
|
{
|
|
|
|
protected override double RollingDuration => 3000;
|
|
|
|
|
|
|
|
protected override Easing RollingEasing => Easing.OutPow10;
|
|
|
|
|
|
|
|
public SlowScoreCounter(uint leading = 0) : base(leading)
|
|
|
|
{
|
|
|
|
DisplayedCountSpriteText.Shadow = false;
|
|
|
|
DisplayedCountSpriteText.Font = @"Venera-Light";
|
|
|
|
UseCommaSeparator = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|