1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Fix colour not updated when index changes

This commit is contained in:
ekrctb 2020-11-27 11:41:39 +09:00
parent dbf67f82c0
commit e36bb7631d
3 changed files with 11 additions and 20 deletions

View File

@ -12,8 +12,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
public class DrawableFruit : DrawablePalpableCatchHitObject
{
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
protected virtual FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => (FruitVisualRepresentation)(indexInBeatmap % 4);
@ -23,7 +21,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
public DrawableFruit(CatchHitObject h)
: base(h)
{
IndexInBeatmap.Value = h.IndexInBeatmap;
}
[BackgroundDependencyLoader]
@ -51,20 +48,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
});
}
protected override void OnApply()
{
base.OnApply();
IndexInBeatmap.BindTo(HitObject.IndexInBeatmapBindable);
}
protected override void OnFree()
{
IndexInBeatmap.UnbindFrom(HitObject.IndexInBeatmapBindable);
base.OnFree();
}
protected override void Update()
{
base.Update();

View File

@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
public Bindable<float> ScaleBindable { get; } = new Bindable<float>(1);
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
/// <summary>
/// The multiplicative factor applied to <see cref="ScaleContainer"/> scale relative to <see cref="HitObject"/> scale.
/// </summary>
@ -41,6 +43,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
});
IndexInBeatmap.Value = h.IndexInBeatmap;
}
[BackgroundDependencyLoader]
@ -55,6 +59,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
{
ScaleContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
}, true);
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
}
protected override void OnApply()
@ -63,12 +69,14 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
HyperDash.BindTo(HitObject.HyperDashBindable);
ScaleBindable.BindTo(HitObject.ScaleBindable);
IndexInBeatmap.BindTo(HitObject.IndexInBeatmapBindable);
}
protected override void OnFree()
{
HyperDash.UnbindFrom(HitObject.HyperDashBindable);
ScaleBindable.UnbindFrom(HitObject.ScaleBindable);
IndexInBeatmap.UnbindFrom(HitObject.IndexInBeatmapBindable);
base.OnFree();
}

View File

@ -190,7 +190,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
base.LoadComplete();
comboIndexBindable.BindValueChanged(_ => updateComboColour(), true);
comboIndexBindable.BindValueChanged(_ => UpdateComboColour(), true);
updateState(ArmedState.Idle, true);
}
@ -533,7 +533,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
base.SkinChanged(skin, allowFallback);
updateComboColour();
UpdateComboColour();
ApplySkin(skin, allowFallback);
@ -541,7 +541,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
updateState(State.Value, true);
}
private void updateComboColour()
protected void UpdateComboColour()
{
if (!(HitObject is IHasComboInformation combo)) return;