mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08: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.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -233,6 +234,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.GetSkin(), loadableBeatmap.BeatmapInfo));
|
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.GetSkin(), loadableBeatmap.BeatmapInfo));
|
||||||
dependencies.CacheAs(editorBeatmap);
|
dependencies.CacheAs(editorBeatmap);
|
||||||
|
|
||||||
|
editorBeatmap.UpdateInProgress.BindValueChanged(updateInProgress);
|
||||||
|
|
||||||
canSave = editorBeatmap.BeatmapInfo.Ruleset.CreateInstance() is ILegacyRuleset;
|
canSave = editorBeatmap.BeatmapInfo.Ruleset.CreateInstance() is ILegacyRuleset;
|
||||||
|
|
||||||
if (canSave)
|
if (canSave)
|
||||||
@ -714,6 +717,27 @@ namespace osu.Game.Screens.Edit
|
|||||||
this.Exit();
|
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
|
#region Clipboard support
|
||||||
|
|
||||||
private EditorMenuItem cutMenuItem;
|
private EditorMenuItem cutMenuItem;
|
||||||
@ -829,7 +853,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private void updateSampleDisabledState()
|
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)
|
private void seek(UIEvent e, int direction)
|
||||||
|
@ -22,6 +22,17 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
public class EditorBeatmap : TransactionalCommitComponent, IBeatmap, IBeatSnapProvider
|
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>
|
/// <summary>
|
||||||
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap"/>.
|
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -228,6 +239,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
// updates are debounced regardless of whether a batch is active.
|
// updates are debounced regardless of whether a batch is active.
|
||||||
batchPendingUpdates.Add(hitObject);
|
batchPendingUpdates.Add(hitObject);
|
||||||
|
|
||||||
|
updateInProgress.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -237,6 +250,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
foreach (var h in HitObjects)
|
foreach (var h in HitObjects)
|
||||||
batchPendingUpdates.Add(h);
|
batchPendingUpdates.Add(h);
|
||||||
|
|
||||||
|
updateInProgress.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -329,6 +344,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
foreach (var h in deletes) HitObjectRemoved?.Invoke(h);
|
foreach (var h in deletes) HitObjectRemoved?.Invoke(h);
|
||||||
foreach (var h in inserts) HitObjectAdded?.Invoke(h);
|
foreach (var h in inserts) HitObjectAdded?.Invoke(h);
|
||||||
foreach (var h in updates) HitObjectUpdated?.Invoke(h);
|
foreach (var h in updates) HitObjectUpdated?.Invoke(h);
|
||||||
|
|
||||||
|
updateInProgress.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user