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

132 lines
3.8 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;
using osu.Framework.Allocation;
2017-08-24 08:30:10 +00:00
using osu.Framework.Extensions.Color4Extensions;
2017-05-17 19:37:34 +00:00
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2017-05-17 19:37:34 +00:00
using osu.Framework.Graphics.Sprites;
2017-07-26 04:22:46 +00:00
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
2017-05-17 19:37:34 +00:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
2017-08-24 08:30:10 +00:00
using OpenTK.Graphics;
2017-05-17 19:37:34 +00:00
namespace osu.Game.Overlays.Direct
{
public abstract class DirectPanel : Container
2017-05-17 19:37:34 +00:00
{
protected readonly BeatmapSetInfo SetInfo;
protected Box BlackBackground;
2017-05-19 22:50:45 +00:00
protected DirectPanel(BeatmapSetInfo setInfo)
{
SetInfo = setInfo;
2017-08-24 08:30:10 +00:00
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 3f,
Colour = Color4.Black.Opacity(0.25f),
};
}
[BackgroundDependencyLoader]
private void load()
{
AddRange(new[]
{
// temporary blackness until the actual background loads.
BlackBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
CreateBackground(),
});
}
2017-08-24 08:30:10 +00:00
protected override void LoadComplete()
{
base.LoadComplete();
this.FadeInFromZero(200, Easing.Out);
}
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-07-13 04:17:47 +00:00
protected Drawable CreateBackground() => new DelayedLoadWrapper(new BeatmapSetCover(SetInfo)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill,
OnLoadComplete = d =>
{
d.FadeInFromZero(400, Easing.Out);
BlackBackground.Delay(400).FadeOut();
},
})
{
RelativeSizeAxes = Axes.Both,
TimeBeforeLoad = 300
};
public class Statistic : FillFlowContainer
2017-05-17 19:37:34 +00:00
{
private readonly SpriteText text;
private int value;
2017-05-17 19:37:34 +00:00
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 SpriteIcon
2017-05-17 19:37:34 +00:00
{
Icon = icon,
Shadow = true,
Size = new Vector2(14),
2017-05-17 19:37:34 +00:00
Margin = new MarginPadding { Top = 1 },
},
};
Value = value;
}
}
}
}