mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
StoryboardSample -> StoryboardSampleInfo
This commit is contained in:
parent
d8535574d1
commit
7b04fb1690
@ -121,7 +121,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
var layer = parseLayer(split[2]);
|
var layer = parseLayer(split[2]);
|
||||||
var path = cleanFilename(split[3]);
|
var path = cleanFilename(split[3]);
|
||||||
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
||||||
storyboard.GetLayer(layer).Add(new StoryboardSample(path, time, volume));
|
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.IO;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -17,25 +16,24 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const double allowable_late_start = 100;
|
private const double allowable_late_start = 100;
|
||||||
|
|
||||||
private readonly StoryboardSample sample;
|
private readonly StoryboardSampleInfo sampleInfo;
|
||||||
private SampleChannel channel;
|
private SampleChannel channel;
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
public DrawableStoryboardSample(StoryboardSample sample)
|
public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
|
||||||
{
|
{
|
||||||
this.sample = sample;
|
this.sampleInfo = sampleInfo;
|
||||||
LifetimeStart = sample.StartTime;
|
LifetimeStart = sampleInfo.StartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> beatmap)
|
private void load(IBindable<WorkingBeatmap> beatmap)
|
||||||
{
|
{
|
||||||
// Try first with the full name, then attempt with no path
|
channel = beatmap.Value.Skin.GetSample(sampleInfo);
|
||||||
channel = beatmap.Value.Skin.GetSample(sample.Path) ?? beatmap.Value.Skin.GetSample(Path.ChangeExtension(sample.Path, null));
|
|
||||||
|
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
channel.Volume.Value = sample.Volume / 100;
|
channel.Volume.Value = sampleInfo.Volume / 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -43,27 +41,27 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
||||||
if (Time.Current < sample.StartTime)
|
if (Time.Current < sampleInfo.StartTime)
|
||||||
{
|
{
|
||||||
// We've rewound before the start time of the sample
|
// We've rewound before the start time of the sample
|
||||||
channel?.Stop();
|
channel?.Stop();
|
||||||
|
|
||||||
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
// 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)
|
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
||||||
LifetimeStart = sample.StartTime;
|
LifetimeStart = sampleInfo.StartTime;
|
||||||
LifetimeEnd = double.MaxValue;
|
LifetimeEnd = double.MaxValue;
|
||||||
}
|
}
|
||||||
else if (Time.Current - Time.Elapsed < sample.StartTime)
|
else if (Time.Current - Time.Elapsed < sampleInfo.StartTime)
|
||||||
{
|
{
|
||||||
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
// 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
|
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
||||||
if (Time.Current - sample.StartTime < allowable_late_start)
|
if (Time.Current - sampleInfo.StartTime < allowable_late_start)
|
||||||
channel?.Play();
|
channel?.Play();
|
||||||
|
|
||||||
// In the case that the user rewinds to a point far behind the start time of the sample,
|
// 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)
|
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
||||||
LifetimeStart = double.MinValue;
|
LifetimeStart = double.MinValue;
|
||||||
LifetimeEnd = sample.StartTime;
|
LifetimeEnd = sampleInfo.StartTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Storyboards.Drawables;
|
using osu.Game.Storyboards.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Storyboards
|
namespace osu.Game.Storyboards
|
||||||
{
|
{
|
||||||
public class StoryboardSample : IStoryboardElement
|
public class StoryboardSampleInfo : IStoryboardElement, ISampleInfo
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public string Path { get; }
|
||||||
public bool IsDrawable => true;
|
public bool IsDrawable => true;
|
||||||
|
|
||||||
public double StartTime { get; }
|
public double StartTime { get; }
|
||||||
|
|
||||||
public float Volume;
|
public int Volume { get; }
|
||||||
|
|
||||||
public StoryboardSample(string path, double time, float volume)
|
public StoryboardSampleInfo(string path, double time, int volume)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
StartTime = time;
|
StartTime = time;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user