1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Refactor DialogOverlay logic to avoid dismissal potentially being unhandled

This commit is contained in:
Dean Herbert 2021-05-19 16:52:34 +09:00
parent 44e22b31a9
commit fc5987bf69
2 changed files with 10 additions and 3 deletions

View File

@ -95,6 +95,8 @@ namespace osu.Game.Overlays.Dialog
}
}
protected override bool StartHidden => true;
protected PopupDialog()
{
RelativeSizeAxes = Axes.Both;
@ -205,6 +207,10 @@ namespace osu.Game.Overlays.Dialog
},
},
};
// It's important we start in a visible state so our state fires on hide, even before load.
// This is used by the DialogOverlay to know when the dialog was dismissed.
Show();
}
/// <summary>

View File

@ -35,15 +35,16 @@ namespace osu.Game.Overlays
public void Push(PopupDialog dialog)
{
if (dialog == CurrentDialog) return;
if (dialog == CurrentDialog || dialog.State.Value != Visibility.Visible) return;
// if any existing dialog is being displayed, dismiss it before showing a new one.
CurrentDialog?.Hide();
CurrentDialog = dialog;
CurrentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
dialogContainer.Add(CurrentDialog);
CurrentDialog.Show();
CurrentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
Show();
}