mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Determine SampleInfo defaults in DrawableHitObject
This commit is contained in:
@ -15,40 +15,19 @@ namespace osu.Game.Audio
|
||||
public const string HIT_NORMAL = @"hitnormal";
|
||||
public const string HIT_CLAP = @"hitclap";
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SoundControlPoint"/> that is used for <see cref="Bank"/> and <see cref="Volume"/>
|
||||
/// if the values have not already been provided by the hitobject.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public SoundControlPoint ControlPoint;
|
||||
|
||||
private string bank;
|
||||
/// <summary>
|
||||
/// The bank to load the sample from.
|
||||
/// </summary>
|
||||
public string Bank
|
||||
{
|
||||
get { return string.IsNullOrEmpty(bank) ? (ControlPoint?.SampleBank ?? "normal") : bank; }
|
||||
set { bank = value; }
|
||||
}
|
||||
|
||||
public bool ShouldSerializeBank() => Bank != ControlPoint.SampleBank;
|
||||
public string Bank;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the sample to load.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string Name;
|
||||
|
||||
private int volume;
|
||||
/// <summary>
|
||||
/// The sample volume.
|
||||
/// </summary>
|
||||
public int Volume
|
||||
{
|
||||
get { return volume == 0 ? (ControlPoint?.SampleVolume ?? 0) : volume; }
|
||||
set { volume = value; }
|
||||
}
|
||||
|
||||
public bool ShouldSerializeVolume() => Volume != ControlPoint.SampleVolume;
|
||||
public int Volume;
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,16 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
public class SoundControlPoint : ControlPoint
|
||||
{
|
||||
public const string DEFAULT_BANK = "normal";
|
||||
|
||||
/// <summary>
|
||||
/// The default sample bank at this control point.
|
||||
/// </summary>
|
||||
public string SampleBank;
|
||||
public string SampleBank = DEFAULT_BANK;
|
||||
|
||||
/// <summary>
|
||||
/// The default sample volume at this control point.
|
||||
/// </summary>
|
||||
public int SampleVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +86,23 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
{
|
||||
foreach (SampleInfo sample in HitObject.Samples)
|
||||
{
|
||||
SampleChannel channel = audio.Sample.Get($@"Gameplay/{sample.Bank}-{sample.Name}");
|
||||
if (HitObject.SoundControlPoint == null)
|
||||
throw new ArgumentNullException(nameof(HitObject.SoundControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SoundControlPoint)}.");
|
||||
|
||||
var bank = sample.Bank;
|
||||
if (string.IsNullOrEmpty(bank))
|
||||
bank = HitObject.SoundControlPoint.SampleBank;
|
||||
|
||||
int volume = sample.Volume;
|
||||
if (volume == 0)
|
||||
volume = HitObject.SoundControlPoint.SampleVolume;
|
||||
|
||||
SampleChannel channel = audio.Sample.Get($@"Gameplay/{bank}-{sample.Name}");
|
||||
|
||||
if (channel == null)
|
||||
continue;
|
||||
|
||||
channel.Volume.Value = sample.Volume;
|
||||
channel.Volume.Value = volume;
|
||||
Samples.Add(channel);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// </summary>
|
||||
public SampleInfoList Samples = new SampleInfoList();
|
||||
|
||||
[JsonIgnore]
|
||||
public SoundControlPoint SoundControlPoint;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="HitObject"/> is in Kiai time.
|
||||
/// </summary>
|
||||
@ -48,13 +51,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
|
||||
|
||||
Kiai = effectPoint.KiaiMode;
|
||||
|
||||
// Initialize first sample
|
||||
Samples.ForEach(s => s.ControlPoint = soundPoint);
|
||||
|
||||
// Initialize any repeat samples
|
||||
var repeatData = this as IHasRepeats;
|
||||
repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => s.ControlPoint = soundPoint));
|
||||
SoundControlPoint = soundPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user