mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Merge pull request #383 from peppy/player-loading-screen
Add loading screen.
This commit is contained in:
commit
f812641696
@ -60,7 +60,16 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
Beatmap b = new Beatmap
|
Beatmap b = new Beatmap
|
||||||
{
|
{
|
||||||
HitObjects = objects
|
HitObjects = objects,
|
||||||
|
BeatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Artist = @"Unknown",
|
||||||
|
Title = @"Sample Beatmap",
|
||||||
|
Author = @"peppy",
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
decoder.Process(b);
|
decoder.Process(b);
|
||||||
@ -74,10 +83,13 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new Player
|
Add(new PlayerLoader(new Player
|
||||||
{
|
{
|
||||||
PreferredPlayMode = PlayMode.Osu,
|
PreferredPlayMode = PlayMode.Osu,
|
||||||
Beatmap = beatmap
|
Beatmap = beatmap
|
||||||
|
})
|
||||||
|
{
|
||||||
|
Beatmap = beatmap
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,8 @@ namespace osu.Game.Beatmaps
|
|||||||
public WorkingBeatmap(Beatmap beatmap)
|
public WorkingBeatmap(Beatmap beatmap)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
BeatmapInfo = beatmap.BeatmapInfo;
|
||||||
|
BeatmapSetInfo = beatmap.BeatmapInfo.BeatmapSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false)
|
public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database, bool withStoryboard = false)
|
||||||
|
@ -60,9 +60,9 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
Beatmap = beatmap;
|
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;
|
blurTarget = sigma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ using System.Linq;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -270,15 +271,19 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
|
||||||
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000);
|
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1500, EasingTypes.OutQuint);
|
||||||
Background?.FadeTo((100f - dimLevel) / 100, 1000);
|
Background?.FadeTo((100f - dimLevel) / 100, 1500, EasingTypes.OutQuint);
|
||||||
|
|
||||||
Content.Alpha = 0;
|
Content.Alpha = 0;
|
||||||
dimLevel.ValueChanged += dimChanged;
|
dimLevel.ValueChanged += dimChanged;
|
||||||
|
|
||||||
|
Content.ScaleTo(0.7f);
|
||||||
|
|
||||||
Content.Delay(250);
|
Content.Delay(250);
|
||||||
Content.FadeIn(250);
|
Content.FadeIn(250);
|
||||||
|
|
||||||
|
Content.ScaleTo(1, 750, EasingTypes.OutQuint);
|
||||||
|
|
||||||
Delay(750);
|
Delay(750);
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -290,6 +295,8 @@ namespace osu.Game.Screens.Play
|
|||||||
protected override void OnSuspending(Screen next)
|
protected override void OnSuspending(Screen next)
|
||||||
{
|
{
|
||||||
Content.FadeOut(350);
|
Content.FadeOut(350);
|
||||||
|
Content.ScaleTo(0.7f, 750, EasingTypes.InQuint);
|
||||||
|
|
||||||
base.OnSuspending(next);
|
base.OnSuspending(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
211
osu.Game/Screens/Play/PlayerLoader.cs
Normal file
211
osu.Game/Screens/Play/PlayerLoader.cs
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
// Copyright (c) 2007-2017 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 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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private FlowContainer buttons;
|
private FlowContainer buttons;
|
||||||
|
|
||||||
|
public OsuLogo StartButton;
|
||||||
|
|
||||||
public void AddButton(string text, Color4 colour, Action action)
|
public void AddButton(string text, Color4 colour, Action action)
|
||||||
{
|
{
|
||||||
var button = new FooterButton
|
var button = new FooterButton
|
||||||
@ -76,7 +78,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Height = 3,
|
Height = 3,
|
||||||
Position = new Vector2(0, -3),
|
Position = new Vector2(0, -3),
|
||||||
},
|
},
|
||||||
new OsuLogo()
|
StartButton = new OsuLogo
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Scale = new Vector2(0.4f),
|
Scale = new Vector2(0.4f),
|
||||||
|
@ -54,32 +54,10 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private Footer footer;
|
private Footer footer;
|
||||||
|
|
||||||
Player player;
|
OsuScreen player;
|
||||||
|
|
||||||
FilterControl filter;
|
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)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game,
|
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game,
|
||||||
OsuGame osuGame, OsuColour colours)
|
OsuGame osuGame, OsuColour colours)
|
||||||
@ -132,10 +110,20 @@ namespace osu.Game.Screens.Select
|
|||||||
Right = 20,
|
Right = 20,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
footer = new Footer()
|
footer = new Footer
|
||||||
{
|
{
|
||||||
OnBack = Exit,
|
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.Beatmap = beatmap;
|
||||||
backgroundModeBeatmap.BlurTo(background_blur, 1000);
|
backgroundModeBeatmap.BlurTo(background_blur, 1000);
|
||||||
|
backgroundModeBeatmap.FadeTo(1, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (beatmap != null)
|
if (beatmap != null)
|
||||||
@ -346,7 +335,7 @@ namespace osu.Game.Screens.Select
|
|||||||
var group = new BeatmapGroup(beatmap)
|
var group = new BeatmapGroup(beatmap)
|
||||||
{
|
{
|
||||||
SelectionChanged = selectionChanged,
|
SelectionChanged = selectionChanged,
|
||||||
StartRequested = b => start()
|
StartRequested = b => footer.StartButton.TriggerClick()
|
||||||
};
|
};
|
||||||
|
|
||||||
//for the time being, let's completely load the difficulty panels in the background.
|
//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)
|
switch (args.Key)
|
||||||
{
|
{
|
||||||
case Key.Enter:
|
case Key.Enter:
|
||||||
start();
|
footer.StartButton.TriggerClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@
|
|||||||
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
||||||
<Compile Include="Screens\Play\FailDialog.cs" />
|
<Compile Include="Screens\Play\FailDialog.cs" />
|
||||||
<Compile Include="Screens\Play\PlayerInputManager.cs" />
|
<Compile Include="Screens\Play\PlayerInputManager.cs" />
|
||||||
|
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
||||||
<Compile Include="Screens\Play\SkipButton.cs" />
|
<Compile Include="Screens\Play\SkipButton.cs" />
|
||||||
<Compile Include="Screens\Select\CarouselContainer.cs" />
|
<Compile Include="Screens\Select\CarouselContainer.cs" />
|
||||||
<Compile Include="Screens\Select\MatchSongSelect.cs" />
|
<Compile Include="Screens\Select\MatchSongSelect.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user