diff --git a/osu.Game.Tournament.Tests/TestSceneTeamsEditorScreen.cs b/osu.Game.Tournament.Tests/TestSceneTeamsEditorScreen.cs new file mode 100644 index 0000000000..d3268219b3 --- /dev/null +++ b/osu.Game.Tournament.Tests/TestSceneTeamsEditorScreen.cs @@ -0,0 +1,15 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Tournament.Screens.Teams; + +namespace osu.Game.Tournament.Tests +{ + public class TestSceneTeamsEditorScreen : LadderTestScene + { + public TestSceneTeamsEditorScreen() + { + Add(new TeamsEditorScreen()); + } + } +} diff --git a/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs b/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs new file mode 100644 index 0000000000..b2392e5dc0 --- /dev/null +++ b/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs @@ -0,0 +1,156 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Allocation; +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.Screens.Ladder.Components; +using osuTK; + +namespace osu.Game.Tournament.Screens.Teams +{ + public class TeamsEditorScreen : TournamentScreen, IProvideVideo + { + private readonly FillFlowContainer items; + + public TeamsEditorScreen() + { + 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, + }, + }, + new ControlPanel + { + Children = new Drawable[] + { + new TriangleButton + { + RelativeSizeAxes = Axes.X, + Text = "Add new", + Action = addNew + }, + } + } + }); + } + + [BackgroundDependencyLoader] + private void load() + { + foreach (var g in LadderInfo.Teams) + items.Add(new TeamRow(g)); + } + + private void addNew() + { + var team = new TournamentTeam + { + StartDate = + { + Value = DateTimeOffset.UtcNow + } + }; + + items.Add(new TeamRow(team)); + LadderInfo.Teams.Add(team); + } + + public class TeamRow : CompositeDrawable + { + public readonly TournamentTeam Team; + + [Resolved] + private LadderInfo ladderInfo { get; set; } + + public TeamRow(TournamentTeam team) + { + Margin = new MarginPadding(10); + + Team = team; + InternalChildren = new Drawable[] + { + new Box + { + Colour = OsuColour.Gray(0.1f), + RelativeSizeAxes = Axes.Both, + }, + new FillFlowContainer + { + Margin = new MarginPadding(5), + Padding = new MarginPadding { Right = 160 }, + Spacing = new Vector2(5), + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new SettingsTextBox + { + LabelText = "Name", + Width = 0.33f, + Bindable = Team.Acronym + }, + new SettingsTextBox + { + LabelText = "Description", + Width = 0.33f, + Bindable = Team.Description + }, + new DateTextBox + { + LabelText = "Start Time", + Width = 0.33f, + Bindable = Team.StartDate + }, + new SettingsSlider + { + LabelText = "Best of", + Width = 0.33f, + Bindable = Team.BestOf + }, + } + }, + new DangerousSettingsButton + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + RelativeSizeAxes = Axes.None, + Width = 150, + Text = "Delete", + Action = () => + { + Expire(); + ladderInfo.Teams.Remove(Team); + }, + } + }; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + } + } + } +} diff --git a/osu.Game.Tournament/Screens/TournamentSceneManager.cs b/osu.Game.Tournament/Screens/TournamentSceneManager.cs index 083f26240b..8393cd52a2 100644 --- a/osu.Game.Tournament/Screens/TournamentSceneManager.cs +++ b/osu.Game.Tournament/Screens/TournamentSceneManager.cs @@ -19,6 +19,7 @@ using osu.Game.Tournament.Screens.MapPool; using osu.Game.Tournament.Screens.Schedule; using osu.Game.Tournament.Screens.Showcase; using osu.Game.Tournament.Screens.TeamIntro; +using osu.Game.Tournament.Screens.Teams; using osu.Game.Tournament.Screens.TeamWin; using osuTK; using osuTK.Graphics; @@ -72,6 +73,7 @@ namespace osu.Game.Tournament.Screens new ScheduleScreen(), new LadderScreen(), new LadderEditorScreen(), + new TeamsEditorScreen(), new GroupingsEditorScreen(), new ShowcaseScreen(), new MapPoolScreen(), @@ -105,8 +107,9 @@ namespace osu.Game.Tournament.Screens Direction = FillDirection.Vertical, Children = new Drawable[] { - new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => SetScreen(typeof(LadderEditorScreen)) }, + new OsuButton { RelativeSizeAxes = Axes.X, Text = "Team Editor", Action = () => SetScreen(typeof(TeamsEditorScreen)) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Groupings Editor", Action = () => SetScreen(typeof(GroupingsEditorScreen)) }, + new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => SetScreen(typeof(LadderEditorScreen)) }, new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => SetScreen(typeof(DrawingsScreen)) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => SetScreen(typeof(ShowcaseScreen)) },