Update accent colour on combo index change

This commit is contained in:
smoogipoo
2019-09-26 17:04:38 +09:00
parent 3155a90501
commit 706e884cc0
2 changed files with 31 additions and 14 deletions

View File

@ -76,6 +76,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary>
public JudgementResult Result { get; private set; }
private Bindable<int> comboIndexBindable;
public override bool RemoveWhenNotAlive => false;
public override bool RemoveCompletedTransforms => false;
protected override bool RequiresChildrenUpdate => true;
@ -122,6 +124,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected override void LoadComplete()
{
base.LoadComplete();
if (HitObject is IHasComboInformation combo)
{
comboIndexBindable = combo.ComboIndexBindable.GetBoundCopy();
comboIndexBindable.BindValueChanged(_ => updateAccentColour());
}
updateState(ArmedState.Idle, true);
}
@ -244,12 +253,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
base.SkinChanged(skin, allowFallback);
if (HitObject is IHasComboInformation combo)
{
var comboColours = skin.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value;
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
}
updateAccentColour();
ApplySkin(skin, allowFallback);
@ -257,6 +261,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
updateState(State.Value, true);
}
private void updateAccentColour()
{
if (HitObject is IHasComboInformation combo)
{
var comboColours = CurrentSkin.GetConfig<GlobalSkinConfiguration, List<Color4>>(GlobalSkinConfiguration.ComboColours)?.Value;
AccentColour.Value = comboColours?.Count > 0 ? comboColours[combo.ComboIndex % comboColours.Count] : Color4.White;
}
}
/// <summary>
/// Called when a change is made to the skin.
/// </summary>