osu/osu.Game/Overlays/BeatmapSet/Details.cs

135 lines
3.8 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 09:19:50 +00:00
using osu.Framework.Allocation;
2018-04-13 09:19:50 +00:00
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Overlays.BeatmapSet.Buttons;
2018-04-13 09:19:50 +00:00
using osu.Game.Screens.Select.Details;
2018-11-20 07:51:59 +00:00
using osuTK;
using osuTK.Graphics;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Overlays.BeatmapSet
{
public class Details : FillFlowContainer
{
protected readonly UserRatings Ratings;
2018-04-13 09:19:50 +00:00
private readonly PreviewButton preview;
private readonly BasicStats basic;
private readonly AdvancedStats advanced;
private BeatmapSetInfo beatmapSet;
2018-04-13 09:19:50 +00:00
public BeatmapSetInfo BeatmapSet
{
get => beatmapSet;
2018-04-13 09:19:50 +00:00
set
{
if (value == beatmapSet) return;
2019-02-28 04:31:40 +00:00
2018-04-13 09:19:50 +00:00
beatmapSet = value;
basic.BeatmapSet = preview.BeatmapSet = BeatmapSet;
updateDisplay();
2018-04-13 09:19:50 +00:00
}
}
private BeatmapInfo beatmap;
2018-04-13 09:19:50 +00:00
public BeatmapInfo Beatmap
{
get => beatmap;
2018-04-13 09:19:50 +00:00
set
{
if (value == beatmap) return;
basic.Beatmap = advanced.Beatmap = beatmap = value;
2018-04-13 09:19:50 +00:00
}
}
private void updateDisplay()
{
Ratings.Metrics = BeatmapSet?.Metrics;
}
2018-04-13 09:19:50 +00:00
public Details()
{
Width = BeatmapSetOverlay.RIGHT_WIDTH;
AutoSizeAxes = Axes.Y;
Spacing = new Vector2(1f);
Children = new Drawable[]
{
preview = new PreviewButton
{
RelativeSizeAxes = Axes.X,
},
new DetailBox
{
Child = basic = new BasicStats
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 10 },
},
},
new DetailBox
{
Child = advanced = new AdvancedStats
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 7.5f },
},
},
new DetailBox
{
Child = Ratings = new UserRatings
2018-04-13 09:19:50 +00:00
{
RelativeSizeAxes = Axes.X,
Height = 95,
Margin = new MarginPadding { Top = 10 },
},
},
};
}
[BackgroundDependencyLoader]
private void load()
{
updateDisplay();
}
2018-04-13 09:19:50 +00:00
private class DetailBox : Container
{
private readonly Container content;
protected override Container<Drawable> Content => content;
public DetailBox()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 15 },
},
};
}
}
}
}