Add ability to load Drawings flags from osu/Drawings/Flags.

This commit is contained in:
smoogipooo 2017-05-02 13:23:09 +09:00
parent e856abe59a
commit f17046abaf
5 changed files with 38 additions and 15 deletions

@ -1 +1 @@
Subproject commit b25ed4291bb8a8a38faf404c68b3f97efc9d3413
Subproject commit a093c6cb70c145168ac359193e72176bf00ee20a

View File

@ -52,6 +52,12 @@ namespace osu.Game.Screens.Tournament
{
this.storage = storage;
// Todo: The way this is done is a haaaaaaaaaaaaaaack.
// Currently this store is being passed down all the way to ScrollingTeam/GroupTeam
// but it should replace the TextureStore DI item instead. This is pending some significant DI improvements.
TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(new StorageBackedResourceStore(storage), "Drawings")));
flagStore.AddStore(textures);
if (TeamList == null)
TeamList = new StorageBackedTeamList(storage);
@ -104,7 +110,7 @@ namespace osu.Game.Screens.Tournament
Lines = 6
},
// Groups
groupsContainer = new GroupContainer(drawingsConfig.Get<int>(DrawingsConfig.Groups), drawingsConfig.Get<int>(DrawingsConfig.TeamsPerGroup))
groupsContainer = new GroupContainer(drawingsConfig.Get<int>(DrawingsConfig.Groups), drawingsConfig.Get<int>(DrawingsConfig.TeamsPerGroup), flagStore)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
@ -119,7 +125,7 @@ namespace osu.Game.Screens.Tournament
}
},
// Scrolling teams
teamsContainer = new ScrollingTeamContainer
teamsContainer = new ScrollingTeamContainer(flagStore)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -73,9 +73,9 @@ namespace osu.Game.Screens.Tournament
};
}
public void AddTeam(Team team)
public void AddTeam(Team team, TextureStore flagStore)
{
GroupTeam gt = new GroupTeam(team);
GroupTeam gt = new GroupTeam(team, flagStore);
if (TeamsCount < 8)
{
@ -127,8 +127,12 @@ namespace osu.Game.Screens.Tournament
private readonly FillFlowContainer innerContainer;
private readonly Sprite flagSprite;
public GroupTeam(Team team)
private readonly TextureStore flagStore;
public GroupTeam(Team team, TextureStore flagStore)
{
this.flagStore = flagStore;
Team = team;
Width = 36;
@ -178,9 +182,9 @@ namespace osu.Game.Screens.Tournament
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
private void load()
{
flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}");
flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}");
}
}
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK;
using osu.Game.Screens.Tournament.Teams;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Screens.Tournament
{
@ -19,8 +20,12 @@ namespace osu.Game.Screens.Tournament
private readonly int maxTeams;
private int currentGroup;
public GroupContainer(int numGroups, int teamsPerGroup)
private readonly TextureStore flagStore;
public GroupContainer(int numGroups, int teamsPerGroup, TextureStore flagStore)
{
this.flagStore = flagStore;
FlowContainer<Group> bottomGroups;
FlowContainer<Group> topGroups;
@ -69,7 +74,7 @@ namespace osu.Game.Screens.Tournament
if (groups[currentGroup].TeamsCount == maxTeams)
return;
groups[currentGroup].AddTeam(team);
groups[currentGroup].AddTeam(team, flagStore);
currentGroup = (currentGroup + 1) % groups.Count;
}

View File

@ -39,8 +39,12 @@ namespace osu.Game.Screens.Tournament
private ScheduledDelegate delayedStateChangeDelegate;
public ScrollingTeamContainer()
private TextureStore flagStore;
public ScrollingTeamContainer(TextureStore flagStore)
{
this.flagStore = flagStore;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
@ -272,7 +276,7 @@ namespace osu.Game.Screens.Tournament
{
foreach (Team t in availableTeams)
{
Add(new ScrollingTeam(t)
Add(new ScrollingTeam(t, flagStore)
{
X = leftPos + DrawWidth
});
@ -340,8 +344,12 @@ namespace osu.Game.Screens.Tournament
}
}
public ScrollingTeam(Team team)
private TextureStore flagStore;
public ScrollingTeam(Team team, TextureStore flagStore)
{
this.flagStore = flagStore;
Team = team;
Anchor = Anchor.CentreLeft;
@ -371,9 +379,9 @@ namespace osu.Game.Screens.Tournament
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
private void load()
{
flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}");
flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}");
}
}
}