2024-02-18 09:13:57 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-02-18 09:13:57 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
|
{
|
|
|
|
|
public partial class MultiplayerModSelectOverlay : UserModSelectOverlay
|
|
|
|
|
{
|
|
|
|
|
public MultiplayerModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum)
|
|
|
|
|
: base(colourScheme)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private IBindable<PlaylistItem>? multiplayerRoomItem { get; set; }
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuGameBase game { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new MultiplayerBeatmapAttributesDisplay
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
2024-02-18 09:15:53 +08:00
|
|
|
|
BeatmapInfo = { Value = Beatmap?.BeatmapInfo }
|
2024-02-18 09:13:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange());
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
protected override IEnumerable<Mod> AllSelectedMods
|
2024-02-18 09:13:57 +08:00
|
|
|
|
{
|
2024-02-20 18:57:28 +08:00
|
|
|
|
get
|
2024-02-18 09:13:57 +08:00
|
|
|
|
{
|
2024-02-20 18:57:28 +08:00
|
|
|
|
IEnumerable<Mod> allMods = SelectedMods.Value;
|
2024-02-18 09:13:57 +08:00
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
if (multiplayerRoomItem?.Value != null)
|
|
|
|
|
{
|
|
|
|
|
Ruleset ruleset = game.Ruleset.Value.CreateInstance();
|
|
|
|
|
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
|
|
|
|
|
allMods = allMods.Concat(multiplayerRoomMods);
|
|
|
|
|
}
|
2024-02-18 09:13:57 +08:00
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
return allMods;
|
2024-02-18 09:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class MultiplayerBeatmapAttributesDisplay : BeatmapAttributesDisplay
|
|
|
|
|
{
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private IBindable<PlaylistItem>? multiplayerRoomItem { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
multiplayerRoomItem?.BindValueChanged(_ => Mods.TriggerChange());
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
protected override IEnumerable<Mod> SelectedMods
|
2024-02-18 09:13:57 +08:00
|
|
|
|
{
|
2024-02-20 18:57:28 +08:00
|
|
|
|
get
|
2024-02-18 09:13:57 +08:00
|
|
|
|
{
|
2024-02-20 18:57:28 +08:00
|
|
|
|
IEnumerable<Mod> selectedMods = Mods.Value;
|
2024-02-18 09:13:57 +08:00
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
if (multiplayerRoomItem?.Value != null)
|
|
|
|
|
{
|
|
|
|
|
Ruleset ruleset = GameRuleset.Value.CreateInstance();
|
|
|
|
|
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
|
|
|
|
|
selectedMods = selectedMods.Concat(multiplayerRoomMods);
|
|
|
|
|
}
|
2024-02-18 09:28:24 +08:00
|
|
|
|
|
2024-02-20 18:57:28 +08:00
|
|
|
|
return selectedMods;
|
2024-02-18 09:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|