mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 07:42:55 +08:00
Refactor DialogOverlay
logic to avoid dismissal potentially being unhandled
This commit is contained in:
parent
44e22b31a9
commit
fc5987bf69
@ -95,6 +95,8 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool StartHidden => true;
|
||||||
|
|
||||||
protected PopupDialog()
|
protected PopupDialog()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
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>
|
/// <summary>
|
||||||
|
@ -35,15 +35,16 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public void Push(PopupDialog dialog)
|
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?.Hide();
|
||||||
|
|
||||||
CurrentDialog = dialog;
|
CurrentDialog = dialog;
|
||||||
|
CurrentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
|
||||||
|
|
||||||
dialogContainer.Add(CurrentDialog);
|
dialogContainer.Add(CurrentDialog);
|
||||||
|
|
||||||
CurrentDialog.Show();
|
|
||||||
CurrentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user