2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-06-14 19:32:02 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-07-16 10:16:59 +08:00
|
|
|
|
using System;
|
2019-06-18 16:59:33 +08:00
|
|
|
|
using System.Collections.Generic;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
using System.Linq;
|
2019-06-14 19:32:02 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-06-17 15:28:58 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-07-16 10:16:59 +08:00
|
|
|
|
using osu.Framework.Extensions;
|
2019-06-14 19:32:02 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
2023-07-21 06:28:31 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-06-14 19:32:02 +08:00
|
|
|
|
using osu.Game.Overlays.Settings;
|
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;
|
2023-07-20 18:02:36 +08:00
|
|
|
|
using osu.Game.Tournament.Screens.Drawings.Components;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
using osu.Game.Users;
|
2019-06-14 19:32:02 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
|
2019-06-18 13:51:48 +08:00
|
|
|
|
namespace osu.Game.Tournament.Screens.Editors
|
2019-06-14 19:32:02 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class TeamEditorScreen : TournamentEditorScreen<TeamEditorScreen.TeamRow, TournamentTeam>
|
2019-06-14 19:32:02 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
protected override BindableList<TournamentTeam> Storage => LadderInfo.Teams;
|
|
|
|
|
|
2019-06-14 19:32:02 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2019-11-08 16:00:47 +08:00
|
|
|
|
ControlPanel.Add(new TourneyButton
|
2019-06-18 16:59:33 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Text = "Add all countries",
|
|
|
|
|
Action = addAllCountries
|
|
|
|
|
});
|
2019-06-14 19:32:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 18:50:56 +08:00
|
|
|
|
protected override TeamRow CreateDrawable(TournamentTeam model) => new TeamRow(model, this);
|
2019-06-18 16:59:33 +08:00
|
|
|
|
|
|
|
|
|
private void addAllCountries()
|
2019-06-14 19:32:02 +08:00
|
|
|
|
{
|
2022-07-16 10:16:59 +08:00
|
|
|
|
var countries = new List<TournamentTeam>();
|
2021-03-30 08:00:09 +08:00
|
|
|
|
|
2022-12-27 03:36:39 +08:00
|
|
|
|
foreach (var country in Enum.GetValues<CountryCode>().Skip(1))
|
2022-07-16 10:16:59 +08:00
|
|
|
|
{
|
|
|
|
|
countries.Add(new TournamentTeam
|
|
|
|
|
{
|
|
|
|
|
FlagName = { Value = country.ToString() },
|
|
|
|
|
FullName = { Value = country.GetDescription() },
|
|
|
|
|
Acronym = { Value = country.GetAcronym() },
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-06-14 19:32:02 +08:00
|
|
|
|
|
2021-03-30 08:03:32 +08:00
|
|
|
|
foreach (var c in countries)
|
|
|
|
|
Storage.Add(c);
|
2019-06-14 19:32:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class TeamRow : CompositeDrawable, IModelBacked<TournamentTeam>
|
2019-06-14 19:32:02 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
public TournamentTeam Model { get; }
|
2019-06-14 19:32:02 +08:00
|
|
|
|
|
2023-06-23 00:37:25 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private TournamentSceneManager? sceneManager { get; set; }
|
2020-03-03 17:12:42 +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-14 19:32:02 +08:00
|
|
|
|
[Resolved]
|
2023-06-23 00:37:25 +08:00
|
|
|
|
private LadderInfo ladderInfo { get; set; } = null!;
|
2019-06-14 19:32:02 +08:00
|
|
|
|
|
2020-05-16 18:50:56 +08:00
|
|
|
|
public TeamRow(TournamentTeam team, TournamentScreen parent)
|
2019-06-14 19:32:02 +08:00
|
|
|
|
{
|
2019-06-18 16:59:33 +08:00
|
|
|
|
Model = team;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = 10;
|
2019-06-14 19:32:02 +08:00
|
|
|
|
|
2023-07-20 18:02:36 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
2023-07-20 18:28:43 +08:00
|
|
|
|
PlayerEditor playerEditor = new PlayerEditor(Model);
|
2019-06-17 15:28:58 +08:00
|
|
|
|
|
2019-06-14 19:32:02 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2023-07-20 18:02:36 +08:00
|
|
|
|
new GroupTeam(team)
|
2019-06-17 19:59:17 +08:00
|
|
|
|
{
|
2023-07-20 18:28:43 +08:00
|
|
|
|
Margin = new MarginPadding(16),
|
|
|
|
|
Scale = new Vector2(2),
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
},
|
2019-06-14 19:32:02 +08:00
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Spacing = new Vector2(5),
|
2023-07-20 18:28:43 +08:00
|
|
|
|
Padding = new MarginPadding(10),
|
2019-06-14 19:32:02 +08:00
|
|
|
|
Direction = FillDirection.Full,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SettingsTextBox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Name",
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Width = 0.2f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.FullName
|
2019-06-14 19:32:02 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsTextBox
|
|
|
|
|
{
|
2019-06-17 15:28:58 +08:00
|
|
|
|
LabelText = "Acronym",
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Width = 0.2f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.Acronym
|
2019-06-14 19:32:02 +08:00
|
|
|
|
},
|
2019-06-17 15:28:58 +08:00
|
|
|
|
new SettingsTextBox
|
2019-06-14 19:32:02 +08:00
|
|
|
|
{
|
2019-06-17 15:28:58 +08:00
|
|
|
|
LabelText = "Flag",
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Width = 0.2f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.FlagName
|
2019-06-14 19:32:02 +08:00
|
|
|
|
},
|
2020-03-03 17:12:42 +08:00
|
|
|
|
new SettingsTextBox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Seed",
|
|
|
|
|
Width = 0.2f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.Seed
|
2020-03-03 17:12:42 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsSlider<int>
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Last Year Placement",
|
|
|
|
|
Width = 0.33f,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = Model.LastYearPlacing
|
2020-03-03 17:12:42 +08:00
|
|
|
|
},
|
2019-06-17 19:47:45 +08:00
|
|
|
|
new SettingsButton
|
|
|
|
|
{
|
2023-07-20 18:02:36 +08:00
|
|
|
|
Width = 0.2f,
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Margin = new MarginPadding(10),
|
2023-07-20 18:28:43 +08:00
|
|
|
|
Text = "Edit seeding results",
|
2019-06-17 19:47:45 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2023-07-20 18:28:43 +08:00
|
|
|
|
sceneManager?.SetScreen(new SeedingEditorScreen(team, parent));
|
|
|
|
|
}
|
2019-06-17 19:59:17 +08:00
|
|
|
|
},
|
2020-03-03 17:12:42 +08:00
|
|
|
|
playerEditor,
|
|
|
|
|
new SettingsButton
|
|
|
|
|
{
|
2019-06-17 19:47:45 +08:00
|
|
|
|
Text = "Add player",
|
2019-06-18 15:10:23 +08:00
|
|
|
|
Action = () => playerEditor.CreateNew()
|
2019-06-17 19:47:45 +08:00
|
|
|
|
},
|
2023-07-20 18:28:43 +08:00
|
|
|
|
new Container
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2023-07-20 18:28:43 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
2020-03-03 17:12:42 +08:00
|
|
|
|
{
|
2023-07-20 18:28:43 +08:00
|
|
|
|
new DangerousSettingsButton
|
|
|
|
|
{
|
|
|
|
|
Width = 0.2f,
|
|
|
|
|
Text = "Delete Team",
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2023-07-22 03:17:14 +08:00
|
|
|
|
Action = () => dialogOverlay?.Push(new DeleteTeamDialog(Model, () =>
|
2023-07-21 06:28:31 +08:00
|
|
|
|
{
|
|
|
|
|
Expire();
|
|
|
|
|
ladderInfo.Teams.Remove(Model);
|
2023-07-22 03:13:42 +08:00
|
|
|
|
})),
|
2023-07-20 18:28:43 +08:00
|
|
|
|
},
|
2020-03-03 17:12:42 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-06-17 19:47:45 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-06-14 19:32:02 +08:00
|
|
|
|
};
|
2019-06-17 15:28:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class PlayerEditor : CompositeDrawable
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly TournamentTeam team;
|
|
|
|
|
private readonly FillFlowContainer flow;
|
|
|
|
|
|
|
|
|
|
public PlayerEditor(TournamentTeam team)
|
|
|
|
|
{
|
|
|
|
|
this.team = team;
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
InternalChild = flow = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2023-07-20 18:28:43 +08:00
|
|
|
|
Padding = new MarginPadding(5),
|
|
|
|
|
Spacing = new Vector2(5),
|
2019-06-17 19:47:45 +08:00
|
|
|
|
ChildrenEnumerable = team.Players.Select(p => new PlayerRow(team, p))
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 15:10:23 +08:00
|
|
|
|
public void CreateNew()
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
var player = new TournamentUser();
|
2022-06-18 02:03:33 +08:00
|
|
|
|
team.Players.Add(player);
|
|
|
|
|
flow.Add(new PlayerRow(team, player));
|
2019-06-17 19:47:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class PlayerRow : CompositeDrawable
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
private readonly TournamentUser user;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
2019-11-11 16:39:48 +08:00
|
|
|
|
[Resolved]
|
2023-06-23 00:37:25 +08:00
|
|
|
|
private TournamentGameBase game { get; set; } = null!;
|
2019-11-11 16:39:48 +08:00
|
|
|
|
|
2022-06-18 02:03:33 +08:00
|
|
|
|
private readonly Bindable<int?> playerId = new Bindable<int?>();
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
2023-07-20 18:02:36 +08:00
|
|
|
|
private readonly Container userPanelContainer;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
2022-06-18 07:33:26 +08:00
|
|
|
|
public PlayerRow(TournamentTeam team, TournamentUser user)
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
this.user = user;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
2019-06-17 19:59:17 +08:00
|
|
|
|
Masking = true;
|
2023-07-20 18:02:36 +08:00
|
|
|
|
CornerRadius = 10;
|
2019-06-17 19:59:17 +08:00
|
|
|
|
|
2019-06-17 19:47:45 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2019-06-17 19:59:17 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = OsuColour.Gray(0.2f),
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2019-06-17 19:47:45 +08:00
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding(5),
|
2023-07-20 18:02:36 +08:00
|
|
|
|
Padding = new MarginPadding { Right = 60 },
|
2019-06-17 19:47:45 +08:00
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2023-07-20 18:02:36 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2019-06-17 19:47:45 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-06-21 21:04:34 +08:00
|
|
|
|
new SettingsNumberBox
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
|
|
|
|
LabelText = "User ID",
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Width = 200,
|
2022-06-18 02:03:33 +08:00
|
|
|
|
Current = playerId,
|
2019-06-17 19:47:45 +08:00
|
|
|
|
},
|
2023-07-20 18:02:36 +08:00
|
|
|
|
userPanelContainer = new Container
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2023-07-20 18:28:43 +08:00
|
|
|
|
Width = 400,
|
2023-07-20 18:02:36 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2019-06-17 19:47:45 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new DangerousSettingsButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Width = 150,
|
|
|
|
|
Text = "Delete Player",
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
Expire();
|
2022-06-18 07:33:26 +08:00
|
|
|
|
team.Players.Remove(user);
|
2019-06-17 19:47:45 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
playerId.Value = user.OnlineID;
|
2022-06-18 02:03:33 +08:00
|
|
|
|
playerId.BindValueChanged(id =>
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2022-06-18 07:33:26 +08:00
|
|
|
|
user.OnlineID = id.NewValue ?? 0;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
2021-06-28 14:23:19 +08:00
|
|
|
|
if (id.NewValue != id.OldValue)
|
2022-06-18 07:33:26 +08:00
|
|
|
|
user.Username = string.Empty;
|
2019-06-17 19:47:45 +08:00
|
|
|
|
|
2022-06-18 07:33:26 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(user.Username))
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
|
|
|
|
updatePanel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-18 07:33:26 +08:00
|
|
|
|
game.PopulatePlayer(user, updatePanel, updatePanel);
|
2019-06-17 19:47:45 +08:00
|
|
|
|
}, true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-12 11:59:55 +08:00
|
|
|
|
private void updatePanel() => Scheduler.AddOnce(() =>
|
2019-06-17 19:47:45 +08:00
|
|
|
|
{
|
2023-07-20 18:02:36 +08:00
|
|
|
|
userPanelContainer.Child = new UserListPanel(user.ToAPIUser())
|
|
|
|
|
{
|
2023-07-21 14:46:14 +08:00
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Scale = new Vector2(1f),
|
2023-07-20 18:02:36 +08:00
|
|
|
|
};
|
2022-07-12 11:59:55 +08:00
|
|
|
|
});
|
2019-06-17 19:47:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-14 19:32:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|