2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-03-11 12:20:31 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics.Shaders;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
|
using osu.Framework.Screens;
|
2020-03-11 01:49:34 +08:00
|
|
|
|
using osu.Framework.Threading;
|
2019-08-09 19:05:28 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2020-03-11 01:49:34 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-08-09 19:05:28 +08:00
|
|
|
|
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class Loader : StartupScreen
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public Loader()
|
|
|
|
|
{
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 19:07:44 +08:00
|
|
|
|
private OsuScreen loadableScreen;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private ShaderPrecompiler precompiler;
|
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
|
private IntroSequence introSequence;
|
2020-03-11 01:49:34 +08:00
|
|
|
|
private LoadingSpinner spinner;
|
|
|
|
|
private ScheduledDelegate spinnerShow;
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
2023-12-28 16:21:29 +08:00
|
|
|
|
protected virtual OsuScreen CreateLoadableScreen() => getIntroSequence();
|
2019-07-09 17:06:49 +08:00
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
|
private IntroScreen getIntroSequence()
|
2019-09-29 03:34:09 +08:00
|
|
|
|
{
|
2019-09-29 14:35:35 +08:00
|
|
|
|
if (introSequence == IntroSequence.Random)
|
|
|
|
|
introSequence = (IntroSequence)RNG.Next(0, (int)IntroSequence.Random);
|
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
|
switch (introSequence)
|
|
|
|
|
{
|
|
|
|
|
case IntroSequence.Circles:
|
2021-10-07 15:38:22 +08:00
|
|
|
|
return new IntroCircles(createMainMenu);
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
2020-06-02 17:25:57 +08:00
|
|
|
|
case IntroSequence.Welcome:
|
2021-10-07 15:38:22 +08:00
|
|
|
|
return new IntroWelcome(createMainMenu);
|
2020-06-02 09:48:23 +08:00
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
|
default:
|
2021-10-07 15:38:22 +08:00
|
|
|
|
return new IntroTriangles(createMainMenu);
|
2019-08-09 19:05:28 +08:00
|
|
|
|
}
|
2021-10-07 15:38:22 +08:00
|
|
|
|
|
|
|
|
|
MainMenu createMainMenu() => new MainMenu();
|
2019-08-09 19:05:28 +08:00
|
|
|
|
}
|
2018-05-31 16:29:59 +08:00
|
|
|
|
|
2018-05-31 19:07:44 +08:00
|
|
|
|
protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler();
|
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
|
public override void OnEntering(ScreenTransitionEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
|
base.OnEntering(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
LoadComponentAsync(precompiler = CreateShaderPrecompiler(), AddInternal);
|
2018-05-31 19:07:44 +08:00
|
|
|
|
|
2022-09-15 15:31:00 +08:00
|
|
|
|
LoadComponentAsync(loadableScreen = CreateLoadableScreen());
|
2022-01-21 13:56:49 +08:00
|
|
|
|
|
2020-03-11 01:49:34 +08:00
|
|
|
|
LoadComponentAsync(spinner = new LoadingSpinner(true, true)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Margin = new MarginPadding(40),
|
|
|
|
|
}, _ =>
|
|
|
|
|
{
|
|
|
|
|
AddInternal(spinner);
|
|
|
|
|
spinnerShow = Scheduler.AddDelayed(spinner.Show, 200);
|
|
|
|
|
});
|
|
|
|
|
|
2018-05-31 19:07:44 +08:00
|
|
|
|
checkIfLoaded();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 19:07:44 +08:00
|
|
|
|
private void checkIfLoaded()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-01-24 17:55:15 +08:00
|
|
|
|
if (loadableScreen?.LoadState != LoadState.Ready || !precompiler.FinishedCompiling)
|
2018-05-31 19:07:44 +08:00
|
|
|
|
{
|
|
|
|
|
Schedule(checkIfLoaded);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return;
|
2018-05-31 19:07:44 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-03-11 01:49:34 +08:00
|
|
|
|
spinnerShow?.Cancel();
|
2020-03-11 12:20:31 +08:00
|
|
|
|
|
|
|
|
|
if (spinner.State.Value == Visibility.Visible)
|
|
|
|
|
{
|
|
|
|
|
spinner.Hide();
|
|
|
|
|
Scheduler.AddDelayed(() => this.Push(loadableScreen), LoadingSpinner.TRANSITION_DURATION);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
this.Push(loadableScreen);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2023-12-28 16:21:29 +08:00
|
|
|
|
private void load(OsuConfigManager config)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-08-09 19:05:28 +08:00
|
|
|
|
introSequence = config.Get<IntroSequence>(OsuSetting.IntroSequence);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Compiles a set of shaders before continuing. Attempts to draw some frames between compilation by limiting to one compile per draw frame.
|
|
|
|
|
/// </summary>
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class ShaderPrecompiler : Drawable
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-07 17:30:18 +08:00
|
|
|
|
private readonly List<IShader> loadTargets = new List<IShader>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public bool FinishedCompiling { get; private set; }
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(ShaderManager manager)
|
|
|
|
|
{
|
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE));
|
2023-09-13 22:10:13 +08:00
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.BLUR));
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
loadTargets.Add(manager.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE));
|
2023-09-13 22:10:13 +08:00
|
|
|
|
|
2023-03-28 13:15:38 +08:00
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, "TriangleBorder"));
|
2023-09-13 22:10:13 +08:00
|
|
|
|
|
2023-03-28 13:15:38 +08:00
|
|
|
|
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 17:30:18 +08:00
|
|
|
|
protected virtual bool AllLoaded => loadTargets.All(s => s.IsLoaded);
|
2018-05-31 19:07:44 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
// if our target is null we are done.
|
2018-05-31 19:07:44 +08:00
|
|
|
|
if (AllLoaded)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
FinishedCompiling = true;
|
|
|
|
|
Expire();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|