1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 23:23:30 +08:00

Team -> Region, +IHasDrawableRepresentation, +Badge(placeholder for now), +Region to User, LeaderboardScoreDisplay -> LeaderboardScore

This commit is contained in:
DrabWeb 2017-03-13 09:33:25 -03:00
parent 5719c6656a
commit 9912f5f9e1
16 changed files with 183 additions and 98 deletions

View File

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

View File

@ -13,6 +13,7 @@ using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Modes;
using osu.Game.Users;
namespace osu.Desktop.VisualTests
{
@ -38,7 +39,12 @@ namespace osu.Desktop.VisualTests
{
Id = 2,
Username = @"peppy",
FlagName = @"AU",
Region = new Region
{
FullName = @"Australia",
Acronym = @"AUS",
FlagName = @"AU",
},
},
});
}

View File

@ -0,0 +1,12 @@
// 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.Framework.Graphics;
namespace osu.Game.Graphics.UserInterface
{
public interface IHasDrawableRepresentation<T> where T : Drawable
{
T CreateDrawable();
}
}

View File

@ -1,25 +1,18 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Colour;
using osu.Game.Graphics;
using osu.Game.Modes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Transforms;
namespace osu.Game.Screens.Select.Leaderboards
{
public class Leaderboard : Container
{
private ScrollContainer scrollContainer;
private FillFlowContainer<LeaderboardScoreDisplay> scrollFlow;
private FillFlowContainer<LeaderboardScore> scrollFlow;
private Score[] scores;
public Score[] Scores
@ -30,10 +23,10 @@ namespace osu.Game.Screens.Select.Leaderboards
if (value == scores) return;
scores = value;
var scoreDisplays = new List<LeaderboardScoreDisplay>();
var scoreDisplays = new List<LeaderboardScore>();
for (int i = 0; i < value.Length; i++)
{
scoreDisplays.Add(new LeaderboardScoreDisplay(value[i], i + 1));
scoreDisplays.Add(new LeaderboardScore(value[i], i + 1));
}
scrollFlow.Children = scoreDisplays;
@ -51,7 +44,7 @@ namespace osu.Game.Screens.Select.Leaderboards
ScrollDraggerVisible = false,
Children = new Drawable[]
{
scrollFlow = new FillFlowContainer<LeaderboardScoreDisplay>
scrollFlow = new FillFlowContainer<LeaderboardScore>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,

View File

@ -13,15 +13,16 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
using System.Linq;
namespace osu.Game.Screens.Select.Leaderboards
{
public class LeaderboardScoreDisplay : Container
public class LeaderboardScore : Container
{
private const float height = 70;
private const float corner_radius = 5;
private const float edge_margin = 10;
private const float background_opacity = 0.25f;
private const float background_alpha = 0.25f;
private const float score_letter_size = 20f;
private readonly EdgeEffect imageShadow = new EdgeEffect
@ -33,7 +34,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private Box background;
private Container content;
private Sprite avatar, flag;
private Sprite avatar;
private FillFlowContainer<ScoreModIcon> modsContainer;
private readonly int index;
@ -43,18 +44,17 @@ namespace osu.Game.Screens.Select.Leaderboards
private void load(TextureStore textures)
{
avatar.Texture = textures.Get($@"https://a.ppy.sh/{Score.User.Id}") ?? textures.Get(@"Online/avatar-guest");
flag.Texture = textures.Get($@"Flags/{Score.User.FlagName}");
}
protected override bool OnHover(Framework.Input.InputState state)
{
background.FadeColour(Color4.Black.Opacity(0.5f), 300, EasingTypes.OutQuint);
background.FadeTo(0.5f, 300, EasingTypes.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(Framework.Input.InputState state)
{
background.FadeColour(Color4.Black.Opacity(background_opacity), 200, EasingTypes.OutQuint);
background.FadeTo(background_alpha, 200, EasingTypes.OutQuint);
base.OnHoverLost(state);
}
@ -73,7 +73,7 @@ namespace osu.Game.Screens.Select.Leaderboards
});
}
public LeaderboardScoreDisplay(Score score, int i)
public LeaderboardScore(Score score, int i)
{
Score = score;
index = i;
@ -81,6 +81,10 @@ namespace osu.Game.Screens.Select.Leaderboards
RelativeSizeAxes = Axes.X;
Height = height;
var flag = Score.User.Region.CreateDrawable();
flag.Width = 30;
flag.RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
new Container
@ -115,7 +119,8 @@ namespace osu.Game.Screens.Select.Leaderboards
background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(background_opacity),
Colour = Color4.Black,
Alpha = background_alpha,
},
},
},
@ -167,18 +172,7 @@ namespace osu.Game.Screens.Select.Leaderboards
Masking = true,
Children = new Drawable[]
{
flag = new Sprite
{
RelativeSizeAxes = Axes.Y,
Width = 30f,
},
new Sprite
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
RelativeSizeAxes = Axes.Y,
Width = 50f,
},
flag,
},
},
new FillFlowContainer

View File

@ -21,6 +21,7 @@ using osu.Game.Screens.Tournament.Components;
using osu.Game.Screens.Tournament.Teams;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Users;
namespace osu.Game.Screens.Tournament
{
@ -36,7 +37,7 @@ namespace osu.Game.Screens.Tournament
private GroupContainer groupsContainer;
private OsuSpriteText fullTeamNameText;
private List<Team> allTeams = new List<Team>();
private List<Region> allTeams = new List<Region>();
private DrawingsConfigManager drawingsConfig;
@ -238,7 +239,7 @@ namespace osu.Game.Screens.Tournament
reset(true);
}
private void onTeamSelected(Team team)
private void onTeamSelected(Region team)
{
groupsContainer.AddTeam(team);
@ -278,13 +279,13 @@ namespace osu.Game.Screens.Tournament
teamsContainer.ClearTeams();
allTeams.Clear();
foreach (Team t in TeamList.Teams)
foreach (Region r in TeamList.Teams)
{
if (groupsContainer.ContainsTeam(t.FullName))
if (groupsContainer.ContainsTeam(r.FullName))
continue;
allTeams.Add(t);
teamsContainer.AddTeam(t);
allTeams.Add(r);
teamsContainer.AddTeam(r);
}
}
@ -314,7 +315,7 @@ namespace osu.Game.Screens.Tournament
if (line.ToUpper().StartsWith("GROUP"))
continue;
Team teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line);
Region teamToAdd = allTeams.FirstOrDefault(r => r.FullName == line);
if (teamToAdd == null)
continue;

View File

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

View File

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

View File

@ -12,18 +12,18 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Threading;
using osu.Game.Screens.Tournament.Teams;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Users;
namespace osu.Game.Screens.Tournament
{
public class ScrollingTeamContainer : Container
{
public event Action OnScrollStarted;
public event Action<Team> OnSelected;
public event Action<Region> OnSelected;
private readonly List<Team> availableTeams = new List<Team>();
private readonly List<Region> availableTeams = new List<Region>();
private Container tracker;
@ -151,7 +151,7 @@ namespace osu.Game.Screens.Tournament
}
}
public void AddTeam(Team team)
public void AddTeam(Region team)
{
if (availableTeams.Contains(team))
return;
@ -162,12 +162,12 @@ namespace osu.Game.Screens.Tournament
scrollState = ScrollState.Idle;
}
public void AddTeams(IEnumerable<Team> teams)
public void AddTeams(IEnumerable<Region> teams)
{
if (teams == null)
return;
foreach (Team t in teams)
foreach (Region t in teams)
AddTeam(t);
}
@ -178,7 +178,7 @@ namespace osu.Game.Screens.Tournament
scrollState = ScrollState.Idle;
}
public void RemoveTeam(Team team)
public void RemoveTeam(Region team)
{
availableTeams.Remove(team);
@ -319,7 +319,7 @@ namespace osu.Game.Screens.Tournament
public const float WIDTH = 58;
public const float HEIGHT = 41;
public Team Team;
public Region Team;
private Sprite flagSprite;
private Box outline;
@ -339,7 +339,7 @@ namespace osu.Game.Screens.Tournament
}
}
public ScrollingTeam(Team team)
public ScrollingTeam(Region team)
{
Team = team;

View File

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

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Users;
namespace osu.Game.Screens.Tournament.Teams
{
@ -20,11 +21,11 @@ namespace osu.Game.Screens.Tournament.Teams
this.storage = storage;
}
public IEnumerable<Team> Teams
public IEnumerable<Region> Teams
{
get
{
var teams = new List<Team>();
var teams = new List<Region>();
try
{
@ -52,7 +53,7 @@ namespace osu.Game.Screens.Tournament.Teams
string acronym = split.Length >= 3 ? split[2].Trim() : teamName;
acronym = acronym.Substring(0, Math.Min(3, acronym.Length));
teams.Add(new Team()
teams.Add(new Region()
{
FlagName = flagName,
FullName = teamName,

View File

@ -1,23 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Tournament.Teams
{
public class Team
{
/// <summary>
/// The name of this team.
/// </summary>
public string FullName;
/// <summary>
/// Short acronym which appears in the group boxes post-selection.
/// </summary>
public string Acronym;
/// <summary>
/// Two-letter flag acronym (ISO 3166 standard)
/// </summary>
public string FlagName;
}
}

23
osu.Game/Users/Badge.cs Normal file
View File

@ -0,0 +1,23 @@
// 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.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Users
{
public class Badge : IHasDrawableRepresentation<Sprite>
{
public string Name;
public Texture Texture; // TODO: Replace this with something better
public Sprite CreateDrawable()
{
return new Sprite
{
Texture = Texture,
};
}
}
}

73
osu.Game/Users/Region.cs Normal file
View File

@ -0,0 +1,73 @@
// 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.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Users
{
public class Region : IHasDrawableRepresentation<DrawableFlag>
{
/// <summary>
/// The name of this team.
/// </summary>
public string FullName;
/// <summary>
/// Short acronym which appears in the group boxes post-selection.
/// </summary>
public string Acronym;
/// <summary>
/// Two-letter flag acronym (ISO 3166 standard)
/// </summary>
public string FlagName;
public DrawableFlag CreateDrawable()
{
return new DrawableFlag(FlagName);
}
}
public class DrawableFlag : Container
{
private Sprite sprite;
private TextureStore textures;
private string flagName;
public string FlagName
{
get { return flagName; }
set
{
if (value == flagName) return;
flagName = value;
sprite.Texture = textures.Get($@"Flags/{flagName}");
}
}
[BackgroundDependencyLoader]
private void load(TextureStore ts)
{
textures = ts;
sprite.Texture = textures.Get($@"Flags/{flagName}");
}
public DrawableFlag(string name)
{
flagName = name;
Children = new Drawable[]
{
sprite = new Sprite
{
RelativeSizeAxes = Axes.Both,
},
};
}
}
}

View File

@ -1,16 +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 System.Collections.Generic;
namespace osu.Game.Users
{
public class User
{
public int Id;
public string Username;
/// <summary>
/// Two-letter flag acronym (ISO 3166 standard)
/// </summary>
public string FlagName;
public Region Region;
public IEnumerable<Badge> Badges;
}
}

View File

@ -217,7 +217,6 @@
<Compile Include="Screens\Tournament\GroupContainer.cs" />
<Compile Include="Screens\Tournament\Teams\ITeamList.cs" />
<Compile Include="Screens\Tournament\ScrollingTeamContainer.cs" />
<Compile Include="Screens\Tournament\Teams\Team.cs" />
<Compile Include="Screens\Tournament\Teams\StorageBackedTeamList.cs" />
<Compile Include="Users\User.cs" />
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
@ -311,7 +310,10 @@
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsRemoveFromUnplayedButton.cs" />
<Compile Include="Screens\Select\Leaderboards\Leaderboard.cs" />
<Compile Include="Screens\Select\Leaderboards\LeaderboardScoreDisplay.cs" />
<Compile Include="Screens\Select\Leaderboards\LeaderboardScore.cs" />
<Compile Include="Graphics\UserInterface\IHasDrawableRepresentation.cs" />
<Compile Include="Users\Region.cs" />
<Compile Include="Users\Badge.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">