2017-05-18 05:02:33 +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
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-19 23:52:23 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Localisation;
|
2017-05-20 06:02:53 +08:00
|
|
|
|
using osu.Framework.Input;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-07-26 12:22:46 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-06-27 20:05:49 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-05-18 05:02:33 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Direct
|
|
|
|
|
{
|
|
|
|
|
public class DirectListPanel : DirectPanel
|
|
|
|
|
{
|
2017-05-20 06:50:45 +08:00
|
|
|
|
private const float horizontal_padding = 10;
|
|
|
|
|
private const float vertical_padding = 5;
|
|
|
|
|
private const float height = 70;
|
2017-05-18 05:02:33 +08:00
|
|
|
|
|
2017-05-19 02:01:01 +08:00
|
|
|
|
public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = height;
|
2017-05-20 04:52:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 23:52:23 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-07-13 09:30:09 +08:00
|
|
|
|
private void load(LocalisationEngine localisation)
|
2017-05-19 23:52:23 +08:00
|
|
|
|
{
|
2017-08-24 17:18:03 +08:00
|
|
|
|
Content.CornerRadius = 5;
|
|
|
|
|
|
|
|
|
|
AddRange(new Drawable[]
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.25f), Color4.Black.Opacity(0.75f)),
|
2017-05-18 05:02:33 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding, Left = horizontal_padding, Right = vertical_padding },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
|
new OsuSpriteText
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
|
Current = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title),
|
2017-05-18 05:02:33 +08:00
|
|
|
|
TextSize = 18,
|
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
|
|
|
|
},
|
2017-05-19 23:52:23 +08:00
|
|
|
|
new OsuSpriteText
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
|
Current = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist),
|
2017-05-18 05:02:33 +08:00
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
|
|
|
|
},
|
2017-05-19 23:52:23 +08:00
|
|
|
|
new FillFlowContainer
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 20,
|
2017-05-18 05:02:33 +08:00
|
|
|
|
Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding },
|
2017-05-20 03:11:45 +08:00
|
|
|
|
Children = GetDifficultyIcons(),
|
2017-05-18 05:02:33 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-05-20 06:50:45 +08:00
|
|
|
|
Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding },
|
2017-05-18 05:02:33 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-28 11:37:55 +08:00
|
|
|
|
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
2017-05-19 02:01:01 +08:00
|
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
|
Margin = new MarginPadding { Right = 1 },
|
2017-05-18 05:02:33 +08:00
|
|
|
|
},
|
2017-05-28 11:37:55 +08:00
|
|
|
|
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
2017-05-18 05:02:33 +08:00
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2017-05-24 13:19:45 +08:00
|
|
|
|
Text = "mapped by ",
|
2017-05-18 05:02:33 +08:00
|
|
|
|
TextSize = 14,
|
|
|
|
|
},
|
2017-05-19 23:52:23 +08:00
|
|
|
|
new OsuSpriteText
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
|
Text = SetInfo.Metadata.Author,
|
2017-05-18 05:02:33 +08:00
|
|
|
|
TextSize = 14,
|
|
|
|
|
Font = @"Exo2.0-SemiBoldItalic",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-05-19 23:52:23 +08:00
|
|
|
|
new OsuSpriteText
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
2017-05-24 13:19:45 +08:00
|
|
|
|
Text = $"from {SetInfo.Metadata.Source}",
|
2017-05-18 05:02:33 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
TextSize = 14,
|
2017-05-20 07:03:07 +08:00
|
|
|
|
Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f,
|
2017-05-18 05:02:33 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new DownloadButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2017-05-20 06:50:45 +08:00
|
|
|
|
Size = new Vector2(height - vertical_padding * 2),
|
2017-08-24 17:51:50 +08:00
|
|
|
|
Action = StartDownload
|
2017-05-18 05:02:33 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-08-24 17:18:03 +08:00
|
|
|
|
});
|
2017-05-18 05:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-27 20:05:49 +08:00
|
|
|
|
private class DownloadButton : OsuClickableContainer
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
|
private readonly SpriteIcon icon;
|
2017-05-20 06:02:53 +08:00
|
|
|
|
|
2017-05-18 05:02:33 +08:00
|
|
|
|
public DownloadButton()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
|
icon = new SpriteIcon
|
2017-05-18 05:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-08-03 13:36:21 +08:00
|
|
|
|
Size = new Vector2(30),
|
2017-05-18 05:02:33 +08:00
|
|
|
|
Icon = FontAwesome.fa_osu_chevron_down_o,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-05-20 06:02:53 +08:00
|
|
|
|
|
2017-05-20 06:22:42 +08:00
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
icon.ScaleTo(0.9f, 1000, Easing.Out);
|
2017-05-20 06:22:42 +08:00
|
|
|
|
return base.OnMouseDown(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
icon.ScaleTo(1f, 500, Easing.OutElastic);
|
2017-05-20 06:22:42 +08:00
|
|
|
|
return base.OnMouseUp(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
icon.ScaleTo(1.1f, 500, Easing.OutElastic);
|
2017-05-20 06:22:42 +08:00
|
|
|
|
return base.OnHover(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
icon.ScaleTo(1f, 500, Easing.OutElastic);
|
2017-05-20 06:02:53 +08:00
|
|
|
|
}
|
2017-05-18 05:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|