mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Convert TournamentTeam props to use binadbles
This commit is contained in:
@ -30,7 +30,7 @@ namespace osu.Game.Tournament.Components
|
||||
|
||||
AcronymText = new OsuSpriteText
|
||||
{
|
||||
Text = team?.Acronym?.ToUpperInvariant() ?? string.Empty,
|
||||
Text = team?.Acronym.Value?.ToUpperInvariant() ?? string.Empty,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Regular),
|
||||
};
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tournament.Components
|
||||
@ -14,33 +14,38 @@ namespace osu.Game.Tournament.Components
|
||||
/// <summary>
|
||||
/// The name of this team.
|
||||
/// </summary>
|
||||
public string FullName;
|
||||
|
||||
private string flagName;
|
||||
public Bindable<string> FullName = new Bindable<string>(string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Name of the file containing the flag.
|
||||
/// </summary>
|
||||
public string FlagName
|
||||
{
|
||||
get => flagName ?? Acronym?.Substring(0, 2);
|
||||
set => flagName = value;
|
||||
}
|
||||
|
||||
private string acronym;
|
||||
public Bindable<string> FlagName = new Bindable<string>(string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Short acronym which appears in the group boxes post-selection.
|
||||
/// </summary>
|
||||
public string Acronym
|
||||
{
|
||||
get => acronym ?? FullName?.Substring(0, 3);
|
||||
set => acronym = value;
|
||||
}
|
||||
public Bindable<string> Acronym = new Bindable<string>(string.Empty);
|
||||
|
||||
[JsonProperty]
|
||||
public List<User> Players { get; set; } = new List<User>();
|
||||
public BindableList<User> Players { get; set; } = new BindableList<User>();
|
||||
|
||||
public override string ToString() => FullName ?? Acronym;
|
||||
public TournamentTeam()
|
||||
{
|
||||
Acronym.ValueChanged += val =>
|
||||
{
|
||||
// use a sane default flag name based on acronym.
|
||||
if (val.OldValue.StartsWith(FlagName.Value, StringComparison.InvariantCultureIgnoreCase))
|
||||
FlagName.Value = val.NewValue.Length >= 2 ? val.NewValue?.Substring(0, 2).ToUpper() : string.Empty;
|
||||
};
|
||||
|
||||
FullName.ValueChanged += val =>
|
||||
{
|
||||
// use a sane acronym based on full name.
|
||||
if (val.OldValue.StartsWith(Acronym.Value, StringComparison.InvariantCultureIgnoreCase))
|
||||
Acronym.Value = val.NewValue.Length >= 3 ? val.NewValue?.Substring(0, 3).ToUpper() : string.Empty;
|
||||
};
|
||||
}
|
||||
|
||||
public override string ToString() => FullName.Value ?? Acronym.Value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user