mirror of
https://github.com/ppy/osu
synced 2025-01-20 21:10:49 +00:00
Update LeaderboardModSelector
to avoid creating mod instances
This commit is contained in:
parent
464797fecf
commit
28e9329136
@ -18,9 +18,9 @@ namespace osu.Game.Online.API.Requests
|
||||
private readonly BeatmapInfo beatmap;
|
||||
private readonly BeatmapLeaderboardScope scope;
|
||||
private readonly RulesetInfo ruleset;
|
||||
private readonly IEnumerable<Mod> mods;
|
||||
private readonly IEnumerable<IMod> mods;
|
||||
|
||||
public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<Mod> mods = null)
|
||||
public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<IMod> mods = null)
|
||||
{
|
||||
if (!beatmap.OnlineBeatmapID.HasValue)
|
||||
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
|
||||
@ -31,7 +31,7 @@ namespace osu.Game.Online.API.Requests
|
||||
this.beatmap = beatmap;
|
||||
this.scope = scope;
|
||||
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
|
||||
this.mods = mods ?? Array.Empty<Mod>();
|
||||
this.mods = mods ?? Array.Empty<IMod>();
|
||||
|
||||
Success += onSuccess;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class LeaderboardModSelector : CompositeDrawable
|
||||
{
|
||||
public readonly BindableList<Mod> SelectedMods = new BindableList<Mod>();
|
||||
public readonly BindableList<IMod> SelectedMods = new BindableList<IMod>();
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private readonly FillFlowContainer<ModButton> modsContainer;
|
||||
@ -54,7 +54,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
return;
|
||||
|
||||
modsContainer.Add(new ModButton(new ModNoMod()));
|
||||
modsContainer.AddRange(ruleset.NewValue.CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m.CreateInstance())));
|
||||
modsContainer.AddRange(ruleset.NewValue.CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m)));
|
||||
|
||||
modsContainer.ForEach(button =>
|
||||
{
|
||||
@ -76,7 +76,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
updateHighlighted();
|
||||
}
|
||||
|
||||
private void selectionChanged(Mod mod, bool selected)
|
||||
private void selectionChanged(IMod mod, bool selected)
|
||||
{
|
||||
if (selected)
|
||||
SelectedMods.Add(mod);
|
||||
@ -101,9 +101,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private const int duration = 200;
|
||||
|
||||
public readonly BindableBool Highlighted = new BindableBool();
|
||||
public Action<Mod, bool> OnSelectionChanged;
|
||||
public Action<IMod, bool> OnSelectionChanged;
|
||||
|
||||
public ModButton(Mod mod)
|
||||
public ModButton(IMod mod)
|
||||
: base(mod)
|
||||
{
|
||||
Scale = new Vector2(0.4f);
|
||||
|
Loading…
Reference in New Issue
Block a user