1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-29 17:47:26 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/Info.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

146 lines
6.3 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
using System;
2017-09-09 05:32:07 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
2017-09-09 05:32:07 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
2017-09-09 05:32:07 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapListing;
2018-04-13 17:19:50 +08:00
2017-09-25 17:26:27 +08:00
namespace osu.Game.Overlays.BeatmapSet
2017-09-09 05:32:07 +08:00
{
public partial class Info : Container
{
private const float metadata_width = 175;
2017-09-09 05:32:07 +08:00
private const float spacing = 20;
private const float base_height = 220;
2018-04-13 17:19:50 +08:00
2017-09-09 05:32:07 +08:00
private readonly Box successRateBackground;
2020-02-04 19:00:18 +08:00
private readonly Box background;
2017-09-11 13:48:48 +08:00
private readonly SuccessRate successRate;
2018-04-13 17:19:50 +08:00
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
2023-06-24 22:07:01 +08:00
public APIBeatmap? BeatmapInfo
2017-09-11 13:48:48 +08:00
{
get => successRate.Beatmap;
set => successRate.Beatmap = value;
2017-09-11 13:48:48 +08:00
}
2018-04-13 17:19:50 +08:00
2017-09-13 23:37:18 +08:00
public Info()
2017-09-09 05:32:07 +08:00
{
MetadataSectionNominators nominators;
MetadataSection source, tags;
MetadataSectionGenre genre;
MetadataSectionLanguage language;
OsuSpriteText notRankedPlaceholder;
2020-02-05 06:09:10 +08:00
2017-09-09 05:32:07 +08:00
RelativeSizeAxes = Axes.X;
Height = base_height;
2018-04-13 17:19:50 +08:00
2017-09-09 05:32:07 +08:00
Children = new Drawable[]
{
2020-02-04 19:00:18 +08:00
background = new Box
2017-09-09 05:32:07 +08:00
{
2020-02-04 19:00:18 +08:00
RelativeSizeAxes = Axes.Both
2017-09-09 05:32:07 +08:00
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 15, Horizontal = WaveOverlayContainer.HORIZONTAL_PADDING },
2017-09-09 05:32:07 +08:00
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
2017-09-25 17:26:27 +08:00
Padding = new MarginPadding { Right = metadata_width + BeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 },
Child = new Container
2017-09-09 05:32:07 +08:00
{
RelativeSizeAxes = Axes.Both,
Child = new MetadataSectionDescription(),
2017-09-09 05:32:07 +08:00
},
},
new Container
2017-09-09 05:32:07 +08:00
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = metadata_width,
Padding = new MarginPadding { Horizontal = 10 },
2017-09-25 17:26:27 +08:00
Margin = new MarginPadding { Right = BeatmapSetOverlay.RIGHT_WIDTH + spacing },
Masking = true,
2017-09-13 23:37:18 +08:00
Child = new FillFlowContainer
2017-09-09 05:32:07 +08:00
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Full,
Children = new Drawable[]
2017-09-13 23:37:18 +08:00
{
nominators = new MetadataSectionNominators(),
source = new MetadataSectionSource(),
genre = new MetadataSectionGenre { Width = 0.5f },
language = new MetadataSectionLanguage { Width = 0.5f },
tags = new MetadataSectionTags(),
2017-09-13 23:37:18 +08:00
},
2017-09-09 05:32:07 +08:00
},
},
new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
2017-09-25 17:26:27 +08:00
Width = BeatmapSetOverlay.RIGHT_WIDTH,
2017-09-11 13:48:48 +08:00
Children = new Drawable[]
2017-09-09 05:32:07 +08:00
{
successRateBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
2017-09-11 13:48:48 +08:00
successRate = new SuccessRate
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 20, Horizontal = 15 },
},
notRankedPlaceholder = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0,
Text = "This beatmap is not ranked",
2020-02-08 03:28:02 +08:00
Font = OsuFont.GetFont(size: 12)
},
2017-09-09 05:32:07 +08:00
},
},
},
},
};
BeatmapSet.ValueChanged += b =>
{
nominators.Metadata = (b.NewValue?.CurrentNominations ?? Array.Empty<BeatmapSetOnlineNomination>(), b.NewValue?.RelatedUsers ?? Array.Empty<APIUser>());
2022-12-24 03:11:15 +08:00
source.Metadata = b.NewValue?.Source ?? string.Empty;
tags.Metadata = b.NewValue?.Tags ?? string.Empty;
genre.Metadata = b.NewValue?.Genre ?? new BeatmapSetOnlineGenre { Id = (int)SearchGenre.Unspecified };
language.Metadata = b.NewValue?.Language ?? new BeatmapSetOnlineLanguage { Id = (int)SearchLanguage.Unspecified };
bool setHasLeaderboard = b.NewValue?.Status > 0;
successRate.Alpha = setHasLeaderboard ? 1 : 0;
notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1;
Height = setHasLeaderboard ? 270 : base_height;
};
2017-09-09 05:32:07 +08:00
}
2018-04-13 17:19:50 +08:00
2017-09-09 05:32:07 +08:00
[BackgroundDependencyLoader]
2020-02-04 19:00:18 +08:00
private void load(OverlayColourProvider colourProvider)
2017-09-09 05:32:07 +08:00
{
2020-02-04 19:00:18 +08:00
successRateBackground.Colour = colourProvider.Background4;
background.Colour = colourProvider.Background5;
2017-09-09 05:32:07 +08:00
}
}
}