1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00
osu-lazer/osu.Game/Screens/Ranking/Results.cs

290 lines
12 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-09-29 19:13:58 +08:00
2017-04-11 15:28:11 +08:00
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
2016-11-29 22:59:56 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Scoring;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
2016-11-14 16:23:33 +08:00
using osu.Game.Screens.Backgrounds;
2016-11-29 22:59:56 +08:00
using OpenTK;
2016-10-05 19:03:52 +08:00
using OpenTK.Graphics;
2017-04-18 20:35:41 +08:00
using osu.Game.Graphics;
2017-04-18 20:38:05 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
2016-09-29 19:13:58 +08:00
2016-11-14 16:23:33 +08:00
namespace osu.Game.Screens.Ranking
2016-09-29 19:13:58 +08:00
{
public class Results : OsuScreen
2016-09-29 19:13:58 +08:00
{
private readonly Score score;
private Container circleOuterBackground;
private Container circleOuter;
private Container circleInner;
private ParallaxContainer backgroundParallax;
private ResultModeTabControl modeChangeButtons;
public override bool AllowBeatmapRulesetChange => false;
private Container currentPage;
2016-11-29 22:59:56 +08:00
2017-02-07 15:15:45 +08:00
private static readonly Vector2 background_blur = new Vector2(20);
2016-11-29 22:59:56 +08:00
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
2016-10-05 19:03:52 +08:00
private const float overscan = 1.3f;
private const float circle_outer_scale = 0.96f;
2016-10-05 19:03:52 +08:00
public Results(Score score)
2016-10-05 19:03:52 +08:00
{
this.score = score;
2016-10-05 19:03:52 +08:00
}
2016-11-29 14:41:48 +08:00
2017-04-11 15:28:11 +08:00
private const float transition_time = 800;
private IEnumerable<Drawable> allCircles => new Drawable[] { circleOuterBackground, circleInner, circleOuter };
protected override void OnEntering(Screen last)
2016-11-29 22:59:56 +08:00
{
base.OnEntering(last);
2017-07-23 02:50:25 +08:00
(Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 2500, Easing.OutQuint);
allCircles.ForEach(c =>
2016-11-29 22:59:56 +08:00
{
c.FadeOut();
c.ScaleTo(0);
});
2016-11-29 22:59:56 +08:00
backgroundParallax.FadeOut();
modeChangeButtons.FadeOut();
currentPage.FadeOut();
2017-07-16 23:28:20 +08:00
circleOuterBackground
2017-07-23 02:50:25 +08:00
.FadeIn(transition_time, Easing.OutQuint)
.ScaleTo(1, transition_time, Easing.OutQuint);
2016-11-29 22:59:56 +08:00
using (BeginDelayedSequence(transition_time * 0.25f, true))
{
2017-07-16 23:28:20 +08:00
circleOuter
2017-07-23 02:50:25 +08:00
.FadeIn(transition_time, Easing.OutQuint)
.ScaleTo(1, transition_time, Easing.OutQuint);
using (BeginDelayedSequence(transition_time * 0.3f, true))
{
2017-07-23 02:50:25 +08:00
backgroundParallax.FadeIn(transition_time, Easing.OutQuint);
2017-07-16 23:28:20 +08:00
circleInner
2017-07-23 02:50:25 +08:00
.FadeIn(transition_time, Easing.OutQuint)
.ScaleTo(1, transition_time, Easing.OutQuint);
using (BeginDelayedSequence(transition_time * 0.4f, true))
{
2017-07-23 02:50:25 +08:00
modeChangeButtons.FadeIn(transition_time, Easing.OutQuint);
currentPage.FadeIn(transition_time, Easing.OutQuint);
}
}
}
2016-11-29 22:59:56 +08:00
}
2017-04-11 15:28:11 +08:00
protected override bool OnExiting(Screen next)
{
allCircles.ForEach(c =>
{
2017-07-23 02:50:25 +08:00
c.ScaleTo(0, transition_time, Easing.OutSine);
2017-04-11 15:28:11 +08:00
});
Content.FadeOut(transition_time / 4);
return base.OnExiting(next);
}
[BackgroundDependencyLoader]
2017-04-18 20:35:41 +08:00
private void load(OsuColour colours)
2016-11-29 22:59:56 +08:00
{
Children = new Drawable[]
{
new AspectContainer
2016-11-29 22:59:56 +08:00
{
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = overscan,
2016-11-29 22:59:56 +08:00
Children = new Drawable[]
{
circleOuterBackground = new CircularContainer
2016-11-29 22:59:56 +08:00
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
new Box
{
Alpha = 0.2f,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
}
}
2016-11-29 22:59:56 +08:00
},
circleOuter = new CircularContainer
2016-11-29 22:59:56 +08:00
{
Size = new Vector2(circle_outer_scale),
2017-06-12 11:48:47 +08:00
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.4f),
Type = EdgeEffectType.Shadow,
Radius = 15,
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
backgroundParallax = new ParallaxContainer
{
RelativeSizeAxes = Axes.Both,
ParallaxAmount = 0.01f,
Scale = new Vector2(1 / circle_outer_scale / overscan),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
2017-04-18 20:35:11 +08:00
Alpha = 0.2f,
Texture = Beatmap.Value.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill
}
}
},
modeChangeButtons = new ResultModeTabControl
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
Height = 50,
Margin = new MarginPadding { Bottom = 110 },
2017-04-18 20:35:41 +08:00
},
new OsuSpriteText
2017-04-18 20:35:41 +08:00
{
Text = $"{score.MaxCombo}x",
TextSize = 40,
RelativePositionAxes = Axes.X,
Font = @"Exo2.0-Bold",
X = 0.1f,
Colour = colours.BlueDarker,
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
},
new OsuSpriteText
2017-04-18 20:35:41 +08:00
{
2017-04-18 21:07:47 +08:00
Text = "max combo",
2017-04-18 20:35:41 +08:00
TextSize = 20,
RelativePositionAxes = Axes.X,
X = 0.1f,
Colour = colours.Gray6,
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
},
new OsuSpriteText
2017-04-18 20:35:41 +08:00
{
Text = $"{score.Accuracy:P2}",
TextSize = 40,
RelativePositionAxes = Axes.X,
Font = @"Exo2.0-Bold",
X = 0.9f,
Colour = colours.BlueDarker,
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
},
new OsuSpriteText
2017-04-18 20:35:41 +08:00
{
2017-04-18 21:07:47 +08:00
Text = "accuracy",
2017-04-18 20:35:41 +08:00
TextSize = 20,
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.Gray6,
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
},
}
2016-11-29 22:59:56 +08:00
},
circleInner = new CircularContainer
2016-11-29 22:59:56 +08:00
{
Size = new Vector2(0.6f),
2017-06-12 11:48:47 +08:00
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.4f),
Type = EdgeEffectType.Shadow,
Radius = 15,
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
}
2016-11-29 22:59:56 +08:00
}
}
2017-04-18 20:38:05 +08:00
},
new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = Exit
},
2016-11-29 22:59:56 +08:00
};
modeChangeButtons.AddItem(ResultMode.Summary);
modeChangeButtons.AddItem(ResultMode.Ranking);
2017-04-18 20:38:29 +08:00
//modeChangeButtons.AddItem(ResultMode.Share);
modeChangeButtons.Current.ValueChanged += mode =>
{
currentPage?.FadeOut();
currentPage?.Expire();
switch (mode)
{
case ResultMode.Summary:
currentPage = new ResultsPageScore(score, Beatmap);
break;
case ResultMode.Ranking:
currentPage = new ResultsPageRanking(score, Beatmap);
break;
}
if (currentPage != null)
circleInner.Add(currentPage);
};
modeChangeButtons.Current.TriggerChange();
2016-11-29 22:59:56 +08:00
}
2016-09-29 19:13:58 +08:00
}
2017-04-18 20:35:41 +08:00
}