From 358345cee72cf0e0c6ae57936ee8df27de4d72ac Mon Sep 17 00:00:00 2001 From: Shivam Date: Sat, 16 May 2020 12:50:56 +0200 Subject: [PATCH] Change logic for parentscreen/subscreen relation --- .../Screens/TestSceneSeedingEditorScreen.cs | 2 +- .../Screens/Editors/SeedingEditorScreen.cs | 7 ++----- .../Screens/Editors/TeamEditorScreen.cs | 6 +++--- .../Screens/Editors/TournamentEditorScreen.cs | 16 +++++++++------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs index 17cccd34b6..8d12d5393d 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs @@ -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 }); diff --git a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs index 0f980ec9a3..0973a7dc75 100644 --- a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs @@ -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; } diff --git a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs index 81487f1bcf..dbfcfe4225 100644 --- a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs @@ -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)); } }, } diff --git a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs index bca0814d3a..c0b56f1e68 100644 --- a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs @@ -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) =>