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

Add ComboIndexWithOffsetsBindable and bind similar to ComboIndexBindable

This commit is contained in:
Salman Ahmed 2021-07-22 16:22:42 +03:00
parent cd7b90363a
commit 523c154f15
7 changed files with 41 additions and 3 deletions

View File

@ -95,7 +95,13 @@ namespace osu.Game.Rulesets.Catch.Objects
set => ComboIndexBindable.Value = value;
}
public int ComboIndexWithOffsets { get; set; }
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
public int ComboIndexWithOffsets
{
get => ComboIndexWithOffsetsBindable.Value;
set => ComboIndexWithOffsetsBindable.Value = value;
}
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();

View File

@ -97,7 +97,13 @@ namespace osu.Game.Rulesets.Osu.Objects
set => ComboIndexBindable.Value = value;
}
public int ComboIndexWithOffsets { get; set; }
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
public int ComboIndexWithOffsets
{
get => ComboIndexWithOffsetsBindable.Value;
set => ComboIndexWithOffsetsBindable.Value = value;
}
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();

View File

@ -100,7 +100,13 @@ namespace osu.Game.Tests.Gameplay
set => ComboIndexBindable.Value = value;
}
public int ComboIndexWithOffsets { get; set; }
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
public int ComboIndexWithOffsets
{
get => ComboIndexWithOffsetsBindable.Value;
set => ComboIndexWithOffsetsBindable.Value = value;
}
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();

View File

@ -124,7 +124,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
public readonly Bindable<double> StartTimeBindable = new Bindable<double>();
private readonly BindableList<HitSampleInfo> samplesBindable = new BindableList<HitSampleInfo>();
private readonly Bindable<bool> userPositionalHitSounds = new Bindable<bool>();
private readonly Bindable<int> comboIndexBindable = new Bindable<int>();
private readonly Bindable<int> comboIndexWithOffsetsBindable = new Bindable<int>();
protected override bool RequiresChildrenUpdate => true;
@ -186,6 +188,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
base.LoadComplete();
comboIndexBindable.BindValueChanged(_ => UpdateComboColour(), true);
comboIndexWithOffsetsBindable.BindValueChanged(_ => UpdateComboColour(), true);
updateState(ArmedState.Idle, true);
}
@ -250,7 +253,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
StartTimeBindable.BindValueChanged(onStartTimeChanged);
if (HitObject is IHasComboInformation combo)
{
comboIndexBindable.BindTo(combo.ComboIndexBindable);
comboIndexWithOffsetsBindable.BindTo(combo.ComboIndexWithOffsetsBindable);
}
samplesBindable.BindTo(HitObject.SamplesBindable);
samplesBindable.BindCollectionChanged(onSamplesChanged, true);
@ -275,8 +281,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected sealed override void OnFree(HitObjectLifetimeEntry entry)
{
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
if (HitObject is IHasComboInformation combo)
{
comboIndexBindable.UnbindFrom(combo.ComboIndexBindable);
comboIndexWithOffsetsBindable.UnbindFrom(combo.ComboIndexWithOffsetsBindable);
}
samplesBindable.UnbindFrom(HitObject.SamplesBindable);
// Changes in start time trigger state updates. When a new hitobject is applied, OnApply() automatically performs a state update anyway.

View File

@ -118,6 +118,7 @@ namespace osu.Game.Rulesets.Objects
foreach (var n in NestedHitObjects.OfType<IHasComboInformation>())
{
n.ComboIndexBindable.BindTo(hasCombo.ComboIndexBindable);
n.ComboIndexWithOffsetsBindable.BindTo(hasCombo.ComboIndexWithOffsetsBindable);
n.IndexInCurrentComboBindable.BindTo(hasCombo.IndexInCurrentComboBindable);
}
}

View File

@ -26,6 +26,8 @@ namespace osu.Game.Rulesets.Objects.Types
/// </summary>
int ComboIndex { get; set; }
Bindable<int> ComboIndexWithOffsetsBindable { get; }
/// <summary>
/// The offset of this combo in relation to the beatmap, with all aggregate <see cref="IHasCombo.ComboOffset"/>s applied.
/// This should be used instead of <see cref="ComboIndex"/> only when retrieving combo colours from the beatmap's skin.

View File

@ -37,7 +37,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private readonly Bindable<double> startTime;
private Bindable<int> indexInCurrentComboBindable;
private Bindable<int> comboIndexBindable;
private Bindable<int> comboIndexWithOffsetsBindable;
private Bindable<Color4> displayColourBindable;
private readonly ExtendableCircle circle;
@ -122,6 +125,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
comboIndexBindable = comboInfo.ComboIndexBindable.GetBoundCopy();
comboIndexBindable.BindValueChanged(_ => updateColour(), true);
comboIndexWithOffsetsBindable = comboInfo.ComboIndexWithOffsetsBindable.GetBoundCopy();
comboIndexWithOffsetsBindable.BindValueChanged(_ => updateColour(), true);
skin.SourceChanged += updateColour;
break;
}