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

46 lines
1.4 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.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
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
{
2024-02-23 22:30:31 +08:00
[Resolved]
private IBindable<PlaylistItem> selectedItem { get; set; } = null!;
2024-02-18 09:13:57 +08:00
[Resolved]
private RulesetStore rulesets { get; set; } = null!;
2024-02-18 09:13:57 +08:00
2024-02-23 22:30:31 +08:00
public RoomModSelectOverlay()
: base(OverlayColourScheme.Plum)
{
}
2024-02-18 09:13:57 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
selectedItem.BindValueChanged(v =>
2024-02-18 09:13:57 +08:00
{
if (v.NewValue is PlaylistItem item)
{
2024-02-23 22:30:31 +08:00
var rulesetInstance = rulesets.GetRuleset(item.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
ActiveMods.Value = item.RequiredMods.Select(m => m.ToMod(rulesetInstance)).Concat(SelectedMods.Value).ToList();
}
else
ActiveMods.Value = SelectedMods.Value;
}, true);
2024-02-18 09:13:57 +08:00
}
}
}