Refactor for formatting sanity

This commit is contained in:
Dean Herbert 2019-03-24 12:03:06 +09:00
parent 8ad19fc2d4
commit 0d72104235

View File

@ -38,13 +38,15 @@ namespace osu.Game.Screens.Play
/// <summary> /// <summary>
/// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered. /// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered.
/// </summary> /// </summary>
protected virtual Action BackAction => () => InternalButtons.Children.Last().Click(); protected virtual Action BackAction => () => InternalButtons.Children.LastOrDefault()?.Click();
/// <summary> /// <summary>
/// Action that is invoked when <see cref="GlobalAction.Select"/> is triggered. /// Action that is invoked when <see cref="GlobalAction.Select"/> is triggered.
/// </summary> /// </summary>
protected Action SelectAction => () => InternalButtons.Children.FirstOrDefault(f => f.Selected)?.Click(); protected virtual Action SelectAction => () => InternalButtons.Children.FirstOrDefault(f => f.Selected.Value)?.Click();
public abstract string Header { get; } public abstract string Header { get; }
public abstract string Description { get; } public abstract string Description { get; }
protected internal FillFlowContainer<DialogButton> InternalButtons; protected internal FillFlowContainer<DialogButton> InternalButtons;
@ -233,22 +235,20 @@ namespace osu.Game.Screens.Play
public bool OnPressed(GlobalAction action) public bool OnPressed(GlobalAction action)
{ {
if (action == GlobalAction.Back) switch (action)
{ {
case GlobalAction.Back:
BackAction.Invoke(); BackAction.Invoke();
return true; return true;
} case GlobalAction.Select:
if (action == GlobalAction.Select)
{
SelectAction.Invoke(); SelectAction.Invoke();
return true; return true;
} default:
return false; return false;
} }
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back; public bool OnReleased(GlobalAction action) => false;
private void buttonSelectionChanged(DialogButton button, bool isSelected) private void buttonSelectionChanged(DialogButton button, bool isSelected)
{ {