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
|
2016-12-06 17:56:20 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2017-01-30 12:12:30 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using System.Linq;
|
2016-11-23 12:07:35 +08:00
|
|
|
|
using OpenTK;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-04-24 19:11:36 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-11-24 12:48:48 +08:00
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2016-12-16 11:25:28 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-12-15 02:55:15 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2017-11-21 10:49:42 +08:00
|
|
|
|
public class BeatmapInfoWedge : OverlayContainer
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2016-11-26 16:31:35 +08:00
|
|
|
|
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
|
|
|
|
|
2017-11-21 10:49:21 +08:00
|
|
|
|
private Drawable info;
|
2016-11-24 12:48:48 +08:00
|
|
|
|
|
2016-11-26 16:31:35 +08:00
|
|
|
|
public BeatmapInfoWedge()
|
|
|
|
|
{
|
|
|
|
|
Shear = wedged_container_shear;
|
|
|
|
|
Masking = true;
|
|
|
|
|
BorderColour = new Color4(221, 255, 255, 255);
|
|
|
|
|
BorderThickness = 2.5f;
|
2017-06-12 11:48:47 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2016-11-26 16:31:35 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Colour = new Color4(130, 204, 255, 150),
|
|
|
|
|
Radius = 20,
|
|
|
|
|
Roundness = 15,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 14:34:53 +08:00
|
|
|
|
protected override bool BlockPassThroughMouse => false;
|
2017-04-17 17:08:01 +08:00
|
|
|
|
|
2017-03-14 16:29:20 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.MoveToX(0, 800, Easing.OutQuint);
|
|
|
|
|
this.RotateTo(0, 800, Easing.OutQuint);
|
2017-03-14 16:29:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.MoveToX(-100, 800, Easing.InQuint);
|
|
|
|
|
this.RotateTo(10, 800, Easing.InQuint);
|
2017-03-14 16:29:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-23 04:51:42 +08:00
|
|
|
|
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
2017-11-21 10:49:21 +08:00
|
|
|
|
LoadComponentAsync(new BufferedWedgeInfo(beatmap)
|
|
|
|
|
{
|
|
|
|
|
Shear = -Shear,
|
|
|
|
|
Depth = info?.Depth + 1 ?? 0,
|
|
|
|
|
}, newInfo =>
|
|
|
|
|
{
|
|
|
|
|
// ensure we ourselves are visible if not already.
|
|
|
|
|
if (!IsPresent)
|
|
|
|
|
this.FadeIn(250);
|
2016-11-23 04:51:42 +08:00
|
|
|
|
|
2017-11-21 10:49:21 +08:00
|
|
|
|
info?.FadeOut(250);
|
|
|
|
|
info?.Expire();
|
2016-11-24 12:48:48 +08:00
|
|
|
|
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Add(info = newInfo);
|
2017-04-28 20:16:37 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-01-30 12:12:30 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
public class BufferedWedgeInfo : BufferedContainer
|
|
|
|
|
{
|
2017-11-21 11:29:46 +08:00
|
|
|
|
private readonly WorkingBeatmap working;
|
2017-11-21 10:49:21 +08:00
|
|
|
|
|
2017-11-21 11:29:46 +08:00
|
|
|
|
public BufferedWedgeInfo(WorkingBeatmap working)
|
2017-11-21 10:49:21 +08:00
|
|
|
|
{
|
2017-11-21 11:29:46 +08:00
|
|
|
|
this.working = working;
|
2017-11-21 10:49:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-01-30 12:12:30 +08:00
|
|
|
|
{
|
2017-11-21 11:29:46 +08:00
|
|
|
|
BeatmapInfo beatmapInfo = working.BeatmapInfo;
|
|
|
|
|
BeatmapMetadata metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
|
|
|
|
Beatmap beatmap = working.Beatmap;
|
2017-03-13 18:15:25 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
List<InfoLabel> labels = new List<InfoLabel>();
|
2017-01-30 14:15:56 +08:00
|
|
|
|
|
2017-11-21 11:29:46 +08:00
|
|
|
|
if (beatmap != null)
|
2017-01-30 14:15:56 +08:00
|
|
|
|
{
|
2017-11-21 11:29:46 +08:00
|
|
|
|
HitObject lastObject = beatmap.HitObjects.LastOrDefault();
|
2017-04-28 20:16:37 +08:00
|
|
|
|
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
|
2017-01-30 12:12:30 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
labels.Add(new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "Length",
|
|
|
|
|
Icon = FontAwesome.fa_clock_o,
|
2017-11-21 11:29:46 +08:00
|
|
|
|
Content = beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(endTime - beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}));
|
2016-12-17 22:53:26 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
labels.Add(new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "BPM",
|
|
|
|
|
Icon = FontAwesome.fa_circle,
|
2017-11-21 11:29:46 +08:00
|
|
|
|
Content = getBPMRange(beatmap),
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}));
|
2017-03-28 13:35:18 +08:00
|
|
|
|
|
2017-05-12 19:05:44 +08:00
|
|
|
|
//get statistics from the current ruleset.
|
2017-11-21 11:29:46 +08:00
|
|
|
|
labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(working).Select(s => new InfoLabel(s)));
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PixelSnapping = true;
|
|
|
|
|
CacheDrawnFrameBuffer = true;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
// We will create the white-to-black gradient by modulating transparency and having
|
|
|
|
|
// a black backdrop. This results in an sRGB-space gradient and not linear space,
|
|
|
|
|
// transitioning from white to black more perceptually uniformly.
|
|
|
|
|
new Box
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
2017-04-02 14:56:12 +08:00
|
|
|
|
},
|
2017-04-28 20:16:37 +08:00
|
|
|
|
// We use a container, such that we can set the colour gradient to go across the
|
|
|
|
|
// vertices of the masked container instead of the vertices of the (larger) sprite.
|
|
|
|
|
new Container
|
2017-04-02 14:56:12 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Children = new[]
|
2017-04-02 14:56:12 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
// Zoomed-in and cropped beatmap background
|
2017-11-21 11:29:46 +08:00
|
|
|
|
new BeatmapBackgroundSprite(working)
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
2017-06-28 17:24:23 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fill,
|
2017-01-13 05:38:27 +08:00
|
|
|
|
},
|
2017-04-02 14:56:12 +08:00
|
|
|
|
},
|
2017-04-28 20:16:37 +08:00
|
|
|
|
},
|
2017-11-21 11:29:46 +08:00
|
|
|
|
new DifficultyColourBar(beatmapInfo)
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 20,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Name = "Top-aligned metadata",
|
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 20 },
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
2017-04-02 14:56:12 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
new OsuSpriteText
|
2017-04-24 19:11:36 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Text = beatmapInfo.Version,
|
|
|
|
|
TextSize = 24,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Name = "Bottom-aligned metadata",
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Margin = new MarginPadding { Top = 15, Left = 25, Right = 10, Bottom = 20 },
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
2017-04-24 19:11:36 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
new OsuSpriteText
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Text = !string.IsNullOrEmpty(metadata.Source) ? metadata.Source + " — " + metadata.Title : metadata.Title,
|
|
|
|
|
TextSize = 28,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Text = metadata.Artist,
|
|
|
|
|
TextSize = 17,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 10 },
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
2017-04-02 14:56:12 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
new OsuSpriteText
|
2017-03-28 13:35:18 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
|
Text = "mapped by ",
|
|
|
|
|
TextSize = 15,
|
2017-11-21 10:49:21 +08:00
|
|
|
|
},
|
2017-04-28 20:16:37 +08:00
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
2017-10-13 19:25:27 +08:00
|
|
|
|
Text = metadata.Author.Username,
|
2017-04-28 20:16:37 +08:00
|
|
|
|
TextSize = 15,
|
2017-11-21 10:49:21 +08:00
|
|
|
|
},
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 20 },
|
|
|
|
|
Spacing = new Vector2(20, 0),
|
2017-04-28 20:16:37 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = labels
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2016-12-18 02:57:58 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
private string getBPMRange(Beatmap beatmap)
|
|
|
|
|
{
|
2017-05-23 12:55:18 +08:00
|
|
|
|
double bpmMax = beatmap.ControlPointInfo.BPMMaximum;
|
|
|
|
|
double bpmMin = beatmap.ControlPointInfo.BPMMinimum;
|
2017-01-30 15:03:45 +08:00
|
|
|
|
|
2017-12-15 02:55:15 +08:00
|
|
|
|
if (Precision.AlmostEquals(bpmMin, bpmMax)) return $"{bpmMin:0}";
|
2017-01-30 15:03:45 +08:00
|
|
|
|
|
2017-12-15 02:55:15 +08:00
|
|
|
|
return $"{bpmMin:0}-{bpmMax:0} (mostly {beatmap.ControlPointInfo.BPMMode:0})";
|
2017-04-28 20:16:37 +08:00
|
|
|
|
}
|
2017-01-29 14:06:44 +08:00
|
|
|
|
|
2017-12-15 02:55:15 +08:00
|
|
|
|
public class InfoLabel : Container, IHasTooltip
|
2016-12-17 22:53:26 +08:00
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
public string TooltipText { get; private set; }
|
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
public InfoLabel(BeatmapStatistic statistic)
|
2017-01-29 13:47:42 +08:00
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
TooltipText = statistic.Name;
|
2017-04-28 20:16:37 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Padding = new MarginPadding { Left = 16 };
|
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-11-21 10:49:21 +08:00
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Colour = OsuColour.FromHex(@"441288"),
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Icon = FontAwesome.fa_square,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Rotation = 45,
|
|
|
|
|
Size = new Vector2(20),
|
|
|
|
|
},
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Colour = OsuColour.FromHex(@"f7dd55"),
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Icon = statistic.Icon,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
|
Size = new Vector2(20),
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Colour = new Color4(255, 221, 85, 255),
|
2017-12-15 02:55:15 +08:00
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Margin = new MarginPadding { Left = 13 },
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2017-11-21 10:49:21 +08:00
|
|
|
|
Text = statistic.Content,
|
|
|
|
|
TextSize = 17,
|
2017-12-15 02:55:15 +08:00
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-04-24 19:11:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
private class DifficultyColourBar : DifficultyColouredContainer
|
2017-04-24 19:11:36 +08:00
|
|
|
|
{
|
2017-11-21 10:49:21 +08:00
|
|
|
|
public DifficultyColourBar(BeatmapInfo beatmap)
|
|
|
|
|
: base(beatmap)
|
2017-04-28 20:16:37 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
2017-04-24 19:11:36 +08:00
|
|
|
|
|
2017-04-28 20:16:37 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-04-24 19:11:36 +08:00
|
|
|
|
{
|
2017-04-28 20:16:37 +08:00
|
|
|
|
const float full_opacity_ratio = 0.7f;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-11-21 10:49:21 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = AccentColour,
|
|
|
|
|
Width = full_opacity_ratio,
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
Colour = AccentColour,
|
|
|
|
|
Alpha = 0.5f,
|
|
|
|
|
X = full_opacity_ratio,
|
|
|
|
|
Width = 1 - full_opacity_ratio,
|
|
|
|
|
}
|
2017-04-28 20:16:37 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-04-24 19:11:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-23 04:51:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|