mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 13:02:54 +08:00
Merge pull request #13303 from LeNitrous/mainmenu-storyboard-backgrounds
Add storyboards as a main menu background source
This commit is contained in:
commit
840f084dc4
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user