mirror of
https://github.com/ppy/osu.git
synced 2025-02-07 17:53:22 +08:00
add warning text on acronym conflict
This commit is contained in:
parent
dfbc93c3dc
commit
cbbcf54d74
@ -71,6 +71,8 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
[Resolved]
|
||||
private LadderInfo ladderInfo { get; set; } = null!;
|
||||
|
||||
private readonly SettingsTextBox acronymTextBox;
|
||||
|
||||
public TeamRow(TournamentTeam team, TournamentScreen parent)
|
||||
{
|
||||
Model = team;
|
||||
@ -112,7 +114,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
Width = 0.2f,
|
||||
Current = Model.FullName
|
||||
},
|
||||
new SettingsTextBox
|
||||
acronymTextBox = new SettingsTextBox
|
||||
{
|
||||
LabelText = "Acronym",
|
||||
Width = 0.2f,
|
||||
@ -177,6 +179,28 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Model.Acronym.BindValueChanged(acronym =>
|
||||
{
|
||||
var matchingTeams = ladderInfo.Teams
|
||||
.Where(t => t.Acronym.Value == acronym.NewValue && t != Model)
|
||||
.ToList();
|
||||
|
||||
if (matchingTeams.Count > 0)
|
||||
{
|
||||
acronymTextBox.SetNoticeText(
|
||||
$"Acronym '{acronym.NewValue}' is already in use by team{(matchingTeams.Count > 1 ? "s" : "")}:\n"
|
||||
+ $"{string.Join(",\n", matchingTeams)}", true);
|
||||
return;
|
||||
}
|
||||
|
||||
acronymTextBox.ClearNoticeText();
|
||||
}, true);
|
||||
}
|
||||
|
||||
private partial class LastYearPlacementSlider : RoundedSliderBar<int>
|
||||
{
|
||||
public override LocalisableString TooltipText => Current.Value == 0 ? "N/A" : base.TooltipText;
|
||||
|
Loading…
Reference in New Issue
Block a user