mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Display a non-parallax background at the appropriate size when storyboards do not replace it.
This commit is contained in:
parent
f5368505ab
commit
757a159516
@ -53,7 +53,7 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
var backgroundPath = BeatmapInfo.BeatmapSet.Metadata.BackgroundFile?.ToLowerInvariant();
|
||||
var backgroundPath = BeatmapInfo.BeatmapSet.Metadata?.BackgroundFile?.ToLowerInvariant();
|
||||
if (backgroundPath == null)
|
||||
return false;
|
||||
|
||||
|
@ -71,7 +71,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private Container storyboardContainer;
|
||||
private DrawableStoryboard storyboard;
|
||||
private bool storyboardReplacesBackground;
|
||||
|
||||
private HUDOverlay hudOverlay;
|
||||
private FailOverlay failOverlay;
|
||||
@ -157,6 +156,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Clock = offsetClock,
|
||||
Alpha = 0,
|
||||
},
|
||||
pauseContainer = new PauseContainer
|
||||
{
|
||||
@ -209,7 +209,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
scoreProcessor = RulesetContainer.CreateScoreProcessor();
|
||||
|
||||
storyboardReplacesBackground = beatmap.StoryboardReplacesBackground;
|
||||
if (showStoryboard)
|
||||
initializeStoryboard(false);
|
||||
|
||||
@ -236,6 +235,8 @@ namespace osu.Game.Screens.Play
|
||||
storyboard.Width = storyboard.Height * beatmap.BeatmapInfo.StoryboardAspect;
|
||||
storyboard.Masking = true;
|
||||
|
||||
if (!beatmap.StoryboardReplacesBackground)
|
||||
storyboard.BackgroundTexture = Beatmap.Value.Background;
|
||||
storyboardContainer.Add(asyncLoad ? new AsyncLoadWrapper(storyboard) { RelativeSizeAxes = Axes.Both } : (Drawable)storyboard);
|
||||
}
|
||||
|
||||
@ -351,10 +352,13 @@ namespace osu.Game.Screens.Play
|
||||
if (showStoryboard && storyboard == null)
|
||||
initializeStoryboard(true);
|
||||
|
||||
storyboard?.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
|
||||
storyboard?.FadeTo(showStoryboard && opacity > 0 ? 1 : 0, 200);
|
||||
var beatmap = Beatmap.Value;
|
||||
var storyboardVisible = showStoryboard && beatmap.Beatmap.Storyboard.HasDrawable;
|
||||
|
||||
Background?.FadeTo(!showStoryboard || !storyboardReplacesBackground ? opacity : 0, 800, Easing.OutQuint);
|
||||
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
|
||||
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0);
|
||||
|
||||
Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void fadeOut()
|
||||
|
@ -5,6 +5,7 @@ using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.IO;
|
||||
|
||||
@ -14,6 +15,13 @@ namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
public Storyboard Storyboard { get; private set; }
|
||||
|
||||
private readonly Background background;
|
||||
public Texture BackgroundTexture
|
||||
{
|
||||
get { return background.Texture; }
|
||||
set { background.Texture = value; }
|
||||
}
|
||||
|
||||
private readonly Container<DrawableStoryboardLayer> content;
|
||||
protected override Container<DrawableStoryboardLayer> Content => content;
|
||||
|
||||
@ -43,6 +51,11 @@ namespace osu.Game.Storyboards.Drawables
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
AddInternal(background = new Background
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
AddInternal(content = new Container<DrawableStoryboardLayer>
|
||||
{
|
||||
Size = new Vector2(640, 480),
|
||||
@ -65,5 +78,10 @@ namespace osu.Game.Storyboards.Drawables
|
||||
foreach (var layer in Children)
|
||||
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
|
||||
}
|
||||
|
||||
private class Background : Sprite
|
||||
{
|
||||
protected override Vector2 DrawScale => Texture != null ? new Vector2(Parent.DrawHeight / Texture.DisplayHeight) : base.DrawScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ namespace osu.Game.Storyboards
|
||||
public interface IStoryboardElement
|
||||
{
|
||||
string Path { get; }
|
||||
bool IsDrawable { get; }
|
||||
|
||||
Drawable CreateDrawable();
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Storyboards
|
||||
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
|
||||
public IEnumerable<StoryboardLayer> Layers => layers.Values;
|
||||
|
||||
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
|
||||
|
||||
public Storyboard()
|
||||
{
|
||||
layers.Add("Background", new StoryboardLayer("Background", 3));
|
||||
|
@ -8,6 +8,8 @@ namespace osu.Game.Storyboards
|
||||
public class StoryboardSample : IStoryboardElement
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public bool IsDrawable => false;
|
||||
|
||||
public double Time;
|
||||
public float Volume;
|
||||
|
||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Storyboards
|
||||
private readonly List<CommandTrigger> triggers = new List<CommandTrigger>();
|
||||
|
||||
public string Path { get; set; }
|
||||
public bool IsDrawable => HasCommands;
|
||||
|
||||
public Anchor Origin;
|
||||
public Vector2 InitialPosition;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user