1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 07:32:55 +08:00

Only add back button if required

This commit is contained in:
Dean Herbert 2020-05-17 17:27:52 +09:00
parent 2c0ac8cc36
commit 864c1a73ae

View File

@ -46,18 +46,6 @@ namespace osu.Game.Tournament.Screens.Editors
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
BackButton.Receptor receptor = new BackButton.Receptor();
backButton = new BackButton(receptor)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = () =>
{
if (parentScreen != null)
backAction.Invoke();
}
};
AddRangeInternal(new Drawable[] AddRangeInternal(new Drawable[]
{ {
new Box new Box
@ -76,10 +64,8 @@ namespace osu.Game.Tournament.Screens.Editors
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Spacing = new Vector2(20), Spacing = new Vector2(20),
Padding = new MarginPadding { Bottom = backButton.Height * 2 },
}, },
}, },
backButton,
ControlPanel = new ControlPanel ControlPanel = new ControlPanel
{ {
Children = new Drawable[] Children = new Drawable[]
@ -101,7 +87,21 @@ namespace osu.Game.Tournament.Screens.Editors
}); });
if (parentScreen != null) if (parentScreen != null)
backButton.Show(); {
AddInternal(backButton = new BackButton(new BackButton.Receptor())
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
State = { Value = Visibility.Visible },
Action = () =>
{
if (parentScreen != null)
backAction.Invoke();
}
});
flow.Padding = new MarginPadding { Bottom = backButton.Height * 2 };
}
Storage.CollectionChanged += (_, args) => Storage.CollectionChanged += (_, args) =>
{ {
@ -126,7 +126,7 @@ namespace osu.Game.Tournament.Screens.Editors
switch (action) switch (action)
{ {
case GlobalAction.Back: case GlobalAction.Back:
backAction.Invoke(); backAction?.Invoke();
return true; return true;
} }