2017-02-07 04:59:30 +00: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 09:56:20 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
2017-01-30 04:12:30 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using System.Linq;
|
2016-11-23 04:07:35 +00:00
|
|
|
|
using OpenTK;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
using OpenTK.Graphics;
|
2017-04-24 11:11:36 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-03-04 18:42:37 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using osu.Framework.MathUtils;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-11-24 04:48:48 +00:00
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using osu.Game.Database;
|
2016-12-16 03:25:28 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2017-01-31 09:53:52 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2017-03-14 08:29:20 +00:00
|
|
|
|
internal class BeatmapInfoWedge : OverlayContainer
|
2016-11-22 20:51:42 +00:00
|
|
|
|
{
|
2016-11-26 08:31:35 +00:00
|
|
|
|
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
|
|
|
|
|
2017-03-28 05:35:18 +00:00
|
|
|
|
private Drawable beatmapInfoContainer;
|
2016-11-24 04:48:48 +00:00
|
|
|
|
|
2016-11-26 08:31:35 +00:00
|
|
|
|
public BeatmapInfoWedge()
|
|
|
|
|
{
|
|
|
|
|
Shear = wedged_container_shear;
|
|
|
|
|
Masking = true;
|
|
|
|
|
BorderColour = new Color4(221, 255, 255, 255);
|
|
|
|
|
BorderThickness = 2.5f;
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Colour = new Color4(130, 204, 255, 150),
|
|
|
|
|
Radius = 20,
|
|
|
|
|
Roundness = 15,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 08:29:20 +00:00
|
|
|
|
protected override bool HideOnEscape => false;
|
|
|
|
|
|
2017-04-18 06:34:53 +00:00
|
|
|
|
protected override bool BlockPassThroughMouse => false;
|
2017-04-17 09:08:01 +00:00
|
|
|
|
|
2017-03-14 08:29:20 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
MoveToX(0, 800, EasingTypes.OutQuint);
|
|
|
|
|
RotateTo(0, 800, EasingTypes.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
MoveToX(-100, 800, EasingTypes.InQuint);
|
|
|
|
|
RotateTo(10, 800, EasingTypes.InQuint);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 20:51:42 +00:00
|
|
|
|
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
2017-03-07 01:59:19 +00:00
|
|
|
|
if (beatmap?.BeatmapInfo == null)
|
2017-03-13 20:59:44 +00:00
|
|
|
|
{
|
2017-03-14 08:29:20 +00:00
|
|
|
|
State = Visibility.Hidden;
|
2017-03-13 20:59:44 +00:00
|
|
|
|
beatmapInfoContainer?.FadeOut(250);
|
|
|
|
|
beatmapInfoContainer?.Expire();
|
|
|
|
|
beatmapInfoContainer = null;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
return;
|
2017-03-13 20:59:44 +00:00
|
|
|
|
}
|
2016-11-22 20:51:42 +00:00
|
|
|
|
|
2017-03-14 08:29:20 +00:00
|
|
|
|
State = Visibility.Visible;
|
2017-04-28 12:16:37 +00:00
|
|
|
|
AlwaysPresent = true;
|
2016-11-24 04:48:48 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
var lastContainer = beatmapInfoContainer;
|
2016-11-29 19:50:12 +00:00
|
|
|
|
float newDepth = lastContainer?.Depth + 1 ?? 0;
|
2016-11-22 20:51:42 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
Add(beatmapInfoContainer = new AsyncLoadWrapper(
|
|
|
|
|
new BufferedWedgeInfo(beatmap)
|
|
|
|
|
{
|
|
|
|
|
Shear = -Shear,
|
|
|
|
|
OnLoadComplete = d =>
|
|
|
|
|
{
|
|
|
|
|
FadeIn(250);
|
2016-11-24 04:48:48 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
lastContainer?.FadeOut(250);
|
|
|
|
|
lastContainer?.Expire();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Depth = newDepth,
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-01-30 04:12:30 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
public class BufferedWedgeInfo : BufferedContainer
|
|
|
|
|
{
|
|
|
|
|
public BufferedWedgeInfo(WorkingBeatmap beatmap)
|
2017-01-30 04:12:30 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
2017-04-28 13:23:10 +00:00
|
|
|
|
BeatmapMetadata metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
2017-03-13 10:15:25 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
List<InfoLabel> labels = new List<InfoLabel>();
|
2017-01-30 06:15:56 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
if (beatmap.Beatmap != null)
|
2017-01-30 06:15:56 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
HitObject lastObject = beatmap.Beatmap.HitObjects.LastOrDefault();
|
|
|
|
|
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
|
2017-01-30 04:12:30 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
labels.Add(new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "Length",
|
|
|
|
|
Icon = FontAwesome.fa_clock_o,
|
|
|
|
|
Content = beatmap.Beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(endTime - beatmap.Beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
|
|
|
|
|
}));
|
2016-12-17 14:53:26 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
labels.Add(new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "BPM",
|
|
|
|
|
Icon = FontAwesome.fa_circle,
|
|
|
|
|
Content = getBPMRange(beatmap.Beatmap),
|
|
|
|
|
}));
|
2017-03-28 05:35:18 +00:00
|
|
|
|
|
2017-05-12 11:05:44 +00:00
|
|
|
|
//get statistics from the current ruleset.
|
2017-04-28 13:23:10 +00:00
|
|
|
|
labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
|
2017-04-28 12:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PixelSnapping = true;
|
|
|
|
|
CacheDrawnFrameBuffer = true;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
2016-11-22 20:51:42 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00: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-22 20:51:42 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
2017-04-02 06:56:12 +00:00
|
|
|
|
},
|
2017-04-28 12:16:37 +00: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 06:56:12 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColourInfo = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
|
|
|
|
|
Children = new[]
|
2017-04-02 06:56:12 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
// Zoomed-in and cropped beatmap background
|
|
|
|
|
new BeatmapBackgroundSprite(beatmap)
|
2017-01-12 21:38:27 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fill,
|
2017-01-12 21:38:27 +00:00
|
|
|
|
},
|
2017-04-02 06:56:12 +00:00
|
|
|
|
},
|
2017-04-28 12:16:37 +00:00
|
|
|
|
},
|
|
|
|
|
new DifficultyColourBar(beatmap.BeatmapInfo)
|
|
|
|
|
{
|
|
|
|
|
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 06:56:12 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
new OsuSpriteText
|
2017-04-24 11:11:36 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00: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 11:11:36 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
new OsuSpriteText
|
2016-11-22 20:51:42 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00: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 06:56:12 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
new OsuSpriteText
|
2017-03-28 05:35:18 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
|
Text = "mapped by ",
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Text = metadata.Author,
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 20, Left = 10 },
|
|
|
|
|
Spacing = new Vector2(40, 0),
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = labels
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2016-12-17 18:57:58 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
private string getBPMRange(Beatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
double bpmMax = beatmap.TimingInfo.BPMMaximum;
|
|
|
|
|
double bpmMin = beatmap.TimingInfo.BPMMinimum;
|
2017-01-30 07:03:45 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";
|
2017-01-30 07:03:45 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.TimingInfo.BPMMode) + "bpm)";
|
|
|
|
|
}
|
2017-01-29 06:06:44 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
public class InfoLabel : Container
|
2016-12-17 14:53:26 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
public InfoLabel(BeatmapStatistic statistic)
|
2017-01-29 05:47:42 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-12-17 14:53:26 +00:00
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
2016-12-18 15:53:52 +00:00
|
|
|
|
Icon = FontAwesome.fa_square,
|
2017-03-06 08:06:48 +00:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-29 06:15:04 +00:00
|
|
|
|
Colour = new Color4(68, 17, 136, 255),
|
2017-03-20 04:48:06 +00:00
|
|
|
|
Rotation = 45,
|
|
|
|
|
TextSize = 20
|
2016-12-17 14:53:26 +00:00
|
|
|
|
},
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
2017-01-30 04:12:30 +00:00
|
|
|
|
Icon = statistic.Icon,
|
2017-03-06 08:06:48 +00:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-29 06:15:04 +00:00
|
|
|
|
Colour = new Color4(255, 221, 85, 255),
|
2017-03-20 04:48:06 +00:00
|
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
|
TextSize = 20
|
2016-12-17 14:53:26 +00:00
|
|
|
|
},
|
2017-01-31 09:53:52 +00:00
|
|
|
|
new OsuSpriteText
|
2017-01-29 05:47:42 +00:00
|
|
|
|
{
|
2017-01-29 06:15:04 +00:00
|
|
|
|
Margin = new MarginPadding { Left = 13 },
|
2017-01-29 05:47:42 +00:00
|
|
|
|
Font = @"Exo2.0-Bold",
|
2017-01-29 06:15:04 +00:00
|
|
|
|
Colour = new Color4(255, 221, 85, 255),
|
2017-01-30 04:12:30 +00:00
|
|
|
|
Text = statistic.Content,
|
2017-01-29 05:47:42 +00:00
|
|
|
|
TextSize = 17,
|
|
|
|
|
Origin = Anchor.CentreLeft
|
2016-12-17 14:53:26 +00:00
|
|
|
|
},
|
2017-04-28 12:16:37 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-04-24 11:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
private class DifficultyColourBar : DifficultyColouredContainer
|
2017-04-24 11:11:36 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
public DifficultyColourBar(BeatmapInfo beatmap) : base(beatmap)
|
|
|
|
|
{
|
|
|
|
|
}
|
2017-04-24 11:11:36 +00:00
|
|
|
|
|
2017-04-28 12:16:37 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-04-24 11:11:36 +00:00
|
|
|
|
{
|
2017-04-28 12:16:37 +00:00
|
|
|
|
const float full_opacity_ratio = 0.7f;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-04-24 11:11:36 +00: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 12:16:37 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-04-24 11:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-22 20:51:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|