1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 10:12:53 +08:00

Merge pull request #13303 from LeNitrous/mainmenu-storyboard-backgrounds

Add storyboards as a main menu background source
This commit is contained in:
Dean Herbert 2021-06-04 19:50:40 +09:00 committed by GitHub
commit 840f084dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 1 deletions

View File

@ -1,11 +1,16 @@
// 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.
using System.ComponentModel;
namespace osu.Game.Configuration
{
public enum BackgroundSource
{
Skin,
Beatmap
Beatmap,
[Description("Beatmap (with storyboard / video)")]
BeatmapWithStoryboard,
}
}

View File

@ -0,0 +1,37 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Storyboards.Drawables;
namespace osu.Game.Graphics.Backgrounds
{
public class BeatmapBackgroundWithStoryboard : BeatmapBackground
{
public BeatmapBackgroundWithStoryboard(WorkingBeatmap beatmap, string fallbackTextureName = "Backgrounds/bg1")
: base(beatmap, fallbackTextureName)
{
}
[BackgroundDependencyLoader]
private void load()
{
if (!Beatmap.Storyboard.HasDrawable)
return;
if (Beatmap.Storyboard.ReplacesBackground)
Sprite.Alpha = 0;
LoadComponentAsync(new AudioContainer
{
RelativeSizeAxes = Axes.Both,
Volume = { Value = 0 },
Child = new DrawableStoryboard(Beatmap.Storyboard) { Clock = new InterpolatingFramedClock(Beatmap.Track) }
}, AddInternal);
}
}
}

View File

@ -172,6 +172,8 @@ namespace osu.Game.Graphics.Containers
private class ScalingBackgroundScreen : BackgroundScreenDefault
{
protected override bool AllowStoryboardBackground => false;
public override void OnEntering(IScreen last)
{
this.FadeInFromZero(4000, Easing.OutQuint);

View File

@ -31,6 +31,8 @@ namespace osu.Game.Screens.Backgrounds
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
protected virtual bool AllowStoryboardBackground => true;
public BackgroundScreenDefault(bool animateOnEnter = true)
: base(animateOnEnter)
{
@ -110,6 +112,12 @@ namespace osu.Game.Screens.Backgrounds
newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
break;
case BackgroundSource.BeatmapWithStoryboard:
newBackground = AllowStoryboardBackground
? new BeatmapBackgroundWithStoryboard(beatmap.Value, backgroundName)
: new BeatmapBackground(beatmap.Value, backgroundName);
break;
default:
newBackground = new SkinnedBackground(skin.Value, backgroundName);
break;