Restore original event flow to allow for OnSuspend case to work correctly

This commit is contained in:
Dean Herbert
2022-08-17 14:32:21 +09:00
parent 8ce50e98a6
commit 6b9dec5996

View File

@ -226,6 +226,8 @@ namespace osu.Game.Screens.Edit
dependencies.CacheAs(clock); dependencies.CacheAs(clock);
AddInternal(clock); AddInternal(clock);
clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
// todo: remove caching of this and consume via editorBeatmap? // todo: remove caching of this and consume via editorBeatmap?
dependencies.Cache(beatDivisor); dependencies.Cache(beatDivisor);
@ -429,12 +431,7 @@ namespace osu.Game.Screens.Edit
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
clock.ProcessFrame(); clock.ProcessFrame();
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value
|| currentScreen is not ComposeScreen
|| temporaryMuteFromUpdateInProgress;
} }
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e) public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
@ -728,10 +725,15 @@ namespace osu.Game.Screens.Edit
private void updateInProgress(ValueChangedEvent<bool> obj) private void updateInProgress(ValueChangedEvent<bool> obj)
{ {
temporaryMuteFromUpdateInProgress = true; temporaryMuteFromUpdateInProgress = true;
updateSampleDisabledState();
// Debounce is arbitrarily high enough to avoid flip-flopping the value each other frame. // Debounce is arbitrarily high enough to avoid flip-flopping the value each other frame.
temporaryMuteRestorationDelegate?.Cancel(); temporaryMuteRestorationDelegate?.Cancel();
temporaryMuteRestorationDelegate = Scheduler.AddDelayed(() => temporaryMuteFromUpdateInProgress = false, 50); temporaryMuteRestorationDelegate = Scheduler.AddDelayed(() =>
{
temporaryMuteFromUpdateInProgress = false;
updateSampleDisabledState();
}, 50);
} }
#endregion #endregion
@ -844,10 +846,18 @@ namespace osu.Game.Screens.Edit
} }
finally finally
{ {
updateSampleDisabledState();
rebindClipboardBindables(); rebindClipboardBindables();
} }
} }
private void updateSampleDisabledState()
{
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value
|| currentScreen is not ComposeScreen
|| temporaryMuteFromUpdateInProgress;
}
private void seek(UIEvent e, int direction) private void seek(UIEvent e, int direction)
{ {
double amount = e.ShiftPressed ? 4 : 1; double amount = e.ShiftPressed ? 4 : 1;
@ -952,7 +962,11 @@ namespace osu.Game.Screens.Edit
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleSwitchToExistingDifficulty(nextBeatmap, GetState(nextBeatmap.Ruleset)); protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleSwitchToExistingDifficulty(nextBeatmap, GetState(nextBeatmap.Ruleset));
private void cancelExit() => loader?.CancelPendingDifficultySwitch(); private void cancelExit()
{
updateSampleDisabledState();
loader?.CancelPendingDifficultySwitch();
}
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime); public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);