mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:28:00 +08:00
Add ability to change best of, add and delete groupings
This commit is contained in:
parent
522f106f74
commit
f5716c3d21
@ -1,8 +1,10 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||||
|
|
||||||
@ -10,20 +12,43 @@ namespace osu.Game.Tournament.Tests
|
|||||||
{
|
{
|
||||||
public class TestCaseGroupingManager : LadderTestCase
|
public class TestCaseGroupingManager : LadderTestCase
|
||||||
{
|
{
|
||||||
|
private readonly FillFlowContainer<GroupingRow> items;
|
||||||
|
|
||||||
public TestCaseGroupingManager()
|
public TestCaseGroupingManager()
|
||||||
{
|
{
|
||||||
FillFlowContainer items;
|
Add(new FillFlowContainer
|
||||||
|
|
||||||
Add(items = new FillFlowContainer
|
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
RelativeSizeAxes = Axes.Both
|
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
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var g in Ladder.Groupings)
|
foreach (var g in Ladder.Groupings)
|
||||||
items.Add(new GroupingRow(g));
|
items.Add(new GroupingRow(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SaveChanges()
|
||||||
|
{
|
||||||
|
Ladder.Groupings = items.Children.Select(c => c.Grouping).ToList();
|
||||||
|
base.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addNew() => items.Add(new GroupingRow(new TournamentGrouping()));
|
||||||
|
|
||||||
public class GroupingRow : CompositeDrawable
|
public class GroupingRow : CompositeDrawable
|
||||||
{
|
{
|
||||||
public readonly TournamentGrouping Grouping;
|
public readonly TournamentGrouping Grouping;
|
||||||
@ -39,8 +64,15 @@ namespace osu.Game.Tournament.Tests
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsTextBox { Width = 0.4f, Bindable = Grouping.Name },
|
new SettingsTextBox { Width = 0.3f, Bindable = Grouping.Name },
|
||||||
new SettingsTextBox { Width = 0.4f, Bindable = Grouping.Description },
|
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()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
public readonly Bindable<string> Name = new Bindable<string>();
|
public readonly Bindable<string> Name = new Bindable<string>();
|
||||||
public readonly Bindable<string> Description = new Bindable<string>();
|
public readonly Bindable<string> Description = new Bindable<string>();
|
||||||
|
|
||||||
public int BestOf;
|
public readonly BindableInt BestOf = new BindableInt(9) { Default = 9, MinValue = 3, MaxValue = 23 };
|
||||||
|
|
||||||
public List<int> Pairings = new List<int>();
|
public List<int> Pairings = new List<int>();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user