Merge branch 'master' into skinnable-things-cleanup

This commit is contained in:
Dean Herbert
2022-11-10 12:09:32 +09:00
committed by GitHub
3 changed files with 59 additions and 26 deletions

View File

@ -513,6 +513,40 @@ namespace osu.Game.Tests.Visual.Navigation
AddWaitStep("wait two frames", 2);
}
[Test]
public void TestMainOverlaysClosesNotificationOverlay()
{
ChangelogOverlay getChangelogOverlay() => Game.ChildrenOfType<ChangelogOverlay>().FirstOrDefault();
AddUntilStep("Wait for notifications to load", () => Game.Notifications.IsLoaded);
AddStep("Show notifications", () => Game.Notifications.Show());
AddUntilStep("wait for notifications shown", () => Game.Notifications.IsPresent && Game.Notifications.State.Value == Visibility.Visible);
AddStep("Show changelog listing", () => Game.ShowChangelogListing());
AddUntilStep("wait for changelog shown", () => getChangelogOverlay()?.IsPresent == true && getChangelogOverlay()?.State.Value == Visibility.Visible);
AddAssert("Notifications is hidden", () => Game.Notifications.State.Value == Visibility.Hidden);
AddStep("Show notifications", () => Game.Notifications.Show());
AddUntilStep("wait for notifications shown", () => Game.Notifications.State.Value == Visibility.Visible);
AddUntilStep("changelog still visible", () => getChangelogOverlay().State.Value == Visibility.Visible);
}
[Test]
public void TestMainOverlaysClosesSettingsOverlay()
{
ChangelogOverlay getChangelogOverlay() => Game.ChildrenOfType<ChangelogOverlay>().FirstOrDefault();
AddUntilStep("Wait for settings to load", () => Game.Settings.IsLoaded);
AddStep("Show settings", () => Game.Settings.Show());
AddUntilStep("wait for settings shown", () => Game.Settings.IsPresent && Game.Settings.State.Value == Visibility.Visible);
AddStep("Show changelog listing", () => Game.ShowChangelogListing());
AddUntilStep("wait for changelog shown", () => getChangelogOverlay()?.IsPresent == true && getChangelogOverlay()?.State.Value == Visibility.Visible);
AddAssert("Settings is hidden", () => Game.Settings.State.Value == Visibility.Hidden);
AddStep("Show settings", () => Game.Settings.Show());
AddUntilStep("wait for settings shown", () => Game.Settings.State.Value == Visibility.Visible);
AddUntilStep("changelog still visible", () => getChangelogOverlay().State.Value == Visibility.Visible);
}
[Test]
public void TestOverlayClosing()
{

View File

@ -1002,6 +1002,9 @@ namespace osu.Game
{
otherOverlays.Where(o => o != overlay).ForEach(o => o.Hide());
Settings.Hide();
Notifications.Hide();
// Partially visible so leave it at the current depth.
if (overlay.IsPresent)
return;

View File

@ -234,7 +234,7 @@ namespace osu.Game.Screens.Edit
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, loadableBeatmap.GetSkin(), loadableBeatmap.BeatmapInfo));
dependencies.CacheAs(editorBeatmap);
editorBeatmap.UpdateInProgress.BindValueChanged(updateInProgress);
editorBeatmap.UpdateInProgress.BindValueChanged(_ => updateSampleDisabledState());
canSave = editorBeatmap.BeatmapInfo.Ruleset.CreateInstance() is ILegacyRuleset;
@ -659,7 +659,7 @@ namespace osu.Game.Screens.Edit
if (isNewBeatmap || HasUnsavedChanges)
{
samplePlaybackDisabled.Value = true;
updateSampleDisabledState();
dialogOverlay?.Push(new PromptForSaveDialog(confirmExit, confirmExitWithSave, cancelExit));
return true;
}
@ -729,27 +729,6 @@ 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;
@ -883,11 +862,28 @@ namespace osu.Game.Screens.Edit
}
}
[CanBeNull]
private ScheduledDelegate playbackDisabledDebounce;
private void updateSampleDisabledState()
{
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value
|| currentScreen is not ComposeScreen
|| temporaryMuteFromUpdateInProgress;
bool shouldDisableSamples = clock.SeekingOrStopped.Value
|| currentScreen is not ComposeScreen
|| editorBeatmap.UpdateInProgress.Value
|| dialogOverlay?.CurrentDialog != null;
playbackDisabledDebounce?.Cancel();
if (shouldDisableSamples)
{
samplePlaybackDisabled.Value = true;
}
else
{
// Debounce re-enabling arbitrarily high enough to avoid flip-flopping during beatmap updates
// or rapid user seeks.
playbackDisabledDebounce = Scheduler.AddDelayed(() => samplePlaybackDisabled.Value = false, 50);
}
}
private void seek(UIEvent e, int direction)