osu/osu.Game/Screens/Ranking/Results.cs

285 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 11:13:58 +00:00
2017-04-11 07:28:11 +00:00
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
2016-11-29 14:59:56 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-04-18 07:05:58 +00:00
using osu.Game.Rulesets.Scoring;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
2016-11-14 08:23:33 +00:00
using osu.Game.Screens.Backgrounds;
2016-11-29 14:59:56 +00:00
using OpenTK;
2016-10-05 11:03:52 +00:00
using OpenTK.Graphics;
2017-04-18 12:35:41 +00:00
using osu.Game.Graphics;
2017-04-18 12:38:05 +00:00
using osu.Game.Graphics.UserInterface;
2016-09-29 11:13:58 +00:00
2016-11-14 08:23:33 +00:00
namespace osu.Game.Screens.Ranking
2016-09-29 11:13:58 +00:00
{
public class Results : OsuScreen
2016-09-29 11:13:58 +00:00
{
private readonly Score score;
private Container circleOuterBackground;
private Container circleOuter;
private Container circleInner;
private ParallaxContainer backgroundParallax;
private ResultModeTabControl modeChangeButtons;
internal override bool AllowRulesetChange => false;
private Container currentPage;
2016-11-29 14:59:56 +00:00
2017-02-07 07:15:45 +00:00
private static readonly Vector2 background_blur = new Vector2(20);
2016-11-29 14:59:56 +00:00
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
2016-10-05 11:03:52 +00:00
private const float overscan = 1.3f;
private const float circle_outer_scale = 0.96f;
2016-10-05 11:03:52 +00:00
public Results(Score score)
2016-10-05 11:03:52 +00:00
{
this.score = score;
2016-10-05 11:03:52 +00:00
}
2016-11-29 06:41:48 +00:00
2017-04-11 07:28:11 +00: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 14:59:56 +00:00
{
base.OnEntering(last);
(Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 2500, EasingTypes.OutQuint);
allCircles.ForEach(c =>
2016-11-29 14:59:56 +00:00
{
c.FadeOut();
c.ScaleTo(0);
});
2016-11-29 14:59:56 +00:00
backgroundParallax.FadeOut();
modeChangeButtons.FadeOut();
currentPage.FadeOut();
2017-04-11 07:28:11 +00:00
circleOuterBackground.ScaleTo(1, transition_time, EasingTypes.OutQuint);
circleOuterBackground.FadeTo(1, transition_time, EasingTypes.OutQuint);
2016-11-29 14:59:56 +00:00
using (BeginDelayedSequence(transition_time * 0.25f, true))
{
circleOuter.ScaleTo(1, transition_time, EasingTypes.OutQuint);
circleOuter.FadeTo(1, transition_time, EasingTypes.OutQuint);
using (BeginDelayedSequence(transition_time * 0.3f, true))
{
backgroundParallax.FadeIn(transition_time, EasingTypes.OutQuint);
circleInner.ScaleTo(1, transition_time, EasingTypes.OutQuint);
circleInner.FadeTo(1, transition_time, EasingTypes.OutQuint);
using (BeginDelayedSequence(transition_time * 0.4f, true))
{
modeChangeButtons.FadeIn(transition_time, EasingTypes.OutQuint);
currentPage.FadeIn(transition_time, EasingTypes.OutQuint);
}
}
}
2016-11-29 14:59:56 +00:00
}
2017-04-11 07:28:11 +00:00
protected override bool OnExiting(Screen next)
{
allCircles.ForEach(c =>
{
c.ScaleTo(0, transition_time, EasingTypes.OutSine);
});
Content.FadeOut(transition_time / 4);
return base.OnExiting(next);
}
[BackgroundDependencyLoader]
2017-04-18 12:35:41 +00:00
private void load(OsuColour colours)
2016-11-29 14:59:56 +00:00
{
Children = new Drawable[]
{
new AspectContainer
2016-11-29 14:59:56 +00:00
{
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = overscan,
2016-11-29 14:59:56 +00:00
Children = new Drawable[]
{
circleOuterBackground = new CircularContainer
2016-11-29 14:59:56 +00: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 14:59:56 +00:00
},
circleOuter = new CircularContainer
2016-11-29 14:59:56 +00:00
{
Size = new Vector2(circle_outer_scale),
EdgeEffect = new EdgeEffect
{
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
{
2017-04-18 12:35:11 +00:00
Alpha = 0.2f,
Texture = Beatmap?.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 12:35:41 +00:00
},
new SpriteText
{
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 SpriteText
{
2017-04-18 13:07:47 +00:00
Text = "max combo",
2017-04-18 12:35:41 +00:00
TextSize = 20,
RelativePositionAxes = Axes.X,
X = 0.1f,
Colour = colours.Gray6,
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
},
new SpriteText
{
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 SpriteText
{
2017-04-18 13:07:47 +00:00
Text = "accuracy",
2017-04-18 12:35:41 +00:00
TextSize = 20,
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.Gray6,
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
},
}
2016-11-29 14:59:56 +00:00
},
circleInner = new CircularContainer
2016-11-29 14:59:56 +00:00
{
Size = new Vector2(0.6f),
EdgeEffect = new EdgeEffect
{
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 14:59:56 +00:00
}
}
2017-04-18 12:38:05 +00:00
},
new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = Exit
},
2016-11-29 14:59:56 +00:00
};
modeChangeButtons.AddItem(ResultMode.Summary);
modeChangeButtons.AddItem(ResultMode.Ranking);
2017-04-18 12:38:29 +00: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 14:59:56 +00:00
}
2016-09-29 11:13:58 +00:00
}
2017-04-18 12:35:41 +00:00
}