1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 03:12:54 +08:00
osu-lazer/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs

73 lines
2.5 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-09-08 05:55:05 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Game.IO;
namespace osu.Game.Storyboards.Drawables
{
2017-09-13 17:22:24 +08:00
public class DrawableStoryboard : Container<DrawableStoryboardLayer>
2017-09-08 05:55:05 +08:00
{
2017-09-13 17:22:24 +08:00
public Storyboard Storyboard { get; private set; }
2017-09-08 05:55:05 +08:00
2017-09-14 20:28:53 +08:00
private readonly Container<DrawableStoryboardLayer> content;
protected override Container<DrawableStoryboardLayer> Content => content;
2017-09-08 05:55:05 +08:00
protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 480);
public override bool HandleKeyboardInput => false;
public override bool HandleMouseInput => false;
2017-09-08 05:55:05 +08:00
private bool passing = true;
public bool Passing
{
get { return passing; }
set
{
if (passing == value) return;
passing = value;
updateLayerVisibility();
}
}
2018-03-04 00:48:00 +08:00
public override bool RemoveCompletedTransforms => false;
2017-09-08 05:55:05 +08:00
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
2017-09-13 17:22:24 +08:00
public DrawableStoryboard(Storyboard storyboard)
2017-09-08 05:55:05 +08:00
{
2017-09-13 17:22:24 +08:00
Storyboard = storyboard;
2017-09-08 05:55:05 +08:00
Size = new Vector2(640, 480);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2017-09-14 20:28:53 +08:00
AddInternal(content = new Container<DrawableStoryboardLayer>
{
Size = new Vector2(640, 480),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
2017-09-08 05:55:05 +08:00
}
[BackgroundDependencyLoader]
private void load(FileStore fileStore)
{
dependencies.Cache(new TextureStore(new RawTextureLoaderStore(fileStore.Store), false) { ScaleAdjust = 1, });
2017-09-13 17:22:24 +08:00
foreach (var layer in Storyboard.Layers)
Add(layer.CreateDrawable());
2017-09-08 05:55:05 +08:00
}
private void updateLayerVisibility()
{
foreach (var layer in Children)
2017-09-13 17:22:24 +08:00
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
2017-09-08 05:55:05 +08:00
}
}
}