1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 15:27:26 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs

118 lines
4.7 KiB
C#
Raw Normal View History

2016-10-14 03:10:00 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
2016-11-23 10:59:50 +08:00
using osu.Framework.Graphics.Colour;
2016-10-14 03:10:00 +08:00
using osu.Framework.Graphics.Containers;
2016-10-27 10:55:55 +08:00
using osu.Framework.Graphics.Primitives;
2016-10-14 03:10:00 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Database;
using osu.Game.Graphics;
2016-10-21 03:33:46 +08:00
using osu.Game.Graphics.UserInterface;
2016-10-27 10:55:55 +08:00
using OpenTK;
using OpenTK.Graphics;
2016-10-14 03:10:00 +08:00
2016-11-23 10:59:50 +08:00
namespace osu.Game.Beatmaps.Drawables
2016-10-14 03:10:00 +08:00
{
class BeatmapPanel : Panel
2016-10-14 03:10:00 +08:00
{
2016-10-26 22:52:04 +08:00
public BeatmapInfo Beatmap;
private Sprite background;
2016-10-14 03:10:00 +08:00
public Action<BeatmapPanel> GainedSelection;
protected override void Selected()
{
base.Selected();
GainedSelection?.Invoke(this);
background.ColourInfo = ColourInfo.GradientVertical(
new Color4(20, 43, 51, 255),
new Color4(40, 86, 102, 255));
}
protected override void Deselected()
{
base.Deselected();
background.Colour = new Color4(20, 43, 51, 255);
}
2016-10-20 04:37:42 +08:00
public BeatmapPanel(BeatmapInfo beatmap)
{
Beatmap = beatmap;
Height *= 0.60f;
2016-10-27 10:55:55 +08:00
Children = new Framework.Graphics.Drawable[]
2016-10-14 03:10:00 +08:00
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
new FlowContainer
{
Padding = new MarginPadding(5),
Direction = FlowDirection.HorizontalOnly,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
2016-10-27 10:55:55 +08:00
Children = new Framework.Graphics.Drawable[]
{
2016-11-07 16:58:32 +08:00
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255))
{
Scale = new Vector2(1.8f),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new FlowContainer
{
Padding = new MarginPadding { Left = 5 },
Spacing = new Vector2(0, 5),
2016-10-21 03:33:46 +08:00
Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both,
2016-10-27 10:55:55 +08:00
Children = new Framework.Graphics.Drawable[]
{
2016-10-21 03:33:46 +08:00
new FlowContainer
{
2016-10-21 03:33:46 +08:00
Direction = FlowDirection.HorizontalOnly,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(4, 0),
2016-10-21 03:33:46 +08:00
Children = new[]
{
new SpriteText
{
Font = @"Exo2.0-Medium",
2016-10-21 03:33:46 +08:00
Text = beatmap.Version,
TextSize = 20,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
2016-10-21 03:33:46 +08:00
},
new SpriteText
{
Font = @"Exo2.0-Medium",
Text = "mapped by",
2016-10-21 03:33:46 +08:00
TextSize = 16,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
},
new SpriteText
{
Font = @"Exo2.0-MediumItalic",
Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}",
TextSize = 16,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
2016-10-21 03:33:46 +08:00
},
}
},
2016-10-21 03:33:46 +08:00
new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 }
}
}
}
}
2016-10-14 03:10:00 +08:00
};
}
2016-10-14 03:10:00 +08:00
}
}