diff --git a/.idea/.idea.osu/.idea/runConfigurations/VisualTests.xml b/.idea/.idea.osu/.idea/runConfigurations/VisualTests.xml
index 95cb4c0e62..34a83af3a1 100644
--- a/.idea/.idea.osu/.idea/runConfigurations/VisualTests.xml
+++ b/.idea/.idea.osu/.idea/runConfigurations/VisualTests.xml
@@ -6,12 +6,15 @@
+
-
-
+
+
+
+
\ No newline at end of file
diff --git a/osu.Game.Tournament.Tests/TestSceneMatchChatDisplay.cs b/osu.Game.Tournament.Tests/TestSceneMatchChatDisplay.cs
index fb31cd0f7c..4fccb2996b 100644
--- a/osu.Game.Tournament.Tests/TestSceneMatchChatDisplay.cs
+++ b/osu.Game.Tournament.Tests/TestSceneMatchChatDisplay.cs
@@ -1,8 +1,8 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System.Collections.Generic;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Online.Chat;
using osu.Game.Tests.Visual;
@@ -58,11 +58,11 @@ namespace osu.Game.Tournament.Tests
{
Team1 =
{
- Value = new TournamentTeam { Players = new List { redUser } }
+ Value = new TournamentTeam { Players = new BindableList { redUser } }
},
Team2 =
{
- Value = new TournamentTeam { Players = new List { blueUser } }
+ Value = new TournamentTeam { Players = new BindableList { blueUser } }
}
};
diff --git a/osu.Game.Tournament.Tests/TestSceneMatchPairings.cs b/osu.Game.Tournament.Tests/TestSceneMatchPairings.cs
index 4d92e209be..611e87717a 100644
--- a/osu.Game.Tournament.Tests/TestSceneMatchPairings.cs
+++ b/osu.Game.Tournament.Tests/TestSceneMatchPairings.cs
@@ -27,8 +27,8 @@ namespace osu.Game.Tournament.Tests
Container level2;
var pairing1 = new MatchPairing(
- new TournamentTeam { FlagName = "AU", FullName = "Australia", },
- new TournamentTeam { FlagName = "JP", FullName = "Japan", Acronym = "JPN" })
+ new TournamentTeam { FlagName = { Value = "AU" }, FullName = { Value = "Australia" }, },
+ new TournamentTeam { FlagName = { Value = "JP" }, FullName = { Value = "Japan" }, Acronym = { Value = "JPN" } })
{
Team1Score = { Value = 4 },
Team2Score = { Value = 1 },
@@ -37,8 +37,8 @@ namespace osu.Game.Tournament.Tests
var pairing2 = new MatchPairing(
new TournamentTeam
{
- FlagName = "RO",
- FullName = "Romania",
+ FlagName = { Value = "RO" },
+ FullName = { Value = "Romania" },
}
);
@@ -77,7 +77,7 @@ namespace osu.Game.Tournament.Tests
level1.Children[1].Pairing.Progression.Value = level2.Children[0].Pairing;
AddRepeatStep("change scores", () => pairing1.Team2Score.Value++, 4);
- AddStep("add new team", () => pairing2.Team2.Value = new TournamentTeam { FlagName = "PT", FullName = "Portugal" });
+ AddStep("add new team", () => pairing2.Team2.Value = new TournamentTeam { FlagName = { Value = "PT" }, FullName = { Value = "Portugal" } });
AddStep("Add progression", () => level1.Children[2].Pairing.Progression.Value = level2.Children[1].Pairing);
AddStep("start match", () => pairing2.StartMatch());
diff --git a/osu.Game.Tournament.Tests/TestSceneTeamIntro.cs b/osu.Game.Tournament.Tests/TestSceneTeamIntro.cs
index b9245c0c25..7d10923949 100644
--- a/osu.Game.Tournament.Tests/TestSceneTeamIntro.cs
+++ b/osu.Game.Tournament.Tests/TestSceneTeamIntro.cs
@@ -19,8 +19,8 @@ namespace osu.Game.Tournament.Tests
private void load()
{
var pairing = new MatchPairing();
- pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA");
- pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN");
+ pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
+ pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
pairing.Grouping.Value = Ladder.Groupings.FirstOrDefault(g => g.Name.Value == "Finals");
currentMatch.Value = pairing;
diff --git a/osu.Game.Tournament.Tests/TestSceneTeamWin.cs b/osu.Game.Tournament.Tests/TestSceneTeamWin.cs
index 3d6813b8d6..1ef81b7550 100644
--- a/osu.Game.Tournament.Tests/TestSceneTeamWin.cs
+++ b/osu.Game.Tournament.Tests/TestSceneTeamWin.cs
@@ -19,8 +19,8 @@ namespace osu.Game.Tournament.Tests
private void load()
{
var pairing = new MatchPairing();
- pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA");
- pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN");
+ pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
+ pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
pairing.Grouping.Value = Ladder.Groupings.FirstOrDefault(g => g.Name.Value == "Finals");
currentMatch.Value = pairing;
diff --git a/osu.Game.Tournament/Components/DrawableTournamentTeam.cs b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
index 8662eeba2d..8fb166f129 100644
--- a/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
+++ b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
@@ -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),
};
}
diff --git a/osu.Game.Tournament/Components/TournamentTeam.cs b/osu.Game.Tournament/Components/TournamentTeam.cs
index 167f77c229..043dcc7084 100644
--- a/osu.Game.Tournament/Components/TournamentTeam.cs
+++ b/osu.Game.Tournament/Components/TournamentTeam.cs
@@ -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
///
/// The name of this team.
///
- public string FullName;
-
- private string flagName;
+ public Bindable FullName = new Bindable(string.Empty);
///
/// Name of the file containing the flag.
///
- public string FlagName
- {
- get => flagName ?? Acronym?.Substring(0, 2);
- set => flagName = value;
- }
-
- private string acronym;
+ public Bindable FlagName = new Bindable(string.Empty);
///
/// Short acronym which appears in the group boxes post-selection.
///
- public string Acronym
- {
- get => acronym ?? FullName?.Substring(0, 3);
- set => acronym = value;
- }
+ public Bindable Acronym = new Bindable(string.Empty);
[JsonProperty]
- public List Players { get; set; } = new List();
+ public BindableList Players { get; set; } = new BindableList();
- 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;
}
}
diff --git a/osu.Game.Tournament/Screens/Drawings/Components/Group.cs b/osu.Game.Tournament/Screens/Drawings/Components/Group.cs
index 50e413afea..adeead277c 100644
--- a/osu.Game.Tournament/Screens/Drawings/Components/Group.cs
+++ b/osu.Game.Tournament/Screens/Drawings/Components/Group.cs
@@ -85,7 +85,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
public bool ContainsTeam(string fullName)
{
- return allTeams.Any(t => t.Team.FullName == fullName);
+ return allTeams.Any(t => t.Team.FullName.Value == fullName);
}
public bool RemoveTeam(TournamentTeam team)
@@ -113,7 +113,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{
StringBuilder sb = new StringBuilder();
foreach (GroupTeam gt in allTeams)
- sb.AppendLine(gt.Team.FullName);
+ sb.AppendLine(gt.Team.FullName.Value);
return sb.ToString();
}
@@ -132,7 +132,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
AcronymText.Anchor = Anchor.TopCentre;
AcronymText.Origin = Anchor.TopCentre;
- AcronymText.Text = team.Acronym.ToUpperInvariant();
+ AcronymText.Text = team.Acronym.Value.ToUpperInvariant();
AcronymText.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 10);
InternalChildren = new Drawable[]
diff --git a/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs b/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs
index 3aafb73503..ca3536965f 100644
--- a/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs
+++ b/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs
@@ -50,9 +50,9 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
teams.Add(new TournamentTeam
{
- FullName = split[1].Trim(),
- Acronym = split.Length >= 3 ? split[2].Trim() : null,
- FlagName = split[0].Trim()
+ FullName = { Value = split[1].Trim(), },
+ Acronym = { Value = split.Length >= 3 ? split[2].Trim() : null, },
+ FlagName = { Value = split[0].Trim() }
});
}
}
diff --git a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
index 9f51ace78d..2ef7f513b6 100644
--- a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
+++ b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs
@@ -169,7 +169,7 @@ namespace osu.Game.Tournament.Screens.Drawings
{
groupsContainer.AddTeam(team);
- fullTeamNameText.Text = team.FullName;
+ fullTeamNameText.Text = team.FullName.Value;
fullTeamNameText.FadeIn(200);
writeResults(groupsContainer.GetStringRepresentation());
@@ -204,7 +204,7 @@ namespace osu.Game.Tournament.Screens.Drawings
foreach (TournamentTeam t in TeamList.Teams)
{
- if (groupsContainer.ContainsTeam(t.FullName))
+ if (groupsContainer.ContainsTeam(t.FullName.Value))
continue;
allTeams.Add(t);
@@ -240,7 +240,7 @@ namespace osu.Game.Tournament.Screens.Drawings
continue;
// ReSharper disable once AccessToModifiedClosure
- TournamentTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line);
+ TournamentTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName.Value == line);
if (teamToAdd == null)
continue;
diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs b/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs
index f9ec16c357..c921967836 100644
--- a/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs
@@ -172,7 +172,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
Flag,
new OsuSpriteText
{
- Text = team?.FullName.ToUpper() ?? "???",
+ Text = team?.FullName.Value.ToUpper() ?? "???",
X = (flip ? -1 : 1) * 90,
Y = -10,
Colour = colour,
diff --git a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs
index 7d6b7ae57f..78eb1063e0 100644
--- a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs
+++ b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs
@@ -89,8 +89,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
editorInfo.Selected.ValueChanged += selection =>
{
- textboxTeam1.Text = selection.NewValue?.Team1.Value?.Acronym;
- textboxTeam2.Text = selection.NewValue?.Team2.Value?.Acronym;
+ textboxTeam1.Text = selection.NewValue?.Team1.Value?.Acronym.Value;
+ textboxTeam2.Text = selection.NewValue?.Team2.Value?.Acronym.Value;
groupingDropdown.Bindable.Value = selection.NewValue?.Grouping.Value;
losersCheckbox.Current.Value = selection.NewValue?.Losers.Value ?? false;
dateTimeBox.Bindable.Value = selection.NewValue?.Date.Value ?? DateTimeOffset.UtcNow;
@@ -99,13 +99,13 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
textboxTeam1.OnCommit = (val, newText) =>
{
if (newText && editorInfo.Selected.Value != null)
- editorInfo.Selected.Value.Team1.Value = teamEntries.FirstOrDefault(t => t.Acronym == val.Text);
+ editorInfo.Selected.Value.Team1.Value = teamEntries.FirstOrDefault(t => t.Acronym.Value == val.Text);
};
textboxTeam2.OnCommit = (val, newText) =>
{
if (newText && editorInfo.Selected.Value != null)
- editorInfo.Selected.Value.Team2.Value = teamEntries.FirstOrDefault(t => t.Acronym == val.Text);
+ editorInfo.Selected.Value.Team2.Value = teamEntries.FirstOrDefault(t => t.Acronym.Value == val.Text);
};
groupingDropdown.Bindable.ValueChanged += grouping =>
diff --git a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs
index 043ade4285..f80263e41a 100644
--- a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs
+++ b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs
@@ -73,8 +73,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
public MatchPairing()
{
- Team1.BindValueChanged(t => Team1Acronym = t.NewValue?.Acronym, true);
- Team2.BindValueChanged(t => Team2Acronym = t.NewValue?.Acronym, true);
+ Team1.BindValueChanged(t => Team1Acronym = t.NewValue?.Acronym.Value, true);
+ Team2.BindValueChanged(t => Team2Acronym = t.NewValue?.Acronym.Value, true);
}
public MatchPairing(TournamentTeam team1 = null, TournamentTeam team2 = null)
diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
index 1efe667eaa..1e08b4add5 100644
--- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
@@ -199,7 +199,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Flag,
new OsuSpriteText
{
- Text = team?.FullName.ToUpper() ?? "???",
+ Text = team?.FullName.Value.ToUpper() ?? "???",
Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 40, FontWeight.Light),
Colour = Color4.Black,
Origin = Anchor.TopCentre,
diff --git a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
index 6d5f7e7ad5..d73ec8fca6 100644
--- a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
@@ -203,7 +203,7 @@ namespace osu.Game.Tournament.Screens.TeamWin
Flag,
new OsuSpriteText
{
- Text = team?.FullName.ToUpper() ?? "???",
+ Text = team?.FullName.Value.ToUpper() ?? "???",
Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 40, FontWeight.Light),
Colour = Color4.Black,
Origin = Anchor.TopCentre,
diff --git a/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs b/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs
index b2392e5dc0..0027ea94db 100644
--- a/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs
+++ b/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs
@@ -1,8 +1,8 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@@ -11,7 +11,6 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components;
-using osu.Game.Tournament.Screens.Ladder.Components;
using osuTK;
namespace osu.Game.Tournament.Screens.Teams
@@ -66,13 +65,7 @@ namespace osu.Game.Tournament.Screens.Teams
private void addNew()
{
- var team = new TournamentTeam
- {
- StartDate =
- {
- Value = DateTimeOffset.UtcNow
- }
- };
+ var team = new TournamentTeam();
items.Add(new TeamRow(team));
LadderInfo.Teams.Add(team);
@@ -82,6 +75,8 @@ namespace osu.Game.Tournament.Screens.Teams
{
public readonly TournamentTeam Team;
+ private readonly Container drawableContainer;
+
[Resolved]
private LadderInfo ladderInfo { get; set; }
@@ -90,6 +85,7 @@ namespace osu.Game.Tournament.Screens.Teams
Margin = new MarginPadding(10);
Team = team;
+
InternalChildren = new Drawable[]
{
new Box
@@ -110,26 +106,26 @@ namespace osu.Game.Tournament.Screens.Teams
new SettingsTextBox
{
LabelText = "Name",
- Width = 0.33f,
+ Width = 0.25f,
+ Bindable = Team.FullName
+ },
+ new SettingsTextBox
+ {
+ LabelText = "Acronym",
+ Width = 0.25f,
Bindable = Team.Acronym
},
new SettingsTextBox
{
- LabelText = "Description",
- Width = 0.33f,
- Bindable = Team.Description
+ LabelText = "Flag",
+ Width = 0.25f,
+ Bindable = Team.FlagName
},
- new DateTextBox
+ drawableContainer = new Container
{
- LabelText = "Start Time",
- Width = 0.33f,
- Bindable = Team.StartDate
- },
- new SettingsSlider
- {
- LabelText = "Best of",
- Width = 0.33f,
- Bindable = Team.BestOf
+ Width = 0.22f,
+ RelativeSizeAxes = Axes.X,
+ Height = 50,
},
}
},
@@ -150,6 +146,26 @@ namespace osu.Game.Tournament.Screens.Teams
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
+
+ Team.FlagName.BindValueChanged(updateDrawable, true);
+ }
+
+ private void updateDrawable(ValueChangedEvent flag)
+ {
+ drawableContainer.Child = new RowTeam(Team);
+ }
+
+ private class RowTeam : DrawableTournamentTeam
+ {
+ public RowTeam(TournamentTeam team)
+ : base(team)
+ {
+ InternalChild = Flag;
+ RelativeSizeAxes = Axes.Both;
+
+ Flag.Anchor = Anchor.Centre;
+ Flag.Origin = Anchor.Centre;
+ }
}
}
}
diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs
index 54d47625fa..e9e2d0f054 100644
--- a/osu.Game.Tournament/TournamentGameBase.cs
+++ b/osu.Game.Tournament/TournamentGameBase.cs
@@ -100,13 +100,13 @@ namespace osu.Game.Tournament
// assign teams
foreach (var pairing in ladder.Pairings)
{
- pairing.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team1Acronym);
- pairing.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team2Acronym);
+ pairing.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == pairing.Team1Acronym);
+ pairing.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == pairing.Team2Acronym);
foreach (var conditional in pairing.ConditionalPairings)
{
- conditional.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym == conditional.Team1Acronym);
- conditional.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym == conditional.Team2Acronym);
+ conditional.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team1Acronym);
+ conditional.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team2Acronym);
conditional.Grouping.Value = pairing.Grouping.Value;
}
}
@@ -207,7 +207,7 @@ namespace osu.Game.Tournament
foreach (var t in ladder.Teams)
{
- if (!string.IsNullOrEmpty(t.FullName))
+ if (!string.IsNullOrEmpty(t.FullName.Value))
continue;
var result = countries.FirstOrDefault(c => c.Acronym == t.Acronym);