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-03-14 16:29:20 +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;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
|
|
|
|
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;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Game.Database;
|
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-01-30 12:12:30 +08:00
|
|
|
|
using osu.Game.Modes;
|
2017-03-13 18:15:25 +08:00
|
|
|
|
using osu.Game.Modes.Objects;
|
|
|
|
|
using osu.Game.Modes.Objects.Types;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2017-03-14 16:29:20 +08:00
|
|
|
|
internal 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-02-27 14:55:34 +08:00
|
|
|
|
private BufferedContainer beatmapInfoContainer;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
|
2017-01-30 14:15:56 +08:00
|
|
|
|
private OsuGameBase game;
|
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;
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Colour = new Color4(130, 204, 255, 150),
|
|
|
|
|
Radius = 20,
|
|
|
|
|
Roundness = 15,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-24 12:48:48 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-01-30 14:15:56 +08:00
|
|
|
|
private void load(OsuGameBase game)
|
2016-11-24 12:48:48 +08:00
|
|
|
|
{
|
|
|
|
|
this.game = game;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 16:29:20 +08:00
|
|
|
|
protected override bool HideOnEscape => false;
|
|
|
|
|
|
|
|
|
|
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-23 04:51:42 +08:00
|
|
|
|
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
if (beatmap?.BeatmapInfo == null)
|
2017-03-14 04:59:44 +08:00
|
|
|
|
{
|
2017-03-14 16:29:20 +08:00
|
|
|
|
State = Visibility.Hidden;
|
2017-03-14 04:59:44 +08:00
|
|
|
|
beatmapInfoContainer?.FadeOut(250);
|
|
|
|
|
beatmapInfoContainer?.Expire();
|
|
|
|
|
beatmapInfoContainer = null;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
return;
|
2017-03-14 04:59:44 +08:00
|
|
|
|
}
|
2016-11-23 04:51:42 +08:00
|
|
|
|
|
2017-03-14 16:29:20 +08:00
|
|
|
|
State = Visibility.Visible;
|
2016-11-24 12:48:48 +08:00
|
|
|
|
var lastContainer = beatmapInfoContainer;
|
|
|
|
|
|
2016-11-30 03:50:12 +08:00
|
|
|
|
float newDepth = lastContainer?.Depth + 1 ?? 0;
|
2016-11-23 04:51:42 +08:00
|
|
|
|
|
|
|
|
|
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
2017-02-27 19:39:04 +08:00
|
|
|
|
BeatmapMetadata metadata = beatmap.BeatmapInfo?.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
2016-11-24 12:48:48 +08:00
|
|
|
|
|
2017-01-30 14:15:56 +08:00
|
|
|
|
List<InfoLabel> labels = new List<InfoLabel>();
|
2017-01-30 12:12:30 +08:00
|
|
|
|
|
2017-01-30 14:15:56 +08:00
|
|
|
|
if (beatmap.Beatmap != null)
|
2017-01-30 12:12:30 +08:00
|
|
|
|
{
|
2017-03-14 18:40:51 +08:00
|
|
|
|
HitObject lastObject = beatmap.Beatmap.HitObjects.LastOrDefault();
|
|
|
|
|
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
|
2017-03-13 18:15:25 +08:00
|
|
|
|
|
2017-01-30 14:15:56 +08:00
|
|
|
|
labels.Add(new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "Length",
|
|
|
|
|
Icon = FontAwesome.fa_clock_o,
|
2017-03-13 18:15:25 +08:00
|
|
|
|
Content = beatmap.Beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(endTime - beatmap.Beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
|
2017-01-30 14:15:56 +08:00
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
labels.Add(new InfoLabel(new BeatmapStatistic
|
|
|
|
|
{
|
|
|
|
|
Name = "BPM",
|
|
|
|
|
Icon = FontAwesome.fa_circle,
|
|
|
|
|
Content = getBPMRange(beatmap.Beatmap),
|
|
|
|
|
}));
|
2017-01-30 12:12:30 +08:00
|
|
|
|
|
2017-01-30 14:15:56 +08:00
|
|
|
|
//get statistics fromt he current ruleset.
|
2017-03-14 04:59:44 +08:00
|
|
|
|
labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
|
2017-01-30 14:15:56 +08:00
|
|
|
|
}
|
2016-12-17 22:53:26 +08:00
|
|
|
|
|
2016-11-24 12:48:48 +08:00
|
|
|
|
(beatmapInfoContainer = new BufferedContainer
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
2016-11-24 01:30:50 +08:00
|
|
|
|
Depth = newDepth,
|
2016-12-18 15:50:39 +08:00
|
|
|
|
PixelSnapping = true,
|
2016-11-23 04:51:42 +08:00
|
|
|
|
CacheDrawnFrameBuffer = true,
|
|
|
|
|
Shear = -Shear,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// 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
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
// 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.
|
2016-11-24 12:48:48 +08:00
|
|
|
|
new Container
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-11 02:44:40 +08:00
|
|
|
|
ColourInfo = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
|
2016-11-23 04:51:42 +08:00
|
|
|
|
Children = new []
|
|
|
|
|
{
|
2016-12-17 22:53:26 +08:00
|
|
|
|
// Zoomed-in and cropped beatmap background
|
2016-11-24 12:48:48 +08:00
|
|
|
|
new BeatmapBackgroundSprite(beatmap)
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2016-11-23 12:07:35 +08:00
|
|
|
|
FillMode = FillMode.Fill,
|
2016-11-23 04:51:42 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// Text for beatmap info
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-01-29 13:47:42 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 20 },
|
2017-01-13 05:38:27 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-01-29 13:47:42 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
2017-01-31 17:53:52 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
2017-02-27 19:39:04 +08:00
|
|
|
|
Text = metadata.Artist + " -- " + metadata.Title,
|
2017-01-13 05:38:27 +08:00
|
|
|
|
TextSize = 28,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Text = beatmapInfo.Version,
|
|
|
|
|
TextSize = 17,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2016-11-23 04:51:42 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 10 },
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2016-11-23 04:51:42 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new []
|
|
|
|
|
{
|
2017-01-31 17:53:52 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-Medium",
|
|
|
|
|
Text = "mapped by ",
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
Shadow = true,
|
2016-11-23 04:51:42 +08:00
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-13 05:38:27 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
2017-02-27 19:39:04 +08:00
|
|
|
|
Text = metadata.Author,
|
2017-01-13 05:38:27 +08:00
|
|
|
|
TextSize = 15,
|
|
|
|
|
Shadow = true,
|
2016-11-23 04:51:42 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2017-01-29 13:47:42 +08:00
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-01-29 13:47:42 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 20 },
|
2017-03-02 02:33:01 +08:00
|
|
|
|
Spacing = new Vector2(40, 0),
|
2017-01-29 13:47:42 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-01-30 12:12:30 +08:00
|
|
|
|
Children = labels
|
2017-01-29 13:47:42 +08:00
|
|
|
|
},
|
2017-01-13 05:38:27 +08:00
|
|
|
|
}
|
2016-12-17 22:53:26 +08:00
|
|
|
|
},
|
2016-11-23 04:51:42 +08:00
|
|
|
|
}
|
2017-02-24 05:32:10 +08:00
|
|
|
|
}).LoadAsync(game, delegate (Drawable d)
|
2016-11-24 12:48:48 +08:00
|
|
|
|
{
|
2016-11-26 16:31:35 +08:00
|
|
|
|
FadeIn(250);
|
|
|
|
|
|
2016-11-24 12:48:48 +08:00
|
|
|
|
lastContainer?.FadeOut(250);
|
|
|
|
|
lastContainer?.Expire();
|
|
|
|
|
|
|
|
|
|
Add(d);
|
2016-11-23 04:51:42 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2016-12-18 02:57:58 +08:00
|
|
|
|
|
2016-12-19 02:34:20 +08:00
|
|
|
|
private string getBPMRange(Beatmap beatmap)
|
2016-12-18 02:57:58 +08:00
|
|
|
|
{
|
2017-03-16 16:11:24 +08:00
|
|
|
|
double bpmMax = beatmap.TimingInfo.BPMMaximum;
|
|
|
|
|
double bpmMin = beatmap.TimingInfo.BPMMinimum;
|
2017-01-30 15:03:45 +08:00
|
|
|
|
|
|
|
|
|
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";
|
|
|
|
|
|
2017-03-16 16:11:24 +08:00
|
|
|
|
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.TimingInfo.BPMMode) + "bpm)";
|
2016-12-18 02:57:58 +08:00
|
|
|
|
}
|
2017-01-29 14:06:44 +08:00
|
|
|
|
|
|
|
|
|
public class InfoLabel : Container
|
2016-12-17 22:53:26 +08:00
|
|
|
|
{
|
2017-01-30 12:12:30 +08:00
|
|
|
|
public InfoLabel(BeatmapStatistic statistic)
|
2016-12-17 22:53:26 +08:00
|
|
|
|
{
|
2017-01-29 14:06:44 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-01-29 13:47:42 +08:00
|
|
|
|
{
|
2016-12-17 22:53:26 +08:00
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
2016-12-18 23:53:52 +08:00
|
|
|
|
Icon = FontAwesome.fa_square,
|
2017-03-06 16:06:48 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-29 14:15:04 +08:00
|
|
|
|
Colour = new Color4(68, 17, 136, 255),
|
2017-03-20 12:48:06 +08:00
|
|
|
|
Rotation = 45,
|
|
|
|
|
TextSize = 20
|
2016-12-17 22:53:26 +08:00
|
|
|
|
},
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
2017-01-30 12:12:30 +08:00
|
|
|
|
Icon = statistic.Icon,
|
2017-03-06 16:06:48 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-29 14:15:04 +08:00
|
|
|
|
Colour = new Color4(255, 221, 85, 255),
|
2017-03-20 12:48:06 +08:00
|
|
|
|
Scale = new Vector2(0.8f),
|
|
|
|
|
TextSize = 20
|
2016-12-17 22:53:26 +08:00
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-29 13:47:42 +08:00
|
|
|
|
{
|
2017-01-29 14:15:04 +08:00
|
|
|
|
Margin = new MarginPadding { Left = 13 },
|
2017-01-29 13:47:42 +08:00
|
|
|
|
Font = @"Exo2.0-Bold",
|
2017-01-29 14:15:04 +08:00
|
|
|
|
Colour = new Color4(255, 221, 85, 255),
|
2017-01-30 12:12:30 +08:00
|
|
|
|
Text = statistic.Content,
|
2017-01-29 13:47:42 +08:00
|
|
|
|
TextSize = 17,
|
|
|
|
|
Origin = Anchor.CentreLeft
|
2016-12-17 22:53:26 +08:00
|
|
|
|
},
|
2017-01-29 14:06:44 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2016-12-17 22:53:26 +08:00
|
|
|
|
}
|
2016-11-23 04:51:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|