1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-21 23:07:45 +08:00

Merge pull request #7896 from peppy/combo-colour-independence

Move DrawableHitObject accent colour update duties to ruleset
This commit is contained in:
Dean Herbert 2020-02-20 17:01:58 +09:00 committed by GitHub
commit 8c8e756149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
if (HitObject is IHasComboInformation combo)
{
comboIndexBindable = combo.ComboIndexBindable.GetBoundCopy();
comboIndexBindable.BindValueChanged(_ => updateAccentColour(), true);
comboIndexBindable.BindValueChanged(_ => updateComboColour(), true);
}
samplesBindable = HitObject.SamplesBindable.GetBoundCopy();
@ -336,7 +336,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
base.SkinChanged(skin, allowFallback);
updateAccentColour();
updateComboColour();
ApplySkin(skin, allowFallback);
@ -344,13 +344,29 @@ namespace osu.Game.Rulesets.Objects.Drawables
updateState(State.Value, true);
}
private void updateAccentColour()
private void updateComboColour()
{
if (HitObject is IHasComboInformation combo)
{
var comboColours = CurrentSkin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
}
if (!(HitObject is IHasComboInformation)) return;
var comboColours = CurrentSkin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
AccentColour.Value = GetComboColour(comboColours);
}
/// <summary>
/// Called to retrieve the combo colour. Automatically assigned to <see cref="AccentColour"/>.
/// Defaults to using <see cref="IHasComboInformation.ComboIndex"/> to decide on a colour.
/// </summary>
/// <remarks>
/// This will only be called if the <see cref="HitObject"/> implements <see cref="IHasComboInformation"/>.
/// </remarks>
/// <param name="comboColours">A list of combo colours provided by the beatmap or skin. Can be null if not available.</param>
protected virtual Color4 GetComboColour(IReadOnlyList<Color4> comboColours)
{
if (!(HitObject is IHasComboInformation combo))
throw new InvalidOperationException($"{nameof(HitObject)} must implement {nameof(IHasComboInformation)}");
return comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
}
/// <summary>