1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 08:07:26 +08:00
osu-lazer/osu.Game/Overlays/Direct/DirectPanel.cs

89 lines
2.6 KiB
C#
Raw Normal View History

2017-05-20 07:34:51 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
2017-05-18 03:37:34 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
2017-05-18 03:37:34 +08:00
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Database;
2017-05-18 03:37:34 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Direct
{
public abstract class DirectPanel : Container
2017-05-18 03:37:34 +08:00
{
protected readonly BeatmapSetInfo SetInfo;
2017-05-20 06:50:45 +08:00
protected DirectPanel(BeatmapSetInfo setInfo)
{
SetInfo = setInfo;
}
protected IEnumerable<DifficultyIcon> GetDifficultyIcons()
{
var icons = new List<DifficultyIcon>();
2017-05-20 06:22:42 +08:00
foreach (var b in SetInfo.Beatmaps)
icons.Add(new DifficultyIcon(b));
2017-05-20 06:27:51 +08:00
return icons;
}
2017-05-20 06:27:51 +08:00
protected Drawable GetBackground(TextureStore textures)
{
return new AsyncLoadWrapper(new Sprite
{
FillMode = FillMode.Fill,
Texture = new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null).Background,
}) { RelativeSizeAxes = Axes.Both };
}
public class Statistic : FillFlowContainer
2017-05-18 03:37:34 +08:00
{
private readonly SpriteText text;
private int value;
public int Value
{
get { return value; }
set
{
this.value = value;
2017-05-20 07:13:59 +08:00
text.Text = string.Format(@"{0:n0}", Value);
2017-05-18 03:37:34 +08:00
}
}
public Statistic(FontAwesome icon, int value = 0)
{
Anchor = Anchor.TopRight;
Origin = Anchor.TopRight;
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
Spacing = new Vector2(5f, 0f);
Children = new Drawable[]
{
text = new OsuSpriteText
{
Font = @"Exo2.0-SemiBoldItalic",
},
new TextAwesome
{
Icon = icon,
Shadow = true,
TextSize = 14,
Margin = new MarginPadding { Top = 1 },
},
};
Value = value;
}
}
}
}