1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-16 00:13:12 +08:00
osu-lazer/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs
2017-03-15 14:42:56 +09:00

65 lines
1.9 KiB
C#

// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Game.Modes;
namespace osu.Game.Screens.Select.Leaderboards
{
public class Leaderboard : Container
{
private ScrollContainer scrollContainer;
private FillFlowContainer<LeaderboardScore> scrollFlow;
private IEnumerable<Score> scores;
public IEnumerable<Score> Scores
{
get { return scores; }
set
{
scores = value;
scrollFlow.Clear();
if (scores == null)
return;
int i = 0;
foreach(var s in scores)
{
scrollFlow.Add(new LeaderboardScore(s, i + 1));
i++;
}
scrollContainer.ScrollTo(0f, false);
}
}
public Leaderboard()
{
Children = new Drawable[]
{
scrollContainer = new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollDraggerVisible = false,
Children = new Drawable[]
{
scrollFlow = new FillFlowContainer<LeaderboardScore>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(0f, 5f),
Padding = new MarginPadding(5),
},
},
},
};
}
}
}