mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Merge pull request #19800 from peppy/fix-editor-ear-rape
Fix slider ticks playing back at infinite rate while making changes to a slider in the editor
This commit is contained in:
commit
0cf3c5570a
@ -24,6 +24,7 @@ using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -233,6 +234,8 @@ namespace osu.Game.Screens.Edit
|
||||
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.GetSkin(), loadableBeatmap.BeatmapInfo));
|
||||
dependencies.CacheAs(editorBeatmap);
|
||||
|
||||
editorBeatmap.UpdateInProgress.BindValueChanged(updateInProgress);
|
||||
|
||||
canSave = editorBeatmap.BeatmapInfo.Ruleset.CreateInstance() is ILegacyRuleset;
|
||||
|
||||
if (canSave)
|
||||
@ -714,6 +717,27 @@ namespace osu.Game.Screens.Edit
|
||||
this.Exit();
|
||||
}
|
||||
|
||||
#region Mute from update application
|
||||
|
||||
private ScheduledDelegate temporaryMuteRestorationDelegate;
|
||||
private bool temporaryMuteFromUpdateInProgress;
|
||||
|
||||
private void updateInProgress(ValueChangedEvent<bool> obj)
|
||||
{
|
||||
temporaryMuteFromUpdateInProgress = true;
|
||||
updateSampleDisabledState();
|
||||
|
||||
// Debounce is arbitrarily high enough to avoid flip-flopping the value each other frame.
|
||||
temporaryMuteRestorationDelegate?.Cancel();
|
||||
temporaryMuteRestorationDelegate = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
temporaryMuteFromUpdateInProgress = false;
|
||||
updateSampleDisabledState();
|
||||
}, 50);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clipboard support
|
||||
|
||||
private EditorMenuItem cutMenuItem;
|
||||
@ -829,7 +853,9 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private void updateSampleDisabledState()
|
||||
{
|
||||
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value || !(currentScreen is ComposeScreen);
|
||||
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value
|
||||
|| currentScreen is not ComposeScreen
|
||||
|| temporaryMuteFromUpdateInProgress;
|
||||
}
|
||||
|
||||
private void seek(UIEvent e, int direction)
|
||||
|
@ -22,6 +22,17 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public class EditorBeatmap : TransactionalCommitComponent, IBeatmap, IBeatSnapProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Will become <c>true</c> when a new update is queued, and <c>false</c> when all updates have been applied.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is intended to be used to avoid performing operations (like playback of samples)
|
||||
/// while mutating hitobjects.
|
||||
/// </remarks>
|
||||
public IBindable<bool> UpdateInProgress => updateInProgress;
|
||||
|
||||
private readonly BindableBool updateInProgress = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap"/>.
|
||||
/// </summary>
|
||||
@ -228,6 +239,8 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
// updates are debounced regardless of whether a batch is active.
|
||||
batchPendingUpdates.Add(hitObject);
|
||||
|
||||
updateInProgress.Value = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -237,6 +250,8 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
foreach (var h in HitObjects)
|
||||
batchPendingUpdates.Add(h);
|
||||
|
||||
updateInProgress.Value = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -329,6 +344,8 @@ namespace osu.Game.Screens.Edit
|
||||
foreach (var h in deletes) HitObjectRemoved?.Invoke(h);
|
||||
foreach (var h in inserts) HitObjectAdded?.Invoke(h);
|
||||
foreach (var h in updates) HitObjectUpdated?.Invoke(h);
|
||||
|
||||
updateInProgress.Value = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user