Merge branch 'master' into score-refactor/isolated-serialisation

This commit is contained in:
Dean Herbert
2021-11-01 15:49:25 +09:00
28 changed files with 628 additions and 360 deletions

View File

@ -3,12 +3,14 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
@ -21,8 +23,10 @@ using osuTK;
namespace osu.Game.Overlays.BeatmapSet
{
public class BeatmapSetHeaderContent : BeatmapDownloadTrackingComposite
public class BeatmapSetHeaderContent : CompositeDrawable
{
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
private const float transition_duration = 200;
private const float buttons_height = 45;
private const float buttons_spacing = 5;
@ -45,6 +49,8 @@ namespace osu.Game.Overlays.BeatmapSet
private readonly FillFlowContainer fadeContent;
private readonly LoadingSpinner loading;
private BeatmapDownloadTracker downloadTracker;
[Resolved]
private IAPIProvider api { get; set; }
@ -222,13 +228,13 @@ namespace osu.Game.Overlays.BeatmapSet
{
coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f));
State.BindValueChanged(_ => updateDownloadButtons());
BeatmapSet.BindValueChanged(setInfo =>
{
Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
cover.OnlineInfo = setInfo.NewValue?.OnlineInfo;
downloadTracker?.RemoveAndDisposeImmediately();
if (setInfo.NewValue == null)
{
onlineStatusPill.FadeTo(0.5f, 500, Easing.OutQuint);
@ -241,6 +247,10 @@ namespace osu.Game.Overlays.BeatmapSet
}
else
{
downloadTracker = new BeatmapDownloadTracker(setInfo.NewValue);
downloadTracker.State.BindValueChanged(_ => updateDownloadButtons());
AddInternal(downloadTracker);
fadeContent.FadeIn(500, Easing.OutQuint);
loading.Hide();
@ -266,13 +276,13 @@ namespace osu.Game.Overlays.BeatmapSet
{
if (BeatmapSet.Value == null) return;
if (BeatmapSet.Value.OnlineInfo.Availability.DownloadDisabled && State.Value != DownloadState.LocallyAvailable)
if (BeatmapSet.Value.OnlineInfo.Availability.DownloadDisabled && downloadTracker.State.Value != DownloadState.LocallyAvailable)
{
downloadButtonsContainer.Clear();
return;
}
switch (State.Value)
switch (downloadTracker.State.Value)
{
case DownloadState.LocallyAvailable:
// temporary for UX until new design is implemented.

View File

@ -22,7 +22,7 @@ using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Buttons
{
public class HeaderDownloadButton : BeatmapDownloadTrackingComposite, IHasTooltip
public class HeaderDownloadButton : CompositeDrawable, IHasTooltip
{
private const int text_size = 12;
@ -35,9 +35,12 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private ShakeContainer shakeContainer;
private HeaderButton button;
private BeatmapDownloadTracker downloadTracker;
private readonly BeatmapSetInfo beatmapSet;
public HeaderDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false)
: base(beatmapSet)
{
this.beatmapSet = beatmapSet;
this.noVideo = noVideo;
Width = 120;
@ -49,13 +52,17 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
{
FillFlowContainer textSprites;
AddInternal(shakeContainer = new ShakeContainer
InternalChildren = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 5,
Child = button = new HeaderButton { RelativeSizeAxes = Axes.Both },
});
shakeContainer = new ShakeContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 5,
Child = button = new HeaderButton { RelativeSizeAxes = Axes.Both },
},
downloadTracker = new BeatmapDownloadTracker(beatmapSet),
};
button.AddRange(new Drawable[]
{
@ -83,7 +90,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
},
}
},
new DownloadProgressBar(BeatmapSet.Value)
new DownloadProgressBar(beatmapSet)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
@ -92,20 +99,20 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
button.Action = () =>
{
if (State.Value != DownloadState.NotDownloaded)
if (downloadTracker.State.Value != DownloadState.NotDownloaded)
{
shakeContainer.Shake();
return;
}
beatmaps.Download(BeatmapSet.Value, noVideo);
beatmaps.Download(beatmapSet, noVideo);
};
localUser.BindTo(api.LocalUser);
localUser.BindValueChanged(userChanged, true);
button.Enabled.BindValueChanged(enabledChanged, true);
State.BindValueChanged(state =>
downloadTracker.State.BindValueChanged(state =>
{
switch (state.NewValue)
{
@ -161,7 +168,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private LocalisableString getVideoSuffixText()
{
if (!BeatmapSet.Value.OnlineInfo.HasVideo)
if (!beatmapSet.OnlineInfo.HasVideo)
return string.Empty;
return noVideo ? BeatmapsetsStrings.ShowDetailsDownloadNoVideo : BeatmapsetsStrings.ShowDetailsDownloadVideo;