mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Update all beatmap overlay views to use APIBeatmap
/APIBeatmapSet
This commit is contained in:
@ -6,7 +6,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
@ -16,6 +15,7 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
@ -26,9 +26,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private UpdateableAvatar avatar;
|
||||
private FillFlowContainer fields;
|
||||
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private APIBeatmapSet beatmapSet;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
public APIBeatmapSet BeatmapSet
|
||||
{
|
||||
get => beatmapSet;
|
||||
set
|
||||
@ -78,30 +78,28 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
avatar.User = BeatmapSet?.Metadata.Author;
|
||||
avatar.User = BeatmapSet?.Author;
|
||||
|
||||
fields.Clear();
|
||||
if (BeatmapSet == null)
|
||||
return;
|
||||
|
||||
var online = BeatmapSet.OnlineInfo;
|
||||
|
||||
fields.Children = new Drawable[]
|
||||
{
|
||||
new Field("mapped by", BeatmapSet.Metadata.Author, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)),
|
||||
new Field("submitted", online.Submitted, OsuFont.GetFont(weight: FontWeight.Bold))
|
||||
new Field("mapped by", BeatmapSet.Author, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)),
|
||||
new Field("submitted", BeatmapSet.Submitted, OsuFont.GetFont(weight: FontWeight.Bold))
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
},
|
||||
};
|
||||
|
||||
if (online.Ranked.HasValue)
|
||||
if (BeatmapSet.Ranked.HasValue)
|
||||
{
|
||||
fields.Add(new Field(online.Status.ToString().ToLowerInvariant(), online.Ranked.Value, OsuFont.GetFont(weight: FontWeight.Bold)));
|
||||
fields.Add(new Field(BeatmapSet.Status.ToString().ToLowerInvariant(), BeatmapSet.Ranked.Value, OsuFont.GetFont(weight: FontWeight.Bold)));
|
||||
}
|
||||
else if (online.LastUpdated.HasValue)
|
||||
else if (BeatmapSet.LastUpdated.HasValue)
|
||||
{
|
||||
fields.Add(new Field("last updated", online.LastUpdated.Value, OsuFont.GetFont(weight: FontWeight.Bold)));
|
||||
fields.Add(new Field("last updated", BeatmapSet.LastUpdated.Value, OsuFont.GetFont(weight: FontWeight.Bold)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osuTK;
|
||||
|
||||
@ -23,9 +24,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
private readonly Statistic length, bpm, circleCount, sliderCount;
|
||||
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private APIBeatmapSet beatmapSet;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
public APIBeatmapSet BeatmapSet
|
||||
{
|
||||
get => beatmapSet;
|
||||
set
|
||||
@ -38,9 +39,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
}
|
||||
}
|
||||
|
||||
private BeatmapInfo beatmapInfo;
|
||||
private IBeatmapInfo beatmapInfo;
|
||||
|
||||
public BeatmapInfo BeatmapInfo
|
||||
public IBeatmapInfo BeatmapInfo
|
||||
{
|
||||
get => beatmapInfo;
|
||||
set
|
||||
@ -55,7 +56,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
bpm.Value = BeatmapSet?.OnlineInfo?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-";
|
||||
bpm.Value = BeatmapSet?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-";
|
||||
|
||||
if (beatmapInfo == null)
|
||||
{
|
||||
@ -68,8 +69,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
length.TooltipText = BeatmapsetsStrings.ShowStatsTotalLength(TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration());
|
||||
length.Value = TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration();
|
||||
|
||||
circleCount.Value = beatmapInfo.OnlineInfo.CircleCount.ToLocalisableString(@"N0");
|
||||
sliderCount.Value = beatmapInfo.OnlineInfo.SliderCount.ToLocalisableString(@"N0");
|
||||
var onlineInfo = beatmapInfo as IBeatmapOnlineInfo;
|
||||
|
||||
circleCount.Value = (onlineInfo?.CircleCount ?? 0).ToLocalisableString(@"N0");
|
||||
sliderCount.Value = (onlineInfo?.SliderCount ?? 0).ToLocalisableString(@"N0");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,19 @@ 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.Online.API.Requests.Responses;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class BeatmapAvailability : Container
|
||||
{
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private APIBeatmapSet beatmapSet;
|
||||
|
||||
private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability.DownloadDisabled ?? false;
|
||||
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability.ExternalLink);
|
||||
private bool downloadDisabled => BeatmapSet?.Availability.DownloadDisabled ?? false;
|
||||
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.Availability.ExternalLink);
|
||||
|
||||
private readonly LinkFlowContainer textContainer;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
};
|
||||
}
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
public APIBeatmapSet BeatmapSet
|
||||
{
|
||||
get => beatmapSet;
|
||||
|
||||
@ -76,7 +76,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
textContainer.NewParagraph();
|
||||
textContainer.NewParagraph();
|
||||
textContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10));
|
||||
textContainer.AddLink("Check here for more information.", BeatmapSet.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
@ -34,10 +35,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
public readonly DifficultiesContainer Difficulties;
|
||||
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
public readonly Bindable<APIBeatmap> Beatmap = new Bindable<APIBeatmap>();
|
||||
private APIBeatmapSet beatmapSet;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
public APIBeatmapSet BeatmapSet
|
||||
{
|
||||
get => beatmapSet;
|
||||
set
|
||||
@ -164,35 +165,38 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
if (BeatmapSet != null)
|
||||
{
|
||||
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Where(b => b.Ruleset.Equals(ruleset.Value)).OrderBy(b => b.StarDifficulty).Select(b => new DifficultySelectorButton(b)
|
||||
{
|
||||
State = DifficultySelectorState.NotSelected,
|
||||
OnHovered = beatmap =>
|
||||
{
|
||||
showBeatmap(beatmap);
|
||||
starRating.Text = beatmap.StarDifficulty.ToLocalisableString(@"0.##");
|
||||
starRatingContainer.FadeIn(100);
|
||||
},
|
||||
OnClicked = beatmap => { Beatmap.Value = beatmap; },
|
||||
});
|
||||
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps
|
||||
.Where(b => b.Ruleset?.OnlineID == ruleset.Value?.OnlineID)
|
||||
.OrderBy(b => b.StarRating)
|
||||
.Select(b => new DifficultySelectorButton(b)
|
||||
{
|
||||
State = DifficultySelectorState.NotSelected,
|
||||
OnHovered = beatmap =>
|
||||
{
|
||||
showBeatmap(beatmap);
|
||||
starRating.Text = beatmap.StarRating.ToLocalisableString(@"0.##");
|
||||
starRatingContainer.FadeIn(100);
|
||||
},
|
||||
OnClicked = beatmap => { Beatmap.Value = beatmap; },
|
||||
});
|
||||
}
|
||||
|
||||
starRatingContainer.FadeOut(100);
|
||||
Beatmap.Value = Difficulties.FirstOrDefault()?.BeatmapInfo;
|
||||
plays.Value = BeatmapSet?.OnlineInfo.PlayCount ?? 0;
|
||||
favourites.Value = BeatmapSet?.OnlineInfo.FavouriteCount ?? 0;
|
||||
Beatmap.Value = Difficulties.FirstOrDefault()?.Beatmap;
|
||||
plays.Value = BeatmapSet?.PlayCount ?? 0;
|
||||
favourites.Value = BeatmapSet?.FavouriteCount ?? 0;
|
||||
|
||||
updateDifficultyButtons();
|
||||
}
|
||||
|
||||
private void showBeatmap(BeatmapInfo beatmapInfo)
|
||||
private void showBeatmap(IBeatmapInfo beatmapInfo)
|
||||
{
|
||||
version.Text = beatmapInfo?.Version;
|
||||
version.Text = beatmapInfo?.DifficultyName;
|
||||
}
|
||||
|
||||
private void updateDifficultyButtons()
|
||||
{
|
||||
Difficulties.Children.ToList().ForEach(diff => diff.State = diff.BeatmapInfo == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected);
|
||||
Difficulties.Children.ToList().ForEach(diff => diff.State = diff.Beatmap == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected);
|
||||
}
|
||||
|
||||
public class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
|
||||
@ -216,10 +220,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private readonly Box backgroundBox;
|
||||
private readonly DifficultyIcon icon;
|
||||
|
||||
public readonly BeatmapInfo BeatmapInfo;
|
||||
public readonly APIBeatmap Beatmap;
|
||||
|
||||
public Action<BeatmapInfo> OnHovered;
|
||||
public Action<BeatmapInfo> OnClicked;
|
||||
public Action<APIBeatmap> OnHovered;
|
||||
public Action<APIBeatmap> OnClicked;
|
||||
public event Action<DifficultySelectorState> StateChanged;
|
||||
|
||||
private DifficultySelectorState state;
|
||||
@ -241,9 +245,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
}
|
||||
}
|
||||
|
||||
public DifficultySelectorButton(BeatmapInfo beatmapInfo)
|
||||
public DifficultySelectorButton(APIBeatmap beatmapInfo)
|
||||
{
|
||||
BeatmapInfo = beatmapInfo;
|
||||
Beatmap = beatmapInfo;
|
||||
Size = new Vector2(size);
|
||||
Margin = new MarginPadding { Horizontal = tile_spacing / 2 };
|
||||
|
||||
@ -273,7 +277,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
fadeIn();
|
||||
OnHovered?.Invoke(BeatmapInfo);
|
||||
OnHovered?.Invoke(Beatmap);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
@ -286,7 +290,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
OnClicked?.Invoke(BeatmapInfo);
|
||||
OnClicked?.Invoke(Beatmap);
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,17 @@
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using System.Linq;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class BeatmapRulesetSelector : OverlayRulesetSelector
|
||||
{
|
||||
private readonly Bindable<BeatmapSetInfo> beatmapSet = new Bindable<BeatmapSetInfo>();
|
||||
private readonly Bindable<APIBeatmapSet> beatmapSet = new Bindable<APIBeatmapSet>();
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
public APIBeatmapSet BeatmapSet
|
||||
{
|
||||
get => beatmapSet.Value;
|
||||
set
|
||||
|
@ -1,22 +1,22 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
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.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class BeatmapRulesetTabItem : OverlayRulesetTabItem
|
||||
{
|
||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
@ -64,7 +64,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
BeatmapSet.BindValueChanged(setInfo =>
|
||||
{
|
||||
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.Equals(Value)) ?? 0;
|
||||
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.OnlineID == Value.OnlineID) ?? 0;
|
||||
|
||||
count.Text = beatmapsCount.ToString();
|
||||
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
|
||||
|
@ -6,7 +6,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
@ -16,7 +16,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class BeatmapSetHeader : OverlayHeader
|
||||
{
|
||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
|
||||
|
||||
public BeatmapSetHeaderContent HeaderContent { get; private set; }
|
||||
|
||||
|
@ -10,13 +10,13 @@ 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;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
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.Overlays.BeatmapSet.Buttons;
|
||||
using osuTK;
|
||||
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class BeatmapSetHeaderContent : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
|
||||
|
||||
private const float transition_duration = 200;
|
||||
private const float buttons_height = 45;
|
||||
@ -219,7 +219,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Picker.Beatmap.ValueChanged += b =>
|
||||
{
|
||||
Details.BeatmapInfo = b.NewValue;
|
||||
externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}";
|
||||
externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineID}";
|
||||
};
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
BeatmapSet.BindValueChanged(setInfo =>
|
||||
{
|
||||
Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
|
||||
cover.OnlineInfo = setInfo.NewValue?.OnlineInfo;
|
||||
cover.OnlineInfo = setInfo.NewValue;
|
||||
|
||||
downloadTracker?.RemoveAndDisposeImmediately();
|
||||
|
||||
@ -254,14 +254,14 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
loading.Hide();
|
||||
|
||||
title.Text = new RomanisableString(setInfo.NewValue.Metadata.TitleUnicode, setInfo.NewValue.Metadata.Title);
|
||||
artist.Text = new RomanisableString(setInfo.NewValue.Metadata.ArtistUnicode, setInfo.NewValue.Metadata.Artist);
|
||||
title.Text = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title);
|
||||
artist.Text = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist);
|
||||
|
||||
explicitContentPill.Alpha = setInfo.NewValue.OnlineInfo.HasExplicitContent ? 1 : 0;
|
||||
featuredArtistPill.Alpha = setInfo.NewValue.OnlineInfo.TrackId != null ? 1 : 0;
|
||||
explicitContentPill.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0;
|
||||
featuredArtistPill.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0;
|
||||
|
||||
onlineStatusPill.FadeIn(500, Easing.OutQuint);
|
||||
onlineStatusPill.Status = setInfo.NewValue.OnlineInfo.Status;
|
||||
onlineStatusPill.Status = setInfo.NewValue.Status;
|
||||
|
||||
downloadButtonsContainer.FadeIn(transition_duration);
|
||||
favouriteButton.FadeIn(transition_duration);
|
||||
@ -275,7 +275,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
if (BeatmapSet.Value == null) return;
|
||||
|
||||
if (BeatmapSet.Value.OnlineInfo.Availability.DownloadDisabled && downloadTracker.State.Value != DownloadState.LocallyAvailable)
|
||||
if (BeatmapSet.Value.Availability.DownloadDisabled && downloadTracker.State.Value != DownloadState.LocallyAvailable)
|
||||
{
|
||||
downloadButtonsContainer.Clear();
|
||||
return;
|
||||
@ -301,7 +301,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
default:
|
||||
downloadButtonsContainer.Child = new HeaderDownloadButton(BeatmapSet.Value);
|
||||
if (BeatmapSet.Value.OnlineInfo.HasVideo)
|
||||
if (BeatmapSet.Value.HasVideo)
|
||||
downloadButtonsContainer.Add(new HeaderDownloadButton(BeatmapSet.Value, true));
|
||||
break;
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -6,6 +6,7 @@ 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.Screens.Select.Details;
|
||||
using osuTK;
|
||||
@ -21,9 +22,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private readonly AdvancedStats advanced;
|
||||
private readonly DetailBox ratingBox;
|
||||
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private APIBeatmapSet beatmapSet;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
public APIBeatmapSet BeatmapSet
|
||||
{
|
||||
get => beatmapSet;
|
||||
set
|
||||
@ -37,9 +38,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
}
|
||||
}
|
||||
|
||||
private BeatmapInfo beatmapInfo;
|
||||
private IBeatmapInfo beatmapInfo;
|
||||
|
||||
public BeatmapInfo BeatmapInfo
|
||||
public IBeatmapInfo BeatmapInfo
|
||||
{
|
||||
get => beatmapInfo;
|
||||
set
|
||||
@ -53,7 +54,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private void updateDisplay()
|
||||
{
|
||||
Ratings.Ratings = BeatmapSet?.Ratings;
|
||||
ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0;
|
||||
ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
public Details()
|
||||
|
@ -6,9 +6,9 @@ using osu.Framework.Bindables;
|
||||
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.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
@ -22,12 +22,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private readonly Box background;
|
||||
private readonly SuccessRate successRate;
|
||||
|
||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
|
||||
|
||||
public BeatmapInfo BeatmapInfo
|
||||
public APIBeatmap BeatmapInfo
|
||||
{
|
||||
get => successRate.BeatmapInfo;
|
||||
set => successRate.BeatmapInfo = value;
|
||||
get => successRate.Beatmap;
|
||||
set => successRate.Beatmap = value;
|
||||
}
|
||||
|
||||
public Info()
|
||||
@ -115,11 +115,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
BeatmapSet.ValueChanged += b =>
|
||||
{
|
||||
source.Text = b.NewValue?.Metadata.Source ?? string.Empty;
|
||||
tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty;
|
||||
genre.Text = b.NewValue?.OnlineInfo?.Genre.Name ?? string.Empty;
|
||||
language.Text = b.NewValue?.OnlineInfo?.Language.Name ?? string.Empty;
|
||||
bool setHasLeaderboard = b.NewValue?.OnlineInfo?.Status > 0;
|
||||
source.Text = b.NewValue?.Source ?? string.Empty;
|
||||
tags.Text = b.NewValue?.Tags ?? string.Empty;
|
||||
genre.Text = b.NewValue?.Genre.Name ?? string.Empty;
|
||||
language.Text = b.NewValue?.Language.Name ?? string.Empty;
|
||||
bool setHasLeaderboard = b.NewValue?.Status > 0;
|
||||
successRate.Alpha = setHasLeaderboard ? 1 : 0;
|
||||
notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1;
|
||||
Height = setHasLeaderboard ? 270 : base_height;
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osuTK.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
@ -20,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
public class LeaderboardModSelector : CompositeDrawable
|
||||
{
|
||||
public readonly BindableList<IMod> SelectedMods = new BindableList<IMod>();
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
public readonly Bindable<IRulesetInfo> Ruleset = new Bindable<IRulesetInfo>();
|
||||
|
||||
private readonly FillFlowContainer<ModButton> modsContainer;
|
||||
|
||||
@ -45,7 +46,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Ruleset.BindValueChanged(onRulesetChanged, true);
|
||||
}
|
||||
|
||||
private void onRulesetChanged(ValueChangedEvent<RulesetInfo> ruleset)
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
private void onRulesetChanged(ValueChangedEvent<IRulesetInfo> ruleset)
|
||||
{
|
||||
SelectedMods.Clear();
|
||||
modsContainer.Clear();
|
||||
@ -54,7 +58,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
return;
|
||||
|
||||
modsContainer.Add(new ModButton(new ModNoMod()));
|
||||
modsContainer.AddRange(ruleset.NewValue.CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m)));
|
||||
modsContainer.AddRange(rulesets.GetRuleset(ruleset.NewValue.OnlineID).CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m)));
|
||||
|
||||
modsContainer.ForEach(button =>
|
||||
{
|
||||
|
@ -1,24 +1,24 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
@ -26,8 +26,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
private const int spacing = 15;
|
||||
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
public readonly Bindable<APIBeatmap> Beatmap = new Bindable<APIBeatmap>();
|
||||
private readonly Bindable<IRulesetInfo> ruleset = new Bindable<IRulesetInfo>();
|
||||
private readonly Bindable<BeatmapLeaderboardScope> scope = new Bindable<BeatmapLeaderboardScope>(BeatmapLeaderboardScope.Global);
|
||||
private readonly IBindable<User> user = new Bindable<User>();
|
||||
|
||||
@ -66,7 +66,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
if (value?.Scores.Any() != true)
|
||||
return;
|
||||
|
||||
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value)).ToArray(), loadCancellationSource.Token)
|
||||
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets))).ToArray(), loadCancellationSource.Token)
|
||||
.ContinueWith(ordered => Schedule(() =>
|
||||
{
|
||||
if (loadCancellationSource.IsCancellationRequested)
|
||||
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
scoreTable.Show();
|
||||
|
||||
var userScore = value.UserScore;
|
||||
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value);
|
||||
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets));
|
||||
|
||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||
|
||||
@ -200,11 +200,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
user.BindValueChanged(onUserChanged, true);
|
||||
}
|
||||
|
||||
private void onBeatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
||||
private void onBeatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
{
|
||||
var beatmapRuleset = beatmap.NewValue?.Ruleset;
|
||||
|
||||
if (ruleset.Value?.Equals(beatmapRuleset) ?? false)
|
||||
if (ruleset.Value?.OnlineID == beatmapRuleset?.OnlineID)
|
||||
{
|
||||
modSelector.DeselectAll();
|
||||
ruleset.TriggerChange();
|
||||
@ -232,7 +232,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
|
||||
noScoresPlaceholder.Hide();
|
||||
|
||||
if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending)
|
||||
if (Beatmap.Value == null || Beatmap.Value.OnlineID <= 0 || (Beatmap.Value?.BeatmapSet as IBeatmapSetOnlineInfo)?.Status <= BeatmapSetOnlineStatus.Pending)
|
||||
{
|
||||
Scores = null;
|
||||
Hide();
|
||||
|
@ -5,10 +5,10 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
|
||||
@ -23,16 +23,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private readonly Bar successRate;
|
||||
private readonly Container percentContainer;
|
||||
|
||||
private BeatmapInfo beatmapInfo;
|
||||
private APIBeatmap beatmap;
|
||||
|
||||
public BeatmapInfo BeatmapInfo
|
||||
public APIBeatmap Beatmap
|
||||
{
|
||||
get => beatmapInfo;
|
||||
get => beatmap;
|
||||
set
|
||||
{
|
||||
if (value == beatmapInfo) return;
|
||||
if (value == beatmap) return;
|
||||
|
||||
beatmapInfo = value;
|
||||
beatmap = value;
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
@ -40,15 +40,15 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
int passCount = beatmapInfo?.OnlineInfo?.PassCount ?? 0;
|
||||
int playCount = beatmapInfo?.OnlineInfo?.PlayCount ?? 0;
|
||||
int passCount = beatmap?.PassCount ?? 0;
|
||||
int playCount = beatmap?.PlayCount ?? 0;
|
||||
|
||||
float rate = playCount != 0 ? (float)passCount / playCount : 0;
|
||||
successPercent.Text = rate.ToLocalisableString(@"0.#%");
|
||||
successRate.Length = rate;
|
||||
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
||||
|
||||
Graph.FailTimes = beatmapInfo?.FailTimes;
|
||||
Graph.FailTimes = beatmap?.FailTimes;
|
||||
}
|
||||
|
||||
public SuccessRate()
|
||||
|
Reference in New Issue
Block a user