mirror of
https://github.com/ppy/osu.git
synced 2025-03-14 05:47:20 +08:00
Merge pull request #9041 from MiraiSubject/tourney-subscreen-back-button
Add a back button to sub screens in the Tournament Client
This commit is contained in:
commit
9003c069bb
@ -16,7 +16,7 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
var match = CreateSampleMatch();
|
||||
|
||||
Add(new SeedingEditorScreen(match.Team1.Value)
|
||||
Add(new SeedingEditorScreen(match.Team1.Value, new TeamEditorScreen())
|
||||
{
|
||||
Width = 0.85f // create room for control panel
|
||||
});
|
||||
|
@ -25,7 +25,11 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
protected override BindableList<SeedingResult> Storage => team.SeedingResults;
|
||||
|
||||
public SeedingEditorScreen(TournamentTeam team)
|
||||
[Resolved(canBeNull: true)]
|
||||
private TournamentSceneManager sceneManager { get; set; }
|
||||
|
||||
public SeedingEditorScreen(TournamentTeam team, TournamentScreen parentScreen)
|
||||
: base(parentScreen)
|
||||
{
|
||||
this.team = team;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
});
|
||||
}
|
||||
|
||||
protected override TeamRow CreateDrawable(TournamentTeam model) => new TeamRow(model);
|
||||
protected override TeamRow CreateDrawable(TournamentTeam model) => new TeamRow(model, this);
|
||||
|
||||
private void addAllCountries()
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[Resolved]
|
||||
private LadderInfo ladderInfo { get; set; }
|
||||
|
||||
public TeamRow(TournamentTeam team)
|
||||
public TeamRow(TournamentTeam team, TournamentScreen parent)
|
||||
{
|
||||
Model = team;
|
||||
|
||||
@ -154,7 +154,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
Text = "Edit seeding results",
|
||||
Action = () =>
|
||||
{
|
||||
sceneManager?.SetScreen(new SeedingEditorScreen(team));
|
||||
sceneManager?.SetScreen(new SeedingEditorScreen(team, parent));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays.Settings;
|
||||
@ -25,8 +26,19 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
|
||||
private FillFlowContainer<TDrawable> flow;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private TournamentSceneManager sceneManager { get; set; }
|
||||
|
||||
protected ControlPanel ControlPanel;
|
||||
|
||||
private readonly TournamentScreen parentScreen;
|
||||
private BackButton backButton;
|
||||
|
||||
protected TournamentEditorScreen(TournamentScreen parentScreen = null)
|
||||
{
|
||||
this.parentScreen = parentScreen;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -47,7 +59,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(20)
|
||||
Spacing = new Vector2(20),
|
||||
},
|
||||
},
|
||||
ControlPanel = new ControlPanel
|
||||
@ -70,6 +82,19 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
}
|
||||
});
|
||||
|
||||
if (parentScreen != null)
|
||||
{
|
||||
AddInternal(backButton = new BackButton
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
State = { Value = Visibility.Visible },
|
||||
Action = () => sceneManager?.SetScreen(parentScreen.GetType())
|
||||
});
|
||||
|
||||
flow.Padding = new MarginPadding { Bottom = backButton.Height * 2 };
|
||||
}
|
||||
|
||||
Storage.CollectionChanged += (_, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
|
@ -16,10 +16,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private readonly TwoLayerButton button;
|
||||
|
||||
public BackButton(Receptor receptor)
|
||||
public BackButton(Receptor receptor = null)
|
||||
{
|
||||
receptor.OnBackPressed = () => button.Click();
|
||||
|
||||
Size = TwoLayerButton.SIZE_EXTENDED;
|
||||
|
||||
Child = button = new TwoLayerButton
|
||||
@ -30,6 +28,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Icon = OsuIcon.LeftCircle,
|
||||
Action = () => Action?.Invoke()
|
||||
};
|
||||
|
||||
if (receptor == null)
|
||||
{
|
||||
// if a receptor wasn't provided, create our own locally.
|
||||
Add(receptor = new Receptor());
|
||||
}
|
||||
|
||||
receptor.OnBackPressed = () => button.Click();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
x
Reference in New Issue
Block a user