1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 13:47:24 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.7 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2024-02-18 09:13:57 +08:00
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Diagnostics;
2024-02-18 09:13:57 +08:00
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
2024-02-18 09:13:57 +08:00
using osu.Game.Rulesets.Mods;
namespace osu.Game.Screens.OnlinePlay.Match
2024-02-18 09:13:57 +08:00
{
public partial class RoomModSelectOverlay : UserModSelectOverlay
2024-02-18 09:13:57 +08:00
{
public RoomModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum)
2024-02-18 09:13:57 +08:00
: base(colourScheme)
{
}
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem>? selectedItem { get; set; }
2024-02-18 09:13:57 +08:00
[Resolved]
private RulesetStore rulesets { get; set; } = null!;
2024-02-18 09:13:57 +08:00
private readonly List<Mod> roomMods = new List<Mod>();
2024-02-18 09:13:57 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
selectedItem?.BindValueChanged(_ =>
2024-02-18 09:13:57 +08:00
{
roomMods.Clear();
2024-02-18 09:13:57 +08:00
if (selectedItem?.Value != null)
{
var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance)));
}
2024-02-18 09:13:57 +08:00
SelectedMods.TriggerChange();
});
2024-02-18 09:13:57 +08:00
}
protected override void UpdateOverlayInformation(IReadOnlyList<Mod> mods)
=> base.UpdateOverlayInformation(roomMods.Concat(mods).ToList());
2024-02-18 09:13:57 +08:00
}
}