1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Replace tournament beatmap storage type with lightweight model

This commit is contained in:
Salman Ahmed 2022-06-18 01:34:09 +03:00
parent 200b23c689
commit 9f97d1a7db
15 changed files with 29 additions and 31 deletions

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tournament.Tests.Components
beatmap.Length = 123456; beatmap.Length = 123456;
beatmap.BPM = 133; beatmap.BPM = 133;
songBar.Beatmap = beatmap; songBar.Beatmap = new TournamentBeatmap(beatmap);
}); });
AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock); AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime); AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);

View File

@ -10,6 +10,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Tests.Components namespace osu.Game.Tournament.Tests.Components
{ {
@ -32,7 +33,7 @@ namespace osu.Game.Tournament.Tests.Components
private void success(APIBeatmap beatmap) private void success(APIBeatmap beatmap)
{ {
Add(new TournamentBeatmapPanel(beatmap) Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap))
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre

View File

@ -11,6 +11,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK; using osuTK;
namespace osu.Game.Tournament.Tests.Components namespace osu.Game.Tournament.Tests.Components
@ -53,7 +54,7 @@ namespace osu.Game.Tournament.Tests.Components
foreach (var mod in mods) foreach (var mod in mods)
{ {
fillFlow.Add(new TournamentBeatmapPanel(beatmap, mod.Acronym) fillFlow.Add(new TournamentBeatmapPanel(new TournamentBeatmap(beatmap), mod.Acronym)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre

View File

@ -9,7 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.IO; using osu.Game.Tournament.IO;
@ -154,10 +154,10 @@ namespace osu.Game.Tournament.Tests
} }
}; };
public static APIBeatmap CreateSampleBeatmap() => public static TournamentBeatmap CreateSampleBeatmap() =>
new APIBeatmap new TournamentBeatmap
{ {
BeatmapSet = new APIBeatmapSet Metadata = new BeatmapMetadata
{ {
Title = "Test Title", Title = "Test Title",
Artist = "Test Artist", Artist = "Test Artist",

View File

@ -14,9 +14,9 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Tournament.Models;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -24,14 +24,14 @@ namespace osu.Game.Tournament.Components
{ {
public class SongBar : CompositeDrawable public class SongBar : CompositeDrawable
{ {
private APIBeatmap beatmap; private TournamentBeatmap beatmap;
public const float HEIGHT = 145 / 2f; public const float HEIGHT = 145 / 2f;
[Resolved] [Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } private IBindable<RulesetInfo> ruleset { get; set; }
public APIBeatmap Beatmap public TournamentBeatmap Beatmap
{ {
set set
{ {

View File

@ -14,7 +14,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps; 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.Online.API.Requests.Responses;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osuTK.Graphics; using osuTK.Graphics;
@ -22,7 +21,7 @@ namespace osu.Game.Tournament.Components
{ {
public class TournamentBeatmapPanel : CompositeDrawable public class TournamentBeatmapPanel : CompositeDrawable
{ {
public readonly APIBeatmap Beatmap; public readonly TournamentBeatmap Beatmap;
private readonly string mod; private readonly string mod;
@ -31,7 +30,7 @@ namespace osu.Game.Tournament.Components
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>(); private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private Box flash; private Box flash;
public TournamentBeatmapPanel(APIBeatmap beatmap, string mod = null) public TournamentBeatmapPanel(TournamentBeatmap beatmap, string mod = null)
{ {
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap)); if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
@ -61,7 +60,7 @@ namespace osu.Game.Tournament.Components
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.5f), Colour = OsuColour.Gray(0.5f),
OnlineInfo = Beatmap.BeatmapSet, OnlineInfo = Beatmap,
}, },
new FillFlowContainer new FillFlowContainer
{ {

View File

@ -96,7 +96,7 @@ namespace osu.Game.Tournament.IPC
else else
{ {
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId }); beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
beatmapLookupRequest.Success += b => Beatmap.Value = b; beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
API.Queue(beatmapLookupRequest); API.Queue(beatmapLookupRequest);
} }
} }

View File

@ -6,13 +6,13 @@
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.IPC namespace osu.Game.Tournament.IPC
{ {
public class MatchIPCInfo : Component public class MatchIPCInfo : Component
{ {
public Bindable<APIBeatmap> Beatmap { get; } = new Bindable<APIBeatmap>(); public Bindable<TournamentBeatmap> Beatmap { get; } = new Bindable<TournamentBeatmap>();
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>(); public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>(); public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
public Bindable<string> ChatChannel { get; } = new Bindable<string>(); public Bindable<string> ChatChannel { get; } = new Bindable<string>();

View File

@ -4,7 +4,6 @@
#nullable disable #nullable disable
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
{ {
@ -14,6 +13,6 @@ namespace osu.Game.Tournament.Models
public string Mods; public string Mods;
[JsonProperty("BeatmapInfo")] [JsonProperty("BeatmapInfo")]
public APIBeatmap Beatmap; public TournamentBeatmap Beatmap;
} }
} }

View File

@ -5,7 +5,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
{ {
@ -14,7 +13,7 @@ namespace osu.Game.Tournament.Models
public int ID; public int ID;
[JsonProperty("BeatmapInfo")] [JsonProperty("BeatmapInfo")]
public APIBeatmap Beatmap; public TournamentBeatmap Beatmap;
public long Score; public long Score;

View File

@ -7,9 +7,9 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Screens namespace osu.Game.Tournament.Screens
{ {
@ -39,7 +39,7 @@ namespace osu.Game.Tournament.Screens
SongBar.Mods = mods.NewValue; SongBar.Mods = mods.NewValue;
} }
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap) private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
{ {
SongBar.FadeInFromZero(300, Easing.OutQuint); SongBar.FadeInFromZero(300, Easing.OutQuint);
SongBar.Beatmap = beatmap.NewValue; SongBar.Beatmap = beatmap.NewValue;

View File

@ -239,7 +239,7 @@ namespace osu.Game.Tournament.Screens.Editors
req.Success += res => req.Success += res =>
{ {
Model.Beatmap = res; Model.Beatmap = new TournamentBeatmap(res);
updatePanel(); updatePanel();
}; };

View File

@ -241,7 +241,7 @@ namespace osu.Game.Tournament.Screens.Editors
req.Success += res => req.Success += res =>
{ {
Model.Beatmap = res; Model.Beatmap = new TournamentBeatmap(res);
updatePanel(); updatePanel();
}; };

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -107,7 +106,7 @@ namespace osu.Game.Tournament.Screens.MapPool
ipc.Beatmap.BindValueChanged(beatmapChanged); ipc.Beatmap.BindValueChanged(beatmapChanged);
} }
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap) private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
{ {
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2) if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
return; return;

View File

@ -211,7 +211,7 @@ namespace osu.Game.Tournament
{ {
var beatmapsRequiringPopulation = ladder.Rounds var beatmapsRequiringPopulation = ladder.Rounds
.SelectMany(r => r.Beatmaps) .SelectMany(r => r.Beatmaps)
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList(); .Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
if (beatmapsRequiringPopulation.Count == 0) if (beatmapsRequiringPopulation.Count == 0)
return false; return false;
@ -222,7 +222,7 @@ namespace osu.Game.Tournament
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
API.Perform(req); API.Perform(req);
b.Beatmap = req.Response ?? new APIBeatmap(); b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }
@ -238,7 +238,7 @@ namespace osu.Game.Tournament
var beatmapsRequiringPopulation = ladder.Teams var beatmapsRequiringPopulation = ladder.Teams
.SelectMany(r => r.SeedingResults) .SelectMany(r => r.SeedingResults)
.SelectMany(r => r.Beatmaps) .SelectMany(r => r.Beatmaps)
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList(); .Where(b => b.Beatmap?.OnlineID == 0 && b.ID > 0).ToList();
if (beatmapsRequiringPopulation.Count == 0) if (beatmapsRequiringPopulation.Count == 0)
return false; return false;
@ -249,7 +249,7 @@ namespace osu.Game.Tournament
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
API.Perform(req); API.Perform(req);
b.Beatmap = req.Response ?? new APIBeatmap(); b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }