1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 10:02:55 +08:00
osu-lazer/osu.Game/Storyboards/Drawables/Storyboard.cs

60 lines
2.0 KiB
C#
Raw Normal View History

2017-09-08 05:55:05 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
public class Storyboard : Container<StoryboardLayer>
{
public StoryboardDefinition Definition { get; private set; }
protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 480);
public override bool HandleInput => false;
private bool passing = true;
public bool Passing
{
get { return passing; }
set
{
if (passing == value) return;
passing = value;
updateLayerVisibility();
}
}
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
public Storyboard(StoryboardDefinition definition)
{
Definition = definition;
Size = new Vector2(640, 480);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
[BackgroundDependencyLoader]
private void load(FileStore fileStore)
{
dependencies.Cache(new TextureStore(new RawTextureLoaderStore(fileStore.Store), false) { ScaleAdjust = 1, });
foreach (var layerDefinition in Definition.Layers)
Add(layerDefinition.CreateDrawable());
}
private void updateLayerVisibility()
{
foreach (var layer in Children)
layer.Enabled = passing ? layer.Definition.EnabledWhenPassing : layer.Definition.EnabledWhenFailing;
2017-09-08 05:55:05 +08:00
}
}
}