osu/osu.Game/Overlays/Direct/DirectPanel.cs

111 lines
3.5 KiB
C#
Raw Normal View History

2017-05-19 23:34:51 +00:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
2017-05-17 19:37:34 +00:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
2017-05-17 19:37:34 +00:00
using OpenTK;
using osu.Framework.Allocation;
2017-05-17 19:37:34 +00:00
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-17 19:37:34 +00:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Direct
{
public abstract class DirectPanel : Container
2017-05-17 19:37:34 +00:00
{
protected readonly BeatmapSetInfo SetInfo;
2017-05-19 22:50:45 +00:00
protected DirectPanel(BeatmapSetInfo setInfo)
{
SetInfo = setInfo;
}
protected List<DifficultyIcon> GetDifficultyIcons()
{
var icons = new List<DifficultyIcon>();
2017-05-19 22:22:42 +00:00
foreach (var b in SetInfo.Beatmaps)
icons.Add(new DifficultyIcon(b));
2017-05-19 22:27:51 +00:00
return icons;
}
2017-05-19 22:27:51 +00:00
2017-06-07 15:15:11 +00:00
protected Drawable GetBackground(TextureStore textures, bool doubleSize)
{
return new DelayedLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize)
{
2017-06-07 12:45:12 +00:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill,
2017-05-19 23:53:51 +00:00
OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out),
}) { RelativeSizeAxes = Axes.Both, TimeBeforeLoad = 300 };
}
public class Statistic : FillFlowContainer
2017-05-17 19:37:34 +00:00
{
private readonly SpriteText text;
private int value;
public int Value
{
get { return value; }
set
{
this.value = value;
text.Text = Value.ToString(@"N0");
2017-05-17 19:37:34 +00: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;
}
}
private class BeatmapSetBackgroundSprite : Sprite
{
private readonly BeatmapSetInfo set;
2017-06-07 15:15:11 +00:00
private readonly bool doubleSize;
2017-06-07 15:15:11 +00:00
public BeatmapSetBackgroundSprite(BeatmapSetInfo set, bool doubleSize)
{
this.set = set;
2017-06-07 15:15:11 +00:00
this.doubleSize = doubleSize;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
if (set.OnlineInfo?.Covers?.Card != null)
2017-07-11 04:42:51 +00:00
Texture = textures.Get(doubleSize ? set.OnlineInfo.Covers.Card2X : set.OnlineInfo.Covers.Card);
}
}
2017-05-17 19:37:34 +00:00
}
}