1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Change logic for parentscreen/subscreen relation

This commit is contained in:
Shivam 2020-05-16 12:50:56 +02:00
parent b1243d6a87
commit 358345cee7
4 changed files with 15 additions and 16 deletions

View File

@ -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
});

View File

@ -28,11 +28,8 @@ namespace osu.Game.Tournament.Screens.Editors
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
protected override bool IsSubScreen => true;
protected override System.Type ParentScreen => typeof(TeamEditorScreen);
public SeedingEditorScreen(TournamentTeam team)
public SeedingEditorScreen(TournamentTeam team, TournamentScreen parentScreen)
: base(parentScreen)
{
this.team = team;
}

View File

@ -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));
}
},
}

View File

@ -33,13 +33,15 @@ namespace osu.Game.Tournament.Screens.Editors
protected ControlPanel ControlPanel;
protected virtual bool IsSubScreen => false;
protected virtual System.Type ParentScreen { get; set; }
private readonly TournamentScreen parentScreen;
private BackButton backButton;
private System.Action backAction => () => sceneManager?.SetScreen(ParentScreen);
private System.Action backAction => () => sceneManager?.SetScreen(parentScreen.GetType());
protected TournamentEditorScreen(TournamentScreen parentScreen = null)
{
this.parentScreen = parentScreen;
}
[BackgroundDependencyLoader]
private void load()
@ -51,7 +53,7 @@ namespace osu.Game.Tournament.Screens.Editors
Origin = Anchor.BottomLeft,
Action = () =>
{
if (IsSubScreen)
if (parentScreen != null)
backAction.Invoke();
}
};
@ -98,7 +100,7 @@ namespace osu.Game.Tournament.Screens.Editors
}
});
if (IsSubScreen)
if (parentScreen != null)
backButton.Show();
Storage.CollectionChanged += (_, args) =>