mirror of https://github.com/ppy/osu
Merge branch 'master' into fix-loaderanimation-testcase
This commit is contained in:
commit
c772a38c1b
|
@ -13,7 +13,7 @@ public class DrawableBananaShower : DrawableCatchHitObject<BananaShower>
|
|||
{
|
||||
private readonly Container bananaContainer;
|
||||
|
||||
public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation = null)
|
||||
public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation = null)
|
||||
: base(s)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
@ -23,7 +23,7 @@ public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObje
|
|||
AddInternal(bananaContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||
|
||||
foreach (var b in s.NestedHitObjects.Cast<Banana>())
|
||||
AddNested(getVisualRepresentation?.Invoke(b));
|
||||
AddNested(createDrawableRepresentation?.Invoke(b));
|
||||
}
|
||||
|
||||
protected override void AddNested(DrawableHitObject h)
|
||||
|
|
|
@ -13,7 +13,7 @@ public class DrawableJuiceStream : DrawableCatchHitObject<JuiceStream>
|
|||
{
|
||||
private readonly Container dropletContainer;
|
||||
|
||||
public DrawableJuiceStream(JuiceStream s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation = null)
|
||||
public DrawableJuiceStream(JuiceStream s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation = null)
|
||||
: base(s)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
@ -23,7 +23,7 @@ public DrawableJuiceStream(JuiceStream s, Func<CatchHitObject, DrawableHitObject
|
|||
AddInternal(dropletContainer = new Container { RelativeSizeAxes = Axes.Both, });
|
||||
|
||||
foreach (var o in s.NestedHitObjects.Cast<CatchHitObject>())
|
||||
AddNested(getVisualRepresentation?.Invoke(o));
|
||||
AddNested(createDrawableRepresentation?.Invoke(o));
|
||||
}
|
||||
|
||||
protected override void AddNested(DrawableHitObject h)
|
||||
|
|
|
@ -19,7 +19,7 @@ public class CatchPlayfield : ScrollingPlayfield
|
|||
|
||||
internal readonly CatcherArea CatcherArea;
|
||||
|
||||
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
|
||||
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation)
|
||||
{
|
||||
Container explodingFruitContainer;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, Drawabl
|
|||
},
|
||||
CatcherArea = new CatcherArea(difficulty)
|
||||
{
|
||||
GetVisualRepresentation = getVisualRepresentation,
|
||||
CreateDrawableRepresentation = createDrawableRepresentation,
|
||||
ExplodingFruitTarget = explodingFruitContainer,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CatcherArea : Container
|
|||
|
||||
protected internal readonly Catcher MovableCatcher;
|
||||
|
||||
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> GetVisualRepresentation;
|
||||
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
|
||||
|
||||
public Container ExplodingFruitTarget
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ void runAfterLoaded(Action action)
|
|||
|
||||
if (result.IsHit && fruit.CanBePlated)
|
||||
{
|
||||
var caughtFruit = (DrawableCatchHitObject)GetVisualRepresentation?.Invoke(fruit.HitObject);
|
||||
var caughtFruit = (DrawableCatchHitObject)CreateDrawableRepresentation?.Invoke(fruit.HitObject);
|
||||
|
||||
if (caughtFruit == null) return;
|
||||
|
||||
|
|
|
@ -34,13 +34,13 @@ public DrawableCatchRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
|||
|
||||
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new CatchFramedReplayInputHandler(replay);
|
||||
|
||||
protected override Playfield CreatePlayfield() => new CatchPlayfield(Beatmap.BeatmapInfo.BaseDifficulty, GetVisualRepresentation);
|
||||
protected override Playfield CreatePlayfield() => new CatchPlayfield(Beatmap.BeatmapInfo.BaseDifficulty, CreateDrawableRepresentation);
|
||||
|
||||
protected override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new CatchPlayfieldAdjustmentContainer();
|
||||
|
||||
protected override PassThroughInputManager CreateInputManager() => new CatchInputManager(Ruleset.RulesetInfo);
|
||||
|
||||
public override DrawableHitObject<CatchHitObject> GetVisualRepresentation(CatchHitObject h)
|
||||
public override DrawableHitObject<CatchHitObject> CreateDrawableRepresentation(CatchHitObject h)
|
||||
{
|
||||
switch (h)
|
||||
{
|
||||
|
@ -49,9 +49,9 @@ public override DrawableHitObject<CatchHitObject> GetVisualRepresentation(CatchH
|
|||
case Fruit fruit:
|
||||
return new DrawableFruit(fruit);
|
||||
case JuiceStream stream:
|
||||
return new DrawableJuiceStream(stream, GetVisualRepresentation);
|
||||
return new DrawableJuiceStream(stream, CreateDrawableRepresentation);
|
||||
case BananaShower shower:
|
||||
return new DrawableBananaShower(shower, GetVisualRepresentation);
|
||||
return new DrawableBananaShower(shower, CreateDrawableRepresentation);
|
||||
case TinyDroplet tiny:
|
||||
return new DrawableTinyDroplet(tiny);
|
||||
case Droplet droplet:
|
||||
|
|
|
@ -98,7 +98,7 @@ private void load()
|
|||
|
||||
protected override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Variant);
|
||||
|
||||
public override DrawableHitObject<ManiaHitObject> GetVisualRepresentation(ManiaHitObject h)
|
||||
public override DrawableHitObject<ManiaHitObject> CreateDrawableRepresentation(ManiaHitObject h)
|
||||
{
|
||||
switch (h)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// 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 System.Linq;
|
||||
|
@ -34,7 +34,7 @@ public DrawableOsuRuleset(Ruleset ruleset, WorkingBeatmap beatmap)
|
|||
|
||||
protected override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new OsuPlayfieldAdjustmentContainer();
|
||||
|
||||
public override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
|
||||
public override DrawableHitObject<OsuHitObject> CreateDrawableRepresentation(OsuHitObject h)
|
||||
{
|
||||
switch (h)
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ private void loadBarLines()
|
|||
|
||||
protected override Playfield CreatePlayfield() => new TaikoPlayfield(Beatmap.ControlPointInfo);
|
||||
|
||||
public override DrawableHitObject<TaikoHitObject> GetVisualRepresentation(TaikoHitObject h)
|
||||
public override DrawableHitObject<TaikoHitObject> CreateDrawableRepresentation(TaikoHitObject h)
|
||||
{
|
||||
switch (h)
|
||||
{
|
||||
|
|
|
@ -29,28 +29,28 @@ public void TestDecodeStoryboardEvents()
|
|||
|
||||
StoryboardLayer background = storyboard.Layers.FirstOrDefault(l => l.Depth == 3);
|
||||
Assert.IsNotNull(background);
|
||||
Assert.AreEqual(16, background.Elements.Count());
|
||||
Assert.AreEqual(16, background.Elements.Count);
|
||||
Assert.IsTrue(background.EnabledWhenFailing);
|
||||
Assert.IsTrue(background.EnabledWhenPassing);
|
||||
Assert.AreEqual("Background", background.Name);
|
||||
|
||||
StoryboardLayer fail = storyboard.Layers.FirstOrDefault(l => l.Depth == 2);
|
||||
Assert.IsNotNull(fail);
|
||||
Assert.AreEqual(0, fail.Elements.Count());
|
||||
Assert.AreEqual(0, fail.Elements.Count);
|
||||
Assert.IsTrue(fail.EnabledWhenFailing);
|
||||
Assert.IsFalse(fail.EnabledWhenPassing);
|
||||
Assert.AreEqual("Fail", fail.Name);
|
||||
|
||||
StoryboardLayer pass = storyboard.Layers.FirstOrDefault(l => l.Depth == 1);
|
||||
Assert.IsNotNull(pass);
|
||||
Assert.AreEqual(0, pass.Elements.Count());
|
||||
Assert.AreEqual(0, pass.Elements.Count);
|
||||
Assert.IsFalse(pass.EnabledWhenFailing);
|
||||
Assert.IsTrue(pass.EnabledWhenPassing);
|
||||
Assert.AreEqual("Pass", pass.Name);
|
||||
|
||||
StoryboardLayer foreground = storyboard.Layers.FirstOrDefault(l => l.Depth == 0);
|
||||
Assert.IsNotNull(foreground);
|
||||
Assert.AreEqual(151, foreground.Elements.Count());
|
||||
Assert.AreEqual(151, foreground.Elements.Count);
|
||||
Assert.IsTrue(foreground.EnabledWhenFailing);
|
||||
Assert.IsTrue(foreground.EnabledWhenPassing);
|
||||
Assert.AreEqual("Foreground", foreground.Name);
|
||||
|
@ -62,7 +62,7 @@ public void TestDecodeStoryboardEvents()
|
|||
Assert.AreEqual(15, spriteCount);
|
||||
Assert.AreEqual(1, animationCount);
|
||||
Assert.AreEqual(0, sampleCount);
|
||||
Assert.AreEqual(background.Elements.Count(), spriteCount + animationCount + sampleCount);
|
||||
Assert.AreEqual(background.Elements.Count, spriteCount + animationCount + sampleCount);
|
||||
|
||||
var sprite = background.Elements.ElementAt(0) as StoryboardSprite;
|
||||
Assert.NotNull(sprite);
|
||||
|
@ -70,9 +70,9 @@ public void TestDecodeStoryboardEvents()
|
|||
Assert.AreEqual(new Vector2(320, 240), sprite.InitialPosition);
|
||||
Assert.IsTrue(sprite.IsDrawable);
|
||||
Assert.AreEqual(Anchor.Centre, sprite.Origin);
|
||||
Assert.AreEqual("SB/lyric/ja-21.png", sprite.Path);
|
||||
Assert.AreEqual("SB/black.jpg", sprite.Path);
|
||||
|
||||
var animation = background.Elements.ElementAt(12) as StoryboardAnimation;
|
||||
var animation = background.Elements.OfType<StoryboardAnimation>().First();
|
||||
Assert.NotNull(animation);
|
||||
Assert.AreEqual(141175, animation.EndTime);
|
||||
Assert.AreEqual(10, animation.FrameCount);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
|
@ -38,6 +39,10 @@ protected override void ParseStreamInto(StreamReader stream, Storyboard storyboa
|
|||
{
|
||||
this.storyboard = storyboard;
|
||||
base.ParseStreamInto(stream, storyboard);
|
||||
|
||||
// OrderBy is used to guarantee that the parsing order of elements with equal start times is maintained (stably-sorted)
|
||||
foreach (StoryboardLayer layer in storyboard.Layers)
|
||||
layer.Elements = layer.Elements.OrderBy(h => h.StartTime).ToList();
|
||||
}
|
||||
|
||||
protected override void ParseLine(Storyboard storyboard, Section section, string line)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -442,7 +441,7 @@ protected override void LoadComplete()
|
|||
|
||||
loadComponentSingleFile(musicController = new MusicController
|
||||
{
|
||||
Position = new Vector2(0, Toolbar.HEIGHT),
|
||||
GetToolbarHeight = () => ToolbarOffset,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
}, floatingOverlayContent.Add);
|
||||
|
|
|
@ -56,6 +56,11 @@ public class MusicController : OsuFocusedOverlayContainer
|
|||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
/// <summary>
|
||||
/// Provide a source for the toolbar height.
|
||||
/// </summary>
|
||||
public Func<float> GetToolbarHeight;
|
||||
|
||||
public MusicController()
|
||||
{
|
||||
Width = 400;
|
||||
|
@ -244,6 +249,8 @@ protected override void UpdateAfterChildren()
|
|||
{
|
||||
base.UpdateAfterChildren();
|
||||
Height = dragContainer.Height;
|
||||
|
||||
dragContainer.Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
|
|
@ -73,7 +73,7 @@ internal override DrawableHitObject Add(HitObject hitObject)
|
|||
processor?.PostProcess();
|
||||
|
||||
// Add visual representation
|
||||
var drawableObject = drawableRuleset.GetVisualRepresentation(tObject);
|
||||
var drawableObject = drawableRuleset.CreateDrawableRepresentation(tObject);
|
||||
|
||||
drawableRuleset.Playfield.Add(drawableObject);
|
||||
drawableRuleset.Playfield.PostProcess();
|
||||
|
|
|
@ -161,7 +161,7 @@ private void load(OsuConfigManager config)
|
|||
private void loadObjects()
|
||||
{
|
||||
foreach (TObject h in Beatmap.HitObjects)
|
||||
addRepresentation(h);
|
||||
addHitObject(h);
|
||||
|
||||
Playfield.PostProcess();
|
||||
|
||||
|
@ -175,9 +175,9 @@ private void loadObjects()
|
|||
/// Creates and adds the visual representation of a <see cref="TObject"/> to this <see cref="DrawableRuleset{TObject}"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="TObject"/> to add the visual representation for.</param>
|
||||
private void addRepresentation(TObject hitObject)
|
||||
private void addHitObject(TObject hitObject)
|
||||
{
|
||||
var drawableObject = GetVisualRepresentation(hitObject);
|
||||
var drawableObject = CreateDrawableRepresentation(hitObject);
|
||||
|
||||
if (drawableObject == null)
|
||||
return;
|
||||
|
@ -209,7 +209,7 @@ public override void SetReplayScore(Score replayScore)
|
|||
/// </summary>
|
||||
/// <param name="h">The HitObject to make drawable.</param>
|
||||
/// <returns>The DrawableHitObject.</returns>
|
||||
public abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
||||
public abstract DrawableHitObject<TObject> CreateDrawableRepresentation(TObject h);
|
||||
|
||||
public void Attach(KeyCounterDisplay keyCounter) =>
|
||||
(KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(keyCounter);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class DrawableStoryboardSample : Component
|
|||
public DrawableStoryboardSample(StoryboardSample sample)
|
||||
{
|
||||
this.sample = sample;
|
||||
LifetimeStart = sample.Time;
|
||||
LifetimeStart = sample.StartTime;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -43,27 +43,27 @@ protected override void Update()
|
|||
base.Update();
|
||||
|
||||
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
||||
if (Time.Current < sample.Time)
|
||||
if (Time.Current < sample.StartTime)
|
||||
{
|
||||
// We've rewound before the start time of the sample
|
||||
channel?.Stop();
|
||||
|
||||
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
||||
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
||||
LifetimeStart = sample.Time;
|
||||
LifetimeStart = sample.StartTime;
|
||||
LifetimeEnd = double.MaxValue;
|
||||
}
|
||||
else if (Time.Current - Time.Elapsed < sample.Time)
|
||||
else if (Time.Current - Time.Elapsed < sample.StartTime)
|
||||
{
|
||||
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
||||
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
||||
if (Time.Current - sample.Time < allowable_late_start)
|
||||
if (Time.Current - sample.StartTime < allowable_late_start)
|
||||
channel?.Play();
|
||||
|
||||
// In the case that the user rewinds to a point far behind the start time of the sample,
|
||||
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
||||
LifetimeStart = double.MinValue;
|
||||
LifetimeEnd = sample.Time;
|
||||
LifetimeEnd = sample.StartTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ public interface IStoryboardElement
|
|||
string Path { get; }
|
||||
bool IsDrawable { get; }
|
||||
|
||||
double StartTime { get; }
|
||||
|
||||
Drawable CreateDrawable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ public class StoryboardLayer
|
|||
public bool EnabledWhenPassing = true;
|
||||
public bool EnabledWhenFailing = true;
|
||||
|
||||
private readonly List<IStoryboardElement> elements = new List<IStoryboardElement>();
|
||||
public IEnumerable<IStoryboardElement> Elements => elements;
|
||||
public List<IStoryboardElement> Elements = new List<IStoryboardElement>();
|
||||
|
||||
public StoryboardLayer(string name, int depth)
|
||||
{
|
||||
|
@ -24,7 +23,7 @@ public StoryboardLayer(string name, int depth)
|
|||
|
||||
public void Add(IStoryboardElement element)
|
||||
{
|
||||
elements.Add(element);
|
||||
Elements.Add(element);
|
||||
}
|
||||
|
||||
public DrawableStoryboardLayer CreateDrawable()
|
||||
|
|
|
@ -11,13 +11,14 @@ public class StoryboardSample : IStoryboardElement
|
|||
public string Path { get; set; }
|
||||
public bool IsDrawable => true;
|
||||
|
||||
public double Time;
|
||||
public double StartTime { get; }
|
||||
|
||||
public float Volume;
|
||||
|
||||
public StoryboardSample(string path, double time, float volume)
|
||||
{
|
||||
Path = path;
|
||||
Time = time;
|
||||
StartTime = time;
|
||||
Volume = volume;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue