Update all beatmap overlay views to use APIBeatmap/APIBeatmapSet

This commit is contained in:
Dean Herbert
2021-10-29 17:58:46 +09:00
parent b8ee7e05f4
commit a16c8f1ebc
45 changed files with 471 additions and 613 deletions

View File

@ -8,10 +8,10 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Notifications;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
{
public class FavouriteButton : HeaderButton, IHasTooltip
{
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
private readonly BindableBool favourited = new BindableBool();
@ -61,13 +61,13 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
Action = () =>
{
// guaranteed by disabled state above.
Debug.Assert(BeatmapSet.Value.OnlineBeatmapSetID != null);
Debug.Assert(BeatmapSet.Value.OnlineID > 0);
loading.Show();
request?.Cancel();
request = new PostBeatmapFavouriteRequest(BeatmapSet.Value.OnlineBeatmapSetID.Value, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);
request = new PostBeatmapFavouriteRequest(BeatmapSet.Value.OnlineID, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);
request.Success += () =>
{
@ -98,11 +98,11 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
BeatmapSet.BindValueChanged(setInfo =>
{
updateEnabled();
favourited.Value = setInfo.NewValue?.OnlineInfo?.HasFavourited ?? false;
favourited.Value = setInfo.NewValue?.HasFavourited ?? false;
}, true);
}
private void updateEnabled() => Enabled.Value = !(localUser.Value is GuestUser) && BeatmapSet.Value?.OnlineBeatmapSetID > 0;
private void updateEnabled() => Enabled.Value = !(localUser.Value is GuestUser) && BeatmapSet.Value?.OnlineID > 0;
protected override void UpdateAfterChildren()
{

View File

@ -14,11 +14,13 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapListing.Panels;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
using CommonStrings = osu.Game.Localisation.CommonStrings;
namespace osu.Game.Overlays.BeatmapSet.Buttons
{
@ -36,9 +38,10 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private HeaderButton button;
private BeatmapDownloadTracker downloadTracker;
private readonly BeatmapSetInfo beatmapSet;
public HeaderDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false)
private readonly APIBeatmapSet beatmapSet;
public HeaderDownloadButton(APIBeatmapSet beatmapSet, bool noVideo = false)
{
this.beatmapSet = beatmapSet;
this.noVideo = noVideo;
@ -105,7 +108,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
return;
}
beatmaps.Download(beatmapSet, noVideo);
beatmaps.Download(new BeatmapSetInfo { OnlineBeatmapSetID = beatmapSet.OnlineID }, noVideo);
};
localUser.BindTo(api.LocalUser);
@ -121,7 +124,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
{
new OsuSpriteText
{
Text = Localisation.CommonStrings.Downloading,
Text = CommonStrings.Downloading,
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
},
};
@ -132,7 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
{
new OsuSpriteText
{
Text = Localisation.CommonStrings.Importing,
Text = CommonStrings.Importing,
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
},
};
@ -168,7 +171,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private LocalisableString getVideoSuffixText()
{
if (!beatmapSet.OnlineInfo.HasVideo)
if (!beatmapSet.HasVideo)
return string.Empty;
return noVideo ? BeatmapsetsStrings.ShowDetailsDownloadNoVideo : BeatmapsetsStrings.ShowDetailsDownloadVideo;

View File

@ -8,9 +8,9 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapListing.Panels;
using osuTK;
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
public IBindable<bool> Playing => playButton.Playing;
public BeatmapSetInfo BeatmapSet
public APIBeatmapSet BeatmapSet
{
get => playButton.BeatmapSet;
set => playButton.BeatmapSet = value;