diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 2f8c37f1bb..2c4729b05a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -60,7 +60,16 @@ namespace osu.Desktop.VisualTests.Tests Beatmap b = new Beatmap { - HitObjects = objects + HitObjects = objects, + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Artist = @"Unknown", + Title = @"Sample Beatmap", + Author = @"peppy", + } + } }; decoder.Process(b); @@ -74,10 +83,13 @@ namespace osu.Desktop.VisualTests.Tests Colour = Color4.Black, }); - Add(new Player + Add(new PlayerLoader(new Player { PreferredPlayMode = PlayMode.Osu, Beatmap = beatmap + }) + { + Beatmap = beatmap }); } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 28c2c5f0e2..c6bc4eeeb8 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -113,6 +113,8 @@ namespace osu.Game.Beatmaps public WorkingBeatmap(Beatmap beatmap) { this.beatmap = beatmap; + BeatmapInfo = beatmap.BeatmapInfo; + BeatmapSetInfo = beatmap.BeatmapInfo.BeatmapSet; } public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index a003fa2d57..f0c5c47797 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -60,9 +60,9 @@ namespace osu.Game.Screens.Backgrounds Beatmap = beatmap; } - public void BlurTo(Vector2 sigma, double duration) + public void BlurTo(Vector2 sigma, double duration, EasingTypes easing = EasingTypes.None) { - background?.BlurTo(sigma, duration, EasingTypes.OutExpo); + background?.BlurTo(sigma, duration, easing); blurTarget = sigma; } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3d21e9cd40..2359dcdcfa 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -23,6 +23,7 @@ using System.Linq; using osu.Game.Beatmaps; using OpenTK.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Transformations; using osu.Framework.Logging; namespace osu.Game.Screens.Play @@ -270,15 +271,19 @@ namespace osu.Game.Screens.Play { base.OnEntering(last); - (Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000); - Background?.FadeTo((100f - dimLevel) / 100, 1000); + (Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1500, EasingTypes.OutQuint); + Background?.FadeTo((100f - dimLevel) / 100, 1500, EasingTypes.OutQuint); Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; + Content.ScaleTo(0.7f); + Content.Delay(250); Content.FadeIn(250); + Content.ScaleTo(1, 750, EasingTypes.OutQuint); + Delay(750); Schedule(() => { @@ -290,6 +295,8 @@ namespace osu.Game.Screens.Play protected override void OnSuspending(Screen next) { Content.FadeOut(350); + Content.ScaleTo(0.7f, 750, EasingTypes.InQuint); + base.OnSuspending(next); } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs new file mode 100644 index 0000000000..294eecd5fa --- /dev/null +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -0,0 +1,211 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Backgrounds; +using osu.Game.Screens.Menu; +using OpenTK; + +namespace osu.Game.Screens.Play +{ + public class PlayerLoader : OsuScreen + { + private readonly Player player; + private OsuLogo logo; + private BeatmapMetadataDisplay info; + + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); + + public PlayerLoader(Player player) + { + ValidForResume = false; + this.player = player; + + Children = new Drawable[] + { + logo = new OsuLogo + { + Scale = new Vector2(0.15f), + Interactive = false, + }, + }; + + } + + [BackgroundDependencyLoader] + private void load() + { + Add(info = new BeatmapMetadataDisplay(Beatmap) + { + Alpha = 0, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + + player.Preload(Game); + } + + protected override void OnEntering(Screen last) + { + base.OnEntering(last); + + Background.FadeTo(0.4f, 250); + + Content.ScaleTo(0.7f); + Content.ScaleTo(1, 750, EasingTypes.OutQuint); + Content.FadeInFromZero(500); + + Delay(1000, true); + + logo.MoveToOffset(new Vector2(0, -180), 500, EasingTypes.InOutExpo); + Delay(250, true); + + info.FadeIn(500); + + Delay(2000, true); + + Content.ScaleTo(0.7f, 300, EasingTypes.InQuint); + Content.FadeOut(250); + + Delay(250); + + Schedule(() => + { + if (!Push(player)) + Exit(); + }); + } + + protected override bool OnExiting(Screen next) + { + Content.ScaleTo(0.7f, 150, EasingTypes.InQuint); + FadeOut(150); + return base.OnExiting(next); + } + + class BeatmapMetadataDisplay : Container + { + class MetadataLine : Container + { + public MetadataLine(string left, string right) + { + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopRight, + Margin = new MarginPadding { Right = 5 }, + Colour = OsuColour.Gray(0.5f), + Text = left, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopLeft, + Margin = new MarginPadding { Left = 5 }, + Text = string.IsNullOrEmpty(right) ? @"-" : right, + } + }; + } + + } + + public BeatmapMetadataDisplay(WorkingBeatmap beatmap) + { + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + new FlowContainer() + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Direction = FlowDirections.Vertical, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = beatmap.BeatmapInfo.Metadata.Title, + TextSize = 36, + Font = @"Exo2.0-MediumItalic", + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, + new OsuSpriteText + { + Text = beatmap.BeatmapInfo.Metadata.Artist, + TextSize = 26, + Font = @"Exo2.0-MediumItalic", + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, + new Container + { + Size = new Vector2(300, 60), + Margin = new MarginPadding(10), + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + CornerRadius = 10, + Masking = true, + Children = new[] + { + new Sprite + { + Texture = beatmap.Background, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + FillMode = FillMode.Fill, + }, + } + }, + new OsuSpriteText + { + Text = beatmap.BeatmapInfo.Version, + TextSize = 26, + Font = @"Exo2.0-MediumItalic", + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Margin = new MarginPadding + { + Bottom = 40 + }, + }, + new MetadataLine("Source", beatmap.BeatmapInfo.Metadata.Source) + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, + new MetadataLine("Composer", string.Empty) + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, + new MetadataLine("Mapper", beatmap.BeatmapInfo.Metadata.Author) + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, + }, + } + }; + } + } + } +} diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index df926c0778..8cde771b50 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -32,6 +32,8 @@ namespace osu.Game.Screens.Select private FlowContainer buttons; + public OsuLogo StartButton; + public void AddButton(string text, Color4 colour, Action action) { var button = new FooterButton @@ -76,7 +78,7 @@ namespace osu.Game.Screens.Select Height = 3, Position = new Vector2(0, -3), }, - new OsuLogo() + StartButton = new OsuLogo { Anchor = Anchor.BottomRight, Scale = new Vector2(0.4f), diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 2dcd957950..474406eb86 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -54,32 +54,10 @@ namespace osu.Game.Screens.Select private Footer footer; - Player player; + OsuScreen player; + FilterControl filter; - private void start() - { - if (player != null || Beatmap == null) - return; - - //in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition - //and provide a better loading experience (at the moment song select is still accepting input during preload). - player = new Player - { - BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, - PreferredPlayMode = playMode.Value - }; - - player.Preload(Game, delegate - { - if (!Push(player)) - { - player = null; - //error occured? - } - }); - } - [BackgroundDependencyLoader(permitNulls: true)] private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game, OsuGame osuGame, OsuColour colours) @@ -132,10 +110,20 @@ namespace osu.Game.Screens.Select Right = 20, }, }, - footer = new Footer() + footer = new Footer { OnBack = Exit, - OnStart = start, + OnStart = () => + { + if (player != null || Beatmap == null) + return; + + (player = new PlayerLoader(new Player + { + BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, + PreferredPlayMode = playMode.Value + })).Preload(Game, l => Push(player)); + } } }; @@ -276,6 +264,7 @@ namespace osu.Game.Screens.Select { backgroundModeBeatmap.Beatmap = beatmap; backgroundModeBeatmap.BlurTo(background_blur, 1000); + backgroundModeBeatmap.FadeTo(1, 250); } if (beatmap != null) @@ -346,7 +335,7 @@ namespace osu.Game.Screens.Select var group = new BeatmapGroup(beatmap) { SelectionChanged = selectionChanged, - StartRequested = b => start() + StartRequested = b => footer.StartButton.TriggerClick() }; //for the time being, let's completely load the difficulty panels in the background. @@ -382,7 +371,7 @@ namespace osu.Game.Screens.Select switch (args.Key) { case Key.Enter: - start(); + footer.StartButton.TriggerClick(); return true; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 790cd0d348..a336f54227 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -147,6 +147,7 @@ +