mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 01:42:54 +08:00
Simplify DrawableHitObject's sample load code
This commit is contained in:
parent
cd8e8c8323
commit
2db68df999
@ -2,9 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Audio
|
namespace osu.Game.Audio
|
||||||
{
|
{
|
||||||
@ -19,8 +17,7 @@ namespace osu.Game.Audio
|
|||||||
public SampleChannel GetChannel(SampleManager manager)
|
public SampleChannel GetChannel(SampleManager manager)
|
||||||
{
|
{
|
||||||
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
|
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
|
||||||
|
channel.Volume.Value = Volume / 100.0;
|
||||||
channel.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(Volume / 100.0));
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,25 +84,23 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
foreach (SampleInfo sample in HitObject.Samples)
|
if (HitObject.SampleControlPoint == null)
|
||||||
|
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
|
||||||
|
|
||||||
|
foreach (SampleInfo s in HitObject.Samples)
|
||||||
{
|
{
|
||||||
if (HitObject.SampleControlPoint == null)
|
SampleInfo localSampleInfo = new SampleInfo
|
||||||
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
|
{
|
||||||
|
Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank,
|
||||||
|
Name = s.Name,
|
||||||
|
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume
|
||||||
|
};
|
||||||
|
|
||||||
var bank = sample.Bank;
|
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample);
|
||||||
if (string.IsNullOrEmpty(bank))
|
|
||||||
bank = HitObject.SampleControlPoint.SampleBank;
|
|
||||||
|
|
||||||
int volume = sample.Volume;
|
|
||||||
if (volume == 0)
|
|
||||||
volume = HitObject.SampleControlPoint.SampleVolume;
|
|
||||||
|
|
||||||
SampleChannel channel = audio.Sample.Get($@"Gameplay/{bank}-{sample.Name}");
|
|
||||||
|
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
channel.Volume.Value = volume;
|
|
||||||
Samples.Add(channel);
|
Samples.Add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user