diff --git a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs index c8c2461b10..125e0a966c 100644 --- a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs @@ -7,8 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; using osu.Game.Tournament.Components; using osu.Game.Tournament.Models; @@ -16,67 +14,23 @@ using osuTK; namespace osu.Game.Tournament.Screens.Editors { - public class RoundEditorScreen : TournamentScreen, IProvideVideo + public class RoundEditorScreen : TournamentEditorScreen { - private readonly FillFlowContainer items; - - public RoundEditorScreen() - { - AddRangeInternal(new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.2f), - }, - new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Width = 0.9f, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Child = items = new FillFlowContainer - { - Direction = FillDirection.Vertical, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - LayoutDuration = 200, - LayoutEasing = Easing.OutQuint, - }, - }, - new ControlPanel - { - Children = new Drawable[] - { - new TriangleButton - { - RelativeSizeAxes = Axes.X, - Text = "Add new", - Action = addNew - }, - } - } - }); - } - [BackgroundDependencyLoader] private void load() { foreach (var r in LadderInfo.Rounds) - items.Add(new RoundRow(r)); + Flow.Add(new RoundRow(r)); } - private void addNew() + protected override void AddNew() { var round = new TournamentRound { - StartDate = - { - Value = DateTimeOffset.UtcNow - } + StartDate = { Value = DateTimeOffset.UtcNow } }; - items.Add(new RoundRow(round)); + Flow.Add(new RoundRow(round)); LadderInfo.Rounds.Add(round); } @@ -141,7 +95,7 @@ namespace osu.Game.Tournament.Screens.Editors Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.None, Width = 150, - Text = "Delete", + Text = "Delete Round", Action = () => { Expire(); diff --git a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs index ff272d5123..4e2c144dd2 100644 --- a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs @@ -8,8 +8,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Settings; @@ -20,62 +18,20 @@ using osuTK; namespace osu.Game.Tournament.Screens.Editors { - public class TeamEditorScreen : TournamentScreen, IProvideVideo + public class TeamEditorScreen : TournamentEditorScreen { - private readonly FillFlowContainer items; - - public TeamEditorScreen() - { - AddRangeInternal(new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.2f), - }, - new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Width = 0.9f, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Child = items = new FillFlowContainer - { - Direction = FillDirection.Vertical, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - LayoutDuration = 200, - LayoutEasing = Easing.OutQuint, - Spacing = new Vector2(20) - }, - }, - new ControlPanel - { - Children = new Drawable[] - { - new TriangleButton - { - RelativeSizeAxes = Axes.X, - Text = "Add new", - Action = addNew - }, - } - } - }); - } - [BackgroundDependencyLoader] private void load() { foreach (var t in LadderInfo.Teams) - items.Add(new TeamRow(t)); + Flow.Add(new TeamRow(t)); } - private void addNew() + protected override void AddNew() { var team = new TournamentTeam(); - items.Add(new TeamRow(team)); + Flow.Add(new TeamRow(team)); LadderInfo.Teams.Add(team); } diff --git a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs new file mode 100644 index 0000000000..a4f7e4172c --- /dev/null +++ b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs @@ -0,0 +1,62 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Tournament.Components; +using osuTK; + +namespace osu.Game.Tournament.Screens.Editors +{ + public abstract class TournamentEditorScreen : TournamentScreen, IProvideVideo + where T : Drawable + { + protected readonly FillFlowContainer Flow; + + protected TournamentEditorScreen() + { + AddRangeInternal(new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.2f), + }, + new OsuScrollContainer + { + RelativeSizeAxes = Axes.Both, + Width = 0.9f, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Child = Flow = new FillFlowContainer + { + Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + LayoutDuration = 200, + LayoutEasing = Easing.OutQuint, + Spacing = new Vector2(20) + }, + }, + new ControlPanel + { + Children = new Drawable[] + { + new TriangleButton + { + RelativeSizeAxes = Axes.X, + Text = "Add new", + Action = AddNew + }, + } + } + }); + } + + protected abstract void AddNew(); + } +}