Add triangles to difficulty panels.

This commit is contained in:
Dean Herbert 2016-11-26 17:10:13 +09:00
parent ebab9d66bf
commit a1c3d15e6c

View File

@ -2,11 +2,14 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -22,6 +25,8 @@ namespace osu.Game.Beatmaps.Drawables
public Action<BeatmapPanel> GainedSelection; public Action<BeatmapPanel> GainedSelection;
Color4 deselectedColour = new Color4(20, 43, 51, 255);
protected override void Selected() protected override void Selected()
{ {
base.Selected(); base.Selected();
@ -36,7 +41,7 @@ namespace osu.Game.Beatmaps.Drawables
{ {
base.Deselected(); base.Deselected();
background.Colour = new Color4(20, 43, 51, 255); background.Colour = deselectedColour;
} }
public BeatmapPanel(BeatmapInfo beatmap) public BeatmapPanel(BeatmapInfo beatmap)
@ -44,12 +49,18 @@ namespace osu.Game.Beatmaps.Drawables
Beatmap = beatmap; Beatmap = beatmap;
Height *= 0.60f; Height *= 0.60f;
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
background = new Box background = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new Triangles
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
Colour = deselectedColour,
},
new FlowContainer new FlowContainer
{ {
Padding = new MarginPadding(5), Padding = new MarginPadding(5),
@ -57,7 +68,7 @@ namespace osu.Game.Beatmaps.Drawables
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)) new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255))
{ {
@ -71,7 +82,7 @@ namespace osu.Game.Beatmaps.Drawables
Spacing = new Vector2(0, 5), Spacing = new Vector2(0, 5),
Direction = FlowDirection.VerticalOnly, Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
new FlowContainer new FlowContainer
{ {
@ -113,5 +124,45 @@ namespace osu.Game.Beatmaps.Drawables
} }
}; };
} }
public class Triangles : Container
{
private Texture triangle;
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
triangle = textures.Get(@"Play/osu/triangle@2x");
}
protected override void LoadComplete()
{
base.LoadComplete();
for (int i = 0; i < 10; i++)
{
Add(new Sprite
{
Texture = triangle,
Origin = Anchor.TopCentre,
RelativePositionAxes = Axes.Both,
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
Alpha = RNG.NextSingle() * 0.3f
});
}
}
protected override void Update()
{
base.Update();
foreach (Drawable d in Children)
{
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 880)));
if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
d.MoveToY(1);
}
}
}
} }
} }