mirror of
https://github.com/ppy/osu
synced 2025-03-02 17:42:13 +00:00
Move logic into BeatmapNotAvailable
This commit is contained in:
parent
c9cffe4394
commit
130ff56886
@ -5,6 +5,7 @@ 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.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -14,9 +15,36 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class BeatmapNotAvailable : Container
|
||||
{
|
||||
private LinkFlowContainer linkContainer;
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
|
||||
public override void Show()
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
{
|
||||
get => beatmapSet;
|
||||
set
|
||||
{
|
||||
if (value == beatmapSet) return;
|
||||
|
||||
beatmapSet = value;
|
||||
|
||||
if (beatmapSet?.OnlineInfo.Availability != null)
|
||||
{
|
||||
Header?.ResizeHeightTo(450, 500);
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Header?.ResizeHeightTo(400, 500);
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Header Header;
|
||||
|
||||
private readonly OsuSpriteText text;
|
||||
private readonly LinkFlowContainer link;
|
||||
|
||||
public BeatmapNotAvailable()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Margin = new MarginPadding { Top = 10 };
|
||||
@ -36,14 +64,13 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = 10, Horizontal = 5 },
|
||||
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium),
|
||||
Text = "This beatmap is currently not available for download.",
|
||||
Colour = Color4.Orange,
|
||||
},
|
||||
linkContainer = new LinkFlowContainer(text => text.Font = OsuFont.GetFont(size: 14))
|
||||
link = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14))
|
||||
{
|
||||
Direction = FillDirection.Full,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -54,12 +81,25 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
},
|
||||
};
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
text.Text = BeatmapSet.OnlineInfo.Availability.DownloadDisabled
|
||||
? "This beatmap is currently not available for download."
|
||||
: "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder.";
|
||||
|
||||
link.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink);
|
||||
|
||||
base.Show();
|
||||
}
|
||||
|
||||
public string Link
|
||||
public override void Hide()
|
||||
{
|
||||
set => linkContainer.AddLink("Check here for more information.", value);
|
||||
link.RemoveAll(x => true);
|
||||
|
||||
base.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private readonly UpdateableBeatmapSetCover cover;
|
||||
private readonly OsuSpriteText title, artist;
|
||||
private readonly AuthorInfo author;
|
||||
private readonly BeatmapNotAvailable unavailableContainer;
|
||||
private readonly FillFlowContainer downloadButtonsContainer;
|
||||
private readonly BeatmapNotAvailable beatmapNotAvailable;
|
||||
private readonly BeatmapSetOnlineStatusPill onlineStatusPill;
|
||||
public Details Details;
|
||||
public FillFlowContainer DownloadButtonsContainer;
|
||||
|
||||
public readonly BeatmapPicker Picker;
|
||||
|
||||
@ -135,7 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Margin = new MarginPadding { Top = 20 },
|
||||
Child = author = new AuthorInfo(),
|
||||
},
|
||||
unavailableContainer = new BeatmapNotAvailable(),
|
||||
beatmapNotAvailable = new BeatmapNotAvailable { Header = this },
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -144,7 +144,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Children = new Drawable[]
|
||||
{
|
||||
favouriteButton = new FavouriteButton(),
|
||||
downloadButtonsContainer = new FillFlowContainer
|
||||
DownloadButtonsContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
|
||||
@ -192,7 +192,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
BeatmapSet.BindValueChanged(setInfo =>
|
||||
{
|
||||
Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
|
||||
Picker.BeatmapSet = author.BeatmapSet = beatmapNotAvailable.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
|
||||
|
||||
title.Text = setInfo.NewValue?.Metadata.Title ?? string.Empty;
|
||||
artist.Text = setInfo.NewValue?.Metadata.Artist ?? string.Empty;
|
||||
@ -201,27 +201,15 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
if (setInfo.NewValue != null)
|
||||
{
|
||||
downloadButtonsContainer.FadeIn(transition_duration);
|
||||
DownloadButtonsContainer.FadeIn(transition_duration);
|
||||
favouriteButton.FadeIn(transition_duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadButtonsContainer.FadeOut(transition_duration);
|
||||
DownloadButtonsContainer.FadeOut(transition_duration);
|
||||
favouriteButton.FadeOut(transition_duration);
|
||||
}
|
||||
|
||||
if (setInfo.NewValue?.OnlineInfo.Availability?.DownloadDisabled ?? false)
|
||||
{
|
||||
this.ResizeHeightTo(460, transition_duration / 2);
|
||||
unavailableContainer.Show();
|
||||
unavailableContainer.Link = setInfo.NewValue.OnlineInfo.Availability.ExternalLink;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ResizeHeightTo(400, transition_duration / 2);
|
||||
unavailableContainer.Hide();
|
||||
}
|
||||
|
||||
updateDownloadButtons();
|
||||
}, true);
|
||||
}
|
||||
@ -232,7 +220,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false)
|
||||
{
|
||||
downloadButtonsContainer.RemoveAll(x => true);
|
||||
DownloadButtonsContainer.RemoveAll(x => true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -240,7 +228,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
case DownloadState.LocallyAvailable:
|
||||
// temporary for UX until new design is implemented.
|
||||
downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value)
|
||||
DownloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value)
|
||||
{
|
||||
Width = 50,
|
||||
RelativeSizeAxes = Axes.Y
|
||||
@ -250,13 +238,13 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
case DownloadState.Downloading:
|
||||
case DownloadState.Downloaded:
|
||||
// temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design.
|
||||
downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value);
|
||||
DownloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value);
|
||||
break;
|
||||
|
||||
default:
|
||||
downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value);
|
||||
DownloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value);
|
||||
if (BeatmapSet.Value.OnlineInfo.HasVideo)
|
||||
downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true));
|
||||
DownloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user