2019-01-24 08:43:03 +00:00
|
|
|
|
// 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 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Shaders;
|
|
|
|
|
using osu.Game.Screens.Menu;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Screens;
|
2018-08-23 02:20:20 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
|
{
|
|
|
|
|
public class Loader : OsuScreen
|
|
|
|
|
{
|
|
|
|
|
private bool showDisclaimer;
|
|
|
|
|
|
2019-01-28 06:41:54 +00:00
|
|
|
|
public override bool HideOverlaysOnEnter => true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-01-28 06:41:54 +00:00
|
|
|
|
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
|
2018-08-23 02:20:20 +00:00
|
|
|
|
|
2019-02-15 07:55:39 +00:00
|
|
|
|
public override bool CursorVisible => false;
|
|
|
|
|
|
2018-05-14 19:09:09 +00:00
|
|
|
|
protected override bool AllowBackButton => false;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public Loader()
|
|
|
|
|
{
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
|
|
|
|
{
|
|
|
|
|
base.LogoArriving(logo, resuming);
|
|
|
|
|
|
2018-05-31 08:14:47 +00:00
|
|
|
|
logo.BeatMatching = false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
logo.Triangles = false;
|
2019-03-27 13:27:53 +00:00
|
|
|
|
logo.RelativePositionAxes = Axes.None;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
logo.Origin = Anchor.BottomRight;
|
|
|
|
|
logo.Anchor = Anchor.BottomRight;
|
|
|
|
|
logo.Position = new Vector2(-40);
|
|
|
|
|
logo.Scale = new Vector2(0.2f);
|
|
|
|
|
|
2018-05-30 11:21:25 +00:00
|
|
|
|
logo.Delay(500).FadeInFromZero(1000, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LogoSuspending(OsuLogo logo)
|
|
|
|
|
{
|
|
|
|
|
base.LogoSuspending(logo);
|
2018-05-31 08:14:04 +00:00
|
|
|
|
logo.FadeOut(logo.Alpha * 400);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 11:07:44 +00:00
|
|
|
|
private OsuScreen loadableScreen;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private ShaderPrecompiler precompiler;
|
|
|
|
|
|
2018-05-31 08:29:59 +00:00
|
|
|
|
protected virtual OsuScreen CreateLoadableScreen() => showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro();
|
|
|
|
|
|
2018-05-31 11:07:44 +00:00
|
|
|
|
protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler();
|
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
public override void OnEntering(IScreen last)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
LoadComponentAsync(precompiler = CreateShaderPrecompiler(), AddInternal);
|
2018-05-31 11:07:44 +00:00
|
|
|
|
LoadComponentAsync(loadableScreen = CreateLoadableScreen());
|
|
|
|
|
|
|
|
|
|
checkIfLoaded();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 11:07:44 +00:00
|
|
|
|
private void checkIfLoaded()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-05-31 11:07:44 +00:00
|
|
|
|
if (loadableScreen.LoadState != LoadState.Ready || !precompiler.FinishedCompiling)
|
|
|
|
|
{
|
|
|
|
|
Schedule(checkIfLoaded);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return;
|
2018-05-31 11:07:44 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
this.Push(loadableScreen);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuGameBase game)
|
|
|
|
|
{
|
|
|
|
|
showDisclaimer = game.IsDeployedBuild;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Compiles a set of shaders before continuing. Attempts to draw some frames between compilation by limiting to one compile per draw frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ShaderPrecompiler : Drawable
|
|
|
|
|
{
|
2019-03-07 09:30:18 +00:00
|
|
|
|
private readonly List<IShader> loadTargets = new List<IShader>();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public bool FinishedCompiling { get; private set; }
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(ShaderManager manager)
|
|
|
|
|
{
|
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED));
|
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.BLUR));
|
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE));
|
|
|
|
|
|
|
|
|
|
loadTargets.Add(manager.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE));
|
|
|
|
|
|
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE_ROUNDED));
|
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE));
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 09:30:18 +00:00
|
|
|
|
protected virtual bool AllLoaded => loadTargets.All(s => s.IsLoaded);
|
2018-05-31 11:07:44 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
// if our target is null we are done.
|
2018-05-31 11:07:44 +00:00
|
|
|
|
if (AllLoaded)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
FinishedCompiling = true;
|
|
|
|
|
Expire();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|