1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:43:21 +08:00

Let's not use Country for drawings-specific stuff...

This commit is contained in:
smoogipooo 2017-05-02 13:02:14 +09:00
parent 3604c3562a
commit e856abe59a
11 changed files with 54 additions and 46 deletions

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Screens.Tournament; using osu.Game.Screens.Tournament;
using osu.Game.Screens.Tournament.Teams; using osu.Game.Screens.Tournament.Teams;
using osu.Game.Users;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -25,57 +24,57 @@ namespace osu.Desktop.VisualTests.Tests
private class TestTeamList : ITeamList private class TestTeamList : ITeamList
{ {
public IEnumerable<Country> Teams { get; } = new[] public IEnumerable<Team> Teams { get; } = new[]
{ {
new Country new Team
{ {
FlagName = "GB", FlagName = "GB",
FullName = "United Kingdom", FullName = "United Kingdom",
Acronym = "UK" Acronym = "UK"
}, },
new Country new Team
{ {
FlagName = "FR", FlagName = "FR",
FullName = "France", FullName = "France",
Acronym = "FRA" Acronym = "FRA"
}, },
new Country new Team
{ {
FlagName = "CN", FlagName = "CN",
FullName = "China", FullName = "China",
Acronym = "CHN" Acronym = "CHN"
}, },
new Country new Team
{ {
FlagName = "AU", FlagName = "AU",
FullName = "Australia", FullName = "Australia",
Acronym = "AUS" Acronym = "AUS"
}, },
new Country new Team
{ {
FlagName = "JP", FlagName = "JP",
FullName = "Japan", FullName = "Japan",
Acronym = "JPN" Acronym = "JPN"
}, },
new Country new Team
{ {
FlagName = "RO", FlagName = "RO",
FullName = "Romania", FullName = "Romania",
Acronym = "ROM" Acronym = "ROM"
}, },
new Country new Team
{ {
FlagName = "IT", FlagName = "IT",
FullName = "Italy", FullName = "Italy",
Acronym = "PIZZA" Acronym = "PIZZA"
}, },
new Country new Team
{ {
FlagName = "VE", FlagName = "VE",
FullName = "Venezuela", FullName = "Venezuela",
Acronym = "VNZ" Acronym = "VNZ"
}, },
new Country new Team
{ {
FlagName = "US", FlagName = "US",
FullName = "United States of America", FullName = "United States of America",

View File

@ -21,7 +21,7 @@ using osu.Game.Screens.Tournament.Components;
using osu.Game.Screens.Tournament.Teams; using osu.Game.Screens.Tournament.Teams;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Users; using osu.Framework.IO.Stores;
namespace osu.Game.Screens.Tournament namespace osu.Game.Screens.Tournament
{ {
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Tournament
private GroupContainer groupsContainer; private GroupContainer groupsContainer;
private OsuSpriteText fullTeamNameText; private OsuSpriteText fullTeamNameText;
private readonly List<Country> allTeams = new List<Country>(); private readonly List<Team> allTeams = new List<Team>();
private DrawingsConfigManager drawingsConfig; private DrawingsConfigManager drawingsConfig;
@ -239,7 +239,7 @@ namespace osu.Game.Screens.Tournament
reset(true); reset(true);
} }
private void onTeamSelected(Country team) private void onTeamSelected(Team team)
{ {
groupsContainer.AddTeam(team); groupsContainer.AddTeam(team);
@ -276,7 +276,7 @@ namespace osu.Game.Screens.Tournament
teamsContainer.ClearTeams(); teamsContainer.ClearTeams();
allTeams.Clear(); allTeams.Clear();
foreach (Country t in TeamList.Teams) foreach (Team t in TeamList.Teams)
{ {
if (groupsContainer.ContainsTeam(t.FullName)) if (groupsContainer.ContainsTeam(t.FullName))
continue; continue;
@ -312,7 +312,7 @@ namespace osu.Game.Screens.Tournament
if (line.ToUpper().StartsWith("GROUP")) if (line.ToUpper().StartsWith("GROUP"))
continue; continue;
Country teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); Team teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line);
if (teamToAdd == null) if (teamToAdd == null)
continue; continue;

View File

@ -13,7 +13,7 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Users; using osu.Game.Screens.Tournament.Teams;
namespace osu.Game.Screens.Tournament namespace osu.Game.Screens.Tournament
{ {
@ -73,7 +73,7 @@ namespace osu.Game.Screens.Tournament
}; };
} }
public void AddTeam(Country team) public void AddTeam(Team team)
{ {
GroupTeam gt = new GroupTeam(team); GroupTeam gt = new GroupTeam(team);
@ -91,7 +91,7 @@ namespace osu.Game.Screens.Tournament
return allTeams.Any(t => t.Team.FullName == fullName); return allTeams.Any(t => t.Team.FullName == fullName);
} }
public bool RemoveTeam(Country team) public bool RemoveTeam(Team team)
{ {
allTeams.RemoveAll(gt => gt.Team == team); allTeams.RemoveAll(gt => gt.Team == team);
@ -122,12 +122,12 @@ namespace osu.Game.Screens.Tournament
private class GroupTeam : Container private class GroupTeam : Container
{ {
public readonly Country Team; public readonly Team Team;
private readonly FillFlowContainer innerContainer; private readonly FillFlowContainer innerContainer;
private readonly Sprite flagSprite; private readonly Sprite flagSprite;
public GroupTeam(Country team) public GroupTeam(Team team)
{ {
Team = team; Team = team;

View File

@ -8,7 +8,7 @@ using System.Text;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using OpenTK; using OpenTK;
using osu.Game.Users; using osu.Game.Screens.Tournament.Teams;
namespace osu.Game.Screens.Tournament namespace osu.Game.Screens.Tournament
{ {
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Tournament
} }
} }
public void AddTeam(Country team) public void AddTeam(Team team)
{ {
if (groups[currentGroup].TeamsCount == maxTeams) if (groups[currentGroup].TeamsCount == maxTeams)
return; return;

View File

@ -15,16 +15,16 @@ using osu.Framework.Graphics.Transforms;
using osu.Framework.Threading; using osu.Framework.Threading;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Users; using osu.Game.Screens.Tournament.Teams;
namespace osu.Game.Screens.Tournament namespace osu.Game.Screens.Tournament
{ {
public class ScrollingTeamContainer : Container public class ScrollingTeamContainer : Container
{ {
public event Action OnScrollStarted; public event Action OnScrollStarted;
public event Action<Country> OnSelected; public event Action<Team> OnSelected;
private readonly List<Country> availableTeams = new List<Country>(); private readonly List<Team> availableTeams = new List<Team>();
private readonly Container tracker; private readonly Container tracker;
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Tournament
} }
} }
public void AddTeam(Country team) public void AddTeam(Team team)
{ {
if (availableTeams.Contains(team)) if (availableTeams.Contains(team))
return; return;
@ -169,12 +169,12 @@ namespace osu.Game.Screens.Tournament
scrollState = ScrollState.Idle; scrollState = ScrollState.Idle;
} }
public void AddTeams(IEnumerable<Country> teams) public void AddTeams(IEnumerable<Team> teams)
{ {
if (teams == null) if (teams == null)
return; return;
foreach (Country t in teams) foreach (Team t in teams)
AddTeam(t); AddTeam(t);
} }
@ -185,7 +185,7 @@ namespace osu.Game.Screens.Tournament
scrollState = ScrollState.Idle; scrollState = ScrollState.Idle;
} }
public void RemoveTeam(Country team) public void RemoveTeam(Team team)
{ {
availableTeams.Remove(team); availableTeams.Remove(team);
@ -270,7 +270,7 @@ namespace osu.Game.Screens.Tournament
private void addFlags() private void addFlags()
{ {
foreach (Country t in availableTeams) foreach (Team t in availableTeams)
{ {
Add(new ScrollingTeam(t) Add(new ScrollingTeam(t)
{ {
@ -320,7 +320,7 @@ namespace osu.Game.Screens.Tournament
public const float WIDTH = 58; public const float WIDTH = 58;
public const float HEIGHT = 41; public const float HEIGHT = 41;
public Country Team; public Team Team;
private readonly Sprite flagSprite; private readonly Sprite flagSprite;
private readonly Box outline; private readonly Box outline;
@ -340,7 +340,7 @@ namespace osu.Game.Screens.Tournament
} }
} }
public ScrollingTeam(Country team) public ScrollingTeam(Team team)
{ {
Team = team; Team = team;

View File

@ -2,12 +2,11 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Users;
namespace osu.Game.Screens.Tournament.Teams namespace osu.Game.Screens.Tournament.Teams
{ {
public interface ITeamList public interface ITeamList
{ {
IEnumerable<Country> Teams { get; } IEnumerable<Team> Teams { get; }
} }
} }

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Users;
namespace osu.Game.Screens.Tournament.Teams namespace osu.Game.Screens.Tournament.Teams
{ {
@ -21,16 +20,16 @@ namespace osu.Game.Screens.Tournament.Teams
this.storage = storage; this.storage = storage;
} }
public IEnumerable<Country> Teams public IEnumerable<Team> Teams
{ {
get get
{ {
var teams = new List<Country>(); var teams = new List<Team>();
try try
{ {
using (Stream stream = storage.GetStream(teams_filename, FileAccess.Read, FileMode.Open)) using (Stream stream = storage.GetStream(teams_filename, FileAccess.Read, FileMode.Open))
using (StreamReader sr = new StreamReader(stream)) using (var sr = new StreamReader(stream))
{ {
while (sr.Peek() != -1) while (sr.Peek() != -1)
{ {
@ -53,7 +52,7 @@ namespace osu.Game.Screens.Tournament.Teams
string acronym = split.Length >= 3 ? split[2].Trim() : teamName; string acronym = split.Length >= 3 ? split[2].Trim() : teamName;
acronym = acronym.Substring(0, Math.Min(3, acronym.Length)); acronym = acronym.Substring(0, Math.Min(3, acronym.Length));
teams.Add(new Country teams.Add(new Team
{ {
FlagName = flagName, FlagName = flagName,
FullName = teamName, FullName = teamName,

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Users;
namespace osu.Game.Screens.Tournament.Teams
{
public class Team : Country
{
/// <summary>
/// Short acronym which appears in the group boxes post-selection.
/// </summary>
public string Acronym;
}
}

View File

@ -18,11 +18,6 @@ namespace osu.Game.Users
[JsonProperty(@"name")] [JsonProperty(@"name")]
public string FullName; public string FullName;
/// <summary>
/// Short acronym which appears in the group boxes post-selection.
/// </summary>
public string Acronym;
/// <summary> /// <summary>
/// Two-letter flag acronym (ISO 3166 standard) /// Two-letter flag acronym (ISO 3166 standard)
/// </summary> /// </summary>

View File

@ -3,7 +3,7 @@
namespace osu.Game.Users namespace osu.Game.Users
{ {
public class Team public class Team : Country
{ {
public string Name; public string Name;
} }

View File

@ -325,6 +325,7 @@
<Compile Include="Screens\Tournament\Teams\ITeamList.cs" /> <Compile Include="Screens\Tournament\Teams\ITeamList.cs" />
<Compile Include="Screens\Tournament\ScrollingTeamContainer.cs" /> <Compile Include="Screens\Tournament\ScrollingTeamContainer.cs" />
<Compile Include="Screens\Tournament\Teams\StorageBackedTeamList.cs" /> <Compile Include="Screens\Tournament\Teams\StorageBackedTeamList.cs" />
<Compile Include="Screens\Tournament\Teams\Team.cs" />
<Compile Include="Users\UpdateableAvatar.cs" /> <Compile Include="Users\UpdateableAvatar.cs" />
<Compile Include="Users\User.cs" /> <Compile Include="Users\User.cs" />
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" /> <Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />