From a4bb4255b167cf051dd9fe60a1942641790529e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 13 Oct 2018 07:10:13 +0900 Subject: [PATCH] Add grouping manager --- .../TestCaseGroupingManager.cs | 50 +++++++++++++++++++ .../Components/DrawableTournamentGrouping.cs | 2 +- .../Ladder/Components/TournamentGrouping.cs | 5 +- osu.Game/Overlays/Settings/SettingsTextBox.cs | 2 +- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 osu.Game.Tournament.Tests/TestCaseGroupingManager.cs diff --git a/osu.Game.Tournament.Tests/TestCaseGroupingManager.cs b/osu.Game.Tournament.Tests/TestCaseGroupingManager.cs new file mode 100644 index 0000000000..0d39ef1c73 --- /dev/null +++ b/osu.Game.Tournament.Tests/TestCaseGroupingManager.cs @@ -0,0 +1,50 @@ +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Overlays.Settings; +using osu.Game.Tournament.Screens.Ladder.Components; + +namespace osu.Game.Tournament.Tests +{ + public class TestCaseGroupingManager : LadderTestCase + { + public TestCaseGroupingManager() + { + FillFlowContainer items; + + Add(items = new FillFlowContainer + { + Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.Both + }); + + foreach (var g in Ladder.Groupings) + items.Add(new GroupingRow(g)); + } + + public class GroupingRow : CompositeDrawable + { + public readonly TournamentGrouping Grouping; + + public GroupingRow(TournamentGrouping grouping) + { + Grouping = grouping; + InternalChildren = new Drawable[] + { + new FillFlowContainer + { + Direction = FillDirection.Horizontal, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new SettingsTextBox { Width = 0.4f, Bindable = Grouping.Name }, + new SettingsTextBox { Width = 0.4f, Bindable = Grouping.Description }, + } + } + }; + + RelativeSizeAxes = Axes.X; + Height = 40; + } + } + } +} diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentGrouping.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentGrouping.cs index 475e735522..8a38f402aa 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentGrouping.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentGrouping.cs @@ -20,7 +20,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components { new OsuSpriteText { - Text = grouping.Description.ToUpper(), + Text = grouping.Description.Value.ToUpper(), Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre }, diff --git a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs index 675bf5fc4f..2e72e1fe06 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs @@ -2,13 +2,14 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Framework.Configuration; namespace osu.Game.Tournament.Screens.Ladder.Components { public class TournamentGrouping { - public string Name; - public string Description; + public readonly Bindable Name = new Bindable(); + public readonly Bindable Description = new Bindable(); public int BestOf; diff --git a/osu.Game/Overlays/Settings/SettingsTextBox.cs b/osu.Game/Overlays/Settings/SettingsTextBox.cs index ce9218bbe7..106b2372e0 100644 --- a/osu.Game/Overlays/Settings/SettingsTextBox.cs +++ b/osu.Game/Overlays/Settings/SettingsTextBox.cs @@ -8,6 +8,6 @@ namespace osu.Game.Overlays.Settings { public class SettingsTextBox : SettingsItem { - protected override Drawable CreateControl() => new OsuTextBox(); + protected override Drawable CreateControl() => new OsuTextBox { RelativeSizeAxes = Axes.X }; } }