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 System.Collections.Generic;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-20 04:37:42 +08:00
|
|
|
using osu.Framework.Input;
|
2016-10-14 03:10:00 +08:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.GameModes.Backgrounds;
|
|
|
|
using osu.Framework;
|
|
|
|
using osu.Game.Database;
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2016-10-14 06:15:43 +08:00
|
|
|
using OpenTK.Graphics;
|
|
|
|
using OpenTK;
|
|
|
|
using osu.Game.Graphics;
|
2016-10-21 03:16:06 +08:00
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-10-14 03:10:00 +08:00
|
|
|
|
|
|
|
namespace osu.Game.GameModes.Play
|
|
|
|
{
|
2016-10-14 06:15:43 +08:00
|
|
|
class BeatmapButton : AutoSizeContainer
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-10-19 22:47:23 +08:00
|
|
|
private BeatmapSetInfo beatmapSet;
|
|
|
|
private BeatmapInfo beatmap;
|
2016-10-14 03:10:00 +08:00
|
|
|
|
2016-10-21 03:16:06 +08:00
|
|
|
public Action<BeatmapInfo> MapSelected;
|
|
|
|
|
|
|
|
private bool selected;
|
|
|
|
|
|
|
|
public bool Selected
|
|
|
|
{
|
|
|
|
get { return selected; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (selected == value)
|
|
|
|
return;
|
|
|
|
selected = value;
|
|
|
|
BorderColour = new Color4(
|
|
|
|
BorderColour.R,
|
|
|
|
BorderColour.G,
|
|
|
|
BorderColour.B,
|
|
|
|
selected ? 255 : 0);
|
|
|
|
GlowRadius = selected ? 3 : 0;
|
|
|
|
}
|
|
|
|
}
|
2016-10-20 04:37:42 +08:00
|
|
|
|
2016-10-19 22:47:23 +08:00
|
|
|
public BeatmapButton(BeatmapSetInfo set, BeatmapInfo beatmap)
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
|
|
|
this.beatmapSet = set;
|
|
|
|
this.beatmap = beatmap;
|
2016-10-21 03:16:06 +08:00
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 5;
|
|
|
|
BorderThickness = 2;
|
|
|
|
BorderColour = new Color4(221, 255, 255, 0);
|
|
|
|
GlowColour = new Color4(166, 221, 251, 0.75f); // TODO: Get actual color for this
|
2016-10-14 06:15:43 +08:00
|
|
|
Children = new Drawable[]
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-10-14 06:15:43 +08:00
|
|
|
new Box
|
|
|
|
{
|
2016-10-20 04:37:42 +08:00
|
|
|
Colour = new Color4(40, 86, 102, 255), // TODO: gradient
|
2016-10-14 06:15:43 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(1),
|
|
|
|
},
|
|
|
|
new FlowContainer
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding(5),
|
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(159, 198, 0, 255)),
|
|
|
|
new FlowContainer
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding { Left = 10 },
|
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new SpriteText
|
|
|
|
{
|
|
|
|
Text = beatmap.Version,
|
|
|
|
TextSize = 20,
|
|
|
|
},
|
|
|
|
new SpriteText
|
|
|
|
{
|
2016-10-14 06:20:08 +08:00
|
|
|
Text = string.Format(" mapped by {0}", (beatmap.Metadata ?? set.Metadata).Author),
|
2016-10-14 06:15:43 +08:00
|
|
|
TextSize = 16,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-14 03:10:00 +08:00
|
|
|
};
|
|
|
|
}
|
2016-10-20 04:37:42 +08:00
|
|
|
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
{
|
2016-10-21 03:16:06 +08:00
|
|
|
MapSelected?.Invoke(beatmap);
|
2016-10-20 04:37:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-10-14 03:10:00 +08:00
|
|
|
}
|
|
|
|
}
|