1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 22:33:05 +08:00

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

This commit is contained in:
Bartłomiej Dach 2021-11-01 09:43:51 +01:00
commit f5feed138d
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
9 changed files with 79 additions and 103 deletions

View File

@ -56,95 +56,71 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("Set width to 300", () => content.ResizeWidthTo(300, 500)); AddStep("Set width to 300", () => content.ResizeWidthTo(300, 500));
} }
private static readonly List<BeatmapSetInfo> new_beatmaps = new List<BeatmapSetInfo> private static readonly List<APIBeatmapSet> new_beatmaps = new List<APIBeatmapSet>
{ {
new BeatmapSetInfo new APIBeatmapSet
{ {
Metadata = new BeatmapMetadata Title = "Very Long Title (TV size) [TATOE]",
Artist = "This artist has a really long name how is this possible",
Author = new User
{ {
Title = "Very Long Title (TV size) [TATOE]", Username = "author",
Artist = "This artist has a really long name how is this possible", Id = 100
Author = new User
{
Username = "author",
Id = 100
}
}, },
OnlineInfo = new APIBeatmapSet Covers = new BeatmapSetOnlineCovers
{ {
Covers = new BeatmapSetOnlineCovers Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608",
{ },
Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608", Ranked = DateTimeOffset.Now
},
Ranked = DateTimeOffset.Now
}
}, },
new BeatmapSetInfo new APIBeatmapSet
{ {
Metadata = new BeatmapMetadata Title = "Very Long Title (TV size) [TATOE]",
Artist = "This artist has a really long name how is this possible",
Author = new User
{ {
Title = "Very Long Title (TV size) [TATOE]", Username = "author",
Artist = "This artist has a really long name how is this possible", Id = 100
Author = new User
{
Username = "author",
Id = 100
}
}, },
OnlineInfo = new APIBeatmapSet Covers = new BeatmapSetOnlineCovers
{ {
Covers = new BeatmapSetOnlineCovers Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608",
{ },
Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608", Ranked = DateTimeOffset.Now
},
Ranked = DateTimeOffset.MinValue
}
} }
}; };
private static readonly List<BeatmapSetInfo> popular_beatmaps = new List<BeatmapSetInfo> private static readonly List<APIBeatmapSet> popular_beatmaps = new List<APIBeatmapSet>
{ {
new BeatmapSetInfo new APIBeatmapSet
{ {
Metadata = new BeatmapMetadata Title = "Very Long Title (TV size) [TATOE]",
Artist = "This artist has a really long name how is this possible",
Author = new User
{ {
Title = "Title", Username = "author",
Artist = "Artist", Id = 100
Author = new User
{
Username = "author",
Id = 100
}
}, },
OnlineInfo = new APIBeatmapSet Covers = new BeatmapSetOnlineCovers
{ {
Covers = new BeatmapSetOnlineCovers Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608",
{ },
Cover = "https://assets.ppy.sh/beatmaps/1079428/covers/cover.jpg?1595295586", Ranked = DateTimeOffset.Now
},
FavouriteCount = 100
}
}, },
new BeatmapSetInfo new APIBeatmapSet
{ {
Metadata = new BeatmapMetadata Title = "Very Long Title (TV size) [TATOE]",
Artist = "This artist has a really long name how is this possible",
Author = new User
{ {
Title = "Title 2", Username = "author",
Artist = "Artist 2", Id = 100
Author = new User
{
Username = "someone",
Id = 100
}
}, },
OnlineInfo = new APIBeatmapSet Covers = new BeatmapSetOnlineCovers
{ {
Covers = new BeatmapSetOnlineCovers Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608",
{ },
Cover = "https://assets.ppy.sh/beatmaps/1079428/covers/cover.jpg?1595295586", Ranked = DateTimeOffset.Now
},
FavouriteCount = 10
}
} }
}; };
} }

View File

@ -8,7 +8,7 @@ namespace osu.Game.Database
public interface IHasOnlineID<out T> public interface IHasOnlineID<out T>
{ {
/// <summary> /// <summary>
/// The server-side ID representing this instance, if one exists. Any value 0 or less denotes a missing ID. /// The server-side ID representing this instance, if one exists. Any value 0 or less denotes a missing ID (except in special cases where autoincrement is not used, like rulesets).
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Generally we use -1 when specifying "missing" in code, but values of 0 are also considered missing as the online source /// Generally we use -1 when specifying "missing" in code, but values of 0 are also considered missing as the online source

View File

@ -5,17 +5,17 @@ using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses;
using osuTK; using osuTK;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
{ {
public class DashboardBeatmapListing : CompositeDrawable public class DashboardBeatmapListing : CompositeDrawable
{ {
private readonly List<BeatmapSetInfo> newBeatmaps; private readonly List<APIBeatmapSet> newBeatmaps;
private readonly List<BeatmapSetInfo> popularBeatmaps; private readonly List<APIBeatmapSet> popularBeatmaps;
public DashboardBeatmapListing(List<BeatmapSetInfo> newBeatmaps, List<BeatmapSetInfo> popularBeatmaps) public DashboardBeatmapListing(List<APIBeatmapSet> newBeatmaps, List<APIBeatmapSet> popularBeatmaps)
{ {
this.newBeatmaps = newBeatmaps; this.newBeatmaps = newBeatmaps;
this.popularBeatmaps = popularBeatmaps; this.popularBeatmaps = popularBeatmaps;

View File

@ -7,11 +7,11 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osuTK; using osuTK;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
@ -24,14 +24,14 @@ namespace osu.Game.Overlays.Dashboard.Home
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private BeatmapSetOverlay beatmapOverlay { get; set; } private BeatmapSetOverlay beatmapOverlay { get; set; }
protected readonly BeatmapSetInfo SetInfo; protected readonly APIBeatmapSet BeatmapSet;
private Box hoverBackground; private Box hoverBackground;
private SpriteIcon chevron; private SpriteIcon chevron;
protected DashboardBeatmapPanel(BeatmapSetInfo setInfo) protected DashboardBeatmapPanel(APIBeatmapSet beatmapSet)
{ {
SetInfo = setInfo; BeatmapSet = beatmapSet;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -82,7 +82,7 @@ namespace osu.Game.Overlays.Dashboard.Home
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
OnlineInfo = SetInfo.OnlineInfo OnlineInfo = BeatmapSet
} }
}, },
new Container new Container
@ -103,14 +103,14 @@ namespace osu.Game.Overlays.Dashboard.Home
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true, Truncate = true,
Font = OsuFont.GetFont(weight: FontWeight.Regular), Font = OsuFont.GetFont(weight: FontWeight.Regular),
Text = SetInfo.Metadata.Title Text = BeatmapSet.Title
}, },
new OsuSpriteText new OsuSpriteText
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Truncate = true, Truncate = true,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
Text = SetInfo.Metadata.Artist Text = BeatmapSet.Artist
}, },
new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular)) new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular))
{ {
@ -121,7 +121,7 @@ namespace osu.Game.Overlays.Dashboard.Home
}.With(c => }.With(c =>
{ {
c.AddText("by"); c.AddText("by");
c.AddUserLink(SetInfo.Metadata.Author); c.AddUserLink(BeatmapSet.Author);
c.AddArbitraryDrawable(CreateInfo()); c.AddArbitraryDrawable(CreateInfo());
}) })
} }
@ -143,8 +143,8 @@ namespace osu.Game.Overlays.Dashboard.Home
Action = () => Action = () =>
{ {
if (SetInfo.OnlineBeatmapSetID.HasValue) if (BeatmapSet.OnlineID > 0)
beatmapOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value); beatmapOverlay?.FetchAndShowBeatmapSet(BeatmapSet.OnlineID);
}; };
} }

View File

@ -3,19 +3,19 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
{ {
public class DashboardNewBeatmapPanel : DashboardBeatmapPanel public class DashboardNewBeatmapPanel : DashboardBeatmapPanel
{ {
public DashboardNewBeatmapPanel(BeatmapSetInfo setInfo) public DashboardNewBeatmapPanel(APIBeatmapSet beatmapSet)
: base(setInfo) : base(beatmapSet)
{ {
} }
protected override Drawable CreateInfo() => new DrawableDate(SetInfo.OnlineInfo.Ranked ?? DateTimeOffset.Now, 10, false) protected override Drawable CreateInfo() => new DrawableDate(BeatmapSet.Ranked ?? DateTimeOffset.Now, 10, false)
{ {
Colour = ColourProvider.Foreground1 Colour = ColourProvider.Foreground1
}; };

View File

@ -4,17 +4,17 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osuTK; using osuTK;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
{ {
public class DashboardPopularBeatmapPanel : DashboardBeatmapPanel public class DashboardPopularBeatmapPanel : DashboardBeatmapPanel
{ {
public DashboardPopularBeatmapPanel(BeatmapSetInfo setInfo) public DashboardPopularBeatmapPanel(APIBeatmapSet beatmapSet)
: base(setInfo) : base(beatmapSet)
{ {
} }
@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Dashboard.Home
new OsuSpriteText new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular), Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular),
Text = SetInfo.OnlineInfo.FavouriteCount.ToString() Text = BeatmapSet.FavouriteCount.ToString()
} }
} }
}; };

View File

@ -6,20 +6,20 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osuTK; using osuTK;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
{ {
public abstract class DrawableBeatmapList : CompositeDrawable public abstract class DrawableBeatmapList : CompositeDrawable
{ {
private readonly List<BeatmapSetInfo> beatmaps; private readonly List<APIBeatmapSet> beatmapSets;
protected DrawableBeatmapList(List<BeatmapSetInfo> beatmaps) protected DrawableBeatmapList(List<APIBeatmapSet> beatmapSets)
{ {
this.beatmaps = beatmaps; this.beatmapSets = beatmapSets;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -46,11 +46,11 @@ namespace osu.Game.Overlays.Dashboard.Home
} }
}; };
flow.AddRange(beatmaps.Select(CreateBeatmapPanel)); flow.AddRange(beatmapSets.Select(CreateBeatmapPanel));
} }
protected abstract string Title { get; } protected abstract string Title { get; }
protected abstract DashboardBeatmapPanel CreateBeatmapPanel(BeatmapSetInfo setInfo); protected abstract DashboardBeatmapPanel CreateBeatmapPanel(APIBeatmapSet beatmapSet);
} }
} }

View File

@ -2,18 +2,18 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
{ {
public class DrawableNewBeatmapList : DrawableBeatmapList public class DrawableNewBeatmapList : DrawableBeatmapList
{ {
public DrawableNewBeatmapList(List<BeatmapSetInfo> beatmaps) public DrawableNewBeatmapList(List<APIBeatmapSet> beatmapSets)
: base(beatmaps) : base(beatmapSets)
{ {
} }
protected override DashboardBeatmapPanel CreateBeatmapPanel(BeatmapSetInfo setInfo) => new DashboardNewBeatmapPanel(setInfo); protected override DashboardBeatmapPanel CreateBeatmapPanel(APIBeatmapSet beatmapSet) => new DashboardNewBeatmapPanel(beatmapSet);
protected override string Title => "New Ranked Beatmaps"; protected override string Title => "New Ranked Beatmaps";
} }

View File

@ -2,18 +2,18 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Dashboard.Home namespace osu.Game.Overlays.Dashboard.Home
{ {
public class DrawablePopularBeatmapList : DrawableBeatmapList public class DrawablePopularBeatmapList : DrawableBeatmapList
{ {
public DrawablePopularBeatmapList(List<BeatmapSetInfo> beatmaps) public DrawablePopularBeatmapList(List<APIBeatmapSet> beatmapSets)
: base(beatmaps) : base(beatmapSets)
{ {
} }
protected override DashboardBeatmapPanel CreateBeatmapPanel(BeatmapSetInfo setInfo) => new DashboardPopularBeatmapPanel(setInfo); protected override DashboardBeatmapPanel CreateBeatmapPanel(APIBeatmapSet beatmapSet) => new DashboardPopularBeatmapPanel(beatmapSet);
protected override string Title => "Popular Beatmaps"; protected override string Title => "Popular Beatmaps";
} }