From cf0976955bb36edf5be7ed9797cb2c8e2a19f1a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 16 Nov 2018 20:30:12 +0900 Subject: [PATCH] Expose groupings editor --- .../TestCaseGroupingsEditorScreen.cs | 15 ++++++++ .../Groupings/GroupingsEditorScreen.cs | 37 +++++++++++++------ .../Ladder/Components/LadderEditorSettings.cs | 11 ++++++ .../Screens/Ladder/LadderScreen.cs | 3 -- .../Screens/TournamentSceneManager.cs | 4 ++ .../Screens/TournamentScreen.cs | 4 ++ 6 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 osu.Game.Tournament.Tests/TestCaseGroupingsEditorScreen.cs rename osu.Game.Tournament.Tests/TestCaseGroupingManager.cs => osu.Game.Tournament/Screens/Groupings/GroupingsEditorScreen.cs (69%) diff --git a/osu.Game.Tournament.Tests/TestCaseGroupingsEditorScreen.cs b/osu.Game.Tournament.Tests/TestCaseGroupingsEditorScreen.cs new file mode 100644 index 0000000000..4e82e27fd9 --- /dev/null +++ b/osu.Game.Tournament.Tests/TestCaseGroupingsEditorScreen.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Tournament.Screens.Groupings; + +namespace osu.Game.Tournament.Tests +{ + public class TestCaseGroupingsEditorScreen : LadderTestCase + { + public TestCaseGroupingsEditorScreen() + { + Add(new GroupingsEditorScreen()); + } + } +} diff --git a/osu.Game.Tournament.Tests/TestCaseGroupingManager.cs b/osu.Game.Tournament/Screens/Groupings/GroupingsEditorScreen.cs similarity index 69% rename from osu.Game.Tournament.Tests/TestCaseGroupingManager.cs rename to osu.Game.Tournament/Screens/Groupings/GroupingsEditorScreen.cs index 531019c28c..1b7e9e6bd1 100644 --- a/osu.Game.Tournament.Tests/TestCaseGroupingManager.cs +++ b/osu.Game.Tournament/Screens/Groupings/GroupingsEditorScreen.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -9,13 +10,13 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; using osu.Game.Tournament.Screens.Ladder.Components; -namespace osu.Game.Tournament.Tests +namespace osu.Game.Tournament.Screens.Groupings { - public class TestCaseGroupingManager : LadderTestCase + public class GroupingsEditorScreen : TournamentScreen, IProvideVideo { private readonly FillFlowContainer items; - public TestCaseGroupingManager() + public GroupingsEditorScreen() { Add(new FillFlowContainer { @@ -37,29 +38,37 @@ namespace osu.Game.Tournament.Tests }, } }); - } [BackgroundDependencyLoader] private void load() { - foreach (var g in Ladder.Groupings) - items.Add(new GroupingRow(g)); + foreach (var g in LadderInfo.Groupings) + items.Add(new GroupingRow(g, updateGroupings)); } - protected override void Dispose(bool isDisposing) + protected override void LoadComplete() { - Ladder.Groupings = items.Children.Select(c => c.Grouping).ToList(); - base.Dispose(isDisposing); + base.LoadComplete(); + Scheduler.AddDelayed(() => LadderInfo.Groupings = items.Children.Select(c => c.Grouping).ToList(), 500, true); } - private void addNew() => items.Add(new GroupingRow(new TournamentGrouping())); + private void addNew() + { + items.Add(new GroupingRow(new TournamentGrouping(), updateGroupings)); + updateGroupings(); + } + + private void updateGroupings() + { + LadderInfo.Groupings = items.Children.Select(c => c.Grouping).ToList(); + } public class GroupingRow : CompositeDrawable { public readonly TournamentGrouping Grouping; - public GroupingRow(TournamentGrouping grouping) + public GroupingRow(TournamentGrouping grouping, Action onDelete) { Grouping = grouping; InternalChildren = new Drawable[] @@ -77,7 +86,11 @@ namespace osu.Game.Tournament.Tests { Width = 0.1f, Text = "Delete", - Action = () => Expire() + Action = () => + { + Expire(); + onDelete(); + } }, } } diff --git a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs index 90f20a3494..4334f75728 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs @@ -6,6 +6,7 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; @@ -115,5 +116,15 @@ namespace osu.Game.Tournament.Screens.Ladder.Components editorInfo.Selected.Value.Losers.Value = losers; }; } + + protected override bool OnHover(HoverEvent e) + { + return false; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + } + } } diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs index 69035c21db..5e0cb13375 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs @@ -22,9 +22,6 @@ namespace osu.Game.Tournament.Screens.Ladder protected ScrollableContainer ScrollContent; - [Resolved] - protected LadderInfo LadderInfo { get; private set; } - [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game.Tournament/Screens/TournamentSceneManager.cs b/osu.Game.Tournament/Screens/TournamentSceneManager.cs index de9e6ee19d..0205838fc2 100644 --- a/osu.Game.Tournament/Screens/TournamentSceneManager.cs +++ b/osu.Game.Tournament/Screens/TournamentSceneManager.cs @@ -11,6 +11,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Screens; using osu.Game.Tournament.Screens.Drawings; using osu.Game.Tournament.Screens.Gameplay; +using osu.Game.Tournament.Screens.Groupings; using osu.Game.Tournament.Screens.Ladder; using osu.Game.Tournament.Screens.MapPool; using osu.Game.Tournament.Screens.Schedule; @@ -27,6 +28,7 @@ namespace osu.Game.Tournament.Screens private ScheduleScreen schedule; private LadderScreen bracket; private LadderEditorScreen bracketEditor; + private GroupingsEditorScreen groupingsEditor; private MapPoolScreen mapPool; private GameplayScreen gameplay; private TeamWinScreen winner; @@ -59,6 +61,7 @@ namespace osu.Game.Tournament.Screens Children = new Drawable[] { new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => setScreen(bracketEditor) }, + new OsuButton { RelativeSizeAxes = Axes.X, Text = "Groupings Editor", Action = () => setScreen(groupingsEditor) }, new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) }, @@ -101,6 +104,7 @@ namespace osu.Game.Tournament.Screens schedule = new ScheduleScreen(), bracket = new LadderScreen(), bracketEditor = new LadderEditorScreen(), + groupingsEditor = new GroupingsEditorScreen(), showcase = new ShowcaseScreen(), mapPool = new MapPoolScreen(), teamIntro = new TeamIntroScreen(), diff --git a/osu.Game.Tournament/Screens/TournamentScreen.cs b/osu.Game.Tournament/Screens/TournamentScreen.cs index dcdd7f8ce5..b440b8e796 100644 --- a/osu.Game.Tournament/Screens/TournamentScreen.cs +++ b/osu.Game.Tournament/Screens/TournamentScreen.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Screens; @@ -8,6 +9,9 @@ namespace osu.Game.Tournament.Screens { public class TournamentScreen : OsuScreen { + [Resolved] + protected LadderInfo LadderInfo { get; private set; } + public override void Hide() { this.FadeOut(200);