2019-03-04 12:24:19 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-10-13 18:45:59 +08:00
|
|
|
|
2018-11-16 19:30:12 +08:00
|
|
|
using System;
|
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-11-17 11:04:19 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
2019-06-14 16:08:44 +08:00
|
|
|
using osu.Game.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;
|
2018-11-17 13:05:22 +08:00
|
|
|
using osu.Game.Tournament.Components;
|
2018-10-13 06:10:13 +08:00
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
2019-06-14 16:08:44 +08:00
|
|
|
using osuTK;
|
2018-10-13 06:10:13 +08:00
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
namespace osu.Game.Tournament.Screens.Rounds
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
2019-06-18 13:44:15 +08:00
|
|
|
public class RoundEditorScreen : TournamentScreen, IProvideVideo
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
2019-06-18 13:44:15 +08:00
|
|
|
private readonly FillFlowContainer<RoundRow> items;
|
2018-10-14 00:03:04 +08:00
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
public RoundEditorScreen()
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
2019-02-02 17:29:20 +08:00
|
|
|
AddRangeInternal(new Drawable[]
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
2018-11-17 11:04:19 +08:00
|
|
|
new Box
|
2018-10-14 00:03:04 +08:00
|
|
|
{
|
2018-11-17 11:04:19 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.Gray(0.2f),
|
|
|
|
},
|
2019-06-14 16:08:44 +08:00
|
|
|
new OsuScrollContainer
|
2018-11-17 11:04:19 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.9f,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2019-06-18 13:44:15 +08:00
|
|
|
Child = items = new FillFlowContainer<RoundRow>
|
2019-06-14 16:08:44 +08:00
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2019-06-17 19:47:45 +08:00
|
|
|
LayoutDuration = 200,
|
|
|
|
LayoutEasing = Easing.OutQuint,
|
2019-06-14 16:08:44 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
new ControlPanel
|
|
|
|
{
|
2018-11-17 11:04:19 +08:00
|
|
|
Children = new Drawable[]
|
2018-10-14 00:03:04 +08:00
|
|
|
{
|
2018-11-17 11:04:19 +08:00
|
|
|
new TriangleButton
|
|
|
|
{
|
2019-06-14 16:08:44 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Add new",
|
2018-11-17 11:04:19 +08:00
|
|
|
Action = addNew
|
|
|
|
},
|
|
|
|
}
|
2018-10-14 00:03:04 +08:00
|
|
|
}
|
2018-10-13 06:10:13 +08:00
|
|
|
});
|
2018-10-16 14:20:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2019-06-18 13:44:15 +08:00
|
|
|
foreach (var r in LadderInfo.Rounds)
|
|
|
|
items.Add(new RoundRow(r));
|
2018-10-13 06:10:13 +08:00
|
|
|
}
|
|
|
|
|
2018-11-16 19:30:12 +08:00
|
|
|
private void addNew()
|
2018-10-14 00:03:04 +08:00
|
|
|
{
|
2019-06-18 13:44:15 +08:00
|
|
|
var round = new TournamentRound
|
2019-06-14 16:08:44 +08:00
|
|
|
{
|
|
|
|
StartDate =
|
|
|
|
{
|
|
|
|
Value = DateTimeOffset.UtcNow
|
|
|
|
}
|
2019-06-14 19:30:09 +08:00
|
|
|
};
|
2019-06-14 16:56:47 +08:00
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
items.Add(new RoundRow(round));
|
|
|
|
LadderInfo.Rounds.Add(round);
|
2018-11-16 19:30:12 +08:00
|
|
|
}
|
2018-10-14 00:03:04 +08:00
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
public class RoundRow : CompositeDrawable
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
2019-06-18 13:44:15 +08:00
|
|
|
public readonly TournamentRound Round;
|
2018-10-13 06:10:13 +08:00
|
|
|
|
2019-06-14 19:30:09 +08:00
|
|
|
[Resolved]
|
|
|
|
private LadderInfo ladderInfo { get; set; }
|
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
public RoundRow(TournamentRound round)
|
2018-10-13 06:10:13 +08:00
|
|
|
{
|
2019-06-14 16:08:44 +08:00
|
|
|
Margin = new MarginPadding(10);
|
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
Round = round;
|
2018-10-13 06:10:13 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2019-06-14 16:08:44 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2018-10-13 06:10:13 +08:00
|
|
|
new FillFlowContainer
|
|
|
|
{
|
2019-06-14 16:08:44 +08:00
|
|
|
Margin = new MarginPadding(5),
|
|
|
|
Padding = new MarginPadding { Right = 160 },
|
|
|
|
Spacing = new Vector2(5),
|
2018-11-17 11:04:19 +08:00
|
|
|
Direction = FillDirection.Full,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-10-13 06:10:13 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2019-06-14 16:08:44 +08:00
|
|
|
new SettingsTextBox
|
|
|
|
{
|
|
|
|
LabelText = "Name",
|
|
|
|
Width = 0.33f,
|
2019-06-18 13:44:15 +08:00
|
|
|
Bindable = Round.Name
|
2019-06-14 16:08:44 +08:00
|
|
|
},
|
|
|
|
new SettingsTextBox
|
|
|
|
{
|
|
|
|
LabelText = "Description",
|
|
|
|
Width = 0.33f,
|
2019-06-18 13:44:15 +08:00
|
|
|
Bindable = Round.Description
|
2019-06-14 16:08:44 +08:00
|
|
|
},
|
|
|
|
new DateTextBox
|
2018-10-14 00:03:04 +08:00
|
|
|
{
|
2019-06-14 16:08:44 +08:00
|
|
|
LabelText = "Start Time",
|
|
|
|
Width = 0.33f,
|
2019-06-18 13:44:15 +08:00
|
|
|
Bindable = Round.StartDate
|
2019-06-14 16:08:44 +08:00
|
|
|
},
|
|
|
|
new SettingsSlider<int>
|
|
|
|
{
|
|
|
|
LabelText = "Best of",
|
|
|
|
Width = 0.33f,
|
2019-06-18 13:44:15 +08:00
|
|
|
Bindable = Round.BestOf
|
2018-10-14 00:03:04 +08:00
|
|
|
},
|
2018-10-13 06:10:13 +08:00
|
|
|
}
|
2019-06-14 16:08:44 +08:00
|
|
|
},
|
|
|
|
new DangerousSettingsButton
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
Width = 150,
|
|
|
|
Text = "Delete",
|
|
|
|
Action = () =>
|
|
|
|
{
|
|
|
|
Expire();
|
2019-06-18 13:44:15 +08:00
|
|
|
ladderInfo.Rounds.Remove(Round);
|
2019-06-14 16:08:44 +08:00
|
|
|
},
|
2018-10-13 06:10:13 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-11-17 11:04:19 +08:00
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-13 06:10:13 +08:00
|
|
|
}
|