1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 15:33:22 +08:00

Merge pull request #31553 from ILW8/add-tourney-acronym-warning

add warning text on team acronym conflict
This commit is contained in:
Dean Herbert 2025-01-20 15:55:37 +09:00 committed by GitHub
commit da6954762a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,6 +71,8 @@ namespace osu.Game.Tournament.Screens.Editors
[Resolved] [Resolved]
private LadderInfo ladderInfo { get; set; } = null!; private LadderInfo ladderInfo { get; set; } = null!;
private readonly SettingsTextBox acronymTextBox;
public TeamRow(TournamentTeam team, TournamentScreen parent) public TeamRow(TournamentTeam team, TournamentScreen parent)
{ {
Model = team; Model = team;
@ -112,7 +114,7 @@ namespace osu.Game.Tournament.Screens.Editors
Width = 0.2f, Width = 0.2f,
Current = Model.FullName Current = Model.FullName
}, },
new SettingsTextBox acronymTextBox = new SettingsTextBox
{ {
LabelText = "Acronym", LabelText = "Acronym",
Width = 0.2f, Width = 0.2f,
@ -177,6 +179,27 @@ namespace osu.Game.Tournament.Screens.Editors
}; };
} }
protected override void LoadComplete()
{
base.LoadComplete();
Model.Acronym.BindValueChanged(acronym =>
{
var teamsWithSameAcronym = ladderInfo.Teams
.Where(t => t.Acronym.Value == acronym.NewValue && t != Model)
.ToList();
if (teamsWithSameAcronym.Count > 0)
{
acronymTextBox.SetNoticeText(
$"Acronym '{acronym.NewValue}' is already in use by team{(teamsWithSameAcronym.Count > 1 ? "s" : "")}:\n"
+ $"{string.Join(",\n", teamsWithSameAcronym)}", true);
}
else
acronymTextBox.ClearNoticeText();
}, true);
}
private partial class LastYearPlacementSlider : RoundedSliderBar<int> private partial class LastYearPlacementSlider : RoundedSliderBar<int>
{ {
public override LocalisableString TooltipText => Current.Value == 0 ? "N/A" : base.TooltipText; public override LocalisableString TooltipText => Current.Value == 0 ? "N/A" : base.TooltipText;