mirror of
https://github.com/osukey/osukey.git
synced 2025-05-06 14:17:27 +09:00
Merge pull request #15319 from peppy/beatmap-refactor/tournament
Remove all usage of `BeatmapInfo` / `BeatmapSetInfo` from tournament mode
This commit is contained in:
commit
f9ca7f5df1
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -23,14 +22,13 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = 1091460 });
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = 1091460 });
|
||||
req.Success += success;
|
||||
api.Queue(req);
|
||||
}
|
||||
|
||||
private void success(APIBeatmap apiBeatmap)
|
||||
private void success(APIBeatmap beatmap)
|
||||
{
|
||||
var beatmap = apiBeatmap.ToBeatmapInfo(rulesets);
|
||||
Add(new TournamentBeatmapPanel(beatmap)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -4,12 +4,12 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.Components
|
||||
{
|
||||
@ -23,12 +23,10 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
private FillFlowContainer<TournamentBeatmapPanel> fillFlow;
|
||||
|
||||
private BeatmapInfo beatmapInfo;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = 490154 });
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = 490154 });
|
||||
req.Success += success;
|
||||
api.Queue(req);
|
||||
|
||||
@ -38,18 +36,17 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Full,
|
||||
Spacing = new osuTK.Vector2(10)
|
||||
Spacing = new Vector2(10)
|
||||
});
|
||||
}
|
||||
|
||||
private void success(APIBeatmap apiBeatmap)
|
||||
private void success(APIBeatmap beatmap)
|
||||
{
|
||||
beatmapInfo = apiBeatmap.ToBeatmapInfo(rulesets);
|
||||
var mods = rulesets.GetRuleset(Ladder.Ruleset.Value.ID ?? 0).CreateInstance().AllMods;
|
||||
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
fillFlow.Add(new TournamentBeatmapPanel(beatmapInfo, mod.Acronym)
|
||||
fillFlow.Add(new TournamentBeatmapPanel(beatmap, mod.Acronym)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
|
@ -44,8 +44,8 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
Beatmaps =
|
||||
{
|
||||
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
|
||||
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
|
||||
new RoundBeatmap { Beatmap = TournamentTestScene.CreateSampleBeatmap() },
|
||||
new RoundBeatmap { Beatmap = TournamentTestScene.CreateSampleBeatmap() },
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -132,7 +132,7 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Add(new RoundBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Mods = mods
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -74,19 +73,19 @@ namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Score = 12345672,
|
||||
Seed = { Value = 24 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Score = 1234567,
|
||||
Seed = { Value = 12 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Score = 1234567,
|
||||
Seed = { Value = 16 },
|
||||
}
|
||||
@ -100,19 +99,19 @@ namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 3 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 6 },
|
||||
},
|
||||
new SeedingBeatmap
|
||||
{
|
||||
BeatmapInfo = CreateSampleBeatmapInfo(),
|
||||
Beatmap = CreateSampleBeatmap(),
|
||||
Score = 234567,
|
||||
Seed = { Value = 12 },
|
||||
}
|
||||
@ -152,16 +151,15 @@ namespace osu.Game.Tournament.Tests
|
||||
}
|
||||
};
|
||||
|
||||
public static BeatmapInfo CreateSampleBeatmapInfo() =>
|
||||
new BeatmapInfo
|
||||
public static APIBeatmap CreateSampleBeatmap() =>
|
||||
new APIBeatmap
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
BeatmapSet = new APIBeatmapSet
|
||||
{
|
||||
Title = "Test Title",
|
||||
Artist = "Test Artist",
|
||||
ID = RNG.Next(0, 1000000)
|
||||
},
|
||||
OnlineInfo = new APIBeatmap(),
|
||||
OnlineID = RNG.Next(0, 1000000),
|
||||
};
|
||||
|
||||
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
|
||||
|
@ -12,6 +12,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK;
|
||||
@ -21,22 +22,21 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class SongBar : CompositeDrawable
|
||||
{
|
||||
private BeatmapInfo beatmapInfo;
|
||||
private APIBeatmap beatmap;
|
||||
|
||||
public const float HEIGHT = 145 / 2f;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
public BeatmapInfo BeatmapInfo
|
||||
public APIBeatmap Beatmap
|
||||
{
|
||||
get => beatmapInfo;
|
||||
set
|
||||
{
|
||||
if (beatmapInfo == value)
|
||||
if (beatmap == value)
|
||||
return;
|
||||
|
||||
beatmapInfo = value;
|
||||
beatmap = value;
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -95,18 +95,18 @@ namespace osu.Game.Tournament.Components
|
||||
|
||||
private void update()
|
||||
{
|
||||
if (beatmapInfo == null)
|
||||
if (beatmap == null)
|
||||
{
|
||||
flow.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
double bpm = beatmapInfo.BeatmapSet.OnlineInfo.BPM;
|
||||
double length = beatmapInfo.Length;
|
||||
double bpm = beatmap.BPM;
|
||||
double length = beatmap.Length;
|
||||
string hardRockExtra = "";
|
||||
string srExtra = "";
|
||||
|
||||
float ar = beatmapInfo.BaseDifficulty.ApproachRate;
|
||||
float ar = beatmap.Difficulty.ApproachRate;
|
||||
|
||||
if ((mods & LegacyMods.HardRock) > 0)
|
||||
{
|
||||
@ -132,9 +132,9 @@ namespace osu.Game.Tournament.Components
|
||||
default:
|
||||
stats = new (string heading, string content)[]
|
||||
{
|
||||
("CS", $"{beatmapInfo.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||
("CS", $"{beatmap.Difficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||
("AR", $"{ar:0.#}{hardRockExtra}"),
|
||||
("OD", $"{beatmapInfo.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||
};
|
||||
break;
|
||||
|
||||
@ -142,15 +142,15 @@ namespace osu.Game.Tournament.Components
|
||||
case 3:
|
||||
stats = new (string heading, string content)[]
|
||||
{
|
||||
("OD", $"{beatmapInfo.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||
("HP", $"{beatmapInfo.BaseDifficulty.DrainRate:0.#}{hardRockExtra}")
|
||||
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||
("HP", $"{beatmap.Difficulty.DrainRate:0.#}{hardRockExtra}")
|
||||
};
|
||||
break;
|
||||
|
||||
case 2:
|
||||
stats = new (string heading, string content)[]
|
||||
{
|
||||
("CS", $"{beatmapInfo.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||
("CS", $"{beatmap.Difficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||
("AR", $"{ar:0.#}"),
|
||||
};
|
||||
break;
|
||||
@ -186,7 +186,7 @@ namespace osu.Game.Tournament.Components
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DiffPiece(stats),
|
||||
new DiffPiece(("Star Rating", $"{beatmapInfo.StarDifficulty:0.#}{srExtra}"))
|
||||
new DiffPiece(("Star Rating", $"{beatmap.StarRating:0.#}{srExtra}"))
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
@ -229,7 +229,7 @@ namespace osu.Game.Tournament.Components
|
||||
}
|
||||
}
|
||||
},
|
||||
new TournamentBeatmapPanel(beatmapInfo)
|
||||
new TournamentBeatmapPanel(beatmap)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -20,7 +21,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class TournamentBeatmapPanel : CompositeDrawable
|
||||
{
|
||||
public readonly IBeatmapInfo BeatmapInfo;
|
||||
public readonly APIBeatmap Beatmap;
|
||||
|
||||
private readonly string mod;
|
||||
|
||||
@ -32,11 +33,11 @@ namespace osu.Game.Tournament.Components
|
||||
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
||||
private Box flash;
|
||||
|
||||
public TournamentBeatmapPanel(IBeatmapInfo beatmapInfo, string mod = null)
|
||||
public TournamentBeatmapPanel(APIBeatmap beatmap, string mod = null)
|
||||
{
|
||||
if (beatmapInfo == null) throw new ArgumentNullException(nameof(beatmapInfo));
|
||||
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
BeatmapInfo = beatmapInfo;
|
||||
Beatmap = beatmap;
|
||||
this.mod = mod;
|
||||
|
||||
Width = 400;
|
||||
@ -62,7 +63,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(0.5f),
|
||||
BeatmapSet = BeatmapInfo.BeatmapSet as IBeatmapSetOnlineInfo,
|
||||
BeatmapSet = Beatmap.BeatmapSet,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -75,7 +76,7 @@ namespace osu.Game.Tournament.Components
|
||||
{
|
||||
new TournamentSpriteText
|
||||
{
|
||||
Text = BeatmapInfo.GetDisplayTitleRomanisable(false),
|
||||
Text = Beatmap.GetDisplayTitleRomanisable(false),
|
||||
Font = OsuFont.Torus.With(weight: FontWeight.Bold),
|
||||
},
|
||||
new FillFlowContainer
|
||||
@ -92,7 +93,7 @@ namespace osu.Game.Tournament.Components
|
||||
},
|
||||
new TournamentSpriteText
|
||||
{
|
||||
Text = BeatmapInfo.Metadata?.Author,
|
||||
Text = Beatmap.Metadata.Author,
|
||||
Padding = new MarginPadding { Right = 20 },
|
||||
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
||||
},
|
||||
@ -104,7 +105,7 @@ namespace osu.Game.Tournament.Components
|
||||
},
|
||||
new TournamentSpriteText
|
||||
{
|
||||
Text = BeatmapInfo.DifficultyName,
|
||||
Text = Beatmap.DifficultyName,
|
||||
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
||||
},
|
||||
}
|
||||
@ -148,7 +149,7 @@ namespace osu.Game.Tournament.Components
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
var found = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == BeatmapInfo.OnlineID);
|
||||
var found = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap.OnlineID);
|
||||
|
||||
bool doFlash = found != choice;
|
||||
choice = found;
|
||||
|
@ -11,10 +11,10 @@ using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
@ -87,14 +87,14 @@ namespace osu.Game.Tournament.IPC
|
||||
|
||||
lastBeatmapId = beatmapId;
|
||||
|
||||
var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.BeatmapInfo != null);
|
||||
var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.Beatmap != null);
|
||||
|
||||
if (existing != null)
|
||||
Beatmap.Value = existing.BeatmapInfo;
|
||||
Beatmap.Value = existing.Beatmap;
|
||||
else
|
||||
{
|
||||
beatmapLookupRequest = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId });
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = b.ToBeatmapInfo(Rulesets);
|
||||
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
|
||||
beatmapLookupRequest.Success += b => Beatmap.Value = b;
|
||||
API.Queue(beatmapLookupRequest);
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,14 @@
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.IPC
|
||||
{
|
||||
public class MatchIPCInfo : Component
|
||||
{
|
||||
public Bindable<BeatmapInfo> Beatmap { get; } = new Bindable<BeatmapInfo>();
|
||||
public Bindable<APIBeatmap> Beatmap { get; } = new Bindable<APIBeatmap>();
|
||||
public Bindable<LegacyMods> Mods { get; } = new Bindable<LegacyMods>();
|
||||
public Bindable<TourneyState> State { get; } = new Bindable<TourneyState>();
|
||||
public Bindable<string> ChatChannel { get; } = new Bindable<string>();
|
||||
|
@ -1,7 +1,8 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -10,6 +11,7 @@ namespace osu.Game.Tournament.Models
|
||||
public int ID;
|
||||
public string Mods;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
[JsonProperty("BeatmapInfo")]
|
||||
public APIBeatmap Beatmap;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
// 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 Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@ -10,7 +11,8 @@ namespace osu.Game.Tournament.Models
|
||||
{
|
||||
public int ID;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
[JsonProperty("BeatmapInfo")]
|
||||
public APIBeatmap Beatmap;
|
||||
|
||||
public long Score;
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
|
||||
@ -37,10 +37,10 @@ namespace osu.Game.Tournament.Screens
|
||||
SongBar.Mods = mods.NewValue;
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
||||
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
{
|
||||
SongBar.FadeInFromZero(300, Easing.OutQuint);
|
||||
SongBar.BeatmapInfo = beatmap.NewValue;
|
||||
SongBar.Beatmap = beatmap.NewValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ 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.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Components;
|
||||
@ -226,25 +226,25 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
Model.ID = id.NewValue ?? 0;
|
||||
|
||||
if (id.NewValue != id.OldValue)
|
||||
Model.BeatmapInfo = null;
|
||||
Model.Beatmap = null;
|
||||
|
||||
if (Model.BeatmapInfo != null)
|
||||
if (Model.Beatmap != null)
|
||||
{
|
||||
updatePanel();
|
||||
return;
|
||||
}
|
||||
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = Model.ID });
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = Model.ID });
|
||||
|
||||
req.Success += res =>
|
||||
{
|
||||
Model.BeatmapInfo = res.ToBeatmapInfo(rulesets);
|
||||
Model.Beatmap = res;
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
req.Failure += _ =>
|
||||
{
|
||||
Model.BeatmapInfo = null;
|
||||
Model.Beatmap = null;
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
@ -259,9 +259,9 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
{
|
||||
drawableContainer.Clear();
|
||||
|
||||
if (Model.BeatmapInfo != null)
|
||||
if (Model.Beatmap != null)
|
||||
{
|
||||
drawableContainer.Child = new TournamentBeatmapPanel(Model.BeatmapInfo, Model.Mods)
|
||||
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap, Model.Mods)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
|
@ -7,10 +7,10 @@ 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.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.Components;
|
||||
@ -234,25 +234,25 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
Model.ID = id.NewValue ?? 0;
|
||||
|
||||
if (id.NewValue != id.OldValue)
|
||||
Model.BeatmapInfo = null;
|
||||
Model.Beatmap = null;
|
||||
|
||||
if (Model.BeatmapInfo != null)
|
||||
if (Model.Beatmap != null)
|
||||
{
|
||||
updatePanel();
|
||||
return;
|
||||
}
|
||||
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = Model.ID });
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = Model.ID });
|
||||
|
||||
req.Success += res =>
|
||||
{
|
||||
Model.BeatmapInfo = res.ToBeatmapInfo(rulesets);
|
||||
Model.Beatmap = res;
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
req.Failure += _ =>
|
||||
{
|
||||
Model.BeatmapInfo = null;
|
||||
Model.Beatmap = null;
|
||||
updatePanel();
|
||||
};
|
||||
|
||||
@ -267,9 +267,9 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
{
|
||||
drawableContainer.Clear();
|
||||
|
||||
if (Model.BeatmapInfo != null)
|
||||
if (Model.Beatmap != null)
|
||||
{
|
||||
drawableContainer.Child = new TournamentBeatmapPanel(Model.BeatmapInfo, result.Mod.Value)
|
||||
drawableContainer.Child = new TournamentBeatmapPanel(Model.Beatmap, result.Mod.Value)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
|
@ -8,8 +8,8 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -105,14 +105,14 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
ipc.Beatmap.BindValueChanged(beatmapChanged);
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
||||
private void beatmapChanged(ValueChangedEvent<APIBeatmap> beatmap)
|
||||
{
|
||||
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
|
||||
return;
|
||||
|
||||
// if bans have already been placed, beatmap changes result in a selection being made autoamtically
|
||||
if (beatmap.NewValue.OnlineBeatmapID != null)
|
||||
addForBeatmap(beatmap.NewValue.OnlineBeatmapID.Value);
|
||||
if (beatmap.NewValue.OnlineID > 0)
|
||||
addForBeatmap(beatmap.NewValue.OnlineID);
|
||||
}
|
||||
|
||||
private void setMode(TeamColour colour, ChoiceType choiceType)
|
||||
@ -147,11 +147,11 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
if (e.Button == MouseButton.Left && map.BeatmapInfo.OnlineID > 0)
|
||||
addForBeatmap(map.BeatmapInfo.OnlineID);
|
||||
if (e.Button == MouseButton.Left && map.Beatmap.OnlineID > 0)
|
||||
addForBeatmap(map.Beatmap.OnlineID);
|
||||
else
|
||||
{
|
||||
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.BeatmapInfo.OnlineID);
|
||||
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineID);
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
@ -179,7 +179,7 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
if (CurrentMatch.Value == null)
|
||||
return;
|
||||
|
||||
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.BeatmapInfo.OnlineBeatmapID != beatmapId))
|
||||
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.Beatmap.OnlineID != beatmapId))
|
||||
// don't attempt to add if the beatmap isn't in our pool
|
||||
return;
|
||||
|
||||
@ -245,7 +245,7 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
flowCount = 1;
|
||||
}
|
||||
|
||||
currentFlow.Add(new TournamentBeatmapPanel(b.BeatmapInfo, b.Mods)
|
||||
currentFlow.Add(new TournamentBeatmapPanel(b.Beatmap, b.Mods)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
|
@ -141,9 +141,9 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TournamentSpriteText { Text = beatmap.BeatmapInfo.Metadata.Title, Colour = TournamentGame.TEXT_COLOUR, },
|
||||
new TournamentSpriteText { Text = beatmap.Beatmap.Metadata.Title, Colour = TournamentGame.TEXT_COLOUR, },
|
||||
new TournamentSpriteText { Text = "by", Colour = TournamentGame.TEXT_COLOUR, Font = OsuFont.Torus.With(weight: FontWeight.Regular) },
|
||||
new TournamentSpriteText { Text = beatmap.BeatmapInfo.Metadata.Artist, Colour = TournamentGame.TEXT_COLOUR, Font = OsuFont.Torus.With(weight: FontWeight.Regular) },
|
||||
new TournamentSpriteText { Text = beatmap.Beatmap.Metadata.Artist, Colour = TournamentGame.TEXT_COLOUR, Font = OsuFont.Torus.With(weight: FontWeight.Regular) },
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
|
@ -7,12 +7,14 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -39,9 +41,18 @@ namespace osu.Game.Tournament
|
||||
return dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
}
|
||||
|
||||
private TournamentSpriteText initialisationText;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(Storage baseStorage)
|
||||
{
|
||||
AddInternal(initialisationText = new TournamentSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.Torus.With(size: 32),
|
||||
});
|
||||
|
||||
Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly));
|
||||
|
||||
dependencies.CacheAs<Storage>(storage = new TournamentStorage(baseStorage));
|
||||
@ -123,7 +134,8 @@ namespace osu.Game.Tournament
|
||||
}
|
||||
|
||||
addedInfo |= addPlayers();
|
||||
addedInfo |= addBeatmaps();
|
||||
addedInfo |= addRoundBeatmaps();
|
||||
addedInfo |= addSeedingBeatmaps();
|
||||
|
||||
if (addedInfo)
|
||||
SaveChanges();
|
||||
@ -145,6 +157,8 @@ namespace osu.Game.Tournament
|
||||
Add(ipc);
|
||||
|
||||
taskCompletionSource.SetResult(true);
|
||||
|
||||
initialisationText.Expire();
|
||||
});
|
||||
}
|
||||
|
||||
@ -153,81 +167,108 @@ namespace osu.Game.Tournament
|
||||
/// </summary>
|
||||
private bool addPlayers()
|
||||
{
|
||||
bool addedInfo = false;
|
||||
var playersRequiringPopulation = ladder.Teams
|
||||
.SelectMany(t => t.Players)
|
||||
.Where(p => string.IsNullOrEmpty(p.Username)
|
||||
|| p.Statistics?.GlobalRank == null
|
||||
|| p.Statistics?.CountryRank == null).ToList();
|
||||
|
||||
foreach (var t in ladder.Teams)
|
||||
if (playersRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < playersRequiringPopulation.Count; i++)
|
||||
{
|
||||
foreach (var p in t.Players)
|
||||
{
|
||||
if (string.IsNullOrEmpty(p.Username)
|
||||
|| p.Statistics?.GlobalRank == null
|
||||
|| p.Statistics?.CountryRank == null)
|
||||
{
|
||||
PopulateUser(p, immediate: true);
|
||||
addedInfo = true;
|
||||
}
|
||||
}
|
||||
var p = playersRequiringPopulation[i];
|
||||
PopulateUser(p, immediate: true);
|
||||
updateLoadProgressMessage($"Populating user stats ({i} / {playersRequiringPopulation.Count})");
|
||||
}
|
||||
|
||||
return addedInfo;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add missing beatmap info based on beatmap IDs
|
||||
/// </summary>
|
||||
private bool addBeatmaps()
|
||||
private bool addRoundBeatmaps()
|
||||
{
|
||||
bool addedInfo = false;
|
||||
var beatmapsRequiringPopulation = ladder.Rounds
|
||||
.SelectMany(r => r.Beatmaps)
|
||||
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList();
|
||||
|
||||
foreach (var r in ladder.Rounds)
|
||||
if (beatmapsRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < beatmapsRequiringPopulation.Count; i++)
|
||||
{
|
||||
foreach (var b in r.Beatmaps.ToList())
|
||||
{
|
||||
if (b.BeatmapInfo != null)
|
||||
continue;
|
||||
var b = beatmapsRequiringPopulation[i];
|
||||
|
||||
if (b.ID > 0)
|
||||
{
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||
API.Perform(req);
|
||||
b.BeatmapInfo = req.Response?.ToBeatmapInfo(RulesetStore);
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
|
||||
API.Perform(req);
|
||||
b.Beatmap = req.Response ?? new APIBeatmap();
|
||||
|
||||
addedInfo = true;
|
||||
}
|
||||
|
||||
if (b.BeatmapInfo == null)
|
||||
// if online population couldn't be performed, ensure we don't leave a null value behind
|
||||
r.Beatmaps.Remove(b);
|
||||
}
|
||||
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
|
||||
}
|
||||
|
||||
foreach (var t in ladder.Teams)
|
||||
{
|
||||
foreach (var s in t.SeedingResults)
|
||||
{
|
||||
foreach (var b in s.Beatmaps)
|
||||
{
|
||||
if (b.BeatmapInfo == null && b.ID > 0)
|
||||
{
|
||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||
req.Perform(API);
|
||||
b.BeatmapInfo = req.Response?.ToBeatmapInfo(RulesetStore);
|
||||
|
||||
addedInfo = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return addedInfo;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add missing beatmap info based on beatmap IDs
|
||||
/// </summary>
|
||||
private bool addSeedingBeatmaps()
|
||||
{
|
||||
var beatmapsRequiringPopulation = ladder.Teams
|
||||
.SelectMany(r => r.SeedingResults)
|
||||
.SelectMany(r => r.Beatmaps)
|
||||
.Where(b => string.IsNullOrEmpty(b.Beatmap?.BeatmapSet?.Title) && b.ID > 0).ToList();
|
||||
|
||||
if (beatmapsRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < beatmapsRequiringPopulation.Count; i++)
|
||||
{
|
||||
var b = beatmapsRequiringPopulation[i];
|
||||
|
||||
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
|
||||
API.Perform(req);
|
||||
b.Beatmap = req.Response ?? new APIBeatmap();
|
||||
|
||||
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
|
||||
|
||||
public void PopulateUser(User user, Action success = null, Action failure = null, bool immediate = false)
|
||||
{
|
||||
var req = new GetUserRequest(user.Id, Ruleset.Value);
|
||||
|
||||
req.Success += res =>
|
||||
if (immediate)
|
||||
{
|
||||
API.Perform(req);
|
||||
populate();
|
||||
}
|
||||
else
|
||||
{
|
||||
req.Success += res => { populate(); };
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
API.Queue(req);
|
||||
}
|
||||
|
||||
void populate()
|
||||
{
|
||||
var res = req.Response;
|
||||
|
||||
if (res == null)
|
||||
return;
|
||||
|
||||
user.Id = res.Id;
|
||||
|
||||
user.Username = res.Username;
|
||||
@ -236,18 +277,7 @@ namespace osu.Game.Tournament
|
||||
user.Cover = res.Cover;
|
||||
|
||||
success?.Invoke();
|
||||
};
|
||||
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
if (immediate)
|
||||
API.Perform(req);
|
||||
else
|
||||
API.Queue(req);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -164,7 +164,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => throw new NotImplementedException();
|
||||
double IBeatmapSetInfo.MaxStarDifficulty => throw new NotImplementedException();
|
||||
double IBeatmapSetInfo.MaxLength => throw new NotImplementedException();
|
||||
double IBeatmapSetInfo.MaxBPM => throw new NotImplementedException();
|
||||
double IBeatmapSetInfo.MaxBPM => BPM;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user