1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 17:57:29 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/DailyChallenge/DailyChallengeIntro.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

278 lines
11 KiB
C#
Raw Normal View History

2024-08-05 17:07:56 +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.
2024-08-06 16:00:04 +08:00
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
2024-08-05 17:07:56 +08:00
using osu.Framework.Graphics;
2024-08-06 16:00:04 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2024-08-05 17:07:56 +08:00
using osu.Framework.Screens;
2024-08-06 16:00:04 +08:00
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Extensions;
using osu.Game.Graphics;
2024-08-05 17:07:56 +08:00
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Rooms;
2024-08-06 16:00:04 +08:00
using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay.Match;
using osuTK;
2024-08-05 17:07:56 +08:00
namespace osu.Game.Screens.OnlinePlay.DailyChallenge
{
public partial class DailyChallengeIntro : OsuScreen
{
private readonly Room room;
2024-08-06 16:00:04 +08:00
private readonly PlaylistItem item;
private FillFlowContainer introContent = null!;
private Container topPart = null!;
private Container bottomPart = null!;
private Container beatmapBackground = null!;
private Container beatmapTitle = null!;
private bool beatmapBackgroundLoaded;
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
2024-08-05 17:07:56 +08:00
public DailyChallengeIntro(Room room)
{
this.room = room;
2024-08-06 16:00:04 +08:00
item = room.Playlist.Single();
2024-08-05 17:07:56 +08:00
ValidForResume = false;
}
2024-08-06 16:00:04 +08:00
protected override BackgroundScreen CreateBackground() => new DailyChallengeIntroBackgroundScreen(colourProvider);
2024-08-05 17:07:56 +08:00
2024-08-06 16:00:04 +08:00
[BackgroundDependencyLoader]
private void load()
{
2024-08-05 17:07:56 +08:00
InternalChildren = new Drawable[]
{
2024-08-06 16:00:04 +08:00
introContent = new FillFlowContainer
2024-08-05 17:07:56 +08:00
{
2024-08-06 16:00:04 +08:00
Alpha = 0f,
2024-08-05 17:07:56 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2024-08-06 16:00:04 +08:00
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0f, 10f),
Children = new Drawable[]
{
new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = topPart = new Container
{
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Right = 200f },
CornerRadius = 10f,
Masking = true,
Shear = new Vector2(OsuGame.SHEAR, 0f),
Children = new Drawable[]
{
new Box
{
Colour = colourProvider.Background3,
RelativeSizeAxes = Axes.Both,
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "Today's Challenge",
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f },
Shear = new Vector2(-OsuGame.SHEAR, 0f),
// Colour = Color4.Black,
Font = OsuFont.GetFont(size: 32, weight: FontWeight.Light, typeface: Typeface.TorusAlternate),
},
}
},
},
beatmapBackground = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(500f, 150f),
CornerRadius = 20f,
BorderColour = colourProvider.Content2,
BorderThickness = 3f,
Masking = true,
Shear = new Vector2(OsuGame.SHEAR, 0f),
Children = new Drawable[]
{
new Box
{
Colour = colourProvider.Background3,
RelativeSizeAxes = Axes.Both,
},
}
},
beatmapTitle = new Container
{
Width = 500f,
Margin = new MarginPadding { Right = 160f * OsuGame.SHEAR },
AutoSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
CornerRadius = 10f,
Masking = true,
Shear = new Vector2(OsuGame.SHEAR, 0f),
Children = new Drawable[]
{
new Box
{
Colour = colourProvider.Background3,
RelativeSizeAxes = Axes.Both,
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = item.Beatmap.GetDisplayString(),
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f },
Shear = new Vector2(-OsuGame.SHEAR, 0f),
Font = OsuFont.GetFont(size: 24),
},
}
},
new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = bottomPart = new Container
{
Alpha = 0f,
AlwaysPresent = true,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Left = 210f },
CornerRadius = 10f,
Masking = true,
Shear = new Vector2(OsuGame.SHEAR, 0f),
Children = new Drawable[]
{
new Box
{
Colour = colourProvider.Background3,
RelativeSizeAxes = Axes.Both,
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "Sunday, July 28th",
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f },
Shear = new Vector2(-OsuGame.SHEAR, 0f),
Font = OsuFont.GetFont(size: 32, weight: FontWeight.Light, typeface: Typeface.TorusAlternate),
},
}
},
}
}
2024-08-05 17:07:56 +08:00
}
};
2024-08-06 16:00:04 +08:00
LoadComponentAsync(new OnlineBeatmapSetCover(item.Beatmap.BeatmapSet as IBeatmapSetOnlineInfo)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fit,
Scale = new Vector2(1.2f),
Shear = new Vector2(-OsuGame.SHEAR, 0f),
}, c =>
2024-08-05 17:07:56 +08:00
{
2024-08-06 16:00:04 +08:00
beatmapBackground.Add(c);
beatmapBackgroundLoaded = true;
updateAnimationState();
});
}
private bool animationBegan;
public override void OnEntering(ScreenTransitionEvent e)
{
base.OnEntering(e);
this.FadeInFromZero(400, Easing.OutQuint);
updateAnimationState();
}
public override void OnSuspending(ScreenTransitionEvent e)
{
this.FadeOut(200, Easing.OutQuint);
base.OnSuspending(e);
}
private void updateAnimationState()
{
if (!beatmapBackgroundLoaded || !this.IsCurrentScreen())
return;
if (animationBegan)
return;
beginAnimation();
animationBegan = true;
}
private void beginAnimation()
{
introContent.Show();
topPart.MoveToX(-500).MoveToX(0, 300, Easing.OutQuint)
.FadeInFromZero(400, Easing.OutQuint);
bottomPart.MoveToX(500).MoveToX(0, 300, Easing.OutQuint)
.FadeInFromZero(400, Easing.OutQuint);
this.Delay(400).Schedule(() =>
{
introContent.AutoSizeDuration = 200;
introContent.AutoSizeEasing = Easing.OutQuint;
});
this.Delay(500).Schedule(() => ApplyToBackground(bs => ((RoomBackgroundScreen)bs).SelectedItem.Value = item));
beatmapBackground.FadeOut().Delay(500)
.FadeIn(200, Easing.InQuart);
beatmapTitle.FadeOut().Delay(500)
.FadeIn(200, Easing.InQuart);
introContent.Delay(1800).FadeOut(200, Easing.OutQuint)
.OnComplete(_ =>
{
if (this.IsCurrentScreen())
this.Push(new DailyChallenge(room));
});
}
private partial class DailyChallengeIntroBackgroundScreen : RoomBackgroundScreen
{
private readonly OverlayColourProvider colourProvider;
public DailyChallengeIntroBackgroundScreen(OverlayColourProvider colourProvider)
: base(null)
{
this.colourProvider = colourProvider;
}
[BackgroundDependencyLoader]
private void load()
{
AddInternal(new Box
{
Depth = float.MinValue,
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5.Opacity(0.6f),
});
}
2024-08-05 17:07:56 +08:00
}
}
}