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;
|
2017-12-12 16:48:38 +08:00
|
|
|
using osu.Framework.Allocation;
|
2017-01-10 06:18:47 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-08-30 19:41:53 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2017-12-12 16:48:38 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-01-10 06:18:47 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-12-12 16:48:38 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Input;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2017-01-10 06:18:47 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2017-12-12 16:48:38 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-01-10 06:18:47 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Graphics;
|
2016-12-18 15:59:13 +08:00
|
|
|
|
2017-12-12 16:48:38 +08:00
|
|
|
namespace osu.Game.Screens.Select.Carousel
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
2017-12-12 16:48:38 +08:00
|
|
|
public class DrawableCarouselBeatmap : DrawableCarouselItem, IHasContextMenu
|
2017-01-10 06:18:47 +08:00
|
|
|
{
|
2017-12-12 16:48:38 +08:00
|
|
|
private readonly BeatmapInfo beatmap;
|
|
|
|
|
2017-12-15 17:38:09 +08:00
|
|
|
private Sprite background;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
2017-12-18 10:13:16 +08:00
|
|
|
private Action<BeatmapInfo> startRequested;
|
|
|
|
private Action<BeatmapInfo> editRequested;
|
|
|
|
private Action<BeatmapInfo> hideRequested;
|
2017-08-30 19:41:53 +08:00
|
|
|
|
2017-12-15 17:38:09 +08:00
|
|
|
private Triangles triangles;
|
|
|
|
private StarCounter starCounter;
|
|
|
|
|
|
|
|
public DrawableCarouselBeatmap(CarouselBeatmap panel) : base(panel)
|
|
|
|
{
|
|
|
|
beatmap = panel.Beatmap;
|
|
|
|
Height *= 0.60f;
|
|
|
|
}
|
2016-10-27 18:52:48 +08:00
|
|
|
|
2017-12-13 18:56:16 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
2017-12-13 11:46:02 +08:00
|
|
|
private void load(SongSelect songSelect, BeatmapManager manager)
|
2017-02-24 18:30:04 +08:00
|
|
|
{
|
2017-12-13 18:56:16 +08:00
|
|
|
if (songSelect != null)
|
|
|
|
{
|
2017-12-18 10:13:16 +08:00
|
|
|
startRequested = songSelect.Start;
|
|
|
|
editRequested = songSelect.Edit;
|
2017-12-13 18:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (manager != null)
|
2017-12-18 10:13:16 +08:00
|
|
|
hideRequested = manager.Hide;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
|
|
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-04 18:00:17 +08:00
|
|
|
Direction = FillDirection.Horizontal,
|
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),
|
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-04 18:00:17 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
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-04 18:00:17 +08:00
|
|
|
Direction = FillDirection.Horizontal,
|
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",
|
2017-10-17 10:24:59 +08:00
|
|
|
Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author.Username}",
|
2017-01-10 06:18:47 +08:00
|
|
|
TextSize = 16,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2017-02-24 18:30:04 +08:00
|
|
|
starCounter = new StarCounter
|
|
|
|
{
|
2017-07-11 21:58:06 +08:00
|
|
|
CountStars = (float)beatmap.StarDifficulty,
|
2017-02-24 18:30:04 +08:00
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
}
|
2017-01-10 06:18:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-10-27 18:52:48 +08:00
|
|
|
}
|
2017-08-30 19:41:53 +08:00
|
|
|
|
2017-12-12 16:48:38 +08:00
|
|
|
protected override void Selected()
|
|
|
|
{
|
|
|
|
base.Selected();
|
|
|
|
|
|
|
|
background.Colour = ColourInfo.GradientVertical(
|
|
|
|
new Color4(20, 43, 51, 255),
|
|
|
|
new Color4(40, 86, 102, 255));
|
|
|
|
|
|
|
|
triangles.Colour = Color4.White;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Deselected()
|
|
|
|
{
|
|
|
|
base.Deselected();
|
|
|
|
|
|
|
|
background.Colour = new Color4(20, 43, 51, 255);
|
|
|
|
triangles.Colour = OsuColour.Gray(0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
{
|
|
|
|
if (Item.State == CarouselItemState.Selected)
|
2017-12-18 10:13:16 +08:00
|
|
|
startRequested?.Invoke(beatmap);
|
2017-12-12 16:48:38 +08:00
|
|
|
|
|
|
|
return base.OnClick(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void ApplyState()
|
|
|
|
{
|
2017-12-16 22:56:14 +08:00
|
|
|
if (Item.State.Value != CarouselItemState.Collapsed && Alpha == 0)
|
2017-12-12 16:48:38 +08:00
|
|
|
starCounter.ReplayAnimation();
|
|
|
|
|
|
|
|
base.ApplyState();
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:41:53 +08:00
|
|
|
public MenuItem[] ContextMenuItems => new MenuItem[]
|
|
|
|
{
|
2017-12-18 10:13:16 +08:00
|
|
|
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)),
|
|
|
|
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
|
|
|
|
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
|
2017-08-30 19:41:53 +08:00
|
|
|
};
|
2017-01-10 06:18:47 +08:00
|
|
|
}
|
|
|
|
}
|