2017-02-07 12:59:30 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Database;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Graphics;
|
2016-12-18 15:59:13 +08:00
|
|
|
using osu.Framework.Input;
|
2017-01-31 17:53:52 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2016-12-18 15:59:13 +08:00
|
|
|
|
2017-01-10 06:18:47 +08:00
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
|
|
|
{
|
|
|
|
class BeatmapPanel : Panel
|
|
|
|
{
|
|
|
|
public BeatmapInfo Beatmap;
|
|
|
|
private Sprite background;
|
|
|
|
|
2016-10-27 18:52:48 +08:00
|
|
|
public Action<BeatmapPanel> GainedSelection;
|
2016-12-18 15:59:13 +08:00
|
|
|
public Action<BeatmapPanel> StartRequested;
|
2017-01-30 15:53:12 +08:00
|
|
|
private Triangles triangles;
|
2017-02-24 18:30:04 +08:00
|
|
|
private StarCounter starCounter;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
|
|
|
protected override void Selected()
|
|
|
|
{
|
|
|
|
base.Selected();
|
2017-02-02 16:33:39 +08:00
|
|
|
|
2016-10-27 18:52:48 +08:00
|
|
|
GainedSelection?.Invoke(this);
|
2016-11-21 03:34:16 +08:00
|
|
|
|
2017-01-13 05:38:27 +08:00
|
|
|
background.ColourInfo = ColourInfo.GradientVertical(
|
|
|
|
new Color4(20, 43, 51, 255),
|
|
|
|
new Color4(40, 86, 102, 255));
|
2017-01-30 15:53:12 +08:00
|
|
|
|
|
|
|
triangles.Colour = Color4.White;
|
2017-01-10 06:18:47 +08:00
|
|
|
}
|
|
|
|
|
2016-11-21 03:34:16 +08:00
|
|
|
protected override void Deselected()
|
|
|
|
{
|
|
|
|
base.Deselected();
|
|
|
|
|
2017-01-13 05:38:27 +08:00
|
|
|
background.Colour = new Color4(20, 43, 51, 255);
|
2017-01-30 15:53:12 +08:00
|
|
|
triangles.Colour = OsuColour.Gray(0.5f);
|
2017-01-10 06:18:47 +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);
|
2017-01-10 06:18:47 +08:00
|
|
|
}
|
|
|
|
|
2017-02-24 18:30:04 +08:00
|
|
|
protected override void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
|
|
|
|
{
|
|
|
|
base.ApplyState(last);
|
|
|
|
|
|
|
|
if (last == PanelSelectedState.Hidden && State != last)
|
|
|
|
starCounter.ReplayAnimation();
|
|
|
|
}
|
|
|
|
|
2017-01-10 06:18:47 +08:00
|
|
|
public BeatmapPanel(BeatmapInfo beatmap)
|
2016-10-27 18:52:48 +08:00
|
|
|
{
|
|
|
|
Beatmap = beatmap;
|
2017-01-10 06:18:47 +08:00
|
|
|
Height *= 0.60f;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
background = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2017-01-30 15:53:12 +08:00
|
|
|
triangles = new Triangles
|
2016-11-26 16:10:13 +08:00
|
|
|
{
|
2017-02-04 21:09:44 +08:00
|
|
|
TriangleScale = 2,
|
2016-11-26 16:10:13 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-30 15:53:12 +08:00
|
|
|
ColourLight = OsuColour.FromHex(@"3a7285"),
|
|
|
|
ColourDark = OsuColour.FromHex(@"123744")
|
2017-01-10 06:18:47 +08:00
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
new FillFlowContainer
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
|
|
|
Padding = new MarginPadding(5),
|
2017-03-02 03:15:38 +08:00
|
|
|
Direction = FillDirection.Right,
|
2017-01-10 06:18:47 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-11-04 17:08:43 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-01-10 06:18:47 +08:00
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2017-01-30 12:35:40 +08:00
|
|
|
new DifficultyIcon(beatmap)
|
2016-11-04 17:08:43 +08:00
|
|
|
{
|
|
|
|
Scale = new Vector2(1.8f),
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2017-01-10 06:18:47 +08:00
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
new FillFlowContainer
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
|
|
|
Padding = new MarginPadding { Left = 5 },
|
2017-03-02 03:15:38 +08:00
|
|
|
Direction = FillDirection.Down,
|
2017-01-10 06:18:47 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2017-03-02 02:33:01 +08:00
|
|
|
new FillFlowContainer
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
2017-03-02 03:15:38 +08:00
|
|
|
Direction = FillDirection.Right,
|
2017-03-02 02:33:01 +08:00
|
|
|
Spacing = new Vector2(4, 0),
|
2017-01-10 06:18:47 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new[]
|
|
|
|
{
|
2017-01-31 17:53:52 +08:00
|
|
|
new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
Text = beatmap.Version,
|
|
|
|
TextSize = 20,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
Text = "mapped by",
|
|
|
|
TextSize = 16,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}",
|
|
|
|
TextSize = 16,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2017-02-24 18:30:04 +08:00
|
|
|
starCounter = new StarCounter
|
|
|
|
{
|
|
|
|
Count = beatmap.StarDifficulty,
|
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
}
|
2017-01-10 06:18:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-10-27 18:52:48 +08:00
|
|
|
}
|
2017-01-10 06:18:47 +08:00
|
|
|
}
|
|
|
|
}
|