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

278 lines
11 KiB
C#
Raw Normal View History

// 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
using System.Collections.Generic;
using System.Linq;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2019-04-02 13:51:28 +08:00
using osu.Framework.Graphics.Effects;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Backgrounds;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
2018-11-28 15:12:57 +08:00
using osu.Game.Scoring;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Ranking
{
public abstract class Results : OsuScreen
2018-04-13 17:19:50 +08:00
{
protected const float BACKGROUND_BLUR = 20;
2018-04-13 17:19:50 +08:00
private Container circleOuterBackground;
private Container circleOuter;
private Container circleInner;
private ParallaxContainer backgroundParallax;
private ResultModeTabControl modeChangeButtons;
2019-02-01 14:42:15 +08:00
public override bool DisallowExternalBeatmapRulesetChanges => true;
2018-04-13 17:19:50 +08:00
protected readonly ScoreInfo Score;
2018-04-13 17:19:50 +08:00
private Container currentPage;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
2018-04-13 17:19:50 +08:00
private const float overscan = 1.3f;
private const float circle_outer_scale = 0.96f;
protected Results(ScoreInfo score)
2018-04-13 17:19:50 +08:00
{
Score = score;
2018-04-13 17:19:50 +08:00
}
private const float transition_time = 800;
private IEnumerable<Drawable> allCircles => new Drawable[] { circleOuterBackground, circleInner, circleOuter };
2019-01-23 19:52:00 +08:00
public override void OnEntering(IScreen last)
2018-04-13 17:19:50 +08:00
{
base.OnEntering(last);
((BackgroundScreenBeatmap)Background).BlurAmount.Value = BACKGROUND_BLUR;
Background.ScaleTo(1.1f, transition_time, Easing.OutQuint);
2018-04-13 17:19:50 +08:00
allCircles.ForEach(c =>
{
c.FadeOut();
c.ScaleTo(0);
});
backgroundParallax.FadeOut();
modeChangeButtons.FadeOut();
currentPage?.FadeOut();
2018-04-13 17:19:50 +08:00
circleOuterBackground
.FadeIn(transition_time, Easing.OutQuint)
.ScaleTo(1, transition_time, Easing.OutQuint);
using (BeginDelayedSequence(transition_time * 0.25f, true))
{
circleOuter
.FadeIn(transition_time, Easing.OutQuint)
.ScaleTo(1, transition_time, Easing.OutQuint);
using (BeginDelayedSequence(transition_time * 0.3f, true))
{
backgroundParallax.FadeIn(transition_time, Easing.OutQuint);
circleInner
.FadeIn(transition_time, Easing.OutQuint)
.ScaleTo(1, transition_time, Easing.OutQuint);
using (BeginDelayedSequence(transition_time * 0.4f, true))
{
modeChangeButtons.FadeIn(transition_time, Easing.OutQuint);
currentPage?.FadeIn(transition_time, Easing.OutQuint);
2018-04-13 17:19:50 +08:00
}
}
}
}
2019-01-23 19:52:00 +08:00
public override bool OnExiting(IScreen next)
2018-04-13 17:19:50 +08:00
{
allCircles.ForEach(c =>
{
c.ScaleTo(0, transition_time, Easing.OutSine);
});
Background.ScaleTo(1f, transition_time / 4, Easing.OutQuint);
2019-01-23 19:52:00 +08:00
this.FadeOut(transition_time / 4);
2018-04-13 17:19:50 +08:00
return base.OnExiting(next);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2019-01-23 19:52:00 +08:00
InternalChildren = new Drawable[]
2018-04-13 17:19:50 +08:00
{
new AspectContainer
{
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = overscan,
Children = new Drawable[]
{
circleOuterBackground = new CircularContainer
{
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,
}
}
},
circleOuter = new CircularContainer
{
Size = new Vector2(circle_outer_scale),
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,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
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 },
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
Text = $"{Score.MaxCombo}x",
2018-04-13 17:19:50 +08:00
RelativePositionAxes = Axes.X,
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
2018-04-13 17:19:50 +08:00
X = 0.1f,
Colour = colours.BlueDarker,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
2018-04-13 17:19:50 +08:00
Text = "max combo",
Font = OsuFont.GetFont(size: 20),
2018-04-13 17:19:50 +08:00
RelativePositionAxes = Axes.X,
X = 0.1f,
Colour = colours.Gray6,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
Text = $"{Score.Accuracy:P2}",
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 40),
2018-04-13 17:19:50 +08:00
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.BlueDarker,
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
2018-04-13 17:19:50 +08:00
Text = "accuracy",
Font = OsuFont.GetFont(size: 20),
2018-04-13 17:19:50 +08:00
RelativePositionAxes = Axes.X,
X = 0.9f,
Colour = colours.Gray6,
},
}
},
circleInner = new CircularContainer
{
Size = new Vector2(0.6f),
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,
},
}
}
}
2019-06-25 15:55:49 +08:00
}
2018-04-13 17:19:50 +08:00
};
2018-12-22 15:20:29 +08:00
foreach (var t in CreateResultPages())
modeChangeButtons.AddItem(t);
modeChangeButtons.Current.Value = modeChangeButtons.Items.FirstOrDefault();
2018-04-13 17:19:50 +08:00
modeChangeButtons.Current.BindValueChanged(page =>
2018-04-13 17:19:50 +08:00
{
currentPage?.FadeOut();
currentPage?.Expire();
currentPage = page.NewValue?.CreatePage();
2018-04-13 17:19:50 +08:00
if (currentPage != null)
LoadComponentAsync(currentPage, circleInner.Add);
}, true);
2018-04-13 17:19:50 +08:00
}
2018-12-22 15:20:29 +08:00
protected abstract IEnumerable<IResultPageInfo> CreateResultPages();
2018-04-13 17:19:50 +08:00
}
}