1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 19:47:51 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/Details.cs

155 lines
4.5 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 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
using osu.Framework.Allocation;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Rulesets;
2018-04-13 17:19:50 +08:00
using osu.Game.Screens.Select.Details;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.BeatmapSet
{
2022-11-24 13:32:20 +08:00
public partial class Details : FillFlowContainer
2018-04-13 17:19:50 +08:00
{
protected readonly UserRatings Ratings;
2018-04-13 17:19:50 +08:00
private readonly PreviewButton preview;
private readonly BasicStats basic;
private readonly AdvancedStats advanced;
private readonly DetailBox ratingBox;
2018-04-13 17:19:50 +08:00
private APIBeatmapSet beatmapSet;
public APIBeatmapSet BeatmapSet
2018-04-13 17:19:50 +08:00
{
get => beatmapSet;
2018-04-13 17:19:50 +08:00
set
{
if (value == beatmapSet) return;
2019-02-28 12:31:40 +08:00
basic.BeatmapSet = preview.BeatmapSet = beatmapSet = value;
2018-04-13 17:19:50 +08:00
if (IsLoaded)
updateDisplay();
2018-04-13 17:19:50 +08:00
}
}
private IBeatmapInfo beatmapInfo;
public IBeatmapInfo BeatmapInfo
2018-04-13 17:19:50 +08:00
{
get => beatmapInfo;
2018-04-13 17:19:50 +08:00
set
{
if (value == beatmapInfo) return;
2018-04-13 17:19:50 +08:00
basic.BeatmapInfo = advanced.BeatmapInfo = beatmapInfo = value;
2018-04-13 17:19:50 +08:00
if (IsLoaded)
updateDisplay();
}
}
2018-04-13 17:19:50 +08:00
public Details()
{
Width = BeatmapSetOverlay.RIGHT_WIDTH;
AutoSizeAxes = Axes.Y;
Spacing = new Vector2(1f);
Children = new Drawable[]
{
preview = new PreviewButton
{
RelativeSizeAxes = Axes.X,
Height = 42,
2018-04-13 17:19:50 +08:00
},
new DetailBox
{
Child = basic = new BasicStats
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Vertical = 10 }
2018-04-13 17:19:50 +08:00
},
},
new DetailBox
{
Child = advanced = new AdvancedStats
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 7.5f },
},
},
ratingBox = new DetailBox
2018-04-13 17:19:50 +08:00
{
Child = Ratings = new UserRatings
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.X,
Height = 95,
Margin = new MarginPadding { Top = 10 },
},
},
};
}
[Resolved]
private RulesetStore rulesets { get; set; }
protected override void LoadComplete()
{
base.LoadComplete();
updateDisplay();
}
private void updateDisplay()
{
Ratings.Ratings = BeatmapSet?.Ratings;
ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0;
advanced.Ruleset.Value = rulesets.GetRuleset(beatmapInfo?.Ruleset.OnlineID ?? 0);
}
2022-11-24 13:32:20 +08:00
private partial class DetailBox : Container
2018-04-13 17:19:50 +08:00
{
private readonly Container content;
2020-02-05 04:00:00 +08:00
private readonly Box background;
2018-04-13 17:19:50 +08:00
protected override Container<Drawable> Content => content;
public DetailBox()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
{
2020-02-05 04:00:00 +08:00
background = new Box
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
2020-02-05 02:54:51 +08:00
Alpha = 0.5f
2018-04-13 17:19:50 +08:00
},
content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 15 },
},
};
}
2020-02-05 04:00:00 +08:00
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colourProvider.Background6;
}
2018-04-13 17:19:50 +08:00
}
}
}