mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +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.Colour;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -59,9 +60,12 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
{
|
{
|
||||||
Schedule(() =>
|
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;
|
return;
|
||||||
|
|
||||||
cancellationSource?.Cancel();
|
cancellationSource?.Cancel();
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
|
|
||||||
private void updateBeatmap()
|
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 };
|
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 class PlaylistItemBackground : Background
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo? BeatmapInfo;
|
public readonly IBeatmapInfo? Beatmap;
|
||||||
|
|
||||||
public PlaylistItemBackground(PlaylistItem? playlistItem)
|
public PlaylistItemBackground(PlaylistItem? playlistItem)
|
||||||
{
|
{
|
||||||
BeatmapInfo = playlistItem?.Beatmap.Value;
|
Beatmap = playlistItem?.APIBeatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -26,8 +26,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
Texture? texture = null;
|
Texture? texture = null;
|
||||||
|
|
||||||
// prefer online cover where available.
|
// prefer online cover where available.
|
||||||
if (BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers.Cover != null)
|
if (Beatmap?.BeatmapSet is IBeatmapSetOnlineInfo online)
|
||||||
texture = textures.Get(BeatmapInfo.BeatmapSet.OnlineInfo.Covers.Cover);
|
texture = textures.Get(online.Covers.Cover);
|
||||||
|
|
||||||
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;
|
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
if (ReferenceEquals(this, other)) return true;
|
if (ReferenceEquals(this, other)) return true;
|
||||||
|
|
||||||
return other.GetType() == GetType()
|
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 ScheduledDelegate scheduledRefresh;
|
||||||
|
private PanelBackground panelBackground;
|
||||||
|
|
||||||
private void scheduleRefresh()
|
private void scheduleRefresh()
|
||||||
{
|
{
|
||||||
@ -105,23 +106,25 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
|
|
||||||
private void refresh()
|
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.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;
|
text.Truncate = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
authorText.Clear();
|
authorText.Clear();
|
||||||
|
|
||||||
if (Item.Beatmap?.Value?.Metadata?.Author != null)
|
if (Item.Beatmap.Value?.Metadata?.Author != null)
|
||||||
{
|
{
|
||||||
authorText.AddText("mapped by ");
|
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;
|
explicitContentPill.Alpha = hasExplicitContent ? 1 : 0;
|
||||||
|
|
||||||
modDisplay.Current.Value = requiredMods.ToArray();
|
modDisplay.Current.Value = requiredMods.ToArray();
|
||||||
@ -145,10 +148,9 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
AlwaysPresent = true
|
AlwaysPresent = true
|
||||||
},
|
},
|
||||||
new PanelBackground
|
panelBackground = new PanelBackground
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Beatmap = { BindTarget = beatmap }
|
|
||||||
},
|
},
|
||||||
new GridContainer
|
new GridContainer
|
||||||
{
|
{
|
||||||
@ -294,7 +296,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
private const float width = 50;
|
private const float width = 50;
|
||||||
|
|
||||||
public PlaylistDownloadButton(PlaylistItem playlistItem)
|
public PlaylistDownloadButton(PlaylistItem playlistItem)
|
||||||
: base(playlistItem.Beatmap.Value.BeatmapSet)
|
: base(playlistItem.APIBeatmap.BeatmapSet)
|
||||||
{
|
{
|
||||||
this.playlistItem = playlistItem;
|
this.playlistItem = playlistItem;
|
||||||
|
|
||||||
@ -316,7 +318,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
case DownloadState.LocallyAvailable:
|
case DownloadState.LocallyAvailable:
|
||||||
// Perform a local query of the beatmap by beatmap checksum, and reset the state if not matching.
|
// 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;
|
State.Value = DownloadState.NotDownloaded;
|
||||||
else
|
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
|
// 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)
|
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()
|
public PanelBackground()
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
if (editButton != null)
|
if (editButton != null)
|
||||||
host.BindValueChanged(h => editButton.Alpha = h.NewValue?.Equals(api.LocalUser.Value) == true ? 1 : 0, true);
|
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();
|
protected override Drawable CreateBackground() => background = new BackgroundSprite();
|
||||||
|
Reference in New Issue
Block a user