1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Rename storyboard classes.

This commit is contained in:
Damnae 2017-09-13 11:22:24 +02:00
parent 58e65397b0
commit bab3ef0669
15 changed files with 119 additions and 119 deletions

View File

@ -21,8 +21,8 @@ namespace osu.Desktop.Tests.Visual
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
private readonly Container<Storyboard> storyboardContainer;
private Storyboard storyboard;
private readonly Container<DrawableStoryboard> storyboardContainer;
private DrawableStoryboard storyboard;
public TestCaseStoryboard()
{
@ -38,7 +38,7 @@ namespace osu.Desktop.Tests.Visual
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
storyboardContainer = new Container<Storyboard>
storyboardContainer = new Container<DrawableStoryboard>
{
RelativeSizeAxes = Axes.Both,
},

View File

@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// The Beatmap's Storyboard.
/// </summary>
public StoryboardDefinition Storyboard = new StoryboardDefinition();
public Storyboard Storyboard = new Storyboard();
/// <summary>
/// Constructs a new beatmap.

View File

@ -242,7 +242,7 @@ namespace osu.Game.Beatmaps.Formats
}
}
private void handleEvents(Beatmap beatmap, string line, ref SpriteDefinition spriteDefinition, ref CommandTimelineGroup timelineGroup)
private void handleEvents(Beatmap beatmap, string line, ref StoryboardSprite storyboardSprite, ref CommandTimelineGroup timelineGroup)
{
var depth = 0;
while (line.StartsWith(" ") || line.StartsWith("_"))
@ -257,7 +257,7 @@ namespace osu.Game.Beatmaps.Formats
if (depth == 0)
{
spriteDefinition = null;
storyboardSprite = null;
EventType type;
if (!Enum.TryParse(split[0], out type))
@ -292,8 +292,8 @@ namespace osu.Game.Beatmaps.Formats
var path = cleanFilename(split[3]);
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
spriteDefinition = new SpriteDefinition(path, origin, new Vector2(x, y));
beatmap.Storyboard.GetLayer(layer).Add(spriteDefinition);
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
beatmap.Storyboard.GetLayer(layer).Add(storyboardSprite);
}
break;
case EventType.Animation:
@ -306,8 +306,8 @@ namespace osu.Game.Beatmaps.Formats
var frameCount = int.Parse(split[6]);
var frameDelay = double.Parse(split[7], NumberFormatInfo.InvariantInfo);
var loopType = split.Length > 8 ? (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), split[8]) : AnimationLoopType.LoopForever;
spriteDefinition = new AnimationDefinition(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
beatmap.Storyboard.GetLayer(layer).Add(spriteDefinition);
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
beatmap.Storyboard.GetLayer(layer).Add(storyboardSprite);
}
break;
case EventType.Sample:
@ -316,7 +316,7 @@ namespace osu.Game.Beatmaps.Formats
var layer = parseLayer(split[2]);
var path = cleanFilename(split[3]);
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
beatmap.Storyboard.GetLayer(layer).Add(new SampleDefinition(path, time, volume));
beatmap.Storyboard.GetLayer(layer).Add(new StoryboardSample(path, time, volume));
}
break;
}
@ -324,7 +324,7 @@ namespace osu.Game.Beatmaps.Formats
else
{
if (depth < 2)
timelineGroup = spriteDefinition?.TimelineGroup;
timelineGroup = storyboardSprite?.TimelineGroup;
var commandType = split[0];
switch (commandType)
@ -335,14 +335,14 @@ namespace osu.Game.Beatmaps.Formats
var startTime = split.Length > 2 ? double.Parse(split[2], CultureInfo.InvariantCulture) : double.MinValue;
var endTime = split.Length > 3 ? double.Parse(split[3], CultureInfo.InvariantCulture) : double.MaxValue;
var groupNumber = split.Length > 4 ? int.Parse(split[4]) : 0;
timelineGroup = spriteDefinition?.AddTrigger(triggerName, startTime, endTime, groupNumber);
timelineGroup = storyboardSprite?.AddTrigger(triggerName, startTime, endTime, groupNumber);
}
break;
case "L":
{
var startTime = double.Parse(split[1], CultureInfo.InvariantCulture);
var loopCount = int.Parse(split[2]);
timelineGroup = spriteDefinition?.AddLoop(startTime, loopCount);
timelineGroup = storyboardSprite?.AddLoop(startTime, loopCount);
}
break;
default:
@ -607,7 +607,7 @@ namespace osu.Game.Beatmaps.Formats
Section section = Section.None;
bool hasCustomColours = false;
SpriteDefinition spriteDefinition = null;
StoryboardSprite storyboardSprite = null;
CommandTimelineGroup timelineGroup = null;
string line;
@ -647,7 +647,7 @@ namespace osu.Game.Beatmaps.Formats
handleDifficulty(beatmap, line);
break;
case Section.Events:
handleEvents(beatmap, line, ref spriteDefinition, ref timelineGroup);
handleEvents(beatmap, line, ref storyboardSprite, ref timelineGroup);
break;
case Section.TimingPoints:
handleTimingPoints(beatmap, line);

View File

@ -10,9 +10,9 @@ using osu.Game.IO;
namespace osu.Game.Storyboards.Drawables
{
public class Storyboard : Container<StoryboardLayer>
public class DrawableStoryboard : Container<DrawableStoryboardLayer>
{
public StoryboardDefinition Definition { get; private set; }
public Storyboard Storyboard { get; private set; }
protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 480);
public override bool HandleInput => false;
@ -33,9 +33,9 @@ namespace osu.Game.Storyboards.Drawables
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
public Storyboard(StoryboardDefinition definition)
public DrawableStoryboard(Storyboard storyboard)
{
Definition = definition;
Storyboard = storyboard;
Size = new Vector2(640, 480);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
@ -46,14 +46,14 @@ namespace osu.Game.Storyboards.Drawables
{
dependencies.Cache(new TextureStore(new RawTextureLoaderStore(fileStore.Store), false) { ScaleAdjust = 1, });
foreach (var layerDefinition in Definition.Layers)
Add(layerDefinition.CreateDrawable());
foreach (var layer in Storyboard.Layers)
Add(layer.CreateDrawable());
}
private void updateLayerVisibility()
{
foreach (var layer in Children)
layer.Enabled = passing ? layer.Definition.EnabledWhenPassing : layer.Definition.EnabledWhenFailing;
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
}
}
}

View File

@ -10,12 +10,12 @@ using System.Linq;
namespace osu.Game.Storyboards.Drawables
{
public class StoryboardAnimation : TextureAnimation, IFlippable
public class DrawableStoryboardAnimation : TextureAnimation, IFlippable
{
public AnimationDefinition Definition { get; private set; }
public StoryboardAnimation Animation { get; private set; }
protected override bool ShouldBeAlive => Definition.HasCommands && base.ShouldBeAlive;
public override bool RemoveWhenNotAlive => !Definition.HasCommands || base.RemoveWhenNotAlive;
protected override bool ShouldBeAlive => Animation.HasCommands && base.ShouldBeAlive;
public override bool RemoveWhenNotAlive => !Animation.HasCommands || base.RemoveWhenNotAlive;
public bool FlipH { get; set; }
public bool FlipV { get; set; }
@ -52,25 +52,25 @@ namespace osu.Game.Storyboards.Drawables
public override bool IsPresent
=> !float.IsNaN(DrawPosition.X) && !float.IsNaN(DrawPosition.Y) && base.IsPresent;
public StoryboardAnimation(AnimationDefinition definition)
public DrawableStoryboardAnimation(StoryboardAnimation animation)
{
Definition = definition;
Origin = definition.Origin;
Position = definition.InitialPosition;
Repeat = definition.LoopType == AnimationLoopType.LoopForever;
Animation = animation;
Origin = animation.Origin;
Position = animation.InitialPosition;
Repeat = animation.LoopType == AnimationLoopType.LoopForever;
if (definition.HasCommands)
if (animation.HasCommands)
{
LifetimeStart = definition.StartTime;
LifetimeEnd = definition.EndTime;
LifetimeStart = animation.StartTime;
LifetimeEnd = animation.EndTime;
}
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game, TextureStore textureStore)
{
var basePath = Definition.Path.ToLowerInvariant();
for (var frame = 0; frame < Definition.FrameCount; frame++)
var basePath = Animation.Path.ToLowerInvariant();
for (var frame = 0; frame < Animation.FrameCount; frame++)
{
var framePath = basePath.Replace(".", frame + ".");
@ -79,9 +79,9 @@ namespace osu.Game.Storyboards.Drawables
continue;
var texture = textureStore.Get(path);
AddFrame(texture, Definition.FrameDelay);
AddFrame(texture, Animation.FrameDelay);
}
Definition.ApplyTransforms(this);
Animation.ApplyTransforms(this);
}
}
}

View File

@ -7,26 +7,26 @@ using osu.Framework.Graphics.Containers;
namespace osu.Game.Storyboards.Drawables
{
public class StoryboardLayer : Container
public class DrawableStoryboardLayer : Container
{
public LayerDefinition Definition { get; private set; }
public StoryboardLayer Layer { get; private set; }
public bool Enabled;
public override bool IsPresent => Enabled && base.IsPresent;
public StoryboardLayer(LayerDefinition definition)
public DrawableStoryboardLayer(StoryboardLayer layer)
{
Definition = definition;
Layer = layer;
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Enabled = definition.EnabledWhenPassing;
Enabled = layer.EnabledWhenPassing;
}
[BackgroundDependencyLoader]
private void load()
{
foreach (var element in Definition.Elements)
foreach (var element in Layer.Elements)
{
var drawable = element.CreateDrawable();
if (drawable != null)

View File

@ -10,12 +10,12 @@ using System.Linq;
namespace osu.Game.Storyboards.Drawables
{
public class StoryboardSprite : Sprite, IFlippable
public class DrawableStoryboardSprite : Sprite, IFlippable
{
public SpriteDefinition Definition { get; private set; }
public StoryboardSprite Sprite { get; private set; }
protected override bool ShouldBeAlive => Definition.HasCommands && base.ShouldBeAlive;
public override bool RemoveWhenNotAlive => !Definition.HasCommands || base.RemoveWhenNotAlive;
protected override bool ShouldBeAlive => Sprite.HasCommands && base.ShouldBeAlive;
public override bool RemoveWhenNotAlive => !Sprite.HasCommands || base.RemoveWhenNotAlive;
public bool FlipH { get; set; }
public bool FlipV { get; set; }
@ -52,29 +52,29 @@ namespace osu.Game.Storyboards.Drawables
public override bool IsPresent
=> !float.IsNaN(DrawPosition.X) && !float.IsNaN(DrawPosition.Y) && base.IsPresent;
public StoryboardSprite(SpriteDefinition definition)
public DrawableStoryboardSprite(StoryboardSprite sprite)
{
Definition = definition;
Origin = definition.Origin;
Position = definition.InitialPosition;
Sprite = sprite;
Origin = sprite.Origin;
Position = sprite.InitialPosition;
if (definition.HasCommands)
if (sprite.HasCommands)
{
LifetimeStart = definition.StartTime;
LifetimeEnd = definition.EndTime;
LifetimeStart = sprite.StartTime;
LifetimeEnd = sprite.EndTime;
}
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game, TextureStore textureStore)
{
var spritePath = Definition.Path.ToLowerInvariant();
var spritePath = Sprite.Path.ToLowerInvariant();
var path = game.Beatmap.Value.BeatmapSetInfo.Files.FirstOrDefault(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath;
if (path == null)
return;
Texture = textureStore.Get(path);
Definition.ApplyTransforms(this);
Sprite.ApplyTransforms(this);
}
}
}

View File

@ -5,7 +5,7 @@ using osu.Framework.Graphics;
namespace osu.Game.Storyboards
{
public interface IElementDefinition
public interface IStoryboardElement
{
string Path { get; }
Drawable CreateDrawable();

View File

@ -0,0 +1,35 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Storyboards.Drawables;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Storyboards
{
public class Storyboard
{
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
public IEnumerable<StoryboardLayer> Layers => layers.Values;
public Storyboard()
{
layers.Add("Background", new StoryboardLayer("Background", 3));
layers.Add("Fail", new StoryboardLayer("Fail", 2) { EnabledWhenPassing = false, });
layers.Add("Pass", new StoryboardLayer("Pass", 1) { EnabledWhenFailing = false, });
layers.Add("Foreground", new StoryboardLayer("Foreground", 0));
}
public StoryboardLayer GetLayer(string name)
{
StoryboardLayer layer;
if (!layers.TryGetValue(name, out layer))
layers[name] = layer = new StoryboardLayer(name, layers.Values.Min(l => l.Depth) - 1);
return layer;
}
public DrawableStoryboard CreateDrawable()
=> new DrawableStoryboard(this);
}
}

View File

@ -7,13 +7,13 @@ using osu.Game.Storyboards.Drawables;
namespace osu.Game.Storyboards
{
public class AnimationDefinition : SpriteDefinition
public class StoryboardAnimation : StoryboardSprite
{
public int FrameCount;
public double FrameDelay;
public AnimationLoopType LoopType;
public AnimationDefinition(string path, Anchor origin, Vector2 initialPosition, int frameCount, double frameDelay, AnimationLoopType loopType)
public StoryboardAnimation(string path, Anchor origin, Vector2 initialPosition, int frameCount, double frameDelay, AnimationLoopType loopType)
: base(path, origin, initialPosition)
{
FrameCount = frameCount;
@ -22,7 +22,7 @@ namespace osu.Game.Storyboards
}
public override Drawable CreateDrawable()
=> new StoryboardAnimation(this);
=> new DrawableStoryboardAnimation(this);
}
public enum AnimationLoopType

View File

@ -1,35 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Storyboards.Drawables;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Storyboards
{
public class StoryboardDefinition
{
private readonly Dictionary<string, LayerDefinition> layers = new Dictionary<string, LayerDefinition>();
public IEnumerable<LayerDefinition> Layers => layers.Values;
public StoryboardDefinition()
{
layers.Add("Background", new LayerDefinition("Background", 3));
layers.Add("Fail", new LayerDefinition("Fail", 2) { EnabledWhenPassing = false, });
layers.Add("Pass", new LayerDefinition("Pass", 1) { EnabledWhenFailing = false, });
layers.Add("Foreground", new LayerDefinition("Foreground", 0));
}
public LayerDefinition GetLayer(string name)
{
LayerDefinition layer;
if (!layers.TryGetValue(name, out layer))
layers[name] = layer = new LayerDefinition(name, layers.Values.Min(l => l.Depth) - 1);
return layer;
}
public Storyboard CreateDrawable()
=> new Storyboard(this);
}
}

View File

@ -6,28 +6,28 @@ using System.Collections.Generic;
namespace osu.Game.Storyboards
{
public class LayerDefinition
public class StoryboardLayer
{
public string Name;
public int Depth;
public bool EnabledWhenPassing = true;
public bool EnabledWhenFailing = true;
private readonly List<IElementDefinition> elements = new List<IElementDefinition>();
public IEnumerable<IElementDefinition> Elements => elements;
private readonly List<IStoryboardElement> elements = new List<IStoryboardElement>();
public IEnumerable<IStoryboardElement> Elements => elements;
public LayerDefinition(string name, int depth)
public StoryboardLayer(string name, int depth)
{
Name = name;
Depth = depth;
}
public void Add(IElementDefinition element)
public void Add(IStoryboardElement element)
{
elements.Add(element);
}
public StoryboardLayer CreateDrawable()
=> new StoryboardLayer(this) { Depth = Depth, };
public DrawableStoryboardLayer CreateDrawable()
=> new DrawableStoryboardLayer(this) { Depth = Depth, };
}
}

View File

@ -5,13 +5,13 @@ using osu.Framework.Graphics;
namespace osu.Game.Storyboards
{
public class SampleDefinition : IElementDefinition
public class StoryboardSample : IStoryboardElement
{
public string Path { get; set; }
public double Time;
public float Volume;
public SampleDefinition(string path, double time, float volume)
public StoryboardSample(string path, double time, float volume)
{
Path = path;
Time = time;

View File

@ -10,7 +10,7 @@ using System.Linq;
namespace osu.Game.Storyboards
{
public class SpriteDefinition : IElementDefinition
public class StoryboardSprite : IStoryboardElement
{
private readonly List<CommandLoop> loops = new List<CommandLoop>();
private readonly List<CommandTrigger> triggers = new List<CommandTrigger>();
@ -34,7 +34,7 @@ namespace osu.Game.Storyboards
private delegate void DrawablePropertyInitializer<in T>(Drawable drawable, T value);
private delegate void DrawableTransformer<in T>(Drawable drawable, T value, double duration, Easing easing);
public SpriteDefinition(string path, Anchor origin, Vector2 initialPosition)
public StoryboardSprite(string path, Anchor origin, Vector2 initialPosition)
{
Path = path;
Origin = origin;
@ -56,7 +56,7 @@ namespace osu.Game.Storyboards
}
public virtual Drawable CreateDrawable()
=> new StoryboardSprite(this);
=> new DrawableStoryboardSprite(this);
public void ApplyTransforms(Drawable drawable, IEnumerable<Tuple<CommandTimelineGroup, double>> triggeredGroups = null)
{

View File

@ -81,21 +81,21 @@
<Compile Include="Beatmaps\DummyWorkingBeatmap.cs" />
<Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" />
<Compile Include="Storyboards\Drawables\IFlippable.cs" />
<Compile Include="Storyboards\Drawables\StoryboardLayer.cs" />
<Compile Include="Storyboards\Drawables\Storyboard.cs" />
<Compile Include="Storyboards\Drawables\StoryboardAnimation.cs" />
<Compile Include="Storyboards\Drawables\StoryboardSprite.cs" />
<Compile Include="Storyboards\AnimationDefinition.cs" />
<Compile Include="Storyboards\Drawables\DrawableStoryboardLayer.cs" />
<Compile Include="Storyboards\Drawables\DrawableStoryboard.cs" />
<Compile Include="Storyboards\Drawables\DrawableStoryboardAnimation.cs" />
<Compile Include="Storyboards\Drawables\DrawableStoryboardSprite.cs" />
<Compile Include="Storyboards\StoryboardAnimation.cs" />
<Compile Include="Storyboards\Drawables\DrawablesExtensions.cs" />
<Compile Include="Storyboards\IElementDefinition.cs" />
<Compile Include="Storyboards\IStoryboardElement.cs" />
<Compile Include="Storyboards\CommandTimeline.cs" />
<Compile Include="Storyboards\CommandTimelineGroup.cs" />
<Compile Include="Storyboards\CommandTrigger.cs" />
<Compile Include="Storyboards\CommandLoop.cs" />
<Compile Include="Storyboards\SampleDefinition.cs" />
<Compile Include="Storyboards\SpriteDefinition.cs" />
<Compile Include="Storyboards\LayerDefinition.cs" />
<Compile Include="Storyboards\StoryboardDefinition.cs" />
<Compile Include="Storyboards\StoryboardSample.cs" />
<Compile Include="Storyboards\StoryboardSprite.cs" />
<Compile Include="Storyboards\StoryboardLayer.cs" />
<Compile Include="Storyboards\Storyboard.cs" />
<Compile Include="Database\StoreVersion.cs" />
<Compile Include="Graphics\Containers\OsuClickableContainer.cs" />
<Compile Include="Graphics\Containers\OsuFocusedOverlayContainer.cs" />