2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-03-04 12:24:19 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-10-13 18:45:59 +08:00
|
|
|
|
|
2019-06-18 15:10:23 +08:00
|
|
|
|
using System.Linq;
|
2018-10-16 14:20:12 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
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-18 15:10:23 +08:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2021-10-27 16:22:23 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2023-07-21 06:28:31 +08:00
|
|
|
|
using osu.Game.Overlays;
|
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;
|
2019-06-18 13:51:48 +08:00
|
|
|
|
using osu.Game.Tournament.Models;
|
2023-07-21 06:28:31 +08:00
|
|
|
|
using osu.Game.Tournament.Screens.Editors.Components;
|
2019-06-14 16:08:44 +08:00
|
|
|
|
using osuTK;
|
2018-10-13 06:10:13 +08:00
|
|
|
|
|
2019-06-18 13:51:48 +08:00
|
|
|
|
namespace osu.Game.Tournament.Screens.Editors
|
2018-10-13 06:10:13 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class RoundEditorScreen : TournamentEditorScreen<RoundEditorScreen.RoundRow, TournamentRound>
|
2018-10-13 06:10:13 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
protected override BindableList<TournamentRound> Storage => LadderInfo.Rounds;
|
2018-10-14 00:03:04 +08:00
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class RoundRow : CompositeDrawable, IModelBacked<TournamentRound>
|
2018-10-13 06:10:13 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
public TournamentRound Model { get; }
|
2018-10-13 06:10:13 +08:00
|
|
|
|
|
2019-06-14 19:30:09 +08:00
|
|
|
|
[Resolved]
|
2023-06-23 00:37:25 +08:00
|
|
|
|
private LadderInfo ladderInfo { get; set; } = null!;
|
2019-06-14 19:30:09 +08:00
|
|
|
|
|
2023-07-22 03:18:49 +08:00
|
|
|
|
[Resolved]
|
2023-07-21 06:28:31 +08:00
|
|
|
|
private IDialogOverlay? dialogOverlay { get; set; }
|
|
|
|
|
|
2019-06-18 13:44:15 +08:00
|
|
|
|
public RoundRow(TournamentRound round)
|
2018-10-13 06:10:13 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
Model = round;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = 10;
|
|
|
|
|
|
|
|
|
|
RoundBeatmapEditor beatmapEditor = new RoundBeatmapEditor(round)
|
|
|
|
|
{
|
|
|
|
|
Width = 0.95f
|
|
|
|
|
};
|
|
|
|
|
|
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,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.Name
|
2019-06-14 16:08:44 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsTextBox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Description",
|
|
|
|
|
Width = 0.33f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.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,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.StartDate
|
2019-06-14 16:08:44 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsSlider<int>
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Best of",
|
|
|
|
|
Width = 0.33f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.BestOf
|
2018-10-14 00:03:04 +08:00
|
|
|
|
},
|
2019-06-18 15:10:23 +08:00
|
|
|
|
new SettingsButton
|
|
|
|
|
{
|
|
|
|
|
Width = 0.2f,
|
|
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
|
Text = "Add beatmap",
|
|
|
|
|
Action = () => beatmapEditor.CreateNew()
|
|
|
|
|
},
|
|
|
|
|
beatmapEditor
|
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,
|
2019-06-18 14:53:03 +08:00
|
|
|
|
Text = "Delete Round",
|
2023-07-22 03:17:14 +08:00
|
|
|
|
Action = () => dialogOverlay?.Push(new DeleteRoundDialog(Model, () =>
|
|
|
|
|
{
|
|
|
|
|
Expire();
|
|
|
|
|
ladderInfo.Rounds.Remove(Model);
|
|
|
|
|
}))
|
2018-10-13 06:10:13 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-11-17 11:04:19 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
}
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class RoundBeatmapEditor : CompositeDrawable
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly TournamentRound round;
|
|
|
|
|
private readonly FillFlowContainer flow;
|
|
|
|
|
|
|
|
|
|
public RoundBeatmapEditor(TournamentRound round)
|
|
|
|
|
{
|
|
|
|
|
this.round = round;
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
InternalChild = flow = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
ChildrenEnumerable = round.Beatmaps.Select(p => new RoundBeatmapRow(round, p))
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateNew()
|
|
|
|
|
{
|
|
|
|
|
var user = new RoundBeatmap();
|
|
|
|
|
round.Beatmaps.Add(user);
|
|
|
|
|
flow.Add(new RoundBeatmapRow(round, user));
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class RoundBeatmapRow : CompositeDrawable
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
public RoundBeatmap Model { get; }
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
2023-06-23 00:37:25 +08:00
|
|
|
|
protected IAPIProvider API { get; private set; } = null!;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
2021-06-28 11:00:07 +08:00
|
|
|
|
private readonly Bindable<int?> beatmapId = new Bindable<int?>();
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
2021-10-08 12:55:20 +08:00
|
|
|
|
private readonly Bindable<string> mods = new Bindable<string>(string.Empty);
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
|
|
|
|
private readonly Container drawableContainer;
|
|
|
|
|
|
|
|
|
|
public RoundBeatmapRow(TournamentRound team, RoundBeatmap beatmap)
|
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
Model = beatmap;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
|
|
|
|
Margin = new MarginPadding(10);
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = 5;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = OsuColour.Gray(0.2f),
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding(5),
|
|
|
|
|
Padding = new MarginPadding { Right = 160 },
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-06-21 21:04:34 +08:00
|
|
|
|
new SettingsNumberBox
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
|
|
|
|
LabelText = "Beatmap ID",
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Width = 200,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = beatmapId,
|
2019-06-18 15:10:23 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsTextBox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Mods",
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Width = 200,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = mods,
|
2019-06-18 15:10:23 +08:00
|
|
|
|
},
|
|
|
|
|
drawableContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(100, 70),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new DangerousSettingsButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Width = 150,
|
|
|
|
|
Text = "Delete Beatmap",
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
Expire();
|
|
|
|
|
team.Beatmaps.Remove(beatmap);
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
|
private void load()
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
2021-06-28 11:00:07 +08:00
|
|
|
|
beatmapId.Value = Model.ID;
|
2021-06-28 14:23:19 +08:00
|
|
|
|
beatmapId.BindValueChanged(id =>
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
2021-06-28 14:23:19 +08:00
|
|
|
|
Model.ID = id.NewValue ?? 0;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
2021-06-28 14:23:19 +08:00
|
|
|
|
if (id.NewValue != id.OldValue)
|
2021-10-27 17:25:23 +08:00
|
|
|
|
Model.Beatmap = null;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
2021-10-27 17:25:23 +08:00
|
|
|
|
if (Model.Beatmap != null)
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
|
|
|
|
updatePanel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 16:22:23 +08:00
|
|
|
|
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = Model.ID });
|
2019-06-18 15:10:23 +08:00
|
|
|
|
|
|
|
|
|
req.Success += res =>
|
|
|
|
|
{
|
2022-06-18 06:34:09 +08:00
|
|
|
|
Model.Beatmap = new TournamentBeatmap(res);
|
2019-06-18 15:10:23 +08:00
|
|
|
|
updatePanel();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
req.Failure += _ =>
|
|
|
|
|
{
|
2021-10-27 17:25:23 +08:00
|
|
|
|
Model.Beatmap = null;
|
2019-06-18 15:10:23 +08:00
|
|
|
|
updatePanel();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
API.Queue(req);
|
|
|
|
|
}, true);
|
|
|
|
|
|
2019-06-18 16:59:33 +08:00
|
|
|
|
mods.Value = Model.Mods;
|
|
|
|
|
mods.BindValueChanged(modString => Model.Mods = modString.NewValue);
|
2019-06-18 15:10:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-07 18:03:56 +08:00
|
|
|
|
private void updatePanel() => Schedule(() =>
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
|
|
|
|
drawableContainer.Clear();
|
|
|
|
|
|
2021-10-27 17:25:23 +08:00
|
|
|
|
if (Model.Beatmap != null)
|
2019-11-11 19:53:22 +08:00
|
|
|
|
{
|
2021-10-27 17:25:23 +08:00
|
|
|
|
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap, Model.Mods)
|
2019-06-18 15:10:23 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Width = 300
|
|
|
|
|
};
|
2019-11-11 19:53:22 +08:00
|
|
|
|
}
|
2022-11-07 18:03:56 +08:00
|
|
|
|
});
|
2019-06-18 15:10:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-17 11:04:19 +08:00
|
|
|
|
}
|
2019-06-18 16:59:33 +08:00
|
|
|
|
|
|
|
|
|
protected override RoundRow CreateDrawable(TournamentRound model) => new RoundRow(model);
|
2018-11-17 11:04:19 +08:00
|
|
|
|
}
|
2018-10-13 06:10:13 +08:00
|
|
|
|
}
|