mirror of
https://github.com/ppy/osu
synced 2025-01-15 10:31:02 +00:00
Merge pull request #12946 from peppy/fix-storyboard-video-widescreen-no-elements
Fix storyboard videos not correctly filling the screen
This commit is contained in:
commit
08c8cd7a66
@ -57,7 +57,13 @@ namespace osu.Game.Storyboards.Drawables
|
||||
public DrawableStoryboard(Storyboard storyboard)
|
||||
{
|
||||
Storyboard = storyboard;
|
||||
|
||||
Size = new Vector2(640, 480);
|
||||
|
||||
bool onlyHasVideoElements = Storyboard.Layers.SelectMany(l => l.Elements).Any(e => !(e is StoryboardVideo));
|
||||
|
||||
Width = Height * (storyboard.BeatmapInfo.WidescreenStoryboard || onlyHasVideoElements ? 16 / 9f : 4 / 3f);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
@ -15,6 +16,8 @@ namespace osu.Game.Storyboards.Drawables
|
||||
|
||||
public override bool IsPresent => Enabled && base.IsPresent;
|
||||
|
||||
protected LayerElementContainer ElementContainer { get; }
|
||||
|
||||
public DrawableStoryboardLayer(StoryboardLayer layer)
|
||||
{
|
||||
Layer = layer;
|
||||
@ -24,10 +27,10 @@ namespace osu.Game.Storyboards.Drawables
|
||||
Enabled = layer.VisibleWhenPassing;
|
||||
Masking = layer.Masking;
|
||||
|
||||
InternalChild = new LayerElementContainer(layer);
|
||||
InternalChild = ElementContainer = new LayerElementContainer(layer);
|
||||
}
|
||||
|
||||
private class LayerElementContainer : LifetimeManagementContainer
|
||||
protected class LayerElementContainer : LifetimeManagementContainer
|
||||
{
|
||||
private readonly StoryboardLayer storyboardLayer;
|
||||
|
||||
@ -35,8 +38,8 @@ namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
storyboardLayer = layer;
|
||||
|
||||
Width = 640;
|
||||
Height = 480;
|
||||
Size = new Vector2(640, 480);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Storyboards
|
||||
|
||||
public Storyboard()
|
||||
{
|
||||
layers.Add("Video", new StoryboardLayer("Video", 4, false));
|
||||
layers.Add("Video", new StoryboardVideoLayer("Video", 4, false));
|
||||
layers.Add("Background", new StoryboardLayer("Background", 3));
|
||||
layers.Add("Fail", new StoryboardLayer("Fail", 2) { VisibleWhenPassing = false, });
|
||||
layers.Add("Pass", new StoryboardLayer("Pass", 1) { VisibleWhenFailing = false, });
|
||||
@ -85,12 +85,8 @@ namespace osu.Game.Storyboards
|
||||
}
|
||||
}
|
||||
|
||||
public DrawableStoryboard CreateDrawable(WorkingBeatmap working = null)
|
||||
{
|
||||
var drawable = new DrawableStoryboard(this);
|
||||
drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
|
||||
return drawable;
|
||||
}
|
||||
public DrawableStoryboard CreateDrawable(WorkingBeatmap working = null) =>
|
||||
new DrawableStoryboard(this);
|
||||
|
||||
public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureStore)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Storyboards
|
||||
Elements.Add(element);
|
||||
}
|
||||
|
||||
public DrawableStoryboardLayer CreateDrawable()
|
||||
public virtual DrawableStoryboardLayer CreateDrawable()
|
||||
=> new DrawableStoryboardLayer(this) { Depth = Depth, Name = Name };
|
||||
}
|
||||
}
|
||||
|
32
osu.Game/Storyboards/StoryboardVideoLayer.cs
Normal file
32
osu.Game/Storyboards/StoryboardVideoLayer.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// 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.Graphics;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Storyboards
|
||||
{
|
||||
public class StoryboardVideoLayer : StoryboardLayer
|
||||
{
|
||||
public StoryboardVideoLayer(string name, int depth, bool masking)
|
||||
: base(name, depth, masking)
|
||||
{
|
||||
}
|
||||
|
||||
public override DrawableStoryboardLayer CreateDrawable()
|
||||
=> new DrawableStoryboardVideoLayer(this) { Depth = Depth, Name = Name };
|
||||
|
||||
public class DrawableStoryboardVideoLayer : DrawableStoryboardLayer
|
||||
{
|
||||
public DrawableStoryboardVideoLayer(StoryboardVideoLayer layer)
|
||||
: base(layer)
|
||||
{
|
||||
// for videos we want to take on the full size of the storyboard container hierarchy
|
||||
// to allow the video to fill the full available region.
|
||||
ElementContainer.RelativeSizeAxes = Axes.Both;
|
||||
ElementContainer.Size = Vector2.One;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user