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;
|
2016-11-26 16:10:13 +08:00
|
|
|
using osu.Framework.Allocation;
|
2016-10-14 03:10:00 +08:00
|
|
|
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;
|
2016-11-26 16:10:13 +08:00
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Framework.MathUtils;
|
2016-10-14 03:10:00 +08:00
|
|
|
using osu.Game.Database;
|
2016-10-14 06:15:43 +08:00
|
|
|
using osu.Game.Graphics;
|
2016-12-01 17:53:13 +08:00
|
|
|
using osu.Game.Graphics.Backgrounds;
|
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-12-18 15:59:13 +08:00
|
|
|
using osu.Framework.Input;
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-10-27 18:52:48 +08:00
|
|
|
class BeatmapPanel : Panel
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-10-26 22:52:04 +08:00
|
|
|
public BeatmapInfo Beatmap;
|
2016-11-21 03:34:16 +08:00
|
|
|
private Sprite background;
|
2016-10-14 03:10:00 +08:00
|
|
|
|
2016-10-27 18:52:48 +08:00
|
|
|
public Action<BeatmapPanel> GainedSelection;
|
2016-12-18 15:59:13 +08:00
|
|
|
public Action<BeatmapPanel> StartRequested;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
2016-11-26 16:10:13 +08:00
|
|
|
Color4 deselectedColour = new Color4(20, 43, 51, 255);
|
|
|
|
|
2016-10-27 18:52:48 +08:00
|
|
|
protected override void Selected()
|
|
|
|
{
|
|
|
|
base.Selected();
|
|
|
|
GainedSelection?.Invoke(this);
|
2016-11-21 03:34:16 +08:00
|
|
|
|
|
|
|
background.ColourInfo = ColourInfo.GradientVertical(
|
|
|
|
new Color4(20, 43, 51, 255),
|
|
|
|
new Color4(40, 86, 102, 255));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Deselected()
|
|
|
|
{
|
|
|
|
base.Deselected();
|
|
|
|
|
2016-11-26 16:10:13 +08:00
|
|
|
background.Colour = deselectedColour;
|
2016-10-21 03:16:06 +08:00
|
|
|
}
|
2016-10-20 04:37:42 +08:00
|
|
|
|
2016-12-18 15:59:13 +08:00
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
{
|
|
|
|
if (State == PanelSelectedState.Selected)
|
|
|
|
StartRequested?.Invoke(this);
|
|
|
|
|
|
|
|
return base.OnClick(state);
|
|
|
|
}
|
|
|
|
|
2016-10-28 22:27:59 +08:00
|
|
|
public BeatmapPanel(BeatmapInfo beatmap)
|
2016-10-27 18:52:48 +08:00
|
|
|
{
|
|
|
|
Beatmap = beatmap;
|
2016-11-04 17:08:43 +08:00
|
|
|
Height *= 0.60f;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
2016-11-26 16:10:13 +08:00
|
|
|
Children = new Drawable[]
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-11-21 03:34:16 +08:00
|
|
|
background = new Box
|
2016-10-14 06:15:43 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2016-11-26 16:10:13 +08:00
|
|
|
new Triangles
|
|
|
|
{
|
2016-11-27 18:49:51 +08:00
|
|
|
// The border is drawn in the shader of the children. Being additive, triangles would over-emphasize
|
|
|
|
// the border wherever they cross it, and thus they get their own masking container without a border.
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = Content.CornerRadius,
|
2016-11-26 16:10:13 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
|
|
|
Colour = deselectedColour,
|
|
|
|
},
|
2016-10-14 06:15:43 +08:00
|
|
|
new FlowContainer
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding(5),
|
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
2016-10-24 21:58:51 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-11-04 17:08:43 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2016-11-26 16:10:13 +08:00
|
|
|
Children = new Drawable[]
|
2016-10-14 06:15:43 +08:00
|
|
|
{
|
2016-11-07 16:58:32 +08:00
|
|
|
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255))
|
2016-11-04 17:08:43 +08:00
|
|
|
{
|
|
|
|
Scale = new Vector2(1.8f),
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
2016-10-14 06:15:43 +08:00
|
|
|
new FlowContainer
|
|
|
|
{
|
2016-11-04 17:08:43 +08:00
|
|
|
Padding = new MarginPadding { Left = 5 },
|
|
|
|
Spacing = new Vector2(0, 5),
|
2016-10-21 03:33:46 +08:00
|
|
|
Direction = FlowDirection.VerticalOnly,
|
2016-10-24 21:58:51 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-11-26 16:10:13 +08:00
|
|
|
Children = new Drawable[]
|
2016-10-14 06:15:43 +08:00
|
|
|
{
|
2016-10-21 03:33:46 +08:00
|
|
|
new FlowContainer
|
2016-10-14 06:15:43 +08:00
|
|
|
{
|
2016-10-21 03:33:46 +08:00
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
2016-10-24 21:58:51 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-11-04 17:08:43 +08:00
|
|
|
Spacing = new Vector2(4, 0),
|
2016-10-21 03:33:46 +08:00
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new SpriteText
|
|
|
|
{
|
2016-11-04 17:08:43 +08:00
|
|
|
Font = @"Exo2.0-Medium",
|
2016-10-21 03:33:46 +08:00
|
|
|
Text = beatmap.Version,
|
|
|
|
TextSize = 20,
|
2016-11-04 17:08:43 +08:00
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft
|
2016-10-21 03:33:46 +08:00
|
|
|
},
|
|
|
|
new SpriteText
|
|
|
|
{
|
2016-11-04 17:08:43 +08:00
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
Text = "mapped by",
|
2016-10-21 03:33:46 +08:00
|
|
|
TextSize = 16,
|
2016-11-04 17:08:43 +08:00
|
|
|
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-14 06:15:43 +08:00
|
|
|
},
|
2016-10-21 03:33:46 +08:00
|
|
|
new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 }
|
2016-10-14 06:15:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-14 03:10:00 +08:00
|
|
|
};
|
2016-10-27 18:52:48 +08:00
|
|
|
}
|
2016-10-14 03:10:00 +08:00
|
|
|
}
|
|
|
|
}
|