mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Use APIBeatmap
instead of BeatmapInfo
in playlist display classes where feasible
This commit is contained in:
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -59,9 +60,12 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
var beatmap = playlistItem?.Beatmap.Value;
|
||||
var beatmap = playlistItem?.APIBeatmap;
|
||||
|
||||
if (background?.BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers.Cover == beatmap?.BeatmapSet?.OnlineInfo?.Covers.Cover)
|
||||
string? lastCover = (background?.Beatmap?.BeatmapSet as IBeatmapSetOnlineInfo)?.Covers.Cover;
|
||||
string? newCover = beatmap?.BeatmapSet?.Covers.Cover;
|
||||
|
||||
if (lastCover == newCover)
|
||||
return;
|
||||
|
||||
cancellationSource?.Cancel();
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
|
||||
private void updateBeatmap()
|
||||
{
|
||||
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.Beatmap.Value;
|
||||
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.APIBeatmap;
|
||||
}
|
||||
|
||||
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
|
@ -13,11 +13,11 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public class PlaylistItemBackground : Background
|
||||
{
|
||||
public readonly BeatmapInfo? BeatmapInfo;
|
||||
public readonly IBeatmapInfo? Beatmap;
|
||||
|
||||
public PlaylistItemBackground(PlaylistItem? playlistItem)
|
||||
{
|
||||
BeatmapInfo = playlistItem?.Beatmap.Value;
|
||||
Beatmap = playlistItem?.APIBeatmap;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -26,8 +26,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
Texture? texture = null;
|
||||
|
||||
// prefer online cover where available.
|
||||
if (BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers.Cover != null)
|
||||
texture = textures.Get(BeatmapInfo.BeatmapSet.OnlineInfo.Covers.Cover);
|
||||
if (Beatmap?.BeatmapSet is IBeatmapSetOnlineInfo online)
|
||||
texture = textures.Get(online.Covers.Cover);
|
||||
|
||||
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;
|
||||
}
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return other.GetType() == GetType()
|
||||
&& ((PlaylistItemBackground)other).BeatmapInfo == BeatmapInfo;
|
||||
&& ((PlaylistItemBackground)other).Beatmap == Beatmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledRefresh;
|
||||
private PanelBackground panelBackground;
|
||||
|
||||
private void scheduleRefresh()
|
||||
{
|
||||
@ -105,23 +106,25 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
difficultyIconContainer.Child = new DifficultyIcon(beatmap.Value, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(32) };
|
||||
difficultyIconContainer.Child = new DifficultyIcon(Item.APIBeatmap, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(32) };
|
||||
|
||||
panelBackground.Beatmap.Value = Item.APIBeatmap;
|
||||
|
||||
beatmapText.Clear();
|
||||
beatmapText.AddLink(Item.Beatmap.Value.GetDisplayTitleRomanisable(), LinkAction.OpenBeatmap, Item.Beatmap.Value.OnlineBeatmapID.ToString(), null, text =>
|
||||
beatmapText.AddLink(Item.APIBeatmap.GetDisplayTitleRomanisable(), LinkAction.OpenBeatmap, Item.APIBeatmap.OnlineID.ToString(), null, text =>
|
||||
{
|
||||
text.Truncate = true;
|
||||
});
|
||||
|
||||
authorText.Clear();
|
||||
|
||||
if (Item.Beatmap?.Value?.Metadata?.Author != null)
|
||||
if (Item.Beatmap.Value?.Metadata?.Author != null)
|
||||
{
|
||||
authorText.AddText("mapped by ");
|
||||
authorText.AddUserLink(Item.Beatmap.Value?.Metadata.Author);
|
||||
authorText.AddUserLink(Item.APIBeatmap?.BeatmapSet?.Author);
|
||||
}
|
||||
|
||||
bool hasExplicitContent = Item.Beatmap.Value.BeatmapSet.OnlineInfo?.HasExplicitContent == true;
|
||||
bool hasExplicitContent = Item.Beatmap.Value?.BeatmapSet.OnlineInfo?.HasExplicitContent == true;
|
||||
explicitContentPill.Alpha = hasExplicitContent ? 1 : 0;
|
||||
|
||||
modDisplay.Current.Value = requiredMods.ToArray();
|
||||
@ -145,10 +148,9 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
},
|
||||
new PanelBackground
|
||||
panelBackground = new PanelBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Beatmap = { BindTarget = beatmap }
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
@ -294,7 +296,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private const float width = 50;
|
||||
|
||||
public PlaylistDownloadButton(PlaylistItem playlistItem)
|
||||
: base(playlistItem.Beatmap.Value.BeatmapSet)
|
||||
: base(playlistItem.APIBeatmap.BeatmapSet)
|
||||
{
|
||||
this.playlistItem = playlistItem;
|
||||
|
||||
@ -316,7 +318,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
case DownloadState.LocallyAvailable:
|
||||
// Perform a local query of the beatmap by beatmap checksum, and reset the state if not matching.
|
||||
if (beatmapManager.QueryBeatmap(b => b.MD5Hash == playlistItem.Beatmap.Value.MD5Hash) == null)
|
||||
if (beatmapManager.QueryBeatmap(b => b.MD5Hash == playlistItem.APIBeatmap.MD5Hash) == null)
|
||||
State.Value = DownloadState.NotDownloaded;
|
||||
else
|
||||
{
|
||||
@ -337,7 +339,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
// For now, this is the same implementation as in PanelBackground, but supports a beatmap info rather than a working beatmap
|
||||
private class PanelBackground : Container // todo: should be a buffered container (https://github.com/ppy/osu-framework/issues/3222)
|
||||
{
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
public readonly Bindable<IBeatmapInfo> Beatmap = new Bindable<IBeatmapInfo>();
|
||||
|
||||
public PanelBackground()
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
if (editButton != null)
|
||||
host.BindValueChanged(h => editButton.Alpha = h.NewValue?.Equals(api.LocalUser.Value) == true ? 1 : 0, true);
|
||||
|
||||
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.Beatmap.Value, true);
|
||||
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.APIBeatmap, true);
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => background = new BackgroundSprite();
|
||||
|
Reference in New Issue
Block a user