2018-10-13 18:45:59 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2018-10-14 00:03:04 +08:00
|
|
|
using System.Linq;
|
2018-10-16 14:20:12 +08:00
|
|
|
using osu.Framework.Allocation;
|
2018-10-13 06:10:13 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-10-14 00:03:04 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-10-13 06:10:13 +08:00
|
|
|
using osu.Game.Overlays.Settings;
|
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Tests
|
|
|
|
{
|
|
|
|
public class TestCaseGroupingManager : LadderTestCase
|
|
|
|
{
|
2018-10-14 00:03:04 +08:00
|
|
|
private readonly FillFlowContainer<GroupingRow> items;
|
|
|
|
|
2018-10-13 06:10:13 +08:00
|
|
|
public TestCaseGroupingManager()
|
|
|
|
{
|
2018-10-14 00:03:04 +08:00
|
|
|
Add(new FillFlowContainer
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
2018-10-14 00:03:04 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
items = new FillFlowContainer<GroupingRow>
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
},
|
|
|
|
new TriangleButton
|
|
|
|
{
|
|
|
|
Width = 100,
|
|
|
|
Text = "Add",
|
|
|
|
Action = addNew
|
|
|
|
},
|
|
|
|
}
|
2018-10-13 06:10:13 +08:00
|
|
|
});
|
|
|
|
|
2018-10-16 14:20:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2018-10-13 06:10:13 +08:00
|
|
|
foreach (var g in Ladder.Groupings)
|
|
|
|
items.Add(new GroupingRow(g));
|
|
|
|
}
|
|
|
|
|
2018-11-06 16:59:01 +08:00
|
|
|
protected override void Dispose(bool isDisposing)
|
2018-10-14 00:03:04 +08:00
|
|
|
{
|
|
|
|
Ladder.Groupings = items.Children.Select(c => c.Grouping).ToList();
|
2018-11-06 16:59:01 +08:00
|
|
|
base.Dispose(isDisposing);
|
2018-10-14 00:03:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void addNew() => items.Add(new GroupingRow(new TournamentGrouping()));
|
|
|
|
|
2018-10-13 06:10:13 +08:00
|
|
|
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[]
|
|
|
|
{
|
2018-10-14 00:03:04 +08:00
|
|
|
new SettingsTextBox { Width = 0.3f, Bindable = Grouping.Name },
|
|
|
|
new SettingsTextBox { Width = 0.3f, Bindable = Grouping.Description },
|
|
|
|
new SettingsSlider<int> { LabelText = "Best of", Width = 0.3f, Bindable = Grouping.BestOf },
|
|
|
|
new DangerousSettingsButton
|
|
|
|
{
|
|
|
|
Width = 0.1f,
|
|
|
|
Text = "Delete",
|
|
|
|
Action = () => Expire()
|
|
|
|
},
|
2018-10-13 06:10:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Height = 40;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|