Merge branch 'master' into fallback-to-skin-combo-colours

This commit is contained in:
Dean Herbert
2019-11-12 19:00:05 +09:00
committed by GitHub
182 changed files with 3216 additions and 3124 deletions

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
// Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first
protected virtual string SampleNamespace => null;
protected SkinnableSound Samples;
protected SkinnableSound Samples { get; private set; }
protected virtual IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples;
@ -78,6 +78,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary>
public JudgementResult Result { get; private set; }
private BindableList<HitSampleInfo> samplesBindable;
private Bindable<double> startTimeBindable;
private Bindable<int> comboIndexBindable;
@ -108,20 +109,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateResult)}.");
}
var samples = GetSamples().ToArray();
if (samples.Length > 0)
{
if (HitObject.SampleControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray();
foreach (var s in samples)
s.Namespace = SampleNamespace;
AddInternal(Samples = new SkinnableSound(samples));
}
loadSamples();
}
protected override void LoadComplete()
@ -139,10 +127,40 @@ namespace osu.Game.Rulesets.Objects.Drawables
comboIndexBindable.BindValueChanged(_ => updateAccentColour(), true);
}
samplesBindable = HitObject.SamplesBindable.GetBoundCopy();
samplesBindable.ItemsAdded += _ => loadSamples();
samplesBindable.ItemsRemoved += _ => loadSamples();
updateState(ArmedState.Idle, true);
onDefaultsApplied();
}
private void loadSamples()
{
if (Samples != null)
{
RemoveInternal(Samples);
Samples = null;
}
var samples = GetSamples().ToArray();
if (samples.Length <= 0)
return;
if (HitObject.SampleControlPoint == null)
{
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
}
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray();
foreach (var s in samples)
s.Namespace = SampleNamespace;
AddInternal(Samples = new SkinnableSound(samples));
}
private void onDefaultsApplied() => apply(HitObject);
private void apply(HitObject hitObject)