mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Expose buttons for test cases
This commit is contained in:
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!args.Repeat && args.Key == Key.Escape)
|
if (!args.Repeat && args.Key == Key.Escape)
|
||||||
{
|
{
|
||||||
Buttons.Children.Last().TriggerOnClick();
|
InternalButtons.Children.Last().TriggerOnClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -31,7 +32,8 @@ namespace osu.Game.Screens.Play
|
|||||||
public abstract string Header { get; }
|
public abstract string Header { get; }
|
||||||
public abstract string Description { get; }
|
public abstract string Description { get; }
|
||||||
|
|
||||||
protected FillFlowContainer<DialogButton> Buttons;
|
protected internal FillFlowContainer<DialogButton> InternalButtons;
|
||||||
|
public IReadOnlyList<DialogButton> Buttons => InternalButtons;
|
||||||
|
|
||||||
private FillFlowContainer retryCounterContainer;
|
private FillFlowContainer retryCounterContainer;
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Buttons = new FillFlowContainer<DialogButton>
|
InternalButtons = new FillFlowContainer<DialogButton>
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
@ -191,7 +193,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
button.Selected.ValueChanged += s => buttonSelectionChanged(button, s);
|
button.Selected.ValueChanged += s => buttonSelectionChanged(button, s);
|
||||||
|
|
||||||
Buttons.Add(button);
|
InternalButtons.Add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _selectionIndex = -1;
|
private int _selectionIndex = -1;
|
||||||
@ -205,13 +207,13 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
// Deselect the previously-selected button
|
// Deselect the previously-selected button
|
||||||
if (_selectionIndex != -1)
|
if (_selectionIndex != -1)
|
||||||
Buttons[_selectionIndex].Selected.Value = false;
|
InternalButtons[_selectionIndex].Selected.Value = false;
|
||||||
|
|
||||||
_selectionIndex = value;
|
_selectionIndex = value;
|
||||||
|
|
||||||
// Select the newly-selected button
|
// Select the newly-selected button
|
||||||
if (_selectionIndex != -1)
|
if (_selectionIndex != -1)
|
||||||
Buttons[_selectionIndex].Selected.Value = true;
|
InternalButtons[_selectionIndex].Selected.Value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,12 +226,12 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
case Key.Up:
|
case Key.Up:
|
||||||
if (selectionIndex == -1 || selectionIndex == 0)
|
if (selectionIndex == -1 || selectionIndex == 0)
|
||||||
selectionIndex = Buttons.Count - 1;
|
selectionIndex = InternalButtons.Count - 1;
|
||||||
else
|
else
|
||||||
selectionIndex--;
|
selectionIndex--;
|
||||||
return true;
|
return true;
|
||||||
case Key.Down:
|
case Key.Down:
|
||||||
if (selectionIndex == -1 || selectionIndex == Buttons.Count - 1)
|
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
||||||
selectionIndex = 0;
|
selectionIndex = 0;
|
||||||
else
|
else
|
||||||
selectionIndex++;
|
selectionIndex++;
|
||||||
@ -244,7 +246,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (!isSelected)
|
if (!isSelected)
|
||||||
selectionIndex = -1;
|
selectionIndex = -1;
|
||||||
else
|
else
|
||||||
selectionIndex = Buttons.IndexOf(button);
|
selectionIndex = InternalButtons.IndexOf(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Button : DialogButton
|
private class Button : DialogButton
|
||||||
|
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!args.Repeat && args.Key == Key.Escape)
|
if (!args.Repeat && args.Key == Key.Escape)
|
||||||
{
|
{
|
||||||
Buttons.Children.First().TriggerOnClick();
|
InternalButtons.Children.First().TriggerOnClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user