mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 19:12:57 +08:00
Reduce the number of state updates
This commit is contained in:
parent
38105ed6a2
commit
35329aa976
@ -170,7 +170,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
StartTimeBindable.BindValueChanged(_ => updateState(State.Value, true));
|
|
||||||
comboIndexBindable.BindValueChanged(_ => updateComboColour(), true);
|
comboIndexBindable.BindValueChanged(_ => updateComboColour(), true);
|
||||||
|
|
||||||
updateState(ArmedState.Idle, true);
|
updateState(ArmedState.Idle, true);
|
||||||
@ -220,6 +219,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
StartTimeBindable.BindTo(HitObject.StartTimeBindable);
|
StartTimeBindable.BindTo(HitObject.StartTimeBindable);
|
||||||
|
StartTimeBindable.BindValueChanged(onStartTimeChanged);
|
||||||
|
|
||||||
if (HitObject is IHasComboInformation combo)
|
if (HitObject is IHasComboInformation combo)
|
||||||
comboIndexBindable.BindTo(combo.ComboIndexBindable);
|
comboIndexBindable.BindTo(combo.ComboIndexBindable);
|
||||||
|
|
||||||
@ -249,9 +250,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
|
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
|
||||||
if (HitObject is IHasComboInformation combo)
|
if (HitObject is IHasComboInformation combo)
|
||||||
comboIndexBindable.UnbindFrom(combo.ComboIndexBindable);
|
comboIndexBindable.UnbindFrom(combo.ComboIndexBindable);
|
||||||
|
|
||||||
samplesBindable.UnbindFrom(HitObject.SamplesBindable);
|
samplesBindable.UnbindFrom(HitObject.SamplesBindable);
|
||||||
|
|
||||||
|
// Changes in start time trigger state updates. When a new hitobject is applied, OnApply() automatically performs a state update anyway.
|
||||||
|
StartTimeBindable.ValueChanged -= onStartTimeChanged;
|
||||||
|
|
||||||
// When a new hitobject is applied, the samples will be cleared before re-populating.
|
// When a new hitobject is applied, the samples will be cleared before re-populating.
|
||||||
// In order to stop this needless update, the event is unbound and re-bound as late as possible in Apply().
|
// In order to stop this needless update, the event is unbound and re-bound as late as possible in Apply().
|
||||||
samplesBindable.CollectionChanged -= onSamplesChanged;
|
samplesBindable.CollectionChanged -= onSamplesChanged;
|
||||||
@ -330,6 +333,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
|
|
||||||
private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples();
|
private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples();
|
||||||
|
|
||||||
|
private void onStartTimeChanged(ValueChangedEvent<double> startTime) => updateState(State.Value, true);
|
||||||
|
|
||||||
private void onNewResult(DrawableHitObject drawableHitObject, JudgementResult result) => OnNewResult?.Invoke(drawableHitObject, result);
|
private void onNewResult(DrawableHitObject drawableHitObject, JudgementResult result) => OnNewResult?.Invoke(drawableHitObject, result);
|
||||||
|
|
||||||
private void onRevertResult(DrawableHitObject drawableHitObject, JudgementResult result) => OnRevertResult?.Invoke(drawableHitObject, result);
|
private void onRevertResult(DrawableHitObject drawableHitObject, JudgementResult result) => OnRevertResult?.Invoke(drawableHitObject, result);
|
||||||
|
Loading…
Reference in New Issue
Block a user