Move combo colour update logic to osu! ruleset

This commit is contained in:
Dean Herbert 2020-02-19 15:05:04 +09:00
parent 02f3e78b14
commit 5340d1de59
2 changed files with 17 additions and 4 deletions

View File

@ -1,11 +1,13 @@
// 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.
using System.Collections.Generic;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Graphics.Containers;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
@ -54,6 +56,8 @@ protected override void UpdateStateTransforms(ArmedState state)
}
}
protected override void UpdateComboColour(Color4 proposedColour, IReadOnlyList<Color4> comboColours) => AccentColour.Value = proposedColour;
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(HitObject, judgement);
}
}

View File

@ -121,7 +121,7 @@ protected override void LoadComplete()
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 @@ protected sealed override void SkinChanged(ISkinSource skin, bool allowFallback)
{
base.SkinChanged(skin, allowFallback);
updateAccentColour();
updateComboColour();
ApplySkin(skin, allowFallback);
@ -344,15 +344,24 @@ protected sealed override void SkinChanged(ISkinSource skin, bool allowFallback)
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;
UpdateComboColour(comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White, comboColours);
}
}
/// <summary>
/// Called when a combo colour change is proposed.
/// </summary>
/// <param name="proposedColour">The proposed combo colour, based off the combo index.</param>
/// <param name="comboColours">A list of combo colours provided by the beatmap or skin. Can be null if not available.</param>
protected virtual void UpdateComboColour(Color4 proposedColour, IReadOnlyList<Color4> comboColours)
{
}
/// <summary>
/// Called when a change is made to the skin.
/// </summary>