2019-08-12 01:04:06 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-08-09 19:05:28 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
using System;
|
2021-10-07 15:38:22 +08:00
|
|
|
using JetBrains.Annotations;
|
2019-08-09 19:05:28 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
2019-10-08 11:07:59 +08:00
|
|
|
using osu.Framework.Audio.Sample;
|
2019-08-09 19:05:28 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2022-06-29 18:37:17 +08:00
|
|
|
using osu.Framework.Logging;
|
2022-07-08 01:01:51 +08:00
|
|
|
using osu.Framework.Screens;
|
2019-08-09 19:05:28 +08:00
|
|
|
using osu.Framework.Timing;
|
2022-07-08 01:01:51 +08:00
|
|
|
using osu.Framework.Utils;
|
2019-08-09 19:05:28 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Menu
|
|
|
|
{
|
|
|
|
public class IntroTriangles : IntroScreen
|
|
|
|
{
|
2019-09-23 20:52:44 +08:00
|
|
|
protected override string BeatmapHash => "a1556d0801b3a6b175dda32ef546f0ec812b400499f575c44fccbe9c67f9b1e5";
|
2019-08-09 19:05:28 +08:00
|
|
|
|
2019-09-23 20:52:44 +08:00
|
|
|
protected override string BeatmapFile => "triangles.osz";
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private AudioManager audio { get; set; }
|
|
|
|
|
2021-01-19 16:11:40 +08:00
|
|
|
private Sample welcome;
|
2019-10-08 11:07:59 +08:00
|
|
|
|
2021-09-09 00:21:19 +08:00
|
|
|
private DecoupleableInterpolatingFramedClock decoupledClock;
|
2021-09-10 17:10:03 +08:00
|
|
|
private TrianglesIntroSequence intro;
|
2021-09-09 00:21:19 +08:00
|
|
|
|
2021-10-07 15:38:22 +08:00
|
|
|
public IntroTriangles([CanBeNull] Func<MainMenu> createNextScreen = null)
|
|
|
|
: base(createNextScreen)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-02-14 19:40:58 +08:00
|
|
|
private void load()
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2020-08-21 14:50:14 +08:00
|
|
|
if (MenuVoice.Value)
|
2020-06-12 21:57:23 +08:00
|
|
|
welcome = audio.Samples.Get(@"Intro/welcome");
|
2019-08-09 19:05:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
|
|
|
{
|
|
|
|
base.LogoArriving(logo, resuming);
|
|
|
|
|
|
|
|
if (!resuming)
|
|
|
|
{
|
|
|
|
PrepareMenuLoad();
|
|
|
|
|
2021-09-09 00:21:19 +08:00
|
|
|
decoupledClock = new DecoupleableInterpolatingFramedClock
|
|
|
|
{
|
|
|
|
IsCoupled = false
|
|
|
|
};
|
|
|
|
|
|
|
|
if (UsingThemedIntro)
|
|
|
|
decoupledClock.ChangeSource(Track);
|
|
|
|
|
2022-07-08 04:31:04 +08:00
|
|
|
LoadComponentAsync(intro = new TrianglesIntroSequence(logo, () => FadeInBackground())
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-09-09 00:21:19 +08:00
|
|
|
Clock = decoupledClock,
|
2019-08-09 19:05:28 +08:00
|
|
|
LoadMenu = LoadMenu
|
|
|
|
}, t =>
|
|
|
|
{
|
|
|
|
AddInternal(t);
|
2020-08-21 17:33:24 +08:00
|
|
|
if (!UsingThemedIntro)
|
|
|
|
welcome?.Play();
|
2019-08-09 19:05:28 +08:00
|
|
|
|
2019-10-08 11:03:42 +08:00
|
|
|
StartTrack();
|
2019-08-09 19:05:28 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override void OnSuspending(ScreenTransitionEvent e)
|
2021-09-10 17:10:03 +08:00
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
base.OnSuspending(e);
|
2021-09-10 17:10:03 +08:00
|
|
|
|
|
|
|
// important as there is a clock attached to a track which will likely be disposed before returning to this screen.
|
|
|
|
intro.Expire();
|
|
|
|
}
|
|
|
|
|
2021-09-09 00:21:19 +08:00
|
|
|
protected override void StartTrack()
|
|
|
|
{
|
2021-09-09 21:04:00 +08:00
|
|
|
decoupledClock.Start();
|
2021-09-09 00:21:19 +08:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
private class TrianglesIntroSequence : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly OsuLogo logo;
|
2022-07-08 01:01:51 +08:00
|
|
|
private readonly Action showBackgroundAction;
|
2019-08-09 19:05:28 +08:00
|
|
|
private OsuSpriteText welcomeText;
|
|
|
|
|
|
|
|
private RulesetFlow rulesets;
|
|
|
|
private Container rulesetsScale;
|
2019-08-23 12:02:50 +08:00
|
|
|
private Container logoContainerSecondary;
|
2020-01-06 05:11:37 +08:00
|
|
|
private LazerLogo lazerLogo;
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
|
|
private GlitchingTriangles triangles;
|
|
|
|
|
|
|
|
public Action LoadMenu;
|
|
|
|
|
2022-07-08 01:01:51 +08:00
|
|
|
public TrianglesIntroSequence(OsuLogo logo, Action showBackgroundAction)
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
this.logo = logo;
|
2022-07-08 01:01:51 +08:00
|
|
|
this.showBackgroundAction = showBackgroundAction;
|
2019-08-09 19:05:28 +08:00
|
|
|
}
|
|
|
|
|
2020-02-14 21:14:00 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuGameBase game { get; set; }
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
private void load()
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2019-08-23 12:02:50 +08:00
|
|
|
InternalChildren = new Drawable[]
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
triangles = new GlitchingTriangles
|
|
|
|
{
|
|
|
|
Alpha = 0,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(0.4f, 0.16f)
|
|
|
|
},
|
|
|
|
welcomeText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Padding = new MarginPadding { Bottom = 10 },
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 42),
|
|
|
|
Alpha = 1,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
},
|
|
|
|
rulesetsScale = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
rulesets = new RulesetFlow()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
logoContainerSecondary = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2020-06-24 20:11:38 +08:00
|
|
|
Child = lazerLogo = new LazerLogo
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
2020-01-06 05:11:37 +08:00
|
|
|
Origin = Anchor.Centre
|
2019-08-09 19:05:28 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private const double text_1 = 200;
|
|
|
|
private const double text_2 = 400;
|
|
|
|
private const double text_3 = 700;
|
|
|
|
private const double text_4 = 900;
|
|
|
|
private const double text_glitch = 1060;
|
|
|
|
|
|
|
|
private const double rulesets_1 = 1450;
|
|
|
|
private const double rulesets_2 = 1650;
|
|
|
|
private const double rulesets_3 = 1850;
|
|
|
|
|
|
|
|
private const double logo_scale_duration = 920;
|
|
|
|
private const double logo_1 = 2080;
|
|
|
|
private const double logo_2 = logo_1 + logo_scale_duration;
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
const float scale_start = 1.2f;
|
|
|
|
const float scale_adjust = 0.8f;
|
|
|
|
|
|
|
|
rulesets.Hide();
|
2019-08-22 12:48:27 +08:00
|
|
|
lazerLogo.Hide();
|
2019-08-09 19:05:28 +08:00
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginAbsoluteSequence(0))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(text_1))
|
2019-08-09 19:05:28 +08:00
|
|
|
welcomeText.FadeIn().OnComplete(t => t.Text = "wel");
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(text_2))
|
2019-08-09 19:05:28 +08:00
|
|
|
welcomeText.FadeIn().OnComplete(t => t.Text = "welcome");
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(text_3))
|
2019-08-09 19:05:28 +08:00
|
|
|
welcomeText.FadeIn().OnComplete(t => t.Text = "welcome to");
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(text_4))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
welcomeText.FadeIn().OnComplete(t => t.Text = "welcome to osu!");
|
|
|
|
welcomeText.TransformTo(nameof(welcomeText.Spacing), new Vector2(50, 0), 5000);
|
|
|
|
}
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(text_glitch))
|
2019-08-09 19:05:28 +08:00
|
|
|
triangles.FadeIn();
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(rulesets_1))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
rulesetsScale.ScaleTo(0.8f, 1000);
|
|
|
|
rulesets.FadeIn().ScaleTo(1).TransformSpacingTo(new Vector2(200, 0));
|
|
|
|
welcomeText.FadeOut();
|
|
|
|
triangles.FadeOut();
|
|
|
|
}
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(rulesets_2))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
rulesets.ScaleTo(2).TransformSpacingTo(new Vector2(30, 0));
|
|
|
|
}
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(rulesets_3))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
rulesets.ScaleTo(4).TransformSpacingTo(new Vector2(10, 0));
|
|
|
|
rulesetsScale.ScaleTo(1.3f, 1000);
|
|
|
|
}
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(logo_1))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
rulesets.FadeOut();
|
|
|
|
|
|
|
|
// matching flyte curve y = 0.25x^2 + (max(0, x - 0.7) / 0.3) ^ 5
|
2019-08-22 12:48:27 +08:00
|
|
|
lazerLogo.FadeIn().ScaleTo(scale_start).Then().Delay(logo_scale_duration * 0.7f).ScaleTo(scale_start - scale_adjust, logo_scale_duration * 0.3f, Easing.InQuint);
|
2020-06-24 20:11:38 +08:00
|
|
|
|
2020-07-15 18:40:46 +08:00
|
|
|
lazerLogo.TransformTo(nameof(LazerLogo.Progress), 1f, logo_scale_duration);
|
2020-06-24 20:11:38 +08:00
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
logoContainerSecondary.ScaleTo(scale_start).Then().ScaleTo(scale_start - scale_adjust * 0.25f, logo_scale_duration, Easing.InQuad);
|
|
|
|
}
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
using (BeginDelayedSequence(logo_2))
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2019-08-22 12:48:27 +08:00
|
|
|
lazerLogo.FadeOut().OnComplete(_ =>
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2019-08-23 12:02:50 +08:00
|
|
|
logoContainerSecondary.Remove(lazerLogo);
|
2019-08-22 12:48:27 +08:00
|
|
|
lazerLogo.Dispose(); // explicit disposal as we are pushing a new screen and the expire may not get run.
|
|
|
|
|
2019-08-09 19:05:28 +08:00
|
|
|
logo.FadeIn();
|
2021-03-08 12:29:09 +08:00
|
|
|
|
2022-07-08 01:01:51 +08:00
|
|
|
showBackgroundAction();
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
|
|
game.Add(new GameWideFlash());
|
|
|
|
|
|
|
|
LoadMenu();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class GameWideFlash : Box
|
|
|
|
{
|
|
|
|
private const double flash_length = 1000;
|
|
|
|
|
|
|
|
public GameWideFlash()
|
|
|
|
{
|
|
|
|
Colour = Color4.White;
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2019-08-21 12:29:50 +08:00
|
|
|
Blending = BlendingParameters.Additive;
|
2019-08-09 19:05:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
this.FadeOutFromOne(flash_length, Easing.Out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class LazerLogo : CompositeDrawable
|
|
|
|
{
|
2020-07-23 04:10:59 +08:00
|
|
|
private LogoAnimation highlight, background;
|
2020-03-11 17:00:39 +08:00
|
|
|
|
2020-07-15 18:40:46 +08:00
|
|
|
public float Progress
|
2020-06-24 20:11:38 +08:00
|
|
|
{
|
2020-07-05 01:06:26 +08:00
|
|
|
get => background.AnimationProgress;
|
2020-07-15 18:40:46 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
background.AnimationProgress = value;
|
|
|
|
highlight.AnimationProgress = value;
|
|
|
|
}
|
2020-06-24 20:11:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public LazerLogo()
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
Size = new Vector2(960);
|
2020-03-11 17:00:39 +08:00
|
|
|
}
|
2019-08-09 19:05:28 +08:00
|
|
|
|
2020-03-11 17:00:39 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-06-24 20:11:38 +08:00
|
|
|
private void load(TextureStore textures)
|
2020-03-11 17:00:39 +08:00
|
|
|
{
|
2020-06-24 20:11:38 +08:00
|
|
|
InternalChildren = new Drawable[]
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2020-07-23 04:10:59 +08:00
|
|
|
highlight = new LogoAnimation
|
2020-06-24 20:11:38 +08:00
|
|
|
{
|
2020-06-24 22:27:00 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-15 18:03:59 +08:00
|
|
|
Texture = textures.Get(@"Intro/Triangles/logo-highlight"),
|
|
|
|
Colour = Color4.White,
|
2020-06-24 20:11:38 +08:00
|
|
|
},
|
2020-07-23 04:10:59 +08:00
|
|
|
background = new LogoAnimation
|
2020-06-24 20:11:38 +08:00
|
|
|
{
|
2020-06-24 22:27:00 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-15 18:03:59 +08:00
|
|
|
Texture = textures.Get(@"Intro/Triangles/logo-background"),
|
2020-07-05 01:06:26 +08:00
|
|
|
Colour = OsuColour.Gray(0.6f),
|
2020-06-24 20:11:38 +08:00
|
|
|
},
|
2019-08-09 19:05:28 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class RulesetFlow : FillFlowContainer
|
|
|
|
{
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(RulesetStore rulesets)
|
|
|
|
{
|
2022-06-29 18:37:17 +08:00
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-08-09 19:05:28 +08:00
|
|
|
|
|
|
|
foreach (var ruleset in rulesets.AvailableRulesets)
|
|
|
|
{
|
2022-06-29 18:37:17 +08:00
|
|
|
try
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
2022-06-29 18:37:17 +08:00
|
|
|
var icon = new ConstrainedIconContainer
|
|
|
|
{
|
|
|
|
Icon = ruleset.CreateInstance().CreateIcon(),
|
|
|
|
Size = new Vector2(30),
|
|
|
|
};
|
2019-08-09 19:05:28 +08:00
|
|
|
|
2022-06-29 18:37:17 +08:00
|
|
|
Add(icon);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
Logger.Log($"Could not create ruleset icon for {ruleset.Name}. Please check for an update from the developer.", level: LogLevel.Error);
|
|
|
|
}
|
2019-08-09 19:05:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class GlitchingTriangles : CompositeDrawable
|
|
|
|
{
|
|
|
|
public GlitchingTriangles()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
private double? lastGenTime;
|
|
|
|
|
|
|
|
private const double time_between_triangles = 22;
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
if (lastGenTime == null || Time.Current - lastGenTime > time_between_triangles)
|
|
|
|
{
|
|
|
|
lastGenTime = (lastGenTime ?? Time.Current) + time_between_triangles;
|
|
|
|
|
|
|
|
Drawable triangle = new OutlineTriangle(RNG.NextBool(), (RNG.NextSingle() + 0.2f) * 80)
|
|
|
|
{
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
|
|
|
|
};
|
|
|
|
|
|
|
|
AddInternal(triangle);
|
|
|
|
|
|
|
|
triangle.FadeOutFromOne(120);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a sprite that is drawn in a triangle shape, instead of a rectangle shape.
|
|
|
|
/// </summary>
|
|
|
|
public class OutlineTriangle : BufferedContainer
|
|
|
|
{
|
|
|
|
public OutlineTriangle(bool outlineOnly, float size)
|
2021-11-05 14:54:27 +08:00
|
|
|
: base(cachedFrameBuffer: true)
|
2019-08-09 19:05:28 +08:00
|
|
|
{
|
|
|
|
Size = new Vector2(size);
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Triangle { RelativeSizeAxes = Axes.Both },
|
|
|
|
};
|
|
|
|
|
|
|
|
if (outlineOnly)
|
|
|
|
{
|
|
|
|
AddInternal(new Triangle
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
Size = new Vector2(size - 5),
|
2019-08-21 12:29:50 +08:00
|
|
|
Blending = BlendingParameters.None,
|
2019-08-09 19:05:28 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-08-21 12:29:50 +08:00
|
|
|
Blending = BlendingParameters.Additive;
|
2019-08-09 19:05:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|